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

Function testMatrixType

test/nullary.cpp:197–222  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196template<typename MatrixType>
197void testMatrixType(const MatrixType& m)
198{
199 using std::abs;
200 const Index rows = m.rows();
201 const Index cols = m.cols();
202 typedef typename MatrixType::Scalar Scalar;
203 typedef typename MatrixType::RealScalar RealScalar;
204
205 Scalar s1;
206 do {
207 s1 = internal::random<Scalar>();
208 } while(abs(s1)<RealScalar(1e-5) && (!NumTraits<Scalar>::IsInteger));
209
210 MatrixType A;
211 A.setIdentity(rows, cols);
212 VERIFY(equalsIdentity(A));
213 VERIFY(equalsIdentity(MatrixType::Identity(rows, cols)));
214
215
216 A = MatrixType::Constant(rows,cols,s1);
217 Index i = internal::random<Index>(0,rows-1);
218 Index j = internal::random<Index>(0,cols-1);
219 VERIFY_IS_APPROX( MatrixType::Constant(rows,cols,s1)(i,j), s1 );
220 VERIFY_IS_APPROX( MatrixType::Constant(rows,cols,s1).coeff(i,j), s1 );
221 VERIFY_IS_APPROX( A(i,j), s1 );
222}
223
224void test_nullary()
225{

Callers 1

test_nullaryFunction · 0.70

Calls 6

equalsIdentityFunction · 0.85
absFunction · 0.50
rowsMethod · 0.45
colsMethod · 0.45
setIdentityMethod · 0.45
coeffMethod · 0.45

Tested by 1

test_nullaryFunction · 0.56