1 #ifndef STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_CHOLESKY_LOG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_CHOLESKY_LOG_HPP
54 template <
bool propto,
55 typename T_covar,
typename T_shape>
56 typename boost::math::tools::promote_args<T_covar, T_shape>::type
58 <T_covar, Eigen::Dynamic, Eigen::Dynamic>& L,
60 static const char*
function(
"stan::math::lkj_corr_cholesky_log");
62 using boost::math::tools::promote_args;
67 typename promote_args<T_covar, T_shape>::type lp(0.0);
71 const unsigned int K = L.rows();
78 const int Km1 = K - 1;
79 Eigen::Matrix<T_covar, Eigen::Dynamic, 1> log_diagonals =
80 L.diagonal().tail(Km1).array().log();
81 Eigen::Matrix<T_covar, Eigen::Dynamic, 1> values(Km1);
82 for (
int k = 0; k < Km1; k++)
83 values(k) = (Km1 - k - 1) * log_diagonals(k);
89 values += (2.0 * eta - 2.0) * log_diagonals;
96 template <
typename T_covar,
typename T_shape>
98 typename boost::math::tools::promote_args<T_covar, T_shape>::type
100 <T_covar, Eigen::Dynamic, Eigen::Dynamic>& L,
101 const T_shape& eta) {
102 return lkj_corr_cholesky_log<false>(L, eta);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
Metaprogramming struct to detect whether a given type is constant in the mathematical sense (not the ...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
boost::math::tools::promote_args< T_covar, T_shape >::type lkj_corr_cholesky_log(const Eigen::Matrix< T_covar, Eigen::Dynamic, Eigen::Dynamic > &L, const T_shape &eta)
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
bool check_lower_triangular(const char *function, const char *name, const Eigen::Matrix< T_y, Dynamic, Dynamic > &y)
Return true if the specified matrix is lower triangular.
T_shape do_lkj_constant(const T_shape &eta, const unsigned int &K)