Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Eigen::MatrixPower< MatrixType > Class Template Reference

Class for computing matrix powers. More...

#include <MatrixPower.h>

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< MatrixTypeoperator() (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< RealScalarComplexScalar
 
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
 

Detailed Description

template<typename MatrixType>
class Eigen::MatrixPower< MatrixType >

Class for computing matrix powers.

Template Parameters
MatrixTypetype 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:

#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
Matrix4cd A = Matrix4cd::Random();
std::cout << "The matrix A is:\n" << A << "\n\n"
"A^3.1 is:\n" << Apow(3.1) << "\n\n"
"A^3.3 is:\n" << Apow(3.3) << "\n\n"
"A^3.7 is:\n" << Apow(3.7) << "\n\n"
"A^3.9 is:\n" << Apow(3.9) << std::endl;
return 0;
}

Output:

 

Definition at line 15 of file MatrixPower.h.

Member Typedef Documentation

◆ ComplexMatrix

template<typename MatrixType >
typedef Matrix<ComplexScalar, Dynamic, Dynamic, 0, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime> Eigen::MatrixPower< MatrixType >::ComplexMatrix
private

Definition at line 385 of file MatrixPower.h.

◆ ComplexScalar

template<typename MatrixType >
typedef std::complex<RealScalar> Eigen::MatrixPower< MatrixType >::ComplexScalar
private

Definition at line 383 of file MatrixPower.h.

◆ RealScalar

template<typename MatrixType >
typedef MatrixType::RealScalar Eigen::MatrixPower< MatrixType >::RealScalar
private

Definition at line 341 of file MatrixPower.h.

◆ Scalar

template<typename MatrixType >
typedef MatrixType::Scalar Eigen::MatrixPower< MatrixType >::Scalar
private

Definition at line 340 of file MatrixPower.h.

Constructor & Destructor Documentation

◆ MatrixPower()

template<typename MatrixType >
Eigen::MatrixPower< MatrixType >::MatrixPower ( const MatrixType A)
inlineexplicit

Constructor.

Parameters
[in]Athe 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 352 of file MatrixPower.h.

Member Function Documentation

◆ cols()

template<typename MatrixType >
Index Eigen::MatrixPower< MatrixType >::cols ( ) const
inline

Definition at line 380 of file MatrixPower.h.

◆ compute()

template<typename MatrixType >
template<typename ResultType >
void Eigen::MatrixPower< MatrixType >::compute ( ResultType &  res,
RealScalar  p 
)

Compute the matrix power.

Parameters
[in]pexponent, a real scalar.
[out]res$ A^p $ where A is specified in the constructor.

Definition at line 448 of file MatrixPower.h.

◆ computeFracPower()

template<typename MatrixType >
template<typename ResultType >
void Eigen::MatrixPower< MatrixType >::computeFracPower ( ResultType &  res,
RealScalar  p 
)
private

Definition at line 551 of file MatrixPower.h.

◆ computeIntPower()

template<typename MatrixType >
template<typename ResultType >
void Eigen::MatrixPower< MatrixType >::computeIntPower ( ResultType &  res,
RealScalar  p 
)
private

Definition at line 528 of file MatrixPower.h.

◆ initialize()

template<typename MatrixType >
void Eigen::MatrixPower< MatrixType >::initialize
private

Perform Schur decomposition for fractional power.

Definition at line 489 of file MatrixPower.h.

◆ operator()()

template<typename MatrixType >
const MatrixPowerParenthesesReturnValue<MatrixType> Eigen::MatrixPower< MatrixType >::operator() ( RealScalar  p)
inline

Returns the matrix power.

Parameters
[in]pexponent, a real scalar.
Returns
The expression $ A^p $, where A is specified in the constructor.

Definition at line 366 of file MatrixPower.h.

◆ revertSchur() [1/2]

template<typename MatrixType >
template<int Rows, int Cols, int Options, int MaxRows, int MaxCols>
void Eigen::MatrixPower< MatrixType >::revertSchur ( Matrix< ComplexScalar, Rows, Cols, Options, MaxRows, MaxCols > &  res,
const ComplexMatrix T,
const ComplexMatrix U 
)
inlinestaticprivate

Definition at line 568 of file MatrixPower.h.

◆ revertSchur() [2/2]

template<typename MatrixType >
template<int Rows, int Cols, int Options, int MaxRows, int MaxCols>
void Eigen::MatrixPower< MatrixType >::revertSchur ( Matrix< RealScalar, Rows, Cols, Options, MaxRows, MaxCols > &  res,
const ComplexMatrix T,
const ComplexMatrix U 
)
inlinestaticprivate

Definition at line 576 of file MatrixPower.h.

◆ rows()

template<typename MatrixType >
Index Eigen::MatrixPower< MatrixType >::rows ( ) const
inline

Definition at line 379 of file MatrixPower.h.

◆ split()

template<typename MatrixType >
void Eigen::MatrixPower< MatrixType >::split ( RealScalar p,
RealScalar intpart 
)
private

Split p into integral part and fractional part.

Parameters
[in]pThe exponent.
[out]pThe fractional part ranging in $ (-1, 1) $.
[out]intpartThe integral part.

Only if the fractional part is nonzero, it calls initialize().

Definition at line 468 of file MatrixPower.h.

Member Data Documentation

◆ m_A

template<typename MatrixType >
MatrixType::Nested Eigen::MatrixPower< MatrixType >::m_A
private

Reference to the base of matrix power.

Definition at line 388 of file MatrixPower.h.

◆ m_conditionNumber

template<typename MatrixType >
RealScalar Eigen::MatrixPower< MatrixType >::m_conditionNumber
private

Condition number of m_A.

It is initialized as 0 to avoid performing unnecessary Schur decomposition, which is the bottleneck.

Definition at line 405 of file MatrixPower.h.

◆ m_fT

template<typename MatrixType >
ComplexMatrix Eigen::MatrixPower< MatrixType >::m_fT
private

Store fractional power of m_T.

Definition at line 397 of file MatrixPower.h.

◆ m_nulls

template<typename MatrixType >
Index Eigen::MatrixPower< MatrixType >::m_nulls
private

Rank deficiency of m_A.

Definition at line 411 of file MatrixPower.h.

◆ m_rank

template<typename MatrixType >
Index Eigen::MatrixPower< MatrixType >::m_rank
private

Rank of m_A.

Definition at line 408 of file MatrixPower.h.

◆ m_T

template<typename MatrixType >
ComplexMatrix Eigen::MatrixPower< MatrixType >::m_T
private

Store the result of Schur decomposition.

Definition at line 394 of file MatrixPower.h.

◆ m_tmp

template<typename MatrixType >
MatrixType Eigen::MatrixPower< MatrixType >::m_tmp
private

Temporary storage.

Definition at line 391 of file MatrixPower.h.

◆ m_U

template<typename MatrixType >
ComplexMatrix Eigen::MatrixPower< MatrixType >::m_U
private

Definition at line 394 of file MatrixPower.h.


The documentation for this class was generated from the following file:
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
main
int main(int argc, char **argv)
Definition: cmake/example_cmake_find_gtsam/main.cpp:63
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
Eigen::MatrixPower
Class for computing matrix powers.
Definition: MatrixPower.h:15


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:10:05