taking a crosssection of a 3-D array
bearophile
bearophileHUGS at lycos.com
Sat May 30 05:07:32 PDT 2009
Andrew:
> So, how do I take a cross section of a 3-D array. Basically I want to be able to take a 2D matrix from a 3-D array.
> auto m = a[][n][];
Languages (or libraries) like matlab and NumPy allow to slice nD arrays like you say, using a very compact syntax, but currently the D1/D2 languages aren't designed for people that perform "serious" numerical computations, so it doesn't offer built-in ways to slice nD arrays.
So you can write a function template that performs such slices, that insides copies items.
Currently D1/D2 1D arrays are 2-structs that point to a memory zone, so 2D arrays are 2-structs that contain a pointer to a memory zone of structs that contain pointers to memory zones of the "rows" of data.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list