MCPcopy Create free account
hub / github.com/Geode-solutions/OpenGeode / test_matrix_3x3

Function test_matrix_3x3

tests/geometry/test-square-matrix.cpp:89–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void test_matrix_3x3()
90{
91 geode::Logger::info( "Test Matrix 3x3" );
92 const geode::SquareMatrix3D matrix{ { geode::Vector3D{ { 1, 2, 3 } },
93 geode::Vector3D{ { -2, 1, 0 } }, geode::Vector3D{ { 3, 0.5, 1 } } } };
94
95 geode::OpenGeodeGeometryException::test( matrix.value( 0, 0 ) == 1,
96 "[TEST] Wrong value for matrix coeff [0,0]" );
97 geode::OpenGeodeGeometryException::test( matrix.value( 0, 1 ) == 2,
98 "[TEST] Wrong value for matrix coeff [0,1]" );
99 geode::OpenGeodeGeometryException::test( matrix.value( 0, 2 ) == 3,
100 "[TEST] Wrong value for matrix coeff [0,2]" );
101 geode::OpenGeodeGeometryException::test( matrix.value( 1, 0 ) == -2,
102 "[TEST] Wrong value for matrix coeff [1,0]" );
103 geode::OpenGeodeGeometryException::test( matrix.value( 1, 1 ) == 1,
104 "[TEST] Wrong value for matrix coeff [1,1]" );
105 geode::OpenGeodeGeometryException::test( matrix.value( 1, 2 ) == 0,
106 "[TEST] Wrong value for matrix coeff [1,2]" );
107 geode::OpenGeodeGeometryException::test( matrix.value( 2, 0 ) == 3,
108 "[TEST] Wrong value for matrix coeff [2,0]" );
109 geode::OpenGeodeGeometryException::test( matrix.value( 2, 1 ) == 0.5,
110 "[TEST] Wrong value for matrix coeff [2,1]" );
111 geode::OpenGeodeGeometryException::test( matrix.value( 2, 2 ) == 1,
112 "[TEST] Wrong value for matrix coeff [2,2]" );
113
114 const auto mult_result = matrix * geode::Vector3D{ { 3, 2, 1 } };
115 const geode::Vector3D answer{ { 10, -4, 11 } };
116 geode::OpenGeodeGeometryException::test( mult_result == answer,
117 "[TEST] Wrong result for matrix multiplication: ", mult_result.string(),
118 " instead of [10,-4,11]" );
119
120 const auto det = matrix.determinant();
121 geode::OpenGeodeGeometryException::test(
122 det == -7, "[TEST] Wrong determinant value: ", det, " instead of -7" );
123
124 const auto transpose_matrix = matrix.transpose();
125 geode::OpenGeodeGeometryException::test(
126 transpose_matrix.value( 0, 0 ) == 1,
127 "[TEST] Wrong value for transpose matrix coeff [0,0]" );
128 geode::OpenGeodeGeometryException::test(
129 transpose_matrix.value( 0, 1 ) == -2,
130 "[TEST] Wrong value for transpose matrix coeff [0,1]" );
131 geode::OpenGeodeGeometryException::test(
132 transpose_matrix.value( 0, 2 ) == 3,
133 "[TEST] Wrong value for transpose matrix coeff [0,2]" );
134 geode::OpenGeodeGeometryException::test(
135 transpose_matrix.value( 1, 0 ) == 2,
136 "[TEST] Wrong value for transpose matrix coeff [1,0]" );
137 geode::OpenGeodeGeometryException::test(
138 transpose_matrix.value( 1, 1 ) == 1,
139 "[TEST] Wrong value for transpose matrix coeff [1,1]" );
140 geode::OpenGeodeGeometryException::test(
141 transpose_matrix.value( 1, 2 ) == 0.5,
142 "[TEST] Wrong value for transpose matrix coeff [1,2]" );
143 geode::OpenGeodeGeometryException::test(
144 transpose_matrix.value( 2, 0 ) == 3,
145 "[TEST] Wrong value for transpose matrix coeff [2,0]" );
146 geode::OpenGeodeGeometryException::test(

Callers 1

testFunction · 0.85

Calls 7

infoFunction · 0.85
determinantMethod · 0.80
transposeMethod · 0.80
testFunction · 0.70
valueMethod · 0.45
stringMethod · 0.45
inverseMethod · 0.45

Tested by

no test coverage detected