dsharlet / array

C++ multidimensional arrays in the spirit of the STL
Apache License 2.0
198 stars 15 forks source link

Automatic strides for a final dim of extent 1 is 1 instead of product of previous extents in the default and dense_array case #101

Open jiawen opened 4 months ago

jiawen commented 4 months ago

Code:

nda::array_of_rank<float, 4> image({640, 480, 3, 1});
LOG(INFO) << image.shape();

nda::array_of_rank<float, 4> image2({640, 480, 3, 10});
LOG(INFO) << image2.shape();

nda::array_of_rank<float, 4> image3({640, 480, 3, 20});
LOG(INFO) << image3.shape();

nda::array_ref_of_rank<float, 5> image3_embedded = nda::convert_shape<nda::shape_of_rank<5>>(image3.ref());
LOG(INFO) << image3_embedded.shape();

Output:

I0000 00:00:1717188518.011478 19279011 array_test.cpp:49] shape<4>(dim(0, 640, 1), dim(0, 480, 640), dim(0, 3, 307200), dim(0, 1, 1))
I0000 00:00:1717188518.047921 19279011 array_test.cpp:52] shape<4>(dim(0, 640, 1), dim(0, 480, 640), dim(0, 3, 307200), dim(0, 10, 921600))
I0000 00:00:1717188518.117122 19279011 array_test.cpp:55] shape<4>(dim(0, 640, 1), dim(0, 480, 640), dim(0, 3, 307200), dim(0, 20, 921600))
I0000 00:00:1717188518.117223 19279011 array_test.cpp:60] shape<5>(dim(0, 640, 1), dim(0, 480, 640), dim(0, 3, 307200), dim(0, 20, 921600), dim(0, 1, 1))

Investigate why this isn't covered by #95.