1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_COV_MATRIX_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_COV_MATRIX_HPP
3 
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/err/check_pos_definite.hpp>
6 
7 namespace stan {
8 namespace math {
9 /**
10  * Check if the specified matrix is a valid
11  * covariance matrix.
12  *
13  * A valid covariance matrix is a square, symmetric matrix that is
14  * positive definite.
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 is not square
23  *   or if the matrix is 0x0
24  * @throw <code>std::domain_error</code> if the matrix is not symmetric,
25  *   if the matrix is not positive definite,
26  *   or if any element of the matrix is nan
27  */
28 template <typename T_y>
check_cov_matrix(const char * function,const char * name,const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic> & y)29 inline void check_cov_matrix(
30     const char* function, const char* name,
31     const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y) {
32   check_pos_definite(function, name, y);
33 }
34 
35 }  // namespace math
36 }  // namespace stan
37 #endif
38