diff options
| author | y-jan137 <yousefjan24000@gmail.com> | 2026-03-13 16:26:47 +0300 |
|---|---|---|
| committer | y-jan137 <yousefjan24000@gmail.com> | 2026-03-13 16:26:47 +0300 |
| commit | 5ac9489c079f3f1a0ba1d2d8385001ada83a13b8 (patch) | |
| tree | a07d57dbcca967685b05ee8b65b5be78e7818202 /tests/test_matrix.cpp | |
| parent | 38004f74df5b2dbcb07e6ad5ac2272f16882e018 (diff) | |
Implement vectorized matmul
Diffstat (limited to 'tests/test_matrix.cpp')
| -rw-r--r-- | tests/test_matrix.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/test_matrix.cpp b/tests/test_matrix.cpp index 4cfc783..fcd3d27 100644 --- a/tests/test_matrix.cpp +++ b/tests/test_matrix.cpp @@ -174,3 +174,28 @@ TEST_CASE("Matrix-matrix multiply handles identity and shape checks", "[matrix]" const Matrix incompatible(4, 1); CHECK_THROWS_AS(lhs * incompatible, DimensionMismatchError); } + +TEST_CASE("Matrix-matrix multiply handles SIMD tail dimensions", "[matrix]") { + const Matrix lhs{ + {1.0, 2.0, 3.0, 4.0, 5.0}, + {6.0, 7.0, 8.0, 9.0, 10.0} + }; + const Matrix rhs{ + {1.0, 0.0, 2.0}, + {0.0, 1.0, 3.0}, + {1.0, 1.0, 4.0}, + {0.0, 2.0, 5.0}, + {1.0, 0.0, 6.0} + }; + + const Matrix product = lhs * rhs; + REQUIRE(product.rows() == 2); + REQUIRE(product.cols() == 3); + + CHECK(product(0, 0) == Catch::Approx(9.0)); + CHECK(product(0, 1) == Catch::Approx(13.0)); + CHECK(product(0, 2) == Catch::Approx(70.0)); + CHECK(product(1, 0) == Catch::Approx(24.0)); + CHECK(product(1, 1) == Catch::Approx(33.0)); + CHECK(product(1, 2) == Catch::Approx(170.0)); +} |