| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

diag_post_multiply.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_DIAG_POST_MULTIPLY_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_DIAG_POST_MULTIPLY_HPP
3
4 #include <stan/math/prim/mat/err/check_vector.hpp>
5 #include <stan/math/prim/scal/err/check_size_match.hpp>
6 #include <stan/math/prim/mat/fun/Eigen.hpp>
7 #include <boost/math/tools/promotion.hpp>
8
9 namespace stan {
10 namespace math {
11
12 template <typename T1, typename T2, int R1, int C1, int R2, int C2>
13 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
14 R1, C1>
15 diag_post_multiply(const Eigen::Matrix<T1, R1, C1>& m1,
16 const Eigen::Matrix<T2, R2, C2>& m2) {
17 check_vector("diag_post_multiply", "m2", m2);
18 int m1_cols = m1.cols();
19 check_size_match("diag_post_multiply",
20 "m2.size()", m2.size(),
21 "m1.cols()", m1_cols);
22 int m1_rows = m1.rows();
23 Eigen::Matrix<typename boost::math::tools::promote_args<T1, T2>::type,
24 R1, C1>
25 result(m1_rows, m1_cols);
26
27 for (int j = 0; j < m1_cols; ++j)
28 for (int i = 0; i < m1_rows; ++i)
29 result(i, j) = m2(j) * m1(i, j);
30 return result;
31 }
32
33 }
34 }
35 #endif
stan::math::check_vector
bool check_vector(const char *function, const char *name, const Eigen::Matrix< T, R, C > &x)
Return true if the matrix is either a row vector or column vector.
Definition: check_vector.hpp:34
check_size_match.hpp
stan
Definition: log_sum_exp.hpp:8
stan::math::check_size_match
bool check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Return true if the provided sizes match.
Definition: check_size_match.hpp:30
Eigen.hpp
check_vector.hpp
stan::math::diag_post_multiply
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C1 > diag_post_multiply(const Eigen::Matrix< T1, R1, C1 > &m1, const Eigen::Matrix< T2, R2, C2 > &m2)
Definition: diag_post_multiply.hpp:15

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