Automatic Differentiation
 
Loading...
Searching...
No Matches
scale_matrix_exp_multiply.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_SCALE_MATRIX_EXP_MULTIPLY_HPP
2#define STAN_MATH_PRIM_FUN_SCALE_MATRIX_EXP_MULTIPLY_HPP
3
9
10namespace stan {
11namespace math {
12
27template <typename EigMat1, typename EigMat2,
28 require_all_eigen_vt<std::is_arithmetic, EigMat1, EigMat2>* = nullptr>
29inline Eigen::Matrix<double, Eigen::Dynamic, EigMat2::ColsAtCompileTime>
30scale_matrix_exp_multiply(const double& t, const EigMat1& A, const EigMat2& B) {
31 check_square("scale_matrix_exp_multiply", "input matrix", A);
32 check_multiplicable("scale_matrix_exp_multiply", "A", A, "B", B);
33 if (A.size() == 0) {
34 return {0, B.cols()};
35 }
36
37 return matrix_exp_action_handler().action(A, B, t);
38}
39
54template <typename Tt, typename EigMat1, typename EigMat2,
57 value_type_t<EigMat2>>* = nullptr>
58inline Eigen::Matrix<return_type_t<Tt, EigMat1, EigMat2>, Eigen::Dynamic,
59 EigMat2::ColsAtCompileTime>
60scale_matrix_exp_multiply(const Tt& t, const EigMat1& A, const EigMat2& B) {
61 check_square("scale_matrix_exp_multiply", "input matrix", A);
62 check_multiplicable("scale_matrix_exp_multiply", "A", A, "B", B);
63 if (A.size() == 0) {
64 return {0, B.cols()};
65 }
66
67 return multiply(matrix_exp(multiply(A, t)), B);
68}
69
70} // namespace math
71} // namespace stan
72#endif
Eigen::MatrixXd action(const EigMat1 &mat, const EigMat2 &b, const double &t=1.0)
Perform the matrix exponential action exp(A*t)*B.
The implementation of the work by Awad H.
require_any_t< is_autodiff< std::decay_t< Types > >... > require_any_autodiff_t
Require any of the types satisfy is_autodiff.
require_all_t< is_eigen< std::decay_t< Types > >... > require_all_eigen_t
Require all of the types satisfy is_eigen.
Definition is_eigen.hpp:65
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
void check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the matrices can be multiplied.
auto multiply(const Mat1 &m1, const Mat2 &m2)
Return the product of the specified matrices.
Definition multiply.hpp:18
Eigen::Matrix< double, Eigen::Dynamic, EigMat2::ColsAtCompileTime > scale_matrix_exp_multiply(const double &t, const EigMat1 &A, const EigMat2 &B)
Return product of exp(At) and B, where A is a NxN double matrix, B is a NxCb double matrix,...
plain_type_t< T > matrix_exp(const T &A_in)
Return the matrix exponential of the input matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...