Stan Math Library  2.15.0
reverse mode automatic differentiation
matrix_exp_pade.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_MATRIX_EXP_PADE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_MATRIX_EXP_PADE_HPP
3 
4 #include <stan/math/prim/mat/fun/MatrixExponential.h>
5 
6 namespace stan {
7  namespace math {
8 
19  template <typename MatrixType>
20  MatrixType
21  matrix_exp_pade(const MatrixType& arg) {
22  MatrixType U, V;
23  int squarings;
24  Eigen::matrix_exp_computeUV<MatrixType>::run(arg, U, V, squarings,
25  arg(0, 0));
26  // Pade approximant is
27  // (U+V) / (-U+V)
28  MatrixType numer = U + V;
29  MatrixType denom = -U + V;
30  MatrixType pade_approximation = denom.partialPivLu().solve(numer);
31  for (int i = 0; i < squarings; ++i)
32  pade_approximation *= pade_approximation; // undo scaling by
33  // repeated squaring
34  return pade_approximation;
35  }
36  }
37 }
38 #endif
MatrixType matrix_exp_pade(const MatrixType &arg)
Computes the matrix exponential, using a Pade approximation, coupled with scaling and squaring...

     [ Stan Home Page ] © 2011–2016, Stan Development Team.