1 #ifndef STAN_MATH_PRIM_MAT_PROB_INV_WISHART_LPDF_HPP 2 #define STAN_MATH_PRIM_MAT_PROB_INV_WISHART_LPDF_HPP 46 template <
bool propto,
typename T_y,
typename T_dof,
typename T_scale>
47 typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type
49 const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& W,
51 const Eigen::Matrix<T_scale, Eigen::Dynamic, Eigen::Dynamic>& S) {
52 static const char*
function =
"inv_wishart_lpdf";
56 using boost::math::tools::promote_args;
59 typename promote_args<T_y, T_dof, T_scale>::type lp(0.0);
61 check_greater(
function,
"Degrees of freedom parameter", nu, k - 1);
65 "columns of scale parameter", S.rows());
89 Eigen::Matrix<typename promote_args<T_y, T_scale>::type, Eigen::Dynamic,
94 Eigen::Matrix<T_scale, Eigen::Dynamic, Eigen::Dynamic>
>(
95 S.template selfadjointView<Eigen::Lower>())));
96 lp -= 0.5 *
trace(Winv_S);
103 template <
typename T_y,
typename T_dof,
typename T_scale>
104 inline typename boost::math::tools::promote_args<T_y, T_dof, T_scale>::type
106 const Eigen::Matrix<T_y, Eigen::Dynamic, Eigen::Dynamic>& W,
108 const Eigen::Matrix<T_scale, Eigen::Dynamic, Eigen::Dynamic>& S) {
109 return inv_wishart_lpdf<false>(W, nu, S);
Eigen::Matrix< fvar< T2 >, R1, C2 > mdivide_left_ldlt(const LDLT_factor< double, R1, C1 > &A, const Eigen::Matrix< fvar< T2 >, R2, C2 > &b)
Returns the solution of the system Ax=b given an LDLT_factor of A.
void check_ldlt_factor(const char *function, const char *name, LDLT_factor< T, R, C > &A)
Raise domain error if the specified LDLT factor is invalid.
void check_square(const char *function, const char *name, const matrix_cl &y)
Check if the matrix_cl is square.
boost::math::tools::promote_args< T_y, T_dof, T_scale >::type inv_wishart_lpdf(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &W, const T_dof &nu, const Eigen::Matrix< T_scale, Eigen::Dynamic, Eigen::Dynamic > &S)
The log of the Inverse-Wishart density for the given W, degrees of freedom, and scale matrix...
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
Primary template class for the metaprogram to compute the index type of a container.
LDLT_factor is a thin wrapper on Eigen::LDLT to allow for reusing factorizations and efficient autodi...
T trace(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
Returns the trace of the specified matrix.
const double NEG_LOG_TWO_OVER_TWO
void check_greater(const char *function, const char *name, const T_y &y, const T_low &low)
Check if y is strictly greater than low.
fvar< typename stan::return_type< T, int >::type > lmgamma(int x1, const fvar< T > &x2)
T log_determinant_ldlt(LDLT_factor< T, R, C > &A)