diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-11-07 18:05:26 +0100 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-11-07 18:05:26 +0100 |
| commit | 2e836ead5c10f00917560e9a98d46b59b2f977d4 (patch) | |
| tree | eba00a1337dbca7db3937c56d7ba9f20f9a9d146 /modules/codec/tests/math.cpp | |
| parent | beed9c20da5fbacf8626e2d4b747bb84ae7f6d93 (diff) | |
| download | forstio-forstio-2e836ead5c10f00917560e9a98d46b59b2f977d4.tar.gz | |
Fixing double bracketing
Diffstat (limited to 'modules/codec/tests/math.cpp')
| -rw-r--r-- | modules/codec/tests/math.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/modules/codec/tests/math.cpp b/modules/codec/tests/math.cpp index 18b6c41..ad79c95 100644 --- a/modules/codec/tests/math.cpp +++ b/modules/codec/tests/math.cpp @@ -24,8 +24,29 @@ SAW_TEST("Math/Basic"){ SAW_TEST("Math/Tensor Construction"){ using namespace saw; - // data<sch::Scalar<sch::Float32>> a{{5.1f}}; - // data<sch::Vector<sch::Int32,3u>> b{{{1,3,5}}}; + data<sch::Vector<sch::Int32,3u>> b{1,3,5}; + + /** + * A one dimensional index keeps the inner braces, since a single + * element has to stay explicit to not clash with data<UInt64>. + */ + SAW_EXPECT(b.at({{0u}}).get() == 1, "Wrong value at 0"); + SAW_EXPECT(b.at({{1u}}).get() == 3, "Wrong value at 1"); + SAW_EXPECT(b.at({{2u}}).get() == 5, "Wrong value at 2"); + + /** + * From two dimensions up the index forwards, since it is a FixedArray + * itself. + * + * The elements are given in flat order, and get_flat_index runs the + * stride from dimension zero up, so the first index varies fastest. + */ + data<sch::Matrix<sch::Float64,2u,2u>> c{1.0, 2.0, 3.0, 4.0}; + + SAW_EXPECT(c.at({0u,0u}).get() == 1.0, "Wrong value at 0,0"); + SAW_EXPECT(c.at({1u,0u}).get() == 2.0, "Wrong value at 1,0"); + SAW_EXPECT(c.at({0u,1u}).get() == 3.0, "Wrong value at 0,1"); + SAW_EXPECT(c.at({1u,1u}).get() == 4.0, "Wrong value at 1,1"); } SAW_TEST("Math/Tensor Fill"){ |
