Automatic Differentiation
 
Loading...
Searching...
No Matches
is_cholesky_factor_corr.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_IS_CHOLESKY_FACTOR_CORR_HPP
2#define STAN_MATH_PRIM_ERR_IS_CHOLESKY_FACTOR_CORR_HPP
3
9
10namespace stan {
11namespace math {
25template <typename EigMat, require_eigen_matrix_dynamic_t<EigMat>* = nullptr>
26inline bool is_cholesky_factor_corr(const EigMat& y) {
27 const auto& y_ref = to_ref(y);
28 if (!is_cholesky_factor(y_ref)) {
29 return false;
30 }
31 for (int i = 0; i < y_ref.rows(); ++i) {
32 if (!is_unit_vector(y_ref.row(i))) {
33 return false;
34 }
35 }
36 return true;
37}
38
39} // namespace math
40} // namespace stan
41#endif
bool is_cholesky_factor_corr(const EigMat &y)
Return true if y is a valid Cholesky factor, if the number of rows is not less than the number of col...
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
bool is_unit_vector(const EigVec &theta)
Return true if the vector is not a unit vector or if any element is NaN.
bool is_cholesky_factor(const EigMat &y)
Return true if y is a valid Cholesky factor, if number of rows is not less than the number of columns...
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Definition fvar.hpp:9