From a198aa1cba49e6f8409779544b28034d5811ad4f Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Mon, 15 Dec 2014 13:30:37 +1100 Subject: [PATCH] matrix: add trivial matrix-mul test --- test/matrix.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/test/matrix.cpp b/test/matrix.cpp index 420e2969..052ef48e 100644 --- a/test/matrix.cpp +++ b/test/matrix.cpp @@ -32,6 +32,39 @@ main (int, char **) { CHECK_EQ (r.w, 150); } + { + // Simple matrix-matrix multiplication + util::matrix a { { + { 1, 2, 3, 4 }, + { 5, 6, 7, 8 }, + { 9, 10, 11, 12 }, + { 13, 14, 15, 16 }, + } }; + + util::matrix b { { + { 17, 18, 19, 20 }, + { 21, 22, 23, 24 }, + { -1, -2, -3, -4 }, + { -5, -6, -7, -8 } + } }; + + util::matrix ab { { + { 9, 8, 7, 6 }, + { 41, 40, 39, 38 }, + { 73, 72, 71, 70 }, + { 105, 104, 103, 102 }, + } }; + + ab *= 4; + + auto res = a * b; + + std::cout << a << "\nx\n" << b << "\n=\n" << (res / 4) << '\n'; + + CHECK_EQ (ab, res); + } + + { // Ensure identity inverts to identity auto m = util::matrix::IDENTITY.inverse ();