MatrixPower.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2012, 2013 Chen-Pang He <jdh8@ms63.hinet.net>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_MATRIX_POWER
11 #define EIGEN_MATRIX_POWER
12 
13 // IWYU pragma: private
14 #include "./InternalHeaderCheck.h"
15 
16 namespace Eigen {
17 
18 template <typename MatrixType>
19 class MatrixPower;
20 
34 /* TODO This class is only used by MatrixPower, so it should be nested
35  * into MatrixPower, like MatrixPower::ReturnValue. However, my
36  * compiler complained about unused template parameter in the
37  * following declaration in namespace internal.
38  *
39  * template<typename MatrixType>
40  * struct traits<MatrixPower<MatrixType>::ReturnValue>;
41  */
42 template <typename MatrixType>
43 class MatrixPowerParenthesesReturnValue : public ReturnByValue<MatrixPowerParenthesesReturnValue<MatrixType> > {
44  public:
46 
54 
60  template <typename ResultType>
61  inline void evalTo(ResultType& result) const {
62  m_pow.compute(result, m_p);
63  }
64 
65  Index rows() const { return m_pow.rows(); }
66  Index cols() const { return m_pow.cols(); }
67 
68  private:
70  const RealScalar m_p;
71 };
72 
88 template <typename MatrixType>
90  private:
91  enum { RowsAtCompileTime = MatrixType::RowsAtCompileTime, MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime };
92  typedef typename MatrixType::Scalar Scalar;
94  typedef std::complex<RealScalar> ComplexScalar;
96 
97  const MatrixType& m_A;
99 
100  void computePade(int degree, const MatrixType& IminusT, ResultType& res) const;
101  void compute2x2(ResultType& res, RealScalar p) const;
102  void computeBig(ResultType& res) const;
103  static int getPadeDegree(float normIminusT);
104  static int getPadeDegree(double normIminusT);
105  static int getPadeDegree(long double normIminusT);
108 
109  public:
122 
129  void compute(ResultType& res) const;
130 };
131 
132 template <typename MatrixType>
134  eigen_assert(T.rows() == T.cols());
135  eigen_assert(p > -1 && p < 1);
136 }
137 
138 template <typename MatrixType>
140  using std::pow;
141  switch (m_A.rows()) {
142  case 0:
143  break;
144  case 1:
145  res(0, 0) = pow(m_A(0, 0), m_p);
146  break;
147  case 2:
148  compute2x2(res, m_p);
149  break;
150  default:
151  computeBig(res);
152  }
153 }
154 
155 template <typename MatrixType>
157  int i = 2 * degree;
158  res = (m_p - RealScalar(degree)) / RealScalar(2 * i - 2) * IminusT;
159 
160  for (--i; i; --i) {
161  res = (MatrixType::Identity(IminusT.rows(), IminusT.cols()) + res)
162  .template triangularView<Upper>()
163  .solve((i == 1 ? -m_p
164  : i & 1 ? (-m_p - RealScalar(i / 2)) / RealScalar(2 * i)
165  : (m_p - RealScalar(i / 2)) / RealScalar(2 * i - 2)) *
166  IminusT)
167  .eval();
168  }
169  res += MatrixType::Identity(IminusT.rows(), IminusT.cols());
170 }
171 
172 // This function assumes that res has the correct size (see bug 614)
173 template <typename MatrixType>
175  using std::abs;
176  using std::pow;
177  res.coeffRef(0, 0) = pow(m_A.coeff(0, 0), p);
178 
179  for (Index i = 1; i < m_A.cols(); ++i) {
180  res.coeffRef(i, i) = pow(m_A.coeff(i, i), p);
181  if (m_A.coeff(i - 1, i - 1) == m_A.coeff(i, i))
182  res.coeffRef(i - 1, i) = p * pow(m_A.coeff(i, i), p - 1);
183  else if (2 * abs(m_A.coeff(i - 1, i - 1)) < abs(m_A.coeff(i, i)) ||
184  2 * abs(m_A.coeff(i, i)) < abs(m_A.coeff(i - 1, i - 1)))
185  res.coeffRef(i - 1, i) =
186  (res.coeff(i, i) - res.coeff(i - 1, i - 1)) / (m_A.coeff(i, i) - m_A.coeff(i - 1, i - 1));
187  else
188  res.coeffRef(i - 1, i) = computeSuperDiag(m_A.coeff(i, i), m_A.coeff(i - 1, i - 1), p);
189  res.coeffRef(i - 1, i) *= m_A.coeff(i - 1, i);
190  }
191 }
192 
193 template <typename MatrixType>
195  using std::ldexp;
196  const int digits = std::numeric_limits<RealScalar>::digits;
197  const RealScalar maxNormForPade =
198  RealScalar(digits <= 24 ? 4.3386528e-1L // single precision
199  : digits <= 53 ? 2.789358995219730e-1L // double precision
200  : digits <= 64 ? 2.4471944416607995472e-1L // extended precision
201  : digits <= 106 ? 1.1016843812851143391275867258512e-1L // double-double
202  : 9.134603732914548552537150753385375e-2L); // quadruple precision
203  MatrixType IminusT, sqrtT, T = m_A.template triangularView<Upper>();
204  RealScalar normIminusT;
205  int degree, degree2, numberOfSquareRoots = 0;
206  bool hasExtraSquareRoot = false;
207 
208  for (Index i = 0; i < m_A.cols(); ++i) eigen_assert(m_A(i, i) != RealScalar(0));
209 
210  while (true) {
211  IminusT = MatrixType::Identity(m_A.rows(), m_A.cols()) - T;
212  normIminusT = IminusT.cwiseAbs().colwise().sum().maxCoeff();
213  if (normIminusT < maxNormForPade) {
214  degree = getPadeDegree(normIminusT);
215  degree2 = getPadeDegree(normIminusT / 2);
216  if (degree - degree2 <= 1 || hasExtraSquareRoot) break;
217  hasExtraSquareRoot = true;
218  }
219  matrix_sqrt_triangular(T, sqrtT);
220  T = sqrtT.template triangularView<Upper>();
221  ++numberOfSquareRoots;
222  }
223  computePade(degree, IminusT, res);
224 
225  for (; numberOfSquareRoots; --numberOfSquareRoots) {
226  compute2x2(res, ldexp(m_p, -numberOfSquareRoots));
227  res = res.template triangularView<Upper>() * res;
228  }
229  compute2x2(res, m_p);
230 }
231 
232 template <typename MatrixType>
233 inline int MatrixPowerAtomic<MatrixType>::getPadeDegree(float normIminusT) {
234  const float maxNormForPade[] = {2.8064004e-1f /* degree = 3 */, 4.3386528e-1f};
235  int degree = 3;
236  for (; degree <= 4; ++degree)
237  if (normIminusT <= maxNormForPade[degree - 3]) break;
238  return degree;
239 }
240 
241 template <typename MatrixType>
242 inline int MatrixPowerAtomic<MatrixType>::getPadeDegree(double normIminusT) {
243  const double maxNormForPade[] = {1.884160592658218e-2 /* degree = 3 */, 6.038881904059573e-2, 1.239917516308172e-1,
244  1.999045567181744e-1, 2.789358995219730e-1};
245  int degree = 3;
246  for (; degree <= 7; ++degree)
247  if (normIminusT <= maxNormForPade[degree - 3]) break;
248  return degree;
249 }
250 
251 template <typename MatrixType>
252 inline int MatrixPowerAtomic<MatrixType>::getPadeDegree(long double normIminusT) {
253 #if LDBL_MANT_DIG == 53
254  const int maxPadeDegree = 7;
255  const double maxNormForPade[] = {1.884160592658218e-2L /* degree = 3 */, 6.038881904059573e-2L, 1.239917516308172e-1L,
256  1.999045567181744e-1L, 2.789358995219730e-1L};
257 #elif LDBL_MANT_DIG <= 64
258  const int maxPadeDegree = 8;
259  const long double maxNormForPade[] = {6.3854693117491799460e-3L /* degree = 3 */,
260  2.6394893435456973676e-2L,
261  6.4216043030404063729e-2L,
262  1.1701165502926694307e-1L,
263  1.7904284231268670284e-1L,
264  2.4471944416607995472e-1L};
265 #elif LDBL_MANT_DIG <= 106
266  const int maxPadeDegree = 10;
267  const double maxNormForPade[] = {1.0007161601787493236741409687186e-4L /* degree = 3 */,
268  1.0007161601787493236741409687186e-3L,
269  4.7069769360887572939882574746264e-3L,
270  1.3220386624169159689406653101695e-2L,
271  2.8063482381631737920612944054906e-2L,
272  4.9625993951953473052385361085058e-2L,
273  7.7367040706027886224557538328171e-2L,
274  1.1016843812851143391275867258512e-1L};
275 #else
276  const int maxPadeDegree = 10;
277  const double maxNormForPade[] = {5.524506147036624377378713555116378e-5L /* degree = 3 */,
278  6.640600568157479679823602193345995e-4L,
279  3.227716520106894279249709728084626e-3L,
280  9.619593944683432960546978734646284e-3L,
281  2.134595382433742403911124458161147e-2L,
282  3.908166513900489428442993794761185e-2L,
283  6.266780814639442865832535460550138e-2L,
284  9.134603732914548552537150753385375e-2L};
285 #endif
286  int degree = 3;
287  for (; degree <= maxPadeDegree; ++degree)
288  if (normIminusT <= static_cast<long double>(maxNormForPade[degree - 3])) break;
289  return degree;
290 }
291 
292 template <typename MatrixType>
294  const ComplexScalar& curr, const ComplexScalar& prev, RealScalar p) {
295  using std::ceil;
296  using std::exp;
297  using std::log;
298  using std::sinh;
299 
300  ComplexScalar logCurr = log(curr);
301  ComplexScalar logPrev = log(prev);
302  RealScalar unwindingNumber =
303  ceil((numext::imag(logCurr - logPrev) - RealScalar(EIGEN_PI)) / RealScalar(2 * EIGEN_PI));
304  ComplexScalar w =
305  numext::log1p((curr - prev) / prev) / RealScalar(2) + ComplexScalar(0, RealScalar(EIGEN_PI) * unwindingNumber);
306  return RealScalar(2) * exp(RealScalar(0.5) * p * (logCurr + logPrev)) * sinh(p * w) / (curr - prev);
307 }
308 
309 template <typename MatrixType>
311  RealScalar curr, RealScalar prev, RealScalar p) {
312  using std::exp;
313  using std::log;
314  using std::sinh;
315 
316  RealScalar w = numext::log1p((curr - prev) / prev) / RealScalar(2);
317  return 2 * exp(p * (log(curr) + log(prev)) / 2) * sinh(p * w) / (curr - prev);
318 }
319 
339 template <typename MatrixType>
341  private:
342  typedef typename MatrixType::Scalar Scalar;
344 
345  public:
354  explicit MatrixPower(const MatrixType& A) : m_A(A), m_conditionNumber(0), m_rank(A.cols()), m_nulls(0) {
355  eigen_assert(A.rows() == A.cols());
356  }
357 
367  }
368 
376  template <typename ResultType>
377  void compute(ResultType& res, RealScalar p);
378 
379  Index rows() const { return m_A.rows(); }
380  Index cols() const { return m_A.cols(); }
381 
382  private:
383  typedef std::complex<RealScalar> ComplexScalar;
386 
388  typename MatrixType::Nested m_A;
389 
392 
395 
398 
406 
409 
412 
422  void split(RealScalar& p, RealScalar& intpart);
423 
425  void initialize();
426 
427  template <typename ResultType>
428  void computeIntPower(ResultType& res, RealScalar p);
429 
430  template <typename ResultType>
431  void computeFracPower(ResultType& res, RealScalar p);
432 
433  template <int Rows, int Cols, int Options, int MaxRows, int MaxCols>
435  const ComplexMatrix& U);
436 
437  template <int Rows, int Cols, int Options, int MaxRows, int MaxCols>
439  const ComplexMatrix& U);
440 };
441 
442 template <typename MatrixType>
443 template <typename ResultType>
445  using std::pow;
446  switch (cols()) {
447  case 0:
448  break;
449  case 1:
450  res(0, 0) = pow(m_A.coeff(0, 0), p);
451  break;
452  default:
453  RealScalar intpart;
454  split(p, intpart);
455 
456  res = MatrixType::Identity(rows(), cols());
457  computeIntPower(res, intpart);
458  if (p) computeFracPower(res, p);
459  }
460 }
461 
462 template <typename MatrixType>
464  using std::floor;
465  using std::pow;
466 
467  intpart = floor(p);
468  p -= intpart;
469 
470  // Perform Schur decomposition if it is not yet performed and the power is
471  // not an integer.
472  if (!m_conditionNumber && p) initialize();
473 
474  // Choose the more stable of intpart = floor(p) and intpart = ceil(p).
475  if (p > RealScalar(0.5) && p > (1 - p) * pow(m_conditionNumber, p)) {
476  --p;
477  ++intpart;
478  }
479 }
480 
481 template <typename MatrixType>
485  ComplexScalar eigenvalue;
486 
487  m_fT.resizeLike(m_A);
488  m_T = schurOfA.matrixT();
489  m_U = schurOfA.matrixU();
490  m_conditionNumber = m_T.diagonal().array().abs().maxCoeff() / m_T.diagonal().array().abs().minCoeff();
491 
492  // Move zero eigenvalues to the bottom right corner.
493  for (Index i = cols() - 1; i >= 0; --i) {
494  if (m_rank <= 2) return;
495  if (m_T.coeff(i, i) == RealScalar(0)) {
496  for (Index j = i + 1; j < m_rank; ++j) {
497  eigenvalue = m_T.coeff(j, j);
498  rot.makeGivens(m_T.coeff(j - 1, j), eigenvalue);
499  m_T.applyOnTheRight(j - 1, j, rot);
500  m_T.applyOnTheLeft(j - 1, j, rot.adjoint());
501  m_T.coeffRef(j - 1, j - 1) = eigenvalue;
502  m_T.coeffRef(j, j) = RealScalar(0);
503  m_U.applyOnTheRight(j - 1, j, rot);
504  }
505  --m_rank;
506  }
507  }
508 
509  m_nulls = rows() - m_rank;
510  if (m_nulls) {
511  eigen_assert(m_T.bottomRightCorner(m_nulls, m_nulls).isZero() &&
512  "Base of matrix power should be invertible or with a semisimple zero eigenvalue.");
513  m_fT.bottomRows(m_nulls).fill(RealScalar(0));
514  }
515 }
516 
517 template <typename MatrixType>
518 template <typename ResultType>
520  using std::abs;
521  using std::fmod;
522  RealScalar pp = abs(p);
523 
524  if (p < 0)
525  m_tmp = m_A.inverse();
526  else
527  m_tmp = m_A;
528 
529  while (true) {
530  if (fmod(pp, 2) >= 1) res = m_tmp * res;
531  pp /= 2;
532  if (pp < 1) break;
533  m_tmp *= m_tmp;
534  }
535 }
536 
537 template <typename MatrixType>
538 template <typename ResultType>
540  Block<ComplexMatrix, Dynamic, Dynamic> blockTp(m_fT, 0, 0, m_rank, m_rank);
541  eigen_assert(m_conditionNumber);
542  eigen_assert(m_rank + m_nulls == rows());
543 
544  MatrixPowerAtomic<ComplexMatrix>(m_T.topLeftCorner(m_rank, m_rank), p).compute(blockTp);
545  if (m_nulls) {
546  m_fT.topRightCorner(m_rank, m_nulls) = m_T.topLeftCorner(m_rank, m_rank)
547  .template triangularView<Upper>()
548  .solve(blockTp * m_T.topRightCorner(m_rank, m_nulls));
549  }
550  revertSchur(m_tmp, m_fT, m_U);
551  res = m_tmp * res;
552 }
553 
554 template <typename MatrixType>
555 template <int Rows, int Cols, int Options, int MaxRows, int MaxCols>
557  const ComplexMatrix& T, const ComplexMatrix& U) {
558  res.noalias() = U * (T.template triangularView<Upper>() * U.adjoint());
559 }
560 
561 template <typename MatrixType>
562 template <int Rows, int Cols, int Options, int MaxRows, int MaxCols>
564  const ComplexMatrix& T, const ComplexMatrix& U) {
565  res.noalias() = (U * (T.template triangularView<Upper>() * U.adjoint())).real();
566 }
567 
581 template <typename Derived>
582 class MatrixPowerReturnValue : public ReturnByValue<MatrixPowerReturnValue<Derived> > {
583  public:
584  typedef typename Derived::PlainObject PlainObject;
585  typedef typename Derived::RealScalar RealScalar;
586 
593  MatrixPowerReturnValue(const Derived& A, RealScalar p) : m_A(A), m_p(p) {}
594 
601  template <typename ResultType>
602  inline void evalTo(ResultType& result) const {
603  MatrixPower<PlainObject>(m_A.eval()).compute(result, m_p);
604  }
605 
606  Index rows() const { return m_A.rows(); }
607  Index cols() const { return m_A.cols(); }
608 
609  private:
610  const Derived& m_A;
612 };
613 
627 template <typename Derived>
628 class MatrixComplexPowerReturnValue : public ReturnByValue<MatrixComplexPowerReturnValue<Derived> > {
629  public:
630  typedef typename Derived::PlainObject PlainObject;
631  typedef typename std::complex<typename Derived::RealScalar> ComplexScalar;
632 
639  MatrixComplexPowerReturnValue(const Derived& A, const ComplexScalar& p) : m_A(A), m_p(p) {}
640 
650  template <typename ResultType>
651  inline void evalTo(ResultType& result) const {
652  result = (m_p * m_A.log()).exp();
653  }
654 
655  Index rows() const { return m_A.rows(); }
656  Index cols() const { return m_A.cols(); }
657 
658  private:
659  const Derived& m_A;
661 };
662 
663 namespace internal {
664 
665 template <typename MatrixPowerType>
666 struct traits<MatrixPowerParenthesesReturnValue<MatrixPowerType> > {
667  typedef typename MatrixPowerType::PlainObject ReturnType;
668 };
669 
670 template <typename Derived>
671 struct traits<MatrixPowerReturnValue<Derived> > {
672  typedef typename Derived::PlainObject ReturnType;
673 };
674 
675 template <typename Derived>
677  typedef typename Derived::PlainObject ReturnType;
678 };
679 
680 } // namespace internal
681 
682 template <typename Derived>
684  return MatrixPowerReturnValue<Derived>(derived(), p);
685 }
686 
687 template <typename Derived>
688 const MatrixComplexPowerReturnValue<Derived> MatrixBase<Derived>::pow(const std::complex<RealScalar>& p) const {
689  return MatrixComplexPowerReturnValue<Derived>(derived(), p);
690 }
691 
692 } // namespace Eigen
693 
694 #endif // EIGEN_MATRIX_POWER
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar imag(const AnnoyingScalar &)
Definition: AnnoyingScalar.h:132
int i
Definition: BiCGSTAB_step_by_step.cpp:9
cout<< "Here is a random 4x4 matrix, A:"<< endl<< A<< endl<< endl;ComplexSchur< MatrixXcf > schurOfA(A, false)
Eigen::Triplet< double > T
Definition: EigenUnitTest.cpp:11
#define eigen_assert(x)
Definition: Macros.h:910
#define EIGEN_PI
Definition: MathFunctions.h:16
RowVector3d w
Definition: Matrix_resize_int.cpp:3
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
Definition: PartialRedux_count.cpp:3
float * p
Definition: Tutorial_Map_using.cpp:9
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Expression of a fixed-size or dynamic-size block.
Definition: Block.h:110
Rotation given by a cosine-sine pair.
Definition: Jacobi.h:38
Proxy for the matrix power of some matrix (expression).
Definition: MatrixPower.h:628
MatrixComplexPowerReturnValue(const Derived &A, const ComplexScalar &p)
Constructor.
Definition: MatrixPower.h:639
Derived::PlainObject PlainObject
Definition: MatrixPower.h:630
Index cols() const
Definition: MatrixPower.h:656
std::complex< typename Derived::RealScalar > ComplexScalar
Definition: MatrixPower.h:631
const Derived & m_A
Definition: MatrixPower.h:659
void evalTo(ResultType &result) const
Compute the matrix power.
Definition: MatrixPower.h:651
Index rows() const
Definition: MatrixPower.h:655
const ComplexScalar m_p
Definition: MatrixPower.h:660
Class for computing matrix powers.
Definition: MatrixPower.h:89
void computePade(int degree, const MatrixType &IminusT, ResultType &res) const
Definition: MatrixPower.h:156
static int getPadeDegree(float normIminusT)
Definition: MatrixPower.h:233
RealScalar m_p
Definition: MatrixPower.h:98
@ RowsAtCompileTime
Definition: MatrixPower.h:91
@ MaxRowsAtCompileTime
Definition: MatrixPower.h:91
static ComplexScalar computeSuperDiag(const ComplexScalar &, const ComplexScalar &, RealScalar p)
Definition: MatrixPower.h:293
MatrixType::Scalar Scalar
Definition: MatrixPower.h:92
void compute2x2(ResultType &res, RealScalar p) const
Definition: MatrixPower.h:174
Block< MatrixType, Dynamic, Dynamic > ResultType
Definition: MatrixPower.h:95
MatrixPowerAtomic(const MatrixType &T, RealScalar p)
Constructor.
Definition: MatrixPower.h:133
void compute(ResultType &res) const
Compute the matrix power.
Definition: MatrixPower.h:139
void computeBig(ResultType &res) const
Definition: MatrixPower.h:194
MatrixType::RealScalar RealScalar
Definition: MatrixPower.h:93
const MatrixType & m_A
Definition: MatrixPower.h:97
std::complex< RealScalar > ComplexScalar
Definition: MatrixPower.h:94
Proxy for the matrix power of some matrix.
Definition: MatrixPower.h:43
MatrixType::RealScalar RealScalar
Definition: MatrixPower.h:45
Index rows() const
Definition: MatrixPower.h:65
Index cols() const
Definition: MatrixPower.h:66
const RealScalar m_p
Definition: MatrixPower.h:70
MatrixPowerParenthesesReturnValue(MatrixPower< MatrixType > &pow, RealScalar p)
Constructor.
Definition: MatrixPower.h:53
void evalTo(ResultType &result) const
Compute the matrix power.
Definition: MatrixPower.h:61
MatrixPower< MatrixType > & m_pow
Definition: MatrixPower.h:69
Proxy for the matrix power of some matrix (expression).
Definition: MatrixPower.h:582
Index cols() const
Definition: MatrixPower.h:607
MatrixPowerReturnValue(const Derived &A, RealScalar p)
Constructor.
Definition: MatrixPower.h:593
Derived::RealScalar RealScalar
Definition: MatrixPower.h:585
void evalTo(ResultType &result) const
Compute the matrix power.
Definition: MatrixPower.h:602
Index rows() const
Definition: MatrixPower.h:606
const Derived & m_A
Definition: MatrixPower.h:610
Derived::PlainObject PlainObject
Definition: MatrixPower.h:584
const RealScalar m_p
Definition: MatrixPower.h:611
Class for computing matrix powers.
Definition: MatrixPower.h:340
Matrix< ComplexScalar, Dynamic, Dynamic, 0, MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime > ComplexMatrix
Definition: MatrixPower.h:385
const MatrixPowerParenthesesReturnValue< MatrixType > operator()(RealScalar p)
Returns the matrix power.
Definition: MatrixPower.h:365
Index m_rank
Rank of m_A.
Definition: MatrixPower.h:408
Index cols() const
Definition: MatrixPower.h:380
ComplexMatrix m_fT
Store fractional power of m_T.
Definition: MatrixPower.h:397
Index m_nulls
Rank deficiency of m_A.
Definition: MatrixPower.h:411
MatrixPower(const MatrixType &A)
Constructor.
Definition: MatrixPower.h:354
void split(RealScalar &p, RealScalar &intpart)
Split p into integral part and fractional part.
Definition: MatrixPower.h:463
MatrixType::RealScalar RealScalar
Definition: MatrixPower.h:343
void computeFracPower(ResultType &res, RealScalar p)
Definition: MatrixPower.h:539
ComplexMatrix m_U
Definition: MatrixPower.h:394
void computeIntPower(ResultType &res, RealScalar p)
Definition: MatrixPower.h:519
void compute(ResultType &res, RealScalar p)
Compute the matrix power.
Definition: MatrixPower.h:444
MatrixType::Scalar Scalar
Definition: MatrixPower.h:342
MatrixType m_tmp
Temporary storage.
Definition: MatrixPower.h:391
void initialize()
Perform Schur decomposition for fractional power.
Definition: MatrixPower.h:482
RealScalar m_conditionNumber
Condition number of m_A.
Definition: MatrixPower.h:405
Index rows() const
Definition: MatrixPower.h:379
std::complex< RealScalar > ComplexScalar
Definition: MatrixPower.h:383
static void revertSchur(Matrix< ComplexScalar, Rows, Cols, Options, MaxRows, MaxCols > &res, const ComplexMatrix &T, const ComplexMatrix &U)
Definition: MatrixPower.h:556
MatrixType::Nested m_A
Reference to the base of matrix power.
Definition: MatrixPower.h:388
ComplexMatrix m_T
Store the result of Schur decomposition.
Definition: MatrixPower.h:394
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index cols() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:192
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE EIGEN_CONSTEXPR Index rows() const EIGEN_NOEXCEPT
Definition: PlainObjectBase.h:191
Definition: ReturnByValue.h:50
Definition: Meta.h:281
EIGEN_BLAS_FUNC() rot(int *n, Scalar *px, int *incx, Scalar *py, int *incy, Scalar *pc, Scalar *ps)
Definition: level1_real_impl.h:88
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 floor(const bfloat16 &a)
Definition: BFloat16.h:643
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 ceil(const bfloat16 &a)
Definition: BFloat16.h:644
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 fmod(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:648
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 exp(const bfloat16 &a)
Definition: BFloat16.h:615
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log(const bfloat16 &a)
Definition: BFloat16.h:618
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 sinh(const bfloat16 &a)
Definition: BFloat16.h:637
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 log1p(const bfloat16 &a)
Definition: BFloat16.h:619
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
void matrix_sqrt_triangular(const MatrixType &arg, ResultType &result)
Compute matrix square root of triangular matrix.
Definition: MatrixSquareRoot.h:194
double U
Swimming speed.
Definition: two_d_variable_diff_adapt.cc:53
const Mdouble degree
Definition: ExtendedMath.h:32
Definition: Eigen_Colamd.h:49
void split(const DoubleVector &in_vector, Vector< DoubleVector * > &out_vector_pt)
Definition: double_vector.cc:1413
internal::nested_eval< T, 1 >::type eval(const T &xpr)
Definition: sparse_permutations.cpp:47
Derived::PlainObject ReturnType
Definition: MatrixPower.h:677
MatrixPowerType::PlainObject ReturnType
Definition: MatrixPower.h:667
Derived::PlainObject ReturnType
Definition: MatrixPower.h:672
Definition: ForwardDeclarations.h:21
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2