11 #ifndef EIGEN_MATRIX_EXPONENTIAL 12 #define EIGEN_MATRIX_EXPONENTIAL 23 template <
typename MatrixType>
41 template <
typename ResultType>
42 void compute(ResultType &result);
57 void pade3(
const MatrixType &
A);
66 void pade5(
const MatrixType &A);
75 void pade7(
const MatrixType &A);
84 void pade9(
const MatrixType &A);
93 void pade13(
const MatrixType &A);
104 void pade17(
const MatrixType &A);
162 template <
typename MatrixType>
165 m_U(M.rows(),M.cols()),
166 m_V(M.rows(),M.cols()),
167 m_tmp1(M.rows(),M.cols()),
168 m_tmp2(M.rows(),M.cols()),
169 m_Id(MatrixType::Identity(M.rows(), M.cols())),
176 template <
typename MatrixType>
177 template <
typename ResultType>
180 #if LDBL_MANT_DIG > 112 // rarely happens 194 template <
typename MatrixType>
204 template <
typename MatrixType>
207 const RealScalar b[] = {30240., 15120., 3360., 420., 30., 1.};
208 MatrixType
A2 = A *
A;
215 template <
typename MatrixType>
218 const RealScalar b[] = {17297280., 8648640., 1995840., 277200., 25200., 1512., 56., 1.};
219 MatrixType
A2 = A *
A;
220 MatrixType A4 = A2 *
A2;
227 template <
typename MatrixType>
230 const RealScalar b[] = {17643225600., 8821612800., 2075673600., 302702400., 30270240.,
231 2162160., 110880., 3960., 90., 1.};
232 MatrixType
A2 = A *
A;
233 MatrixType A4 = A2 *
A2;
234 MatrixType A6 = A4 *
A2;
241 template <
typename MatrixType>
244 const RealScalar b[] = {64764752532480000., 32382376266240000., 7771770303897600.,
245 1187353796428800., 129060195264000., 10559470521600., 670442572800.,
246 33522128640., 1323241920., 40840800., 960960., 16380., 182., 1.};
247 MatrixType
A2 = A *
A;
248 MatrixType A4 = A2 *
A2;
254 m_tmp2 = b[12]*
m_tmp1 + b[10]*A4 + b[8]*
A2;
256 m_V += b[6]*
m_tmp1 + b[4]*A4 + b[2]*A2 + b[0]*
m_Id;
259 #if LDBL_MANT_DIG > 64 260 template <
typename MatrixType>
263 const RealScalar b[] = {830034394580628357120000.L, 415017197290314178560000.L,
264 100610229646136770560000.L, 15720348382208870400000.L,
265 1774878043152614400000.L, 153822763739893248000.L, 10608466464820224000.L,
266 595373117923584000.L, 27563570274240000.L, 1060137318240000.L,
267 33924394183680.L, 899510451840.L, 19554575040.L, 341863200.L, 4651200.L,
268 46512.L, 306.L, 1.L};
269 MatrixType
A2 = A *
A;
270 MatrixType A4 = A2 *
A2;
271 MatrixType A6 = A4 *
A2;
272 m_tmp1.noalias() = A4 * A4;
273 m_V = b[17]*
m_tmp1 + b[15]*A6 + b[13]*A4 + b[11]*
A2;
277 m_tmp2 = b[16]*
m_tmp1 + b[14]*A6 + b[12]*A4 + b[10]*
A2;
279 m_V += b[8]*
m_tmp1 + b[6]*A6 + b[4]*A4 + b[2]*A2 + b[0]*
m_Id;
283 template <
typename MatrixType>
288 if (
m_l1norm < 4.258730016922831e-001) {
290 }
else if (
m_l1norm < 1.880152677804762e+000) {
293 const float maxnorm = 3.925724783138660f;
301 template <
typename MatrixType>
306 if (
m_l1norm < 1.495585217958292e-002) {
308 }
else if (
m_l1norm < 2.539398330063230e-001) {
310 }
else if (
m_l1norm < 9.504178996162932e-001) {
312 }
else if (
m_l1norm < 2.097847961257068e+000) {
315 const double maxnorm = 5.371920351148152;
323 template <
typename MatrixType>
328 #if LDBL_MANT_DIG == 53 // double precision 330 #elif LDBL_MANT_DIG <= 64 // extended precision 331 if (
m_l1norm < 4.1968497232266989671e-003
L) {
333 }
else if (
m_l1norm < 1.1848116734693823091e-001
L) {
335 }
else if (
m_l1norm < 5.5170388480686700274e-001
L) {
337 }
else if (
m_l1norm < 1.3759868875587845383e+000
L) {
340 const long double maxnorm = 4.0246098906697353063L;
346 #elif LDBL_MANT_DIG <= 106 // double-double 347 if (
m_l1norm < 3.2787892205607026992947488108213e-005
L) {
349 }
else if (
m_l1norm < 6.4467025060072760084130906076332e-003
L) {
351 }
else if (
m_l1norm < 6.8988028496595374751374122881143e-002
L) {
353 }
else if (
m_l1norm < 2.7339737518502231741495857201670e-001
L) {
355 }
else if (
m_l1norm < 1.3203382096514474905666448850278e+000
L) {
358 const long double maxnorm = 3.2579440895405400856599663723517L;
364 #elif LDBL_MANT_DIG <= 112 // quadruple precison 365 if (
m_l1norm < 1.639394610288918690547467954466970e-005
L) {
367 }
else if (
m_l1norm < 4.253237712165275566025884344433009e-003
L) {
369 }
else if (
m_l1norm < 5.125804063165764409885122032933142e-002
L) {
371 }
else if (
m_l1norm < 2.170000765161155195453205651889853e-001
L) {
373 }
else if (
m_l1norm < 1.125358383453143065081397882891878e+000
L) {
376 const long double maxnorm = 2.884233277829519311757165057717815L;
385 #endif // LDBL_MANT_DIG 401 :
public ReturnByValue<MatrixExponentialReturnValue<Derived> >
403 typedef typename Derived::Index
Index;
417 template <
typename ResultType>
418 inline void evalTo(ResultType& result)
const 420 const typename Derived::PlainObject srcEvaluated = m_src.eval();
425 Index
rows()
const {
return m_src.rows(); }
426 Index
cols()
const {
return m_src.cols(); }
435 template<
typename Derived>
442 template <
typename Derived>
451 #endif // EIGEN_MATRIX_EXPONENTIAL MatrixType m_tmp2
Used for temporary storage.
const Eigen::CwiseUnaryOp< Eigen::internal::scalar_pow_op< typename Derived::Scalar >, const Derived > pow(const Eigen::ArrayBase< Derived > &x, const typename Derived::Scalar &exponent)
void pade5(const MatrixType &A)
Compute the (5,5)-Padé approximant to the exponential.
void evalTo(ResultType &result) const
Compute the matrix exponential.
#define EIGEN_STRONG_INLINE
std::complex< RealScalar > ComplexScalar
iterative scaling algorithm to equilibrate rows and column norms in matrices
IntermediateState pow(const Expression &arg1, const Expression &arg2)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
void pade17(const MatrixType &A)
Compute the (17,17)-Padé approximant to the exponential.
MatrixType m_Id
Identity matrix of the same size as m_M.
EIGEN_STRONG_INLINE const CwiseUnaryOp< internal::scalar_abs_op< Scalar >, const Derived > cwiseAbs() const
void pade13(const MatrixType &A)
Compute the (13,13)-Padé approximant to the exponential.
int m_squarings
Number of squarings required in the last step.
Class for computing the matrix exponential.
internal::nested< MatrixType >::type m_M
Reference to matrix whose exponential is to be computed.
void computeUV(double)
Compute Padé approximant to the exponential.
const MatrixExponentialReturnValue< Derived > exp() const
Derived::PlainObject ReturnType
void compute(ResultType &result)
Computes the matrix exponential.
NumTraits< Scalar >::Real RealScalar
MatrixType m_U
Odd-degree terms in numerator of Padé approximant.
void pade3(const MatrixType &A)
Compute the (3,3)-Padé approximant to the exponential.
Stem functions corresponding to standard mathematical functions.
void pade9(const MatrixType &A)
Compute the (9,9)-Padé approximant to the exponential.
MatrixType m_tmp1
Used for temporary storage.
Proxy for the matrix exponential of some matrix (expression).
MatrixExponential(const MatrixType &M)
Constructor.
void pade7(const MatrixType &A)
Compute the (7,7)-Padé approximant to the exponential.
MatrixExponential & operator=(const MatrixExponential &)
MatrixExponentialReturnValue(const Derived &src)
Constructor.
RealScalar m_l1norm
L1 norm of m_M.
internal::traits< MatrixType >::Scalar Scalar
MatrixType m_V
Even-degree terms in numerator of Padé approximant.