Automatic Differentiation
 
Loading...
Searching...
No Matches
cov_matrix_constrain_lkj.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP
2#define STAN_MATH_REV_CONSTRAINT_COV_MATRIX_CONSTRAIN_LKJ_HPP
3
10
11namespace stan {
12namespace math {
13
34template <typename T, require_var_vector_t<T>* = nullptr>
36 size_t k_choose_2 = (k * (k - 1)) / 2;
37 return read_cov_matrix(corr_constrain(x.head(k_choose_2)),
38 positive_constrain(x.tail(k)));
39}
40
66template <typename T, require_var_vector_t<T>* = nullptr>
68 scalar_type_t<T>& lp) {
69 size_t k_choose_2 = (k * (k - 1)) / 2;
70 return read_cov_matrix(corr_constrain(x.head(k_choose_2)),
71 positive_constrain(x.tail(k)), lp);
72}
73
74} // namespace math
75} // namespace stan
76
77#endif
Eigen::Matrix< value_type_t< T_CPCs >, Eigen::Dynamic, Eigen::Dynamic > read_cov_matrix(const T_CPCs &CPCs, const T_sds &sds, value_type_t< T_CPCs > &log_prob)
A generally worse alternative to call prior to evaluating the density of an elliptical distribution.
Eigen::Matrix< value_type_t< T >, Eigen::Dynamic, Eigen::Dynamic > cov_matrix_constrain_lkj(const T &x, size_t k)
Return the covariance matrix of the specified dimensionality derived from constraining the specified ...
plain_type_t< T > corr_constrain(const T &x)
Return the result of transforming the specified scalar or container of values to have a valid correla...
auto positive_constrain(const T &x)
Return the positive value for the specified unconstrained input.
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...