template<typename MatrixType>
class Eigen::MatrixPower< MatrixType >
Class for computing matrix powers.
- Template Parameters
-
| MatrixType | type 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 a non-integral power has ever 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 <contrib/Eigen/MatrixFunctions>
#include <iostream>
int main() {
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;
}
Matrix< std::complex< double >, 4, 4 > Matrix4cd
Namespace containing all symbols from the Eigen library.
Output:
The matrix A is:
(-0.211234,0.596881) (0.434594,0.213937) (-0.407936,0.0485741) (0.898654,-0.827888)
(-0.604897,0.536459) (-0.514227,0.608353) (0.94555,0.542715) (0.326453,-0.302214)
(0.10794,0.257741) (-0.198111,-0.782383) (0.539828,0.783059) (-0.959954,-0.873808)
(0.0268015,0.832391) (-0.563486,0.678224) (-0.295084,0.838054) (0.941268,0.70184)
A^3.1 is:
(-1.93513,0.648575) (-2.07718,-0.703256) (-3.87582,3.83458) (2.86313,2.40978)
(0.568806,0.785524) (2.19191,0.535855) (-0.709163,-0.486426) (1.1808,-2.02005)
(1.16555,2.13452) (0.413611,2.48565) (5.47544,2.85412) (1.9366,-4.81275)
(-1.56915,0.251293) (-2.00077,1.72421) (-4.49146,-0.84688) (2.4147,6.60277)
A^3.3 is:
(-2.14002,0.225285) (-1.43881,-1.15283) (-5.37706,3.39506) (3.28526,2.78026)
(0.416205,1.00085) (2.2285,1.39662) (-0.0914379,-0.720032) (1.9675,-2.10796)
(0.790046,2.34299) (-0.183361,2.1086) (5.6589,4.53725) (2.46589,-5.37454)
(-2.2067,0.313465) (-2.90677,1.72209) (-5.11023,-1.00965) (2.23473,7.84969)
A^3.7 is:
(-1.97863,-0.413093) (0.284849,-0.700203) (-7.82754,1.30184) (4.49337,4.09104)
(0.0579547,1.35991) (1.31385,3.18425) (1.58929,-0.18202) (3.62347,-1.55686)
(0.333883,2.26581) (-0.307753,0.597838) (4.75734,7.98149) (3.86857,-6.87044)
(-3.8398,-0.361606) (-4.82091,0.916708) (-7.13948,-1.67237) (1.52857,11.0221)
A^3.9 is:
(-1.77174,-0.404906) (0.911227,0.3358) (-8.51159,-0.0843889) (5.22304,5.15299)
(-0.161506,1.53969) (0.332862,3.8326) (2.3709,0.761741) (4.31279,-0.958972)
(0.439061,2.15025) (0.398939,-0.183662) (3.78526,9.45362) (4.85176,-7.86587)
(-4.61349,-1.14578) (-5.66312,0.165718) (-8.56205,-2.39729) (0.865657,13.0295)