added missed commit

This commit is contained in:
froejdh_e 2025-04-22 15:22:47 +02:00
parent 326941e2b4
commit b501c31e38
2 changed files with 17 additions and 30 deletions

View File

@ -3,6 +3,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <numeric>
using aare::NDView; using aare::NDView;
using aare::Shape; using aare::Shape;
@ -21,10 +22,8 @@ TEST_CASE("Element reference 1D") {
} }
TEST_CASE("Element reference 2D") { TEST_CASE("Element reference 2D") {
std::vector<int> vec; std::vector<int> vec(12);
for (int i = 0; i != 12; ++i) { std::iota(vec.begin(), vec.end(), 0);
vec.push_back(i);
}
NDView<int, 2> data(vec.data(), Shape<2>{3, 4}); NDView<int, 2> data(vec.data(), Shape<2>{3, 4});
REQUIRE(vec.size() == static_cast<size_t>(data.size())); REQUIRE(vec.size() == static_cast<size_t>(data.size()));
@ -58,10 +57,8 @@ TEST_CASE("Element reference 3D") {
} }
TEST_CASE("Plus and miuns with single value") { TEST_CASE("Plus and miuns with single value") {
std::vector<int> vec; std::vector<int> vec(12);
for (int i = 0; i != 12; ++i) { std::iota(vec.begin(), vec.end(), 0);
vec.push_back(i);
}
NDView<int, 2> data(vec.data(), Shape<2>{3, 4}); NDView<int, 2> data(vec.data(), Shape<2>{3, 4});
data += 5; data += 5;
int i = 0; int i = 0;
@ -116,10 +113,8 @@ TEST_CASE("elementwise assign") {
} }
TEST_CASE("iterators") { TEST_CASE("iterators") {
std::vector<int> vec; std::vector<int> vec(12);
for (int i = 0; i != 12; ++i) { std::iota(vec.begin(), vec.end(), 0);
vec.push_back(i);
}
NDView<int, 1> data(vec.data(), Shape<1>{12}); NDView<int, 1> data(vec.data(), Shape<1>{12});
int i = 0; int i = 0;
for (const auto item : data) { for (const auto item : data) {
@ -167,26 +162,20 @@ TEST_CASE("divide with another span") {
} }
TEST_CASE("Retrieve shape") { TEST_CASE("Retrieve shape") {
std::vector<int> vec; std::vector<int> vec(12);
for (int i = 0; i != 12; ++i) { std::iota(vec.begin(), vec.end(), 0);
vec.push_back(i);
}
NDView<int, 2> data(vec.data(), Shape<2>{3, 4}); NDView<int, 2> data(vec.data(), Shape<2>{3, 4});
REQUIRE(data.shape()[0] == 3); REQUIRE(data.shape()[0] == 3);
REQUIRE(data.shape()[1] == 4); REQUIRE(data.shape()[1] == 4);
} }
TEST_CASE("compare two views") { TEST_CASE("compare two views") {
std::vector<int> vec1; std::vector<int> vec1(12);
for (int i = 0; i != 12; ++i) { std::iota(vec1.begin(), vec1.end(), 0);
vec1.push_back(i);
}
NDView<int, 2> view1(vec1.data(), Shape<2>{3, 4}); NDView<int, 2> view1(vec1.data(), Shape<2>{3, 4});
std::vector<int> vec2; std::vector<int> vec2(12);
for (int i = 0; i != 12; ++i) { std::iota(vec2.begin(), vec2.end(), 0);
vec2.push_back(i);
}
NDView<int, 2> view2(vec2.data(), Shape<2>{3, 4}); NDView<int, 2> view2(vec2.data(), Shape<2>{3, 4});
REQUIRE((view1 == view2)); REQUIRE((view1 == view2));
@ -194,10 +183,8 @@ TEST_CASE("compare two views") {
TEST_CASE("Create a view over a vector"){ TEST_CASE("Create a view over a vector"){
std::vector<int> vec; std::vector<int> vec(12);
for (int i = 0; i != 12; ++i) { std::iota(vec.begin(), vec.end(), 0);
vec.push_back(i);
}
auto v = aare::make_view(vec); auto v = aare::make_view(vec);
REQUIRE(v.shape()[0] == 12); REQUIRE(v.shape()[0] == 12);
REQUIRE(v[0] == 0); REQUIRE(v[0] == 0);

View File

@ -64,12 +64,12 @@ TEST_CASE("test_adc_sar_05_decode64to16"){
double output = aare::apply_custom_weights(input, weights); double output = aare::apply_custom_weights(input, weights);
CHECK_THAT(output, WithinAbs(1.0, 0.001)); CHECK_THAT(output, WithinAbs(1.0, 0.001));
input = 1UL << 1; input = 1 << 1;
output = aare::apply_custom_weights(input, weights); output = aare::apply_custom_weights(input, weights);
CHECK_THAT(output, WithinAbs(2.1, 0.001)); CHECK_THAT(output, WithinAbs(2.1, 0.001));
input = 1UL << 2; input = 1 << 2;
output = aare::apply_custom_weights(input, weights); output = aare::apply_custom_weights(input, weights);
CHECK_THAT(output, WithinAbs(3.24, 0.001)); CHECK_THAT(output, WithinAbs(3.24, 0.001));