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

Function testGonioFunctions

unsupported/test/matrix_function.cpp:137–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135
136template<typename MatrixType>
137void testGonioFunctions(const MatrixType& A)
138{
139 typedef typename MatrixType::Scalar Scalar;
140 typedef typename NumTraits<Scalar>::Real RealScalar;
141 typedef std::complex<RealScalar> ComplexScalar;
142 typedef Matrix<ComplexScalar, MatrixType::RowsAtCompileTime,
143 MatrixType::ColsAtCompileTime, MatrixType::Options> ComplexMatrix;
144
145 ComplexScalar imagUnit(0,1);
146 ComplexScalar two(2,0);
147
148 ComplexMatrix Ac = A.template cast<ComplexScalar>();
149
150 ComplexMatrix exp_iA = (imagUnit * Ac).exp();
151 ComplexMatrix exp_miA = (-imagUnit * Ac).exp();
152
153 ComplexMatrix sinAc = A.sin().template cast<ComplexScalar>();
154 VERIFY_IS_APPROX_ABS(sinAc, (exp_iA - exp_miA) / (two*imagUnit));
155
156 ComplexMatrix cosAc = A.cos().template cast<ComplexScalar>();
157 VERIFY_IS_APPROX_ABS(cosAc, (exp_iA + exp_miA) / 2);
158}
159
160template<typename MatrixType>
161void testMatrix(const MatrixType& A)

Callers 1

testMatrixFunction · 0.85

Calls 3

sinMethod · 0.80
cosMethod · 0.80
expMethod · 0.45

Tested by

no test coverage detected