Stan  1.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros Pages
check_cov_matrix.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_COV_MATRIX_HPP__
2 #define __STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_COV_MATRIX_HPP__
3 
4 #include <sstream>
12 
13 
14 namespace stan {
15  namespace math {
16 
29  // FIXME: update warnings
30  template <typename T_y, typename T_result, class Policy>
31  inline bool check_cov_matrix(const char* function,
32  const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
33  const char* name,
34  T_result* result,
35  const Policy&) {
36  if (!check_size_match(function,
37  y.rows(), "Rows of covariance matrix",
38  y.cols(), "columns of covariance matrix",
39  result, Policy()))
40  return false;
41  if (!check_positive(function, y.rows(), "rows", result, Policy()))
42  return false;
43  if (!check_symmetric(function, y, name, result, Policy()))
44  return false;
45  if (!check_pos_definite(function, y, name, result, Policy()))
46  return false;
47  return true;
48  }
49 
50  template <typename T_y, typename T_result>
51  inline bool check_cov_matrix(const char* function,
52  const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
53  const char* name,
54  T_result* result) {
55  return check_cov_matrix(function,y,name,result,default_policy());
56  }
57 
58  template <typename T>
59  inline bool check_cov_matrix(const char* function,
60  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& y,
61  const char* name,
62  T* result = 0) {
63  return check_cov_matrix(function,y,name,result,default_policy());
64  }
65 
66 
67  // FIXME: this looks redundant
79  // FIXME: update warnings
80  template <typename T_covar, typename T_result, class Policy>
81  inline bool check_cov_matrix(const char* function,
82  const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
83  T_result* result,
84  const Policy&) {
85  if (!check_size_match(function,
86  Sigma.rows(), "Rows of covariance matrix",
87  Sigma.cols(), "columns of covariance matrix",
88  result, Policy()))
89  return false;
90  if (!check_positive(function, Sigma.rows(), "rows", result, Policy()))
91  return false;
92  if (!check_symmetric(function, Sigma, "Sigma", result, Policy()))
93  return false;
94  return true;
95  }
96  template <typename T_covar, typename T_result>
97  inline bool check_cov_matrix(const char* function,
98  const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
99  T_result* result) {
100  return check_cov_matrix(function,Sigma,result,default_policy());
101 
102  }
103  template <typename T>
104  inline bool check_cov_matrix(const char* function,
105  const Eigen::Matrix<T,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
106  T* result = 0) {
107  return check_cov_matrix(function,Sigma,result,default_policy());
108  }
109 
110  }
111 }
112 #endif

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