10 #ifndef EIGEN_MATRIX_FUNCTION_ATOMIC 11 #define EIGEN_MATRIX_FUNCTION_ATOMIC 23 template <
typename MatrixType>
29 typedef typename MatrixType::Index Index;
70 template <
typename MatrixType>
75 m_avgEival = A.trace() / Scalar(RealScalar(m_Arows));
76 m_Ashifted = A - m_avgEival * MatrixType::Identity(m_Arows, m_Arows);
78 MatrixType F = m_f(m_avgEival, 0) * MatrixType::Identity(m_Arows, m_Arows);
81 for (Index s = 1; s < 1.1 * m_Arows + 10; s++) {
82 Fincr = m_f(m_avgEival, static_cast<int>(s)) * P;
84 P = Scalar(RealScalar(1.0/(s + 1))) * P * m_Ashifted;
85 if (taylorConverged(s, F, Fincr, P)) {
89 eigen_assert(
"Taylor series does not converge" && 0);
94 template <
typename MatrixType>
97 const MatrixType N = MatrixType::Identity(m_Arows, m_Arows) - m_Ashifted;
99 N.template triangularView<Upper>().solveInPlace(e);
100 m_mu = e.cwiseAbs().maxCoeff();
104 template <
typename MatrixType>
108 const Index n = F.rows();
109 const RealScalar F_norm = F.cwiseAbs().rowwise().sum().maxCoeff();
110 const RealScalar Fincr_norm = Fincr.cwiseAbs().rowwise().sum().maxCoeff();
112 RealScalar delta = 0;
113 RealScalar rfactorial = 1;
114 for (Index r = 0; r < n; r++) {
116 for (Index i = 0; i < n; i++)
117 mx = (std::max)(mx, std::abs(m_f(m_Ashifted(i, i) + m_avgEival, static_cast<int>(s+r))));
119 rfactorial *= RealScalar(r);
120 delta = (std::max)(delta, mx / rfactorial);
122 const RealScalar P_norm = P.cwiseAbs().rowwise().sum().maxCoeff();
131 #endif // EIGEN_MATRIX_FUNCTION_ATOMIC
iterative scaling algorithm to equilibrate rows and column norms in matrices
Definition: TestIMU_Common.h:87
Holds information about the various numeric (i.e.
Definition: NumTraits.h:88
MatrixFunctionAtomic(StemFunction f)
Constructor.
Definition: MatrixFunctionAtomic.h:37
MatrixType compute(const MatrixType &A)
Compute matrix function of atomic matrix.
Definition: MatrixFunctionAtomic.h:71
Definition: ForwardDeclarations.h:281
Helper class for computing matrix functions of atomic matrices.
Definition: MatrixFunctionAtomic.h:24
The matrix class, also used for vectors and row-vectors.
Definition: Matrix.h:127
double Scalar
Common scalar type.
Definition: FlexibleKalmanBase.h:48