From af87db21b8c72d16e4f63aba9fcfecd48167e71d Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Sun, 12 Oct 2025 12:50:40 +0200 Subject: Added multiplication for matrices and vectors --- modules/codec/tests/math.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/codec/tests') 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> a; + { + a.at({{0u,0u}}) = 1; + a.at({{0u,1u}}) = 3; + a.at({{1u,0u}}) = 2; + a.at({{1u,1u}}) = 4; + } + data> 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()) ); +} } -- cgit v1.2.3