Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
check_cholesky_factor_corr.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_CHOLESKY_FACTOR_CORR_HPP
2 #define STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_CHOLESKY_FACTOR_CORR_HPP
3 
10 
11 namespace stan {
12 
13  namespace math {
14 
33  template <typename T_y, typename T_result>
34  bool check_cholesky_factor_corr(const char* function,
35  const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
36  const char* name,
37  T_result* result) {
38  if (!check_square(function,y,name,result))
39  return false;
40  if (!check_lower_triangular(function,y,name,result))
41  return false;
42  for (int i = 0; i < y.rows(); ++i)
43  if (!check_positive(function, y(i,i), name, result))
44  return false;
45  for (int i = 0; i < y.rows(); ++i) {
46  Eigen::Matrix<T_y,Eigen::Dynamic,1> y_i = y.row(i).transpose();
47  if (!check_unit_vector(function, y_i, name, result))
48  return false;
49  }
50  return true;
51  }
52 
53  template <typename T>
54  inline bool check_cholesky_factor_corr(const char* function,
55  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& y,
56  const char* name,
57  T* result = 0) {
58  return check_cholesky_factor_corr<T,T>(function,y,name,result);
59  }
60 
61 
74  template <typename T_y, typename T_result>
75  inline bool check_cholesky_factor_corr(const char* function,
76  const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
77  T_result* result) {
78  return check_cholesky_factor_corr(function,y,"(internal variable)",
79  result);
80  }
81 
82  template <typename T>
83  inline bool check_cholesky_factor_corr(const char* function,
84  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& y,
85  T* result = 0) {
86  return check_cholesky_factor_corr<T,T>(function,y,result);
87  }
88 
89  }
90 }
91 #endif
bool check_unit_vector(const char *function, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta, const char *name, T_result *result)
Return true if the specified vector is unit vector.
bool check_positive(const char *function, const T_y &y, const char *name, T_result *result)
bool check_lower_triangular(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is lower triangular.
bool check_square(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is square.
bool check_cholesky_factor_corr(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is a valid Cholesky factor.

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