Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for negative strides #73

Merged
merged 5 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Minor syntax improvements in c++/nda/layout/idx_map.hpp and test/c++/…
…nda_basic_array_and_view.cpp
Wentzell committed Jul 30, 2024
commit 5d100970ab506e39655b34a7fcb1e412ec2662b7
2 changes: 1 addition & 1 deletion c++/nda/layout/idx_map.hpp
Original file line number Diff line number Diff line change
@@ -224,7 +224,7 @@ namespace nda {
auto s = size();
if (s == 0) return true;
int i = Rank - 1;
for (; len[stride_order[i]] == 1; --i);
while (len[stride_order[i]] == 1 and i > 0) --i;
return (std::abs(str[stride_order[0]] * len[stride_order[0]]) == s * std::abs(str[stride_order[i]]));
}

9 changes: 4 additions & 5 deletions test/c++/nda_basic_array_and_view.cpp
Original file line number Diff line number Diff line change
@@ -568,10 +568,11 @@ TEST_F(NDAArrayAndView, SliceAccessFull) {
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_3d(i, j, k), 42);
}
}
A_s3 = A_3d;
auto A_3d_copy = A_3d;
A_s3 = A_3d_copy;
for (long i = 0; i < 2; ++i) {
for (long j = 0; j < 3; ++j) {
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_s3(i, j, k), A_3d(1 - i, 2 - j, 3 - k));
for (long k = 0; k < 4; ++k) EXPECT_EQ(A_3d(i, j, k), A_3d_copy(1 - i, 2 - j, 3 - k));
}
}
}
@@ -965,8 +966,6 @@ TEST_F(NDAArrayAndView, StrideOrderOfArrays) {

#if defined(__has_feature)
#if !__has_feature(address_sanitizer)
TEST_F(NDAArrayAndView, BadAlloc) {
EXPECT_THROW(nda::vector<int>(long(1e16)), std::bad_alloc);
}
TEST_F(NDAArrayAndView, BadAlloc) { EXPECT_THROW(nda::vector<int>(long(1e16)), std::bad_alloc); }
#endif
#endif