1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_SQUARE_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_SQUARE_HPP
3 
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/scal/err/check_size_match.hpp>
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>
check_square(const char * function,const char * name,const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic> & 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
36