Skip to content

Commit

Permalink
Matrix3_TEST: improve multiplication test
Browse files Browse the repository at this point in the history
This changes the test matrices that are multiplied
togther so that they aren't scalar multiples of each other.
This confirms non-commutativity in the test.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters committed Sep 16, 2021
1 parent 93bed04 commit c541db4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions src/Matrix3_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,24 @@ TEST(Matrix3dTest, OperatorMul)
4, 5, 6,
7, 8, 9);

math::Matrix3d matB(10, 20, 30,
40, 50, 60,
70, 80, 90);
math::Matrix3d matB(11, 21, 31,
41, 51, 61,
71, 81, 91);

mat = matA * matB;
EXPECT_EQ(mat, math::Matrix3d(300, 360, 420,
660, 810, 960,
1020, 1260, 1500));
EXPECT_EQ(mat, math::Matrix3d(306, 366, 426,
675, 825, 975,
1044, 1284, 1524));

mat = matB * matA;
EXPECT_EQ(mat, math::Matrix3d(300, 360, 420,
660, 810, 960,
1020, 1260, 1500));
EXPECT_EQ(mat, math::Matrix3d(312, 375, 438,
672, 825, 978,
1032, 1275, 1518));

mat = mat * 2.0;
EXPECT_EQ(mat, math::Matrix3d(600, 720, 840,
1320, 1620, 1920,
2040, 2520, 3000));
EXPECT_EQ(mat, math::Matrix3d(624, 750, 876,
1344, 1650, 1956,
2064, 2550, 3036));
}

/////////////////////////////////////////////////
Expand Down
26 changes: 13 additions & 13 deletions src/python/Matrix3_TEST.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,24 @@ def test_mul(self):
matA = Matrix3d(1, 2, 3,
4, 5, 6,
7, 8, 9)
matB = Matrix3d(10, 20, 30,
40, 50, 60,
70, 80, 90)
matB = Matrix3d(11, 21, 31,
41, 51, 61,
71, 81, 91)

mat = matB * matA
self.assertAlmostEqual(mat, Matrix3d(300, 360, 420,
660, 810, 960,
1020, 1260, 1500))
mat = matA * matB
self.assertAlmostEqual(mat, Matrix3d(306, 366, 426,
675, 825, 975,
1044, 1284, 1524))

mat = matB * matA
self.assertAlmostEqual(mat, Matrix3d(300, 360, 420,
660, 810, 960,
1020, 1260, 1500))
self.assertAlmostEqual(mat, Matrix3d(312, 375, 438,
672, 825, 978,
1032, 1275, 1518))

mat = mat * 2.0
self.assertAlmostEqual(mat, Matrix3d(600, 720, 840,
1320, 1620, 1920,
2040, 2520, 3000))
self.assertAlmostEqual(mat, Matrix3d(624, 750, 876,
1344, 1650, 1956,
2064, 2550, 3036))

def test_vector3_mul(self):
matrix = Matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9)
Expand Down

0 comments on commit c541db4

Please sign in to comment.