Open cbodenst opened 8 years ago
thats easy, i think: af::moddims(array, array.dims(0) * array.dims(1), array.dims(2))
for 3D to 2D.
for 4D its then af::moddims(array, array.dims(0) * array.dims(1) * array.dims(2), array.dims(3))
moddims will copy the data
#include <arrayfire.h>
int main()
{
af::array a = af::constant(1,4,3,2);
af::array b = af::moddims(a, a.dims(0) * a.dims(1), a.dims(2));
b *= 2;
af_print(a);
af_print(b);
}
will result in
a
[4 3 2 1]
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
1.0000 1.0000 1.0000
b
[12 2 1 1]
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
2.0000 2.0000
But only if you modify them, i hope.
If the data is more than 2-dimensional we have to find a way to create a view on the data that lets the array look 2-dimensional. This way we could easily use all algorithms that has been developed for 2-D data on n-D data.