1 #ifndef STAN_MATH_PRIM_MAT_FUN_COV_MATRIX_CONSTRAIN_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_COV_MATRIX_CONSTRAIN_HPP
28 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
31 <Eigen::Matrix<T, Eigen::Dynamic, 1> >::type K) {
37 Matrix<T, Dynamic, Dynamic> L(K, K);
40 "K + (K choose 2)", (K * (K + 1)) / 2);
42 for (index_t m = 0; m < K; ++m) {
43 for (
int n = 0; n < m; ++n)
45 L(m, m) =
exp(x(i++));
46 for (index_t n = m + 1; n < K; ++n)
65 Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>
69 Eigen::Dynamic> >::type K,
78 "K + (K choose 2)", (K * (K + 1)) / 2);
79 Matrix<T, Dynamic, Dynamic> L(K, K);
81 for (index_t m = 0; m < K; ++m) {
82 for (index_t n = 0; n < m; ++n)
84 L(m, m) =
exp(x(i++));
85 for (index_t n = m + 1; n < K; ++n)
90 for (index_t k = 0; k < K; ++k)
91 lp += (K - k + 1) *
log(L(k, k));
const double LOG_2
The natural logarithm of 2, .
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > cov_matrix_constrain(const Eigen::Matrix< T, Eigen::Dynamic, 1 > &x, typename math::index_type< Eigen::Matrix< T, Eigen::Dynamic, 1 > >::type K)
Return the symmetric, positive-definite matrix of dimensions K by K resulting from transforming the s...
fvar< T > log(const fvar< T > &x)
Eigen::Matrix< fvar< T >, R, R > multiply_lower_tri_self_transpose(const Eigen::Matrix< fvar< T >, R, C > &m)
Primary template class for the metaprogram to compute the index type of a container.
fvar< T > exp(const fvar< T > &x)
bool check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Return true if the provided sizes match.