## digitalmars.D.learn - taking a crosssection of a 3-D array

- Andrew (5/5) May 29 2009 So, how do I take a cross section of a 3-D array. Basically I want to b...
- bearophile (6/8) May 30 2009 Languages (or libraries) like matlab and NumPy allow to slice nD arrays ...

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][]; something like that. Any ideas? if you need more info, let me know. -Andrew

May 29 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

May 30 2009