Excellent! I have toying around with similar ideas for years. Never
found the time to really get into it. :-(
Some ideas below inline.
On 25.10.2011 13:52, Denis Shelomovskij wrote:
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".
Certainly not easy in C++.
After trying it in C++, surprisingly easy in D...
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).
The question about adding it to Phobos is not just whether it is
valuable enough, but whether it is generic enough to be *the* library
for numerical arrays. Numerical arrays are foremost the interface
between numerical libraries.
I have not had a close look at your code to form an opinion about this.
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?
Ultimately, yes.
* 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)?
As terminology, I find the following convenient:
"rank" - the number of dimensions
"shape" - the collection of lengths of all dimensions
In those terms, I believe that CT rank is good for most relevant
purposes. I don't know of any use for RT ranks except to overcome
limitations of other languages. D't powerful variadic functions should
deal with that nicely.
CT shapes on the other hand can become relevant, but these would be a
different kind of arrays. Some comparable C++ libraries offer
"TinyArrays" which have a CT shape. I myself made heavy use of those in
one project, where I had to handle myriads of complex 3x3 matrices.
However, TinyArrays are conceptually quite different from the more
commonly used numerical arrays with RT shape.
* 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?).
Better put it in a module with a descriptive name and keep the names of
individual elements inside short.
* Have I misused some terminology (top dimension etc.)?
I don't know what "top" means here. Isn't "first" or "last" clearer?
For the remaining questions I have nothing smart to add, so I leave
those to others...