20 #include <vnl/vnl_vector_fixed.txx>
26 itk::Vector<mitk::ScalarType, 3> itkVector_1;
28 itkVector_1[1] = 9.76543;
29 itkVector_1[2] = 746.09;
31 itk::Vector<mitk::ScalarType, 3> itkVector_2;
32 itk::Vector<mitk::ScalarType, 3> itkVector_3;
33 for (
int i = 0; i < 3; i++)
35 itkVector_2[i] = itkVector_1[i] -
mitk::eps * 1.1;
36 itkVector_3[i] = itkVector_1[i] -
mitk::eps * 0.9;
40 "Test vector equality using the same vector with mitk::eps");
43 "Test vector equality using different vectors with an element-wise difference greater than mitk::eps");
45 "Vectors are equal for higher epsilon tolerance ( 1.2 * mitk::eps )");
48 "Test vector equality using different vectors with an element-wise difference less than mitk::eps");
50 itk::Point<mitk::ScalarType, 3> itkPoint_1;
51 itk::Point<mitk::ScalarType, 3> itkPoint_2;
52 itk::Point<mitk::ScalarType, 3> itkPoint_3;
53 for (
int i = 0; i < 3; i++)
55 itkPoint_1[i] = itkVector_1[i];
56 itkPoint_2[i] = itkVector_2[i];
57 itkPoint_3[i] = itkVector_3[i];
62 "Test point equality using different points with an element-wise difference greater than mitk::eps");
64 "Points are equal for higher epsilon tolerance ( 1.2 * mitk::eps )");
66 "Test point equality using different points with an element-wise difference less than mitk::eps");
71 for (
int i = 0; i < 3; i++)
73 mitk_vnl_vector_1.put(i, itkVector_1[i]);
74 mitk_vnl_vector_2.put(i, itkVector_2[i]);
75 mitk_vnl_vector_3.put(i, itkVector_1[i]);
79 "Test mitk vnl vector equality using the same mitk vnl vector with mitk::eps");
81 "Test mitk vnl vector equality using different mitk vnl vectors with an element-wise difference "
82 "greater than mitk::eps");
84 "Vnl vectors are equal for higher epsilon tolerance ( 1.2 * mitk::eps )");
86 "Test mitk vnl vector equality using "
87 "different mitk vnl vectors with an "
88 "element-wise difference less than mitk::eps");
92 vnl_vector_fixed<VnlValueType, 7> vnlVector_1;
93 vnlVector_1[3] = 56.98;
94 vnlVector_1[4] = 22.32;
95 vnlVector_1[5] = 1.00;
96 vnlVector_1[6] = 746.09;
97 vnl_vector_fixed<VnlValueType, 7> vnlVector_2;
98 vnl_vector_fixed<VnlValueType, 7> vnlVector_3;
99 for (
int i = 0; i < 7; i++)
103 vnlVector_1.put(i, itkVector_1[i]);
106 vnlVector_2[i] = vnlVector_1[i] -
mitk::eps * 1.1f;
107 vnlVector_3[i] = vnlVector_1[i] -
mitk::eps * 0.9f;
110 MITK_TEST_CONDITION((mitk::Equal<VnlValueType, 7>(vnlVector_1, vnlVector_1)),
"vnl_fixed : v_1 == v_1 ");
114 "vnl_fixed : v_1 != v_2 with mitk::eps ");
117 "vnl_fixed : v_1 == v_2 with eps = 1.2 * mitk::eps ");
119 "vnl_fixed : v_1 == v_3 with eps = 0.8 * mitk::eps ");
121 "vnl_fixed : v_1 != v_3 with eps = 0.8 * mitk::eps ");
130 "Test scalar equality using the different scalars with a difference greater than mitk::eps");
132 "Test scalar equality using the different scalars with a difference equal to mitk::eps");
134 "Test scalar equality using the different scalars with a difference less than mitk::eps");
137 vnl_matrix_fixed<mitk::ScalarType, 3, 3> vnlMatrix3x3_1;
138 vnlMatrix3x3_1(0, 0) = 1.1;
139 vnlMatrix3x3_1(0, 1) = 0.4;
140 vnlMatrix3x3_1(0, 2) = 5.3;
141 vnlMatrix3x3_1(1, 0) = 2.7;
142 vnlMatrix3x3_1(1, 1) = 3578.56418;
143 vnlMatrix3x3_1(1, 2) = 123.56;
144 vnlMatrix3x3_1(2, 0) = 546.89;
145 vnlMatrix3x3_1(2, 1) = 0.0001;
146 vnlMatrix3x3_1(2, 2) = 1.0;
147 vnl_matrix_fixed<mitk::ScalarType, 3, 3> vnlMatrix3x3_2;
148 vnlMatrix3x3_2(0, 0) = 1.1000009;
149 vnlMatrix3x3_2(0, 1) = 0.4000009;
150 vnlMatrix3x3_2(0, 2) = 5.3000009;
151 vnlMatrix3x3_2(1, 0) = 2.7000009;
152 vnlMatrix3x3_2(1, 1) = 3578.5641809;
153 vnlMatrix3x3_2(1, 2) = 123.5600009;
154 vnlMatrix3x3_2(2, 0) = 546.8900009;
155 vnlMatrix3x3_2(2, 1) = 0.0001009;
156 vnlMatrix3x3_2(2, 2) = 1.0000009;
160 "Test for matrix equality with given epsilon=mitk::eps and exactly the same matrix elements");
162 "Test for matrix equality with given epsilon=0.0 and slightly different matrix elements");
164 "Test for matrix equality with given epsilon and slightly different matrix elements");
166 "Test for matrix equality with given epsilon=0.0 and slightly different matrix elements");
168 "Test for matrix equality with given epsilon and slightly different matrix elements");
bool MatrixEqualElementWise(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for element-wise matrix equality with a user defined accuracy.
vnl_vector< ScalarType > VnlVector
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
#define MITK_TEST_CONDITION(COND, MSG)
bool MatrixEqualRMS(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for matrix equality with a user defined accuracy. As an equality metric the root mean squared e...
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
int mitkVectorTest(int, char *[])
MITKCORE_EXPORT const ScalarType eps