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