Ocean
Loading...
Searching...
No Matches
TestMatrix.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_MATRIX_H
9#define META_OCEAN_TEST_TESTMATH_TEST_MATRIX_H
10
12
14
15#include "ocean/math/Matrix.h"
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestMath
24{
25
26/**
27 * This class implements a matrix test.
28 * @ingroup testmath
29 */
30class OCEAN_TEST_MATH_EXPORT TestMatrix
31{
32 public:
33
34 /**
35 * Tests all matrix functions.
36 * @param testDuration The number of seconds for each test, with range (0, infinity)
37 * @param selector The test selector
38 * @return True, if succeeded
39 */
40 static bool test(const double testDuration, const TestSelector& selector);
41
42 /**
43 * Tests the element-based constructor.
44 * @param testDuration The number of seconds for each test, with range (0, infinity)
45 * @return True, if succeeded
46 */
47 static bool testElementConstructor(const double testDuration);
48
49 /**
50 * Tests the sub-matrix-based constructor.
51 * @param testDuration The number of seconds for each test, with range (0, infinity)
52 * @return True, if succeeded
53 */
54 static bool testSubMatrixConstructor(const double testDuration);
55
56 /**
57 * Tests the self square matrix function determining matrix * matrix.transposed().
58 * @param testDuration The number of seconds for each test, with range (0, infinity)
59 * @return True, if succeeded
60 */
61 static bool testSelfSquareMatrix(const double testDuration);
62
63 /**
64 * Tests the self transposed matrix function determining matrix.transposed() * matrix for an existing result matrix.
65 * @param testDuration The number of seconds for each test, with range (0, infinity)
66 * @return True, if succeeded
67 */
68 static bool testSelfTransposedSquareMatrixExistingResult(const double testDuration);
69
70 /**
71 * Tests the self transposed matrix function determining matrix.transposed() * matrix.
72 * @param testDuration The number of seconds for each test, with range (0, infinity)
73 * @return True, if succeeded
74 */
75 static bool testSelfTransposedSquareMatrix(const double testDuration);
76
77 /**
78 * Tests the self transposed matrix function determining (*this).transposed() * diag(weightDiagonal) * (*this).
79 * @param testDuration The number of seconds for each test, with range (0, infinity)
80 * @return True, if succeeded
81 */
82 static bool testWeightedSelfTransposedSquareMatrixExistingResult(const double testDuration);
83
84 /**
85 * Tests the invert function.
86 * @param testDuration The number of seconds for each test, with range (0, infinity)
87 * @return True, if succeeded
88 */
89 static bool testInvert(const double testDuration);
90
91 /**
92 * Tests the pseudo inverted matrix function.
93 * @param testDuration The number of seconds for each test, with range (0, infinity)
94 * @return True, if succeeded
95 */
96 static bool testPseudoInverted(const double testDuration);
97
98 /**
99 * Tests the rank function.
100 * @param testDuration The number of seconds for each test, with range (0, infinity)
101 * @return True, if succeeded
102 */
103 static bool testRank(const double testDuration);
104
105 /**
106 * Tests the non-negative matrix factorization
107 * @param testDuration The number of seconds for each test, with range (0, infinity)
108 * @param maxComponents The number of factorization compoments to test with, with range (1, infinity)
109 * @return True, if succeeded
110 */
111 static bool testNonNegativeMatrixFactorization(const double testDuration, const unsigned int maxComponents = 10u);
112
113 /**
114 * Tests the matrix multiplication of different matrix sizes.
115 * @param testDuration The number of seconds for each test, with range (0, infinity)
116 * @return True, if succeeded
117 */
118 static bool testMatrixMultiplication(const double testDuration);
119
120 private:
121
122 /**
123 * Validate matrix multiplication left * right = result
124 * @param left Left matrix of the matrix multiplication
125 * @param right Right matrix of the matrix multiplication
126 * @param result Result matrix of the matrix multiplication
127 * @return True, if succeeded
128 */
129 static bool validateMatrixMultiplication(const Matrix & left, const Matrix & right, const Matrix& result);
130};
131
132}
133
134}
135
136}
137
138#endif // META_OCEAN_TEST_TESTMATH_TEST_MATRIX_H
This class implements a matrix test.
Definition TestMatrix.h:31
static bool testInvert(const double testDuration)
Tests the invert function.
static bool testElementConstructor(const double testDuration)
Tests the element-based constructor.
static bool testPseudoInverted(const double testDuration)
Tests the pseudo inverted matrix function.
static bool validateMatrixMultiplication(const Matrix &left, const Matrix &right, const Matrix &result)
Validate matrix multiplication left * right = result.
static bool testMatrixMultiplication(const double testDuration)
Tests the matrix multiplication of different matrix sizes.
static bool testNonNegativeMatrixFactorization(const double testDuration, const unsigned int maxComponents=10u)
Tests the non-negative matrix factorization.
static bool testSelfTransposedSquareMatrixExistingResult(const double testDuration)
Tests the self transposed matrix function determining matrix.transposed() * matrix for an existing re...
static bool test(const double testDuration, const TestSelector &selector)
Tests all matrix functions.
static bool testSelfTransposedSquareMatrix(const double testDuration)
Tests the self transposed matrix function determining matrix.transposed() * matrix.
static bool testWeightedSelfTransposedSquareMatrixExistingResult(const double testDuration)
Tests the self transposed matrix function determining (*this).transposed() * diag(weightDiagonal) * (...
static bool testRank(const double testDuration)
Tests the rank function.
static bool testSubMatrixConstructor(const double testDuration)
Tests the sub-matrix-based constructor.
static bool testSelfSquareMatrix(const double testDuration)
Tests the self square matrix function determining matrix * matrix.transposed().
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