Stan Math Library  2.20.0
reverse mode automatic differentiation
is_cholesky_factor_corr.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_IS_CHOLESKY_FACTOR_CORR_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_IS_CHOLESKY_FACTOR_CORR_HPP
3 
8 
9 namespace stan {
10 namespace math {
25 template <typename T_y>
27  const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y) {
28  if (!is_cholesky_factor(y))
29  return false;
30  for (int i = 0; i < y.rows(); ++i) {
31  Eigen::Matrix<T_y, Eigen::Dynamic, 1> y_i = y.row(i).transpose();
32  if (!is_unit_vector(y_i))
33  return false;
34  }
35  return true;
36 }
37 
38 } // namespace math
39 } // namespace stan
40 #endif
bool is_cholesky_factor_corr(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if y is a valid Cholesky factor, if the number of rows is not less than the number of col...
bool is_cholesky_factor(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if y is a valid Choleksy factor, if number of rows is not less than the number of columns...
bool is_unit_vector(const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Return true if the vector is not a unit vector or if any element is NaN.

     [ Stan Home Page ] © 2011–2018, Stan Development Team.