check_square.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_SQUARE_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_SQUARE_HPP
3 
6 #include <sstream>
7 
8 namespace stan {
9 namespace math {
10 
11 /**
12  * Check if the specified matrix is square.
13  *
14  * This check allows 0x0 matrices.
15  *
16  * @tparam T Type of scalar.
17  *
18  * @param function Function name (for error messages)
19  * @param name Variable name (for error messages)
20  * @param y Matrix to test
21  *
22  * @throw <code>std::invalid_argument</code> if the matrix
23  * is not square
24  */
25 template <typename T_y>
26 inline void check_square(
27  const char* function, const char* name,
28  const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y) {
29  check_size_match(function, "Expecting a square matrix; rows of ", name,
30  y.rows(), "columns of ", name, y.cols());
31 }
32 
33 } // namespace math
34 } // namespace stan
35 #endif
const XML_Char * name
Definition: expat.h:151
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
void check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)