inline bool check_corr_matrix(const char* function, const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y, const char* name, T_result* result, const Policy&) { if (!check_size_match(function, y.rows(), "Rows of correlation matrix", y.cols(), "columns of correlation matrix", result, Policy())) return false; if (!check_positive(function, y.rows(), "rows", result, Policy())) return false; if (!check_symmetric(function, y, "y", result, Policy())) return false; for (typename Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>::size_type k = 0; k < y.rows(); ++k) { if (fabs(y(k,k) - 1.0) > CONSTRAINT_TOLERANCE) { std::ostringstream message; message << name << " is not a valid correlation matrix. " << name << "(" << k << "," << k << ") is %1%, but should be near 1.0"; T_result tmp = policies::raise_domain_error<T_y>(function, message.str().c_str(), y(k,k), Policy()); if (result != 0) *result = tmp; return false; } } if (!check_pos_definite(function, y, "y", result, Policy())) return false; return true; }
inline bool check_cov_matrix(const std::string& function, const std::string& name, const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y) { check_size_match(function, "Rows of covariance matrix", y.rows(), "columns of covariance matrix", y.cols()); check_positive(function, "rows", y.rows()); check_symmetric(function, name, y); check_pos_definite(function, name, y); return true; }
inline bool check_cov_matrix(const char* function, const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y, const char* name, T_result* result) { check_size_match(function, y.rows(), "Rows of covariance matrix", y.cols(), "columns of covariance matrix", result); check_positive(function, y.rows(), "rows", result); check_symmetric(function, y, name, result); check_pos_definite(function, y, name, result); return true; }