Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Loading...
Searching...
No Matches
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();
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;
}
MatrixPower(const MatrixType &A)
Constructor.
Definition MatrixPower.h:352
Namespace containing all symbols from the Eigen library.

Output:

The matrix A is:
 (0.680375,-0.211234)   (-0.444451,0.10794)   (0.271423,0.434594) (-0.686642,-0.198111)
   (0.566198,0.59688) (-0.0452059,0.257742)  (-0.716795,0.213938) (-0.740419,-0.782382)
 (0.823295,-0.604897) (-0.270431,0.0268018) (-0.967399,-0.514226)  (0.997849,-0.563486)
 (-0.329554,0.536459)    (0.904459,0.83239)  (-0.725537,0.608354)  (0.0258648,0.678224)

A^3.1 is:
 (0.545666,-2.63743)   (0.203869,1.16554)  (-0.513414,1.32972) (-0.394715,0.661316)
  (3.57161,-1.33776) (0.101221,-0.608487)   (-1.04091,1.01587)  (0.699862,0.200293)
   (1.85761,1.00285) (-2.68235,-0.227423)   (-2.0981,-4.59955)   (1.63697,-1.63407)
 (-1.16175,0.775529)  (0.626925,-2.10814)   (0.169783,1.84705)  (0.924855,-2.09924)

A^3.3 is:
(0.0481398,-2.42133)   (0.491198,1.46821)  (0.0806201,1.58482)  (-0.929845,1.22472)
   (3.5958,-1.76607)   (0.31909,0.273064)   (-1.44547,1.96548) (-0.262064,0.499327)
 (1.74455,-0.474671)  (-2.94048,0.387475)  (-4.08207,-3.19963)   (1.34832,-3.23714)
(-0.955046,0.747909)     (1.592,-2.51771)   (0.825871,2.67682)   (1.19399,-1.26471)

A^3.7 is:
(-0.683949,-1.23824)   (0.362023,1.50441)    (1.69442,0.31258)    (-1.3016,2.28742)
  (2.85165,-1.62403)   (0.500062,1.59928)   (-0.394364,3.2083)   (-2.62883,1.59426)
  (-0.625316,-3.148)   (-1.13982,1.33807)   (-4.67137,3.06961) (-0.849967,-4.49735)
  (0.427211,1.41352)   (3.25419,-2.81767)    (1.75702,3.05918)    (1.65052,1.16473)

A^3.9 is:
(-0.745292,-0.57331)   (-0.20408,1.31739)   (2.13611,-1.21715)   (-0.975954,2.4151)
 (2.34627,-0.999025)   (0.185441,1.75177)    (0.97214,2.81983)    (-3.5101,2.22601)
 (-2.46846,-3.40907)   (0.739741,1.09748)   (-2.35143,6.38974)  (-2.11108,-3.41234)
   (1.63659,1.98727)   (3.59318,-2.52272)    (1.57219,2.48698)     (1.70771,2.3174)

Public Member Functions

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

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: