#include #include #include "Math.h" #include "MathCommon.ut.h" /// Test nxn matrix multiplication template void testMatrixMul() { int dimention = log2(sizeof(Type) / sizeof(float)); Type r, a, b; // Fill for(int i = 0; i < dimention; i++) { for(int j = 0; j < dimention; j++) { a(i, j) = randFloat(); b(i, j) = randFloat(); } } // Calc r = a * b as usual for(int i = 0; i < dimention; i++) { for(int j = 0; j < dimention; j++) { r(i, j) = 0.0; for(int k = 0; k < dimention; k++) { r(i, j) += a(i, k) * b(k, j); } } } EXPECT_EQ(r, a * b); } template void arithmeticOperations() { testOperators(); testMatrixMul(); testOperators(); testOperatorsWithFloat(); testOperatorsWithFloat(); testOperatorsWithFloat(); testOperatorsWithFloat(); testCmpOperators(); } TEST(MathTests, MatrixOperators) { arithmeticOperations(); arithmeticOperations(); }