All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
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();
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:

The matrix A is:
 (-0.648549,0.0277413) (-0.750603,-0.0104678)    (0.292947,0.531358)   (0.834407,-0.306192)
 (0.0690634,-0.382733)   (-0.22074,-0.832209)    (0.560472,0.534288)  (-0.197668,0.0395215)
   (-0.656545,0.89526)   (-0.263894,-0.44554)   (-0.696158,0.645924)    (0.570849,0.213538)
  (-0.547166,0.404462)   (0.0707724,0.966918)   (-0.370647,0.250954)     (0.73986,0.863094)

A^3.1 is:
   (1.53921,-2.21672) (-0.152738,-0.531621)   (0.744528,0.460973)   (-1.93135,0.930749)
   (1.61517,0.191717)   (0.648847,0.421734) (-0.266715,-0.157021)  (-0.713313,0.165248)
   (1.66269,0.118989)   (-1.98124,0.742179)   (1.86269,-0.238557)   (-2.90426,-1.67862)
   (1.01534,-1.61964) (-1.51941,-0.0117811)    (1.81775,-1.30197)    (-3.23754,-1.1513)

A^3.3 is:
   (1.11559,-2.36285)   (-1.09168,-0.87062)    (1.37251,0.521268)   (-2.13414,0.277749)
  (1.89066,-0.161471) (0.466112,-0.0256628)  (0.0427374,0.379418) (-0.703122,-0.038526)
   (1.65395,0.964914)   (-2.04163,0.180987)    (1.62485,0.377591)   (-2.45151,-2.75087)
  (1.16967,-0.809816)  (-1.8862,-0.0297793)    (2.25662,-1.17844)   (-3.16781,-2.26322)

A^3.7 is:
 (-0.296805,-1.53599)  (-2.59867,-0.994492)   (2.01458,0.0709003)   (-2.01547,-1.33373)
   (1.4325,-0.786308) (-0.348575,-0.970408)    (0.712131,1.21976) (-0.310228,-0.584719)
    (1.17306,2.23883)   (-1.19233,-1.23495)    (0.487876,1.33196)   (-0.50025,-4.22612)
    (1.42881,1.41495)  (-1.87002,-0.363685)   (2.34242,-0.398045)    (-2.00947,-4.4525)

A^3.9 is:
 (-0.965666,-0.59101)   (-2.84598,-0.75051)    (1.89998,-0.38567)   (-1.70186,-2.12135)
 (0.713573,-0.904013)  (-0.826987,-1.26053)     (0.94132,1.34061) (0.0514912,-0.845441)
   (0.770839,2.45969)  (-0.351596,-1.87391)   (-0.178957,1.53874)   (0.823369,-4.40007)
    (1.49913,2.54287)   (-1.3955,-0.727114)    (1.96774,0.224795)  (-0.883161,-5.26838)

Public Member Functions

template<typename ResultType >
void compute (ResultType &res, RealScalar p)
 Compute the matrix power. More...
 
 MatrixPower (const MatrixType &A)
 Constructor. More...
 
const MatrixPowerRetval
< MatrixType > 
operator() (RealScalar p)
 Returns the matrix power. More...
 

Constructor & Destructor Documentation

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

void 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.
const MatrixPowerRetval<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: