Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
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.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.51917,-1.39228)   (0.305116,0.443986) (-0.850731,-0.780385) (-0.405328,-0.275935)
 (-0.143941,-3.71218)   (1.17691,-0.289299)   (-0.437539,1.14618) (-0.0537512,-1.13856)
  (-2.28638,-1.20748)     (1.47589,2.13373)   (5.17579,-0.439207)    (0.453333,-2.1446)
  (-0.947708,1.89181)    (2.4771,-0.174722)  (-1.17299,-0.526951)    (2.63124,-1.25041)

A^3.3 is:
   (1.27166,-2.08246)    (4.06985,0.137905)   (-1.92968,-5.15621)  (-0.781256,-1.13576)
  (-2.62826,-2.88897)    (1.19249,-1.35286)  (-0.0379966,2.07915) (-0.0542638,-1.51187)
  (-3.15324,0.842686)    (3.76488,0.311301)    (4.18833,-4.39152)    (-1.01571,-3.2548)
  (-0.631744,3.64756)     (3.9545,-0.37417)   (-1.21613,-2.41519)    (3.01284,-2.32338)

A^3.7 is:
  (-1.48707,2.93615)   (11.0051,-10.9169)  (-17.9883,-13.7901) (-3.81835,-0.656894)
  (-2.98452,3.16595)  (-2.13219,-3.86704)    (1.52488,5.08412) (-0.711857,-2.59662)
    (2.12616,7.1602)    (3.4107,-10.4947)   (-10.1966,-8.6363)  (-6.69482,-2.05418)
   (2.63888,7.28214)   (7.57904,-2.31938)  (-4.86369,-7.65214)    (3.02456,-4.4209)

A^3.9 is:
    (-1.72497,-1.514)  (-0.717982,-0.88639)     (2.58206,2.90185)   (-0.90218,-1.91445)
     (1.7791,1.38082) (0.00219452,-2.01609)     (1.63541,-1.1798)   (-2.80308,-3.08464)
   (-3.90784,2.11445)   (1.45612,-0.212939)    (1.34094,-6.51192)    (-2.73425,1.71247)
   (2.15406,-2.52508)     (2.71643,2.22891)    (1.98229,-1.45005)     (1.0318,-2.57514)

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: