summaryrefslogtreecommitdiff
path: root/modules/codec/tests/math.cpp
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-10-12 12:50:40 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-10-12 12:50:40 +0200
commitaf87db21b8c72d16e4f63aba9fcfecd48167e71d (patch)
tree2d65d081ef99ff72cb7beaf7e606c83c3d355417 /modules/codec/tests/math.cpp
parente39ee8cb7e664439db06e37fab89c7f570d4da2f (diff)
downloadforstio-forstio-af87db21b8c72d16e4f63aba9fcfecd48167e71d.tar.gz
Added multiplication for matrices and vectors
Diffstat (limited to 'modules/codec/tests/math.cpp')
-rw-r--r--modules/codec/tests/math.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/codec/tests/math.cpp b/modules/codec/tests/math.cpp
index 6f60e9c..25608e2 100644
--- a/modules/codec/tests/math.cpp
+++ b/modules/codec/tests/math.cpp
@@ -120,4 +120,25 @@ SAW_TEST("Math/Normalize"){
SAW_EXPECT(c.at({{0u}}).get() == 1.0, std::string{"Unexpected value for dot + sqrt "} + std::to_string(c.at({{0u}}).get()) );
SAW_EXPECT(c.at({{1u}}).get() == 0.0, std::string{"Unexpected value for dot + sqrt "} + std::to_string(c.at({{1u}}).get()) );
}
+
+SAW_TEST("Math/Matrix Multiply"){
+ using namespace saw;
+
+ data<sch::Matrix<sch::Int64, 2u, 2u>> a;
+ {
+ a.at({{0u,0u}}) = 1;
+ a.at({{0u,1u}}) = 3;
+ a.at({{1u,0u}}) = 2;
+ a.at({{1u,1u}}) = 4;
+ }
+ data<sch::Matrix<sch::Int64, 2u, 1u>> b;
+ {
+ b.at({{0u,0u}}) = -1;
+ b.at({{1u,0u}}) = 2;
+ }
+ auto c = math::multiply(a,b);
+
+ SAW_EXPECT(c.at({{0u,0u}}).get() == 5, std::string{"Unexpected value for Matrix Multiply (0,0): "} + std::to_string(c.at({{0u,0u}}).get()) );
+ SAW_EXPECT(c.at({{1u,0u}}).get() == 6, std::string{"Unexpected value for Matrix Multiply (1,0): "} + std::to_string(c.at({{1u,0u}}).get()) );
+}
}