35 :
UnitTest (
"Linear Algebra UnitTests", UnitTestCategories::dsp)
40 template <
typename ElementType>
43 const ElementType data1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
44 const ElementType data2[] = { 1, -1, 3, -1, 5, -1, 7, -1 };
45 const ElementType data3[] = { 2, 1, 6, 3, 10, 5, 14, 7 };
51 u.
expect((mat1 + mat2) == mat3);
57 template <
typename ElementType>
60 const ElementType data1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
61 const ElementType data2[] = { 1, -1, 3, -1, 5, -1, 7, -1 };
62 const ElementType data3[] = { 0, 3, 0, 5, 0, 7, 0, 9 };
68 u.
expect((mat1 - mat2) == mat3);
74 template <
typename ElementType>
77 const ElementType data1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
78 const ElementType scalar = 2.0;
79 const ElementType data2[] = { 2, 4, 6, 8, 10, 12, 14, 16 };
84 u.
expect ((x * scalar) == expected);
90 template <
typename ElementType>
93 const ElementType data1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
94 const ElementType data2[] = { 1, -1, 3, -1, 5, -1, 7, -1 };
95 const ElementType data3[] = { 1, -2, 9, -4, 25, -6, 49, -8 };
107 template <
typename ElementType>
110 const ElementType data1[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
111 const ElementType data2[] = { 1, -1, 3, -1, 5, -1, 7, -1 };
112 const ElementType data3[] = { 50, -10, 114, -26 };
118 u.
expect((mat1 * mat2) == mat3);
124 template <
typename ElementType>
127 const ElementType data1[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
134 template <
typename ElementType>
137 const ElementType data1[] = { 1, -1, 2, -2 };
138 const ElementType data2[] = { -1, 0, -1, -7 };
139 const ElementType data3[] = { 1, 4, 2, 1, -1, 1, 4, 3, -2, -1, 1, 1, -1, 0, 1, 4 };
150 template <
class TheTest>
151 void runTestForAllTypes (
const char* unitTestName)
155 TheTest::template run<float> (*
this);
156 TheTest::template run<double> (*
this);
161 runTestForAllTypes<AdditionTest> (
"AdditionTest");
162 runTestForAllTypes<DifferenceTest> (
"DifferenceTest");
163 runTestForAllTypes<ScalarMultiplicationTest> (
"ScalarMultiplication");
164 runTestForAllTypes<HadamardProductTest> (
"HadamardProductTest");
165 runTestForAllTypes<MultiplicationTest> (
"MultiplicationTest");
166 runTestForAllTypes<IdentityMatrixTest> (
"IdentityMatrixTest");
167 runTestForAllTypes<SolvingTest> (
"SolvingTest");
171static LinearAlgebraUnitTest linearAlgebraUnitTest;
This is a base class for classes that perform a unit test.
UnitTest(const String &name, const String &category=String())
Creates a test with the given name and optionally places it in a category.
void beginTest(const String &testName)
Tells the system that a new subsection of tests is beginning.
void expect(bool testResult, const String &failureMessage=String())
Checks that the result of a test is true, and logs this result.
General matrix and vectors class, meant for classic math manipulation such as additions,...
bool solve(Matrix &b) const noexcept
Solves a linear system of equations represented by this object and the argument b,...
void runTest() override
Implement this method in your subclass to actually run your tests.