1 #ifndef STAN_MATH_REV_FUN_MATRIX_EXP_MULTIPLY_HPP
2 #define STAN_MATH_REV_FUN_MATRIX_EXP_MULTIPLY_HPP
3
4 #include <stan/math/rev/meta.hpp>
5 #include <stan/math/rev/core.hpp>
6 #include <stan/math/rev/fun/multiply.hpp>
7 #include <stan/math/prim/err.hpp>
8 #include <stan/math/prim/fun/Eigen.hpp>
9 #include <stan/math/prim/fun/matrix_exp.hpp>
10
11 namespace stan {
12 namespace math {
13
14 /**
15 * Wrapper of matrix_exp_action function for a more literal name
16 *
17 * @tparam Ta type of the matrix A
18 * @tparam Tb type of the matrix B
19 *
20 * @param[in] A Matrix
21 * @param[in] B Matrix
22 * @return exponential of A multiplies B
23 */
24 template <typename Ta, typename Tb, require_all_eigen_t<Ta, Tb>* = nullptr,
25 require_any_st_autodiff<Ta, Tb>* = nullptr>
26 inline Eigen::Matrix<return_type_t<Ta, Tb>, -1, Tb::ColsAtCompileTime>
matrix_exp_multiply(const Ta & A,const Tb & B)27 matrix_exp_multiply(const Ta& A, const Tb& B) {
28 check_square("matrix_exp_multiply", "input matrix", A);
29 check_multiplicable("matrix_exp_multiply", "A", A, "B", B);
30 if (A.size() == 0) {
31 return {0, B.cols()};
32 }
33
34 return multiply(matrix_exp(A), B);
35 }
36
37 } // namespace math
38 } // namespace stan
39
40 #endif
41