From 98bc157e00dbc81f1bf5dd217c0778c5b44b8eb2 Mon Sep 17 00:00:00 2001 From: Pavel Krajcevski Date: Thu, 20 Feb 2014 16:11:25 -0500 Subject: [PATCH] Add matrix multiplication test --- Base/test/TestMatrix.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Base/test/TestMatrix.cpp b/Base/test/TestMatrix.cpp index 0c3423f..baf3898 100644 --- a/Base/test/TestMatrix.cpp +++ b/Base/test/TestMatrix.cpp @@ -133,8 +133,27 @@ TEST(MatrixBase, CastVector) { } TEST(MatrixBase, MatrixMultiplication) { - // Stub - EXPECT_EQ(0, 1); + FasTC::MatrixBase a; + a(0, 0) = 1; a(0, 1) = 2; a(0, 2) = 3; + a(1, 0) = 4; a(1, 1) = 5; a(1, 2) = 6; + + FasTC::MatrixBase b; + b(0, 0) = -1; b(0, 1) = 2; b(0, 2) = -4; b(0, 3) = 5; b(0, 4) = 0; + b(1, 0) = 1; b(1, 1) = 2; b(1, 2) = 4; b(1, 3) = 6; b(1, 4) = 3; + b(2, 0) = -1; b(2, 1) = -2; b(2, 2) = -3; b(2, 3) = -4; b(2, 4) = 5; + + FasTC::MatrixBase amb = a * b; + EXPECT_NEAR(amb(0, 0), -2, kEpsilon); + EXPECT_NEAR(amb(0, 1), 0, kEpsilon); + EXPECT_NEAR(amb(0, 2), -5, kEpsilon); + EXPECT_NEAR(amb(0, 3), 5, kEpsilon); + EXPECT_NEAR(amb(0, 4), 21, kEpsilon); + + EXPECT_NEAR(amb(1, 0), -5, kEpsilon); + EXPECT_NEAR(amb(1, 1), 6, kEpsilon); + EXPECT_NEAR(amb(1, 2), -14, kEpsilon); + EXPECT_NEAR(amb(1, 3), 26, kEpsilon); + EXPECT_NEAR(amb(1, 4), 45, kEpsilon); } TEST(MatrixBase, VectorMultiplication) {