matrix: add trivial matrix-mul test

This commit is contained in:
Danny Robson 2014-12-15 13:30:37 +11:00
parent 6a6933ea70
commit a198aa1cba

View File

@ -32,6 +32,39 @@ main (int, char **) {
CHECK_EQ (r.w, 150);
}
{
// Simple matrix-matrix multiplication
util::matrix<float> a { {
{ 1, 2, 3, 4 },
{ 5, 6, 7, 8 },
{ 9, 10, 11, 12 },
{ 13, 14, 15, 16 },
} };
util::matrix<float> b { {
{ 17, 18, 19, 20 },
{ 21, 22, 23, 24 },
{ -1, -2, -3, -4 },
{ -5, -6, -7, -8 }
} };
util::matrix<float> 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<float>::IDENTITY.inverse ();