On Tue, 25 Oct 2011 14:52:04 +0300, Denis Shelomovskij wrote: Looks interesting. This summer I did a small lib around vectors and matrices, at same time that I was learning D. Perhaps you can borrow some idea or not. It's focused for using it with OpenGL so they are limited to squared matrices of 2 to 4 dimension and column major ordered : https://github.com/Zardoz89/zmath
> What does D already have: build-in rectangular static arrays, dynamic > arrays of arrays, std.range.frontTransversal, std.range.transversal. > > Some time ago I was told that "FORTRAN is good for its arrays" and heard > me saying "it is easy to implement in C++ or D, but in D it will have > more convenient syntax". But than I have understood that I > underestimated the problem and it isn't easy to implement in D and looks > much more harder to implement in C++. In spite of this I decided to > implement it in D. So, my implementation is ready for test/use but still > has some TODO-s because it is just a straightforward implementation of > basic multidimensional array operations with no optimisations. And I > think it is valuable enough to be added in Phobos in future (tell me if > it isn't). > > Documentation and sources: > http://deoma-cmd.ru/d/docs/src/my/rarray.html > > Sources will be at GitHub as soon as I am asked for it. > > I have some questions about my array: * Should such array be a part of > Phobos or Druntime? * Now my array has CT dimensions and RT lengths, > should there be a version with RT dimensions (or maybe it is the only > needed version)? * Some (or most) of element names should be changed > (like RectangularArray, because is isn't a rectangular array in the > general case). So if one knows better names, tell me please (at least > RectangularArray -> MultidimensionalArray, rectArray -> multiArray?). * > Have I misused some terminology (top dimension etc.)? * What `Throwable` > types should be thrown and when? Currently I use `AssertError` for my > own mistakes and user incorrect ranges using and `Exception` for user > incorrect array using, all are in debug mode only. And I don't > understand Druntime exceptions: it uses `Exception` for "lengths don't > match for array copy" and `core.exception.RangeError` if array index is > out of bounds and calls it "Range violation" (all are in debug mode > only). It looks inconsistent. * For `int a = b / c, d = b % c;` will > compiler optimize it or should I add there an inline assembly to get `d` > from `EDX` on x86 after division? > > I also have some questions about other files (my.typetuple and > my.traits): * I was confused with Phobos TypeTuple because it isn't a > type tuple. Should it be replaced with some modification of my variant? > * Have any additions in my.traits a general use? IMHO ArrayElementType, > isType and staticRange have. > > I also have some ideas (TODO-s) for my array which looks good: * > opSliceAssign with an array or a RectangularArray as its operand should > use array copy for as much tail dimensions as possible (if data has no > copy constructor because of dmd bug 6470). * byElementRandomAccess > should also look at all packed tail dimensions if they are one dimension > for faster indexing. * Special optimized case for 2^^n-lengths. > > > Thanks everybody for reading such a big post! -- Yep, I'm afraid that I have a blog : zardoz.es