Ocean
Loading...
Searching...
No Matches
TestStaticMatrix.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTMATH_TEST_STATIC_MATRIX_H
9#define META_OCEAN_TEST_TESTMATH_TEST_STATIC_MATRIX_H
10
12
14
15namespace Ocean
16{
17
18namespace Test
19{
20
21namespace TestMath
22{
23
24/**
25 * This class implements the test of the StaticMatrix class.
26 * @ingroup testmath
27 */
28class OCEAN_TEST_MATH_EXPORT TestStaticMatrix
29{
30 public:
31
32 /**
33 * Tests all matrix functions.
34 * @param testDuration The number of seconds for each test, with range (0, infinity)
35 * @param selector The test selector
36 * @return True, if succeeded
37 */
38 static bool test(const double testDuration, const TestSelector& selector);
39
40 /**
41 * Tests the constructor creating a identity or null matrix.
42 * @return True, if succeeded
43 */
45
46 /**
47 * Tests the constructor creating a matrix from a given buffer.
48 * @return True, if succeeded
49 */
50 static bool testConstructorData();
51
52 /**
53 * Tests the transpose function.
54 * @param testDuration The number of seconds for each test, with range (0, infinity)
55 * @return True, if succeeded
56 */
57 static bool testTranspose(const double testDuration);
58
59 /**
60 * Tests the add operator.
61 * @param testDuration The number of seconds for each test, with range (0, infinity)
62 * @return True, if succeeded
63 */
64 static bool testMatrixAdd(const double testDuration);
65
66 /**
67 * Tests the matrix add function for transposed matrices.
68 * @param testDuration The number of seconds for each test, with range (0, infinity)
69 * @return True, if succeeded
70 */
71 static bool testMatrixAddTransposed(const double testDuration);
72
73 /**
74 * Tests the scalar multiplication operator.
75 * @param testDuration The number of seconds for each test, with range (0, infinity)
76 * @return True, if succeeded
77 */
78 static bool testScalarMultiplication(const double testDuration);
79
80 /**
81 * Tests the vector multiplication.
82 * @param testDuration The number of seconds for each test, with range (0, infinity)
83 * @return True, if succeeded
84 * @tparam T The data type of a scalar value
85 */
86 template <typename T>
87 static bool testVectorMultiplication(const double testDuration);
88
89 /**
90 * Tests the matrix multiplication operator.
91 * @param testDuration The number of seconds for each test, with range (0, infinity)
92 * @return True, if succeeded
93 */
94 static bool testMatrixMultiplication(const double testDuration);
95
96 /**
97 * Tests the matrix multiplication between the transposed and non-transposed matrix.
98 * @param testDuration The number of seconds for each test, with range (0, infinity)
99 * @return True, if succeeded
100 */
101 static bool testMatrixMultiplicationTransposedLeft(const double testDuration);
102
103 /**
104 * Tests the matrix multiplication between the non-transposed and transposed matrix.
105 * @param testDuration The number of seconds for each test, with range (0, infinity)
106 * @return True, if succeeded
107 */
108 static bool testMatrixMultiplicationTransposedRight(const double testDuration);
109
110 /**
111 * Tests the linear solver by application of the cholesky decomposition.
112 * @param testDuration Number of seconds for each test, with range (0, infinity)
113 * @return True, if succeeded
114 */
115 static bool testSolveCholesky(const double testDuration);
116
117 protected:
118
119 /**
120 * Tests the constructor creating a matrix from a given buffer.
121 * @return True, if succeeded
122 * @tparam tRows The number of matrix rows, with range [1, infinity)
123 * @tparam tColumns The number of matrix columns, with range [1, infinity)
124 */
125 template <size_t tRows, size_t tColumns>
126 static bool testConstructorData();
127
128 /**
129 * Tests the transpose function.
130 * @return True, if succeeded
131 * @tparam tRows The number of matrix rows, with range [1, infinity)
132 * @tparam tColumns The number of matrix columns, with range [1, infinity)
133 */
134 template <size_t tRows, size_t tColumns>
135 static bool testTranspose();
136
137 /**
138 * Tests the matrix add operator.
139 * @return True, if succeeded
140 * @tparam tRows The number of matrix rows, with range [1, infinity)
141 * @tparam tColumns The number of matrix columns, with range [1, infinity)
142 */
143 template <size_t tRows, size_t tColumns>
144 static bool testMatrixAdd();
145
146 /**
147 * Tests the add function for transposed matrices.
148 * @return True, if succeeded
149 * @tparam tRows The number of matrix rows, with range [1, infinity)
150 * @tparam tColumns The number of matrix columns, with range [1, infinity)
151 */
152 template <size_t tRows, size_t tColumns>
154
155 /**
156 * Tests the scalar multiplication operator.
157 * @return True, if succeeded
158 * @tparam tRows The number of matrix rows, with range [1, infinity)
159 * @tparam tColumns The number of matrix columns, with range [1, infinity)
160 */
161 template <size_t tRows, size_t tColumns>
163
164 /**
165 * Tests the vector multiplication operator.
166 * @param testDuration The number of seconds for each test, with range (0, infinity)
167 * @return True, if succeeded
168 * @tparam T The data type of a scalar value
169 * @tparam tSize The number of vector elements (the matrix will be a matching square matrix), with range [1, infinity)
170 */
171 template <typename T, size_t tSize>
172 static bool testVectorMultiplication(const double testDuration);
173
174 /**
175 * Tests the matrix multiplication operator.
176 * @return True, if succeeded
177 * @tparam tRows The number of matrix rows, with range [1, infinity)
178 * @tparam tColumns The number of matrix columns, with range [1, infinity)
179 * @tparam tColumns2 The number of columns of the second matrix, with range [1, infinity)
180 */
181 template <size_t tRows, size_t tColumns, size_t tColumns2>
183
184 /**
185 * Tests the matrix multiplication between the transposed and non-transposed matrix.
186 * @return True, if succeeded
187 * @tparam tRows The number of matrix rows, with range [1, infinity)
188 * @tparam tColumns The number of matrix columns, with range [1, infinity)
189 */
190 template <size_t tRows, size_t tColumns>
192
193 /**
194 * Tests the matrix multiplication between the non-transposed and transposed matrix.
195 * @return True, if succeeded
196 * @tparam tRows The number of matrix rows, with range [1, infinity)
197 * @tparam tColumns The number of matrix columns, with range [1, infinity)
198 */
199 template <size_t tRows, size_t tColumns>
201
202 /**
203 * Returns whether the provided matrix is a identity matrix.
204 * @param matrix The matrix to be checked
205 * @param rows The explicit number of rows to be checked, with range [0, matrix.rows()]
206 * @param columns The explicit number of columns to be checked, with range [0, matrix.columns()]
207 * @return True, if so
208 * @tparam T The data type of the matrix
209 */
210 template <typename T>
211 static bool isIdentityMatrix(const T& matrix, const size_t rows, const size_t columns);
212
213 /**
214 * Returns whether all elements of the provided matrix are zero.
215 * @param matrix The matrix to be checked
216 * @param rows The explicit number of rows to be checked, with range [0, matrix.rows()]
217 * @param columns The explicit number of columns to be checked, with range [0, matrix.columns()]
218 * @return True, if so
219 * @tparam T The data type of the matrix
220 */
221 template <typename T>
222 static bool isNullMatrix(const T& matrix, const size_t rows, const size_t columns);
223
224 /**
225 * Tests the linear solver by application of the cholesky decomposition.
226 * @param testDuration Number of seconds for each test, with range (0, infinity)
227 * @return True, if succeeded
228 * @tparam tSize The number of rows and columns of the symmetric matrix, with range [1, infinity)
229 */
230 template <size_t tSize>
231 static bool testSolveCholeskyMatrix(double testDuration);
232};
233
234}
235
236}
237
238}
239
240#endif // META_OCEAN_TEST_TESTMATH_TEST_STATIC_MATRIX_H
This class implements the test of the StaticMatrix class.
Definition TestStaticMatrix.h:29
static bool testTranspose(const double testDuration)
Tests the transpose function.
static bool testConstructorData()
Tests the constructor creating a matrix from a given buffer.
static bool testScalarMultiplication()
Tests the scalar multiplication operator.
static bool testTranspose()
Tests the transpose function.
static bool testMatrixAddTransposed()
Tests the add function for transposed matrices.
static bool testMatrixMultiplication()
Tests the matrix multiplication operator.
static bool testMatrixMultiplicationTransposedRight()
Tests the matrix multiplication between the non-transposed and transposed matrix.
static bool testSolveCholeskyMatrix(double testDuration)
Tests the linear solver by application of the cholesky decomposition.
static bool testVectorMultiplication(const double testDuration)
Tests the vector multiplication operator.
static bool testMatrixMultiplicationTransposedLeft(const double testDuration)
Tests the matrix multiplication between the transposed and non-transposed matrix.
static bool testVectorMultiplication(const double testDuration)
Tests the vector multiplication.
static bool testMatrixAdd()
Tests the matrix add operator.
static bool testMatrixMultiplicationTransposedLeft()
Tests the matrix multiplication between the transposed and non-transposed matrix.
static bool testMatrixAdd(const double testDuration)
Tests the add operator.
static bool isIdentityMatrix(const T &matrix, const size_t rows, const size_t columns)
Returns whether the provided matrix is a identity matrix.
static bool testConstructorData()
Tests the constructor creating a matrix from a given buffer.
static bool testMatrixAddTransposed(const double testDuration)
Tests the matrix add function for transposed matrices.
static bool testSolveCholesky(const double testDuration)
Tests the linear solver by application of the cholesky decomposition.
static bool testConstructorIdentity()
Tests the constructor creating a identity or null matrix.
static bool testScalarMultiplication(const double testDuration)
Tests the scalar multiplication operator.
static bool test(const double testDuration, const TestSelector &selector)
Tests all matrix functions.
static bool isNullMatrix(const T &matrix, const size_t rows, const size_t columns)
Returns whether all elements of the provided matrix are zero.
static bool testMatrixMultiplication(const double testDuration)
Tests the matrix multiplication operator.
static bool testMatrixMultiplicationTransposedRight(const double testDuration)
Tests the matrix multiplication between the non-transposed and transposed matrix.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15