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

Function testMatrixLogarithm

unsupported/test/matrix_function.cpp:109–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107
108template<typename MatrixType>
109void testMatrixLogarithm(const MatrixType& A)
110{
111 typedef typename internal::traits<MatrixType>::Scalar Scalar;
112 typedef typename NumTraits<Scalar>::Real RealScalar;
113
114 MatrixType scaledA;
115 RealScalar maxImagPartOfSpectrum = A.eigenvalues().imag().cwiseAbs().maxCoeff();
116 if (maxImagPartOfSpectrum >= RealScalar(0.9L * EIGEN_PI))
117 scaledA = A * RealScalar(0.9L * EIGEN_PI) / maxImagPartOfSpectrum;
118 else
119 scaledA = A;
120
121 // identity X.exp().log() = X only holds if Im(lambda) < pi for all eigenvalues of X
122 MatrixType expA = scaledA.exp();
123 MatrixType logExpA = expA.log();
124 VERIFY_IS_APPROX(logExpA, scaledA);
125}
126
127template<typename MatrixType>
128void testHyperbolicFunctions(const MatrixType& A)

Callers 1

testMatrixFunction · 0.85

Calls 5

imagMethod · 0.80
maxCoeffMethod · 0.45
eigenvaluesMethod · 0.45
expMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected