MCPcopy Create free account
hub / github.com/PX4/eigen / test_nullary

Function test_nullary

test/nullary.cpp:224–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224void test_nullary()
225{
226 CALL_SUBTEST_1( testMatrixType(Matrix2d()) );
227 CALL_SUBTEST_2( testMatrixType(MatrixXcf(internal::random<int>(1,300),internal::random<int>(1,300))) );
228 CALL_SUBTEST_3( testMatrixType(MatrixXf(internal::random<int>(1,300),internal::random<int>(1,300))) );
229
230 for(int i = 0; i < g_repeat*10; i++) {
231 CALL_SUBTEST_4( testVectorType(VectorXd(internal::random<int>(1,30000))) );
232 CALL_SUBTEST_5( testVectorType(Vector4d()) ); // regression test for bug 232
233 CALL_SUBTEST_6( testVectorType(Vector3d()) );
234 CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,30000))) );
235 CALL_SUBTEST_8( testVectorType(Vector3f()) );
236 CALL_SUBTEST_8( testVectorType(Vector4f()) );
237 CALL_SUBTEST_8( testVectorType(Matrix<float,8,1>()) );
238 CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) );
239
240 CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,10))) );
241 CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(9,300))) );
242 CALL_SUBTEST_9( testVectorType(Matrix<int,1,1>()) );
243 }
244
245#ifdef EIGEN_TEST_PART_6
246 // Assignment of a RowVectorXd to a MatrixXd (regression test for bug #79).
247 VERIFY( (MatrixXd(RowVectorXd::LinSpaced(3, 0, 1)) - RowVector3d(0, 0.5, 1)).norm() < std::numeric_limits<double>::epsilon() );
248#endif
249
250#ifdef EIGEN_TEST_PART_9
251 // Check possible overflow issue
252 {
253 int n = 60000;
254 ArrayXi a1(n), a2(n);
255 a1.setLinSpaced(n, 0, n-1);
256 for(int i=0; i<n; ++i)
257 a2(i) = i;
258 VERIFY_IS_APPROX(a1,a2);
259 }
260#endif
261
262#ifdef EIGEN_TEST_PART_10
263 // check some internal logic
264 VERIFY(( internal::has_nullary_operator<internal::scalar_constant_op<double> >::value ));
265 VERIFY(( !internal::has_unary_operator<internal::scalar_constant_op<double> >::value ));
266 VERIFY(( !internal::has_binary_operator<internal::scalar_constant_op<double> >::value ));
267 VERIFY(( internal::functor_has_linear_access<internal::scalar_constant_op<double> >::ret ));
268
269 VERIFY(( !internal::has_nullary_operator<internal::scalar_identity_op<double> >::value ));
270 VERIFY(( !internal::has_unary_operator<internal::scalar_identity_op<double> >::value ));
271 VERIFY(( internal::has_binary_operator<internal::scalar_identity_op<double> >::value ));
272 VERIFY(( !internal::functor_has_linear_access<internal::scalar_identity_op<double> >::ret ));
273
274 VERIFY(( !internal::has_nullary_operator<internal::linspaced_op<float,float> >::value ));
275 VERIFY(( internal::has_unary_operator<internal::linspaced_op<float,float> >::value ));
276 VERIFY(( !internal::has_binary_operator<internal::linspaced_op<float,float> >::value ));
277 VERIFY(( internal::functor_has_linear_access<internal::linspaced_op<float,float> >::ret ));
278
279 // Regression unit test for a weird MSVC bug.
280 // Search "nullary_wrapper_workaround_msvc" in CoreEvaluators.h for the details.
281 // See also traits<Ref>::match.

Callers

nothing calls this directly

Calls 3

testVectorTypeFunction · 0.85
testMatrixTypeFunction · 0.70
normMethod · 0.45

Tested by

no test coverage detected