1 #ifndef STAN_MATH_PRIM_FUN_DIAG_POST_MULTIPLY_HPP
2 #define STAN_MATH_PRIM_FUN_DIAG_POST_MULTIPLY_HPP
3
4 #include <stan/math/prim/err.hpp>
5 #include <stan/math/prim/fun/Eigen.hpp>
6
7 namespace stan {
8 namespace math {
9
10 /**
11 * Return the product of the matrix and the diagonal matrix
12 * formed from the vector or row_vector.
13 *
14 * @tparam T1 type of the matrix
15 * @tparam T2 type of the vector/row_vector
16 * @param m1 input matrix
17 * @param m2 input vector/row_vector
18 *
19 * @return product of the matrix and the diagonal matrix formed from the
20 * vector or row_vector.
21 */
22 template <typename T1, typename T2, require_eigen_t<T1>* = nullptr,
23 require_eigen_vector_t<T2>* = nullptr,
24 require_all_not_st_var<T1, T2>* = nullptr>
diag_post_multiply(const T1 & m1,const T2 & m2)25 auto diag_post_multiply(const T1& m1, const T2& m2) {
26 check_size_match("diag_post_multiply", "m2.size()", m2.size(), "m1.cols()",
27 m1.cols());
28 return m1 * m2.asDiagonal();
29 }
30
31 } // namespace math
32 } // namespace stan
33 #endif
34