Class for computing matrix powers. More...
Inherits internal::noncopyable.
Public Member Functions | |
Index | cols () const |
template<typename ResultType > | |
void | compute (ResultType &res, RealScalar p) |
Compute the matrix power. More... | |
MatrixPower (const MatrixType &A) | |
Constructor. More... | |
const MatrixPowerParenthesesReturnValue< MatrixType > | operator() (RealScalar p) |
Returns the matrix power. More... | |
Index | rows () const |
Private Types | |
typedef Matrix< ComplexScalar, Dynamic, Dynamic, 0, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime > | ComplexMatrix |
typedef std::complex< RealScalar > | ComplexScalar |
typedef MatrixType::RealScalar | RealScalar |
typedef MatrixType::Scalar | Scalar |
Private Member Functions | |
template<typename ResultType > | |
void | computeFracPower (ResultType &res, RealScalar p) |
template<typename ResultType > | |
void | computeIntPower (ResultType &res, RealScalar p) |
void | initialize () |
Perform Schur decomposition for fractional power. More... | |
void | split (RealScalar &p, RealScalar &intpart) |
Split p into integral part and fractional part. More... | |
Static Private Member Functions | |
template<int Rows, int Cols, int Options, int MaxRows, int MaxCols> | |
static void | revertSchur (Matrix< ComplexScalar, Rows, Cols, Options, MaxRows, MaxCols > &res, const ComplexMatrix &T, const ComplexMatrix &U) |
template<int Rows, int Cols, int Options, int MaxRows, int MaxCols> | |
static void | revertSchur (Matrix< RealScalar, Rows, Cols, Options, MaxRows, MaxCols > &res, const ComplexMatrix &T, const ComplexMatrix &U) |
Private Attributes | |
MatrixType::Nested | m_A |
Reference to the base of matrix power. More... | |
RealScalar | m_conditionNumber |
Condition number of m_A. More... | |
ComplexMatrix | m_fT |
Store fractional power of m_T. More... | |
Index | m_nulls |
Rank deficiency of m_A. More... | |
Index | m_rank |
Rank of m_A. More... | |
ComplexMatrix | m_T |
Store the result of Schur decomposition. More... | |
MatrixType | m_tmp |
Temporary storage. More... | |
ComplexMatrix | m_U |
Class for computing matrix powers.
MatrixType | type of the base, expected to be an instantiation of the Matrix class template. |
This class is capable of computing real/complex matrices raised to an arbitrary real power. Meanwhile, it saves the result of Schur decomposition if an non-integral power has even been calculated. Therefore, if you want to compute multiple (>= 2) matrix powers for the same matrix, using the class directly is more efficient than calling MatrixBase::pow().
Example:
Output:
The matrix A is: (-0.211234,0.680375) (0.10794,-0.444451) (0.434594,0.271423) (-0.198111,-0.686642) (0.59688,0.566198) (0.257742,-0.0452059) (0.213938,-0.716795) (-0.782382,-0.740419) (-0.604897,0.823295) (0.0268018,-0.270431) (-0.514226,-0.967399) (-0.563486,0.997849) (0.536459,-0.329554) (0.83239,0.904459) (0.608354,-0.725537) (0.678224,0.0258648) A^3.1 is: (2.80575,-0.607662) (-1.16847,-0.00660555) (-0.760385,1.01461) (-0.38073,-0.106512) (1.4041,-3.61891) (1.00481,0.186263) (-0.163888,0.449419) (-0.388981,-1.22629) (-2.07957,-1.58136) (0.825866,2.25962) (5.09383,0.155736) (0.394308,-1.63034) (-0.818997,0.671026) (2.11069,-0.00768024) (-1.37876,0.140165) (2.50512,-0.854429) A^3.3 is: (2.83571,-0.238717) (-1.48174,-0.0615217) (-0.0544396,1.68092) (-0.292699,-0.621726) (2.0521,-3.58316) (0.87894,0.400548) (0.738072,-0.121242) (-1.07957,-1.63492) (-3.00106,-1.10558) (1.52205,1.92407) (5.29759,-1.83562) (-0.532038,-1.50253) (-0.491353,-0.4145) (2.5761,0.481286) (-1.21994,0.0367069) (2.67112,-1.06331) A^3.7 is: (1.42126,0.33362) (-1.39486,-0.560486) (1.44968,2.47066) (-0.324079,-1.75879) (2.65301,-1.82427) (0.357333,-0.192429) (2.01017,-1.4791) (-2.71518,-2.35892) (-3.98544,0.964861) (2.26033,0.554254) (3.18211,-5.94352) (-2.22888,0.128951) (0.944969,-2.14683) (3.31345,1.66075) (-0.0623743,-0.848324) (2.3897,-1.863) A^3.9 is: (0.0720766,0.378685) (-0.931961,-0.978624) (1.9855,2.34105) (-0.530547,-2.17664) (2.40934,-0.265286) (0.0299975,-1.08827) (1.98974,-2.05886) (-3.45767,-2.50235) (-3.71666,2.3874) (2.054,-0.303) (0.844348,-7.29588) (-2.59136,1.57689) (1.87645,-2.38798) (3.52111,2.10508) (0.799055,-1.6122) (1.93452,-2.44408)
Definition at line 339 of file MatrixPower.h.
|
private |
Definition at line 387 of file MatrixPower.h.
|
private |
Definition at line 385 of file MatrixPower.h.
|
private |
Definition at line 343 of file MatrixPower.h.
|
private |
Definition at line 342 of file MatrixPower.h.
|
inlineexplicit |
Constructor.
[in] | A | the base of the matrix power. |
The class stores a reference to A, so it should not be changed (or destroyed) before evaluation.
Definition at line 354 of file MatrixPower.h.
|
inline |
Definition at line 382 of file MatrixPower.h.
void Eigen::MatrixPower< MatrixType >::compute | ( | ResultType & | res, |
RealScalar | p | ||
) |
Compute the matrix power.
[in] | p | exponent, a real scalar. |
[out] | res | \( A^p \) where A is specified in the constructor. |
Definition at line 450 of file MatrixPower.h.
|
private |
Definition at line 553 of file MatrixPower.h.
|
private |
Definition at line 530 of file MatrixPower.h.
|
private |
Perform Schur decomposition for fractional power.
Definition at line 491 of file MatrixPower.h.
|
inline |
Returns the matrix power.
[in] | p | exponent, a real scalar. |
Definition at line 368 of file MatrixPower.h.
|
inlinestaticprivate |
Definition at line 570 of file MatrixPower.h.
|
inlinestaticprivate |
Definition at line 578 of file MatrixPower.h.
|
inline |
Definition at line 381 of file MatrixPower.h.
|
private |
Split p into integral part and fractional part.
[in] | p | The exponent. |
[out] | p | The fractional part ranging in \( (-1, 1) \). |
[out] | intpart | The integral part. |
Only if the fractional part is nonzero, it calls initialize().
Definition at line 470 of file MatrixPower.h.
|
private |
Reference to the base of matrix power.
Definition at line 390 of file MatrixPower.h.
|
private |
Condition number of m_A.
It is initialized as 0 to avoid performing unnecessary Schur decomposition, which is the bottleneck.
Definition at line 407 of file MatrixPower.h.
|
private |
Store fractional power of m_T.
Definition at line 399 of file MatrixPower.h.
|
private |
Rank deficiency of m_A.
Definition at line 413 of file MatrixPower.h.
|
private |
Rank of m_A.
Definition at line 410 of file MatrixPower.h.
|
private |
Store the result of Schur decomposition.
Definition at line 396 of file MatrixPower.h.
|
private |
Temporary storage.
Definition at line 393 of file MatrixPower.h.
|
private |
Definition at line 396 of file MatrixPower.h.