check_multiplicable.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_MULTIPLICABLE_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_MULTIPLICABLE_HPP
3 
7 
8 namespace stan {
9 namespace math {
10 
11 /**
12  * Check if the matrices can be multiplied.
13  *
14  * This checks the runtime sizes to determine whether the two
15  * matrices are multiplicable. This allows Eigen matrices,
16  * vectors, and row vectors to be checked.
17  *
18  * @tparam T1 Type of first matrix
19  * @tparam T2 Type of second matrix
20  *
21  * @param function Function name (for error messages)
22  * @param name1 Variable name for the first matrix (for error messages)
23  * @param y1 First matrix
24  * @param name2 Variable name for the second matrix (for error messages)
25  * @param y2 Second matrix
26  *
27  * @throw <code>std::invalid_argument</code> if the matrices are not
28  * multiplicable or if either matrix is size 0 for either rows or columns
29  */
30 template <typename T1, typename T2>
31 inline void check_multiplicable(const char* function, const char* name1,
32  const T1& y1, const char* name2, const T2& y2) {
33  check_positive_size(function, name1, "rows()", y1.rows());
34  check_positive_size(function, name2, "cols()", y2.cols());
35  check_size_match(function, "Columns of ", name1, y1.cols(), "Rows of ", name2,
36  y2.rows());
37  check_positive_size(function, name1, "cols()", y1.cols());
38 }
39 } // namespace math
40 } // namespace stan
41 #endif
Float_t y1[n_points_granero]
Definition: compare.C:5
void check_positive_size(const char *function, const char *name, const char *expr, int size)
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
void check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)