1 #ifndef STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_LOG_HPP 2 #define STAN_MATH_PRIM_MAT_PROB_LKJ_CORR_LOG_HPP 55 template <
bool propto,
56 typename T_y,
typename T_shape>
57 typename boost::math::tools::promote_args<T_y, T_shape>::type
58 lkj_corr_log(
const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y,
60 static const char*
function(
"lkj_corr_log");
62 using boost::math::tools::promote_args;
64 typename promote_args<T_y, T_shape>::type lp(0.0);
68 const unsigned int K = y.rows();
82 Eigen::Matrix<T_y, Eigen::Dynamic, 1> values =
83 y.ldlt().vectorD().array().log().matrix();
84 lp += (eta - 1.0) *
sum(values);
88 template <
typename T_y,
typename T_shape>
90 typename boost::math::tools::promote_args<T_y, T_shape>::type
91 lkj_corr_log(
const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& y,
93 return lkj_corr_log<false>(y, 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 ...
Metaprogram structure to determine the base scalar type of a template argument.
boost::math::tools::promote_args< T_y, T_shape >::type lkj_corr_log(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const T_shape &eta)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
void check_corr_matrix(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is a valid correlation matrix.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
T_shape do_lkj_constant(const T_shape &eta, const unsigned int &K)