Rectangular multidimensional arrays for D

H. S. Teoh hsteoh at quickfur.ath.cx
Fri Oct 11 15:39:49 PDT 2013


On Tue, Oct 08, 2013 at 06:42:12PM +0400, Denis Shelomovskij wrote:
> I accidentally discovered Andrei wrote [1] multidimensional array
> implementation is needed. If it really is, I will work to revise the
> API and prepare my implementation [2] for review if nobody is doing
> it already.
> 
> Also as Kenji's "multidimensional indexing and slicing" pull [3]
> still not merged the only way is to use hacks like this:
> ---
> // first two rows and three columns of the second matrix
> array2d = matrices[1, R[0 .. 2], R[0 .. 3]];
> ---
[...]

What's the reason Kenji's pull isn't merged yet? As I see it, it does
not introduce any problematic areas, but streamlines multidimensional
indexing notation in a nice way that fits in well with the rest of the
language. I, for one, would push for it to be merged.

In any case, I've seen your multidimensional array implementation
before, and I think it would be a good thing to have it in Phobos. In
fact, I've written my own as well, and IIRC one or two other people have
done the same. Clearly, the demand is there.

See also the thread about std.linalg; I think before we can even talk
about having linear algebra code in Phobos, we need a solidly-designed
rectangular array API. As I said in that other thread, matrix algebra
really should be built on top of a solid rectangular array API, and not
be yet another separate kind of type that's similar to, but incompatible
with rectangular arrays. A wrapper type can be used to make a
rectangular array behave in the linear algebra sense (i.e. matrix
product instead of per-element multiplication).


T

-- 
Debian GNU/Linux: Cray on your desktop.


More information about the Digitalmars-d mailing list