Eigen-unsupported  3.4.90 (git rev a4098ac676528a83cfb73d4d26ce1b42ec05f47c)
Eigen::MatrixPower< MatrixType > Class Template Reference

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();
MatrixPower<Matrix4cd> Apow(A);
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;
}
Namespace containing all symbols from the Eigen library.

Output:

The matrix A is:
(-0.999984,-0.736924)   (0.358593,0.869386)  (0.342299,-0.984604)  (0.692334,0.0538576)
(0.511211,-0.0826997) (-0.232996,0.0388327) (-0.233169,-0.866316)   (-0.81607,0.307838)
(0.0655345,-0.562082)  (0.661931,-0.930856)  (-0.165028,0.373545)  (-0.168001,0.402381)
 (-0.905911,0.357729) (-0.893077,0.0594004)   (0.177953,0.860873)   (0.820642,0.524396)

A^3.1 is:
   (1.72257,-2.70381)    (0.540963,2.36827)   (-0.251785,1.67974)    (0.950068,2.03845)
   (-0.23814,1.24213)  (-0.609708,-1.09702)  (-0.648231,0.741588)   (0.20442,-0.107284)
(-0.0669646,0.564601)   (-1.61565,0.462499)  (-0.133892,-1.74235) (-0.775622,-0.685425)
 (0.569705,-0.891909)       (2.08793,2.034)  (-1.74387,-0.697262)   (-0.731061,0.50819)

A^3.3 is:
  (0.517932,-3.33724)     (1.80778,3.00124)   (-0.52531,0.712117)      (1.2568,1.77262)
   (0.322937,1.24027)  (-1.03234,-0.738796)   (-0.607212,1.08789)   (0.129478,0.241952)
(-0.0639215,0.565523)    (-1.88075,0.29941)   (0.558837,-1.43905)  (-0.46048,-0.962814)
 (0.231218,-0.612453)     (2.06105,2.17664)   (-1.68847,-1.78817)  (-1.06043,0.0580043)

A^3.7 is:
 (-2.51153,-2.39874)    (3.75928,2.36133)   (-1.4382,-1.49702)  (0.984644,0.217559)
  (1.19503,0.413517)   (-1.4841,0.476423)  (-0.221745,1.46307)  (0.215741,0.949732)
(-0.138804,0.395192) (-1.86781,-0.104239)  (1.79945,-0.389005)  (0.479043,-1.30024)
(-0.252036,0.456531)    (1.12154,1.66307)  (-0.97941,-3.59713)  (-1.78738,-1.11224)

A^3.9 is:
(-3.59685,-0.772441)    (3.88211,1.13013)  (-1.94382,-2.35807) (0.278649,-0.817206)
 (1.25945,-0.286285)   (-1.33603,1.14294)  (0.0492397,1.42702)   (0.398577,1.16056)
(-0.228683,0.270377)  (-1.57779,-0.30702)   (2.21812,0.286616)    (1.02455,-1.3175)
 (-0.239687,1.06545)   (0.252353,1.09621)  (-0.300805,-4.0949)  (-2.06483,-1.68965)

Inherits internal::noncopyable.

Public Member Functions

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...
 

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.

Member Function Documentation

◆ 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.

◆ 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.

The documentation for this class was generated from the following file: