You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug or expected behavior.
Consider the following unit tests (following style from tests/c++/nda_functions.cpp
TEST(reshape, reshape_view) { //NOLINT
nda::array<long, 1> a{1, 2, 3, 4, 5, 6}; // 1d array
auto v = reshape(a(nda::range::all), std::array{2, 3}); // v is an array_view<long,2> of size 2 x 3
v(0, nda::range::all) *= 10; // a is now {10, 20, 30, 4, 5, 6}
nda::array<long, 1> a{1, 2, 3, 4, 5, 6}; // 1d array
auto v = reshape(a(nda::range(6)), std::array{2, 3}); // v is an array_view<long,2> of size 2 x 3
v(0, nda::range::all) *= 10; // a is now {10, 20, 30, 4, 5, 6}
The first one works as expected. The second one fails with the following message:
nda/c++/nda/./././layout/idx_map.hpp: In instantiation of 'class nda::idx_map<2, 0, 0, nda::layout_prop_e::strided_1d>':
nda/c++/nda/././linalg/../blas/../layout_transforms.hpp:121:32: required from 'auto nda::reshape(A&&, const std::array<Int, Rank>&) [with A = nda::basic_array_view<long int, 1, nda::basic_layout<0, 0, nda::layout_prop_e::strided_1d>, 'A', nda::default_accessor, nda::borrowed<> >; Int = int; auto R = 2]'
nda/test/c++/nda_functions.cpp:104:19: required from here
nda/c++/nda/./././layout/idx_map.hpp:105:38: error: static assertion failed: Error in nda::idx_map: StrideOrder can only be zero for 1D arrays
105 | static_assert((StrideOrder != 0) or (Rank == 1), "Error in nda::idx_map: StrideOrder can only be zero for 1D arrays");
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
nda/c++/nda/./././layout/idx_map.hpp:105:38: note: '((0 != 0) || (2 == 1))' evaluates to false
...
nda/c++/nda/././layout/./../stdutil/array.hpp: In instantiation of 'nda::stdutil::make_initialized_array<4, int>(int)::<lambda(std::index_sequence<I ...>)> [with long unsigned int ...Is = {0, 1, 2, 3}; std::index_sequence<I ...> = std::integer_sequence<long unsigned int, 0, 1, 2, 3>]':
Steps to Reproduce
Add unit tests described above to nda_functions.cpp.
Expected behavior: [What you expect to happen]
To be able to reshape an array_view (with strided_1d layout) in cases where the storage is contiguous (compact strides).
Actual behavior:
Compilation error.
Possibly coming from layout_transformations.hpp,
line ~125
using layout_t = typename std::decay_t::layout_policy_t::template mapping;
Versions
1.3.x (and all versions before).
The text was updated successfully, but these errors were encountered:
Prerequisites
Description
Not sure if this is a bug or expected behavior.
Consider the following unit tests (following style from tests/c++/nda_functions.cpp
TEST(reshape, reshape_view) { //NOLINT
nda::array<long, 1> a{1, 2, 3, 4, 5, 6}; // 1d array
auto v = reshape(a(nda::range::all), std::array{2, 3}); // v is an array_view<long,2> of size 2 x 3
v(0, nda::range::all) *= 10; // a is now {10, 20, 30, 4, 5, 6}
EXPECT_EQ_ARRAY(a, (nda::array<long, 1>{10, 20, 30, 4, 5, 6}));
}
//================================================
TEST(reshape, reshape_view_strided) { //NOLINT
nda::array<long, 1> a{1, 2, 3, 4, 5, 6}; // 1d array
auto v = reshape(a(nda::range(6)), std::array{2, 3}); // v is an array_view<long,2> of size 2 x 3
v(0, nda::range::all) *= 10; // a is now {10, 20, 30, 4, 5, 6}
EXPECT_EQ_ARRAY(a, (nda::array<long, 1>{10, 20, 30, 4, 5, 6}));
}
//================================================
The first one works as expected. The second one fails with the following message:
nda/c++/nda/./././layout/idx_map.hpp: In instantiation of 'class nda::idx_map<2, 0, 0, nda::layout_prop_e::strided_1d>':
nda/c++/nda/././linalg/../blas/../layout_transforms.hpp:121:32: required from 'auto nda::reshape(A&&, const std::array<Int, Rank>&) [with A = nda::basic_array_view<long int, 1, nda::basic_layout<0, 0, nda::layout_prop_e::strided_1d>, 'A', nda::default_accessor, nda::borrowed<> >; Int = int; auto R = 2]'
nda/test/c++/nda_functions.cpp:104:19: required from here
nda/c++/nda/./././layout/idx_map.hpp:105:38: error: static assertion failed: Error in nda::idx_map: StrideOrder can only be zero for 1D arrays
105 | static_assert((StrideOrder != 0) or (Rank == 1), "Error in nda::idx_map: StrideOrder can only be zero for 1D arrays");
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
nda/c++/nda/./././layout/idx_map.hpp:105:38: note: '((0 != 0) || (2 == 1))' evaluates to false
...
nda/c++/nda/././layout/./../stdutil/array.hpp: In instantiation of 'nda::stdutil::make_initialized_array<4, int>(int)::<lambda(std::index_sequence<I ...>)> [with long unsigned int ...Is = {0, 1, 2, 3}; std::index_sequence<I ...> = std::integer_sequence<long unsigned int, 0, 1, 2, 3>]':
Steps to Reproduce
Add unit tests described above to nda_functions.cpp.
Expected behavior: [What you expect to happen]
To be able to reshape an array_view (with strided_1d layout) in cases where the storage is contiguous (compact strides).
Actual behavior:
Compilation error.
Possibly coming from layout_transformations.hpp,
line ~125
using layout_t = typename std::decay_t::layout_policy_t::template mapping;
Versions
1.3.x (and all versions before).
The text was updated successfully, but these errors were encountered: