Stan Math Library  2.15.0
reverse mode automatic differentiation
matrix_exp.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_MATRIX_EXP_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_MATRIX_EXP_HPP
3 
6 
7 namespace stan {
8  namespace math {
9 
19  template <typename T>
20  inline
21  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
22  matrix_exp(const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> A) {
23  check_nonzero_size("matrix_exp", "input matrix", A);
24  check_square("matrix_exp", "input matrix", A);
25 
26  return (A.cols() == 2
27  && square(value_of(A(0, 0)) - value_of(A(1, 1)))
28  + 4 * value_of(A(0, 1)) * value_of(A(1, 0)) > 0)
30  }
31  }
32 }
33 #endif
void check_nonzero_size(const char *function, const char *name, const T_y &y)
Check if the specified matrix/vector is of non-zero size.
T value_of(const fvar< T > &v)
Return the value of the specified variable.
Definition: value_of.hpp:16
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > matrix_exp_2x2(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &A)
Return the matrix exponential of a 2x2 matrix.
fvar< T > square(const fvar< T > &x)
Definition: square.hpp:14
void check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is square.
MatrixType matrix_exp_pade(const MatrixType &arg)
Computes the matrix exponential, using a Pade approximation, coupled with scaling and squaring...
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > matrix_exp(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > A)
Return the matrix exponential of the input matrix.
Definition: matrix_exp.hpp:22

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