Automatic Differentiation
 
Loading...
Searching...
No Matches
check_cholesky_factor_corr.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_CHOLESKY_FACTOR_CORR_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_CHOLESKY_FACTOR_CORR_HPP
3
13
14namespace stan {
15namespace math {
16
36template <typename Mat, require_matrix_t<Mat>* = nullptr>
37void check_cholesky_factor_corr(const char* function, const char* name,
38 const Mat& y) {
39 const auto& y_ref = to_ref(value_of_rec(y));
40 check_square(function, name, y_ref);
41 check_lower_triangular(function, name, y_ref);
42 check_positive(function, name, y_ref.diagonal());
43 for (Eigen::Index i = 0; i < y_ref.rows(); ++i) {
44 check_unit_vector(function, name, y_ref.row(i));
45 }
46}
47
68template <typename StdVec, require_std_vector_t<StdVec>* = nullptr>
69void check_cholesky_factor_corr(const char* function, const char* name,
70 const StdVec& y) {
71 for (size_t i = 0; i < y.size(); ++i) {
73 internal::make_iter_name(name, i).c_str(), y[i]);
74 }
75}
76} // namespace math
77} // namespace stan
78#endif
auto make_iter_name(const char *name)
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
void check_unit_vector(const char *function, const char *name, const Vec &theta)
Throw an exception if the specified vector does not have unit Euclidiean length.
void check_cholesky_factor_corr(const char *function, const char *name, const Mat &y)
Throw an exception if the specified matrix is not a valid Cholesky factor of a correlation matrix.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
void check_lower_triangular(const char *function, const char *name, const T_y &y)
Check if the specified matrix is lower triangular.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9