Ocean
TestEigenUtilities.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_TESTCV_TEST_EIGEN_UTILITIES_H
9 #define META_OCEAN_TEST_TESTCV_TEST_EIGEN_UTILITIES_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Test
17 {
18 
19 namespace TestCV
20 {
21 
22 /**
23  * This class implements tests for the EigenUtilities class.
24  * @ingroup testcv
25  */
26 class OCEAN_TEST_CV_EXPORT TestEigenUtilities
27 {
28  public:
29 
30  /**
31  * Invokes all tests.
32  * @param testDuration 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 frame to matrix conversion function.
39  * @param testDuration Number of seconds for each test, with range (0, infinity)
40  * @return True, if succeeded
41  */
42  static bool testFrame2Matrix(const double testDuration);
43 
44  /**
45  * Tests the conversion of Ocean VectorT2 to Eigen::Vector2T
46  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
47  * @return True, if succeeded
48  */
49  static bool testToEigenVector(const double testDuration);
50 
51  /**
52  * Tests the conversion of Eigen::Vector2T to Ocean VectorT2
53  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
54  * @return True, if succeeded
55  */
56  static bool testToOceanVector(const double testDuration);
57 
58  /**
59  * Tests the conversion of Ocean::QuaternionT<T> to Eigen::Quaternion<T>
60  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
61  * @return True, if succeeded
62  */
63  static bool testToEigenQuaternion(const double testDuration);
64 
65  /**
66  * Tests the conversion of Eigen::Quaternion<T> to Ocean::QuaternionT<T>
67  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
68  * @return True, if succeeded
69  */
70  static bool testToOceanQuaternion(const double testDuration);
71 
72  protected:
73 
74  /**
75  * Tests the frame to matrix conversion function for a specific source type and target type.
76  * @param testDuration Number of seconds for each test, with range (0, infinity)
77  * @return True, if succeeded
78  * @tparam TSource The data type of each source element
79  * @tparam TTarget The data type of each target element
80  */
81  template <typename TSource, typename TTarget>
82  static bool testFrame2Matrix(const double testDuration);
83 
84  /**
85  * Tests the conversion of Ocean VectorT{2,3,4}T to Eigen::Vector{2,3,4}T
86  * @param testDuration Number of seconds that this test will be run, range: (0, infinity)
87  * @return True if the test passed, otherwise false
88  * @tparam TType The type of the vector elements, must be either `int`, `float`, or `double`
89  * @tparam tElements Number of vector elements, range: [2, 4]
90  * @tparam TOceanVector The type of the Ocean vector that has `tElements` elements of type `TType`, e.g., `TType=int` and `tElements=3` then `TOceanVector=VectorI3`
91  */
92  template <typename TType, size_t tElements, typename TOceanVector>
93  static bool testToEigenVector(const double testDuration);
94 
95  /**
96  * Tests the conversion of Eigen::Vector{2,3,4}T to Ocean VectorT{2,3,4}T
97  * @param testDuration Number of seconds that this test will be run, range: (0, infinity)
98  * @return True if the test passed, otherwise false
99  * @tparam TType The type of the vector elements, must be either `int`, `float`, or `double`
100  * @tparam tElements Number of vector elements, range: [2, 4]
101  * @tparam TOceanVector The type of the Ocean vector that has `tElements` elements of type `TType`, e.g., `TType=int` and `tElements=3` then `TOceanVector=VectorI3`
102  */
103  template <typename TType, size_t tElements, typename TOceanVector>
104  static bool testToOceanVector(const double testDuration);
105 
106  /**
107  * Tests the conversion of Ocean::QuaternionT<T> to Eigen::Quaternion<T>
108  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
109  * @return True, if succeeded
110  * @tparam TType Type of the quaternion elements, must be either {float, double}
111  */
112  template <typename TType>
113  static bool testToEigenQuaternion(const double testDuration);
114 
115  /**
116  * Tests the conversion of Eigen::Quaternion<T> to Ocean::QuaternionT<T>
117  * @param testDuration Number of seconds that this test is rung, with range (0, infinity)
118  * @return True, if succeeded
119  * @tparam TType Type of the quaternion elements, must be either {float, double}
120  */
121  template <typename TType>
122  static bool testToOceanQuaternion(const double testDuration);
123 };
124 
125 } // namespace CV
126 
127 } // namespace Test
128 
129 } // namespace Ocean
130 
131 #endif // META_OCEAN_TEST_TESTCV_TEST_EIGEN_UTILITIES_H
This class implements tests for the EigenUtilities class.
Definition: TestEigenUtilities.h:27
static bool testToOceanVector(const double testDuration)
Tests the conversion of Eigen::Vector{2,3,4}T to Ocean VectorT{2,3,4}T.
static bool testFrame2Matrix(const double testDuration)
Tests the frame to matrix conversion function for a specific source type and target type.
static bool testToOceanQuaternion(const double testDuration)
Tests the conversion of Eigen::Quaternion<T> to Ocean::QuaternionT<T>
static bool testToEigenQuaternion(const double testDuration)
Tests the conversion of Ocean::QuaternionT<T> to Eigen::Quaternion<T>
static bool testToEigenVector(const double testDuration)
Tests the conversion of Ocean VectorT2 to Eigen::Vector2T.
static bool testFrame2Matrix(const double testDuration)
Tests the frame to matrix conversion function.
static bool testToOceanVector(const double testDuration)
Tests the conversion of Eigen::Vector2T to Ocean VectorT2.
static bool testToEigenQuaternion(const double testDuration)
Tests the conversion of Ocean::QuaternionT<T> to Eigen::Quaternion<T>
static bool test(const double testDuration)
Invokes all tests.
static bool testToEigenVector(const double testDuration)
Tests the conversion of Ocean VectorT{2,3,4}T to Eigen::Vector{2,3,4}T.
static bool testToOceanQuaternion(const double testDuration)
Tests the conversion of Eigen::Quaternion<T> to Ocean::QuaternionT<T>
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15