1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_LOG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_MULTI_NORMAL_PREC_LOG_HPP
31 template <
bool propto,
32 typename T_y,
typename T_loc,
typename T_covar>
33 typename return_type<T_y, T_loc, T_covar>::type
36 const T_covar& Sigma) {
37 static const char*
function(
"multi_normal_prec_log");
46 Eigen::Dynamic, Eigen::Dynamic> ldlt_Sigma(Sigma);
56 int size_y = y_vec[0].size();
57 int size_mu = mu_vec[0].size();
59 int size_y_old = size_y;
62 int size_y_new = y_vec[i].size();
64 "Size of one of the vectors "
65 "of the random variable", size_y_new,
66 "Size of another vector of "
67 "the random variable", size_y_old);
68 size_y_old = size_y_new;
70 int size_mu_old = size_mu;
73 int size_mu_new = mu_vec[i].size();
75 "Size of one of the vectors "
76 "of the location variable", size_mu_new,
77 "Size of another vector of "
78 "the location variable", size_mu_old);
79 size_mu_old = size_mu_new;
88 "Size of random variable", size_y,
89 "size of location parameter", size_mu);
91 "Size of random variable", size_y,
92 "rows of covariance parameter", Sigma.rows());
94 "Size of random variable", size_y,
95 "columns of covariance parameter", Sigma.cols());
97 for (
size_t i = 0; i < size_vec; i++) {
112 lp_type sum_lp_vec(0.0);
113 for (
size_t i = 0; i < size_vec; i++) {
114 Eigen::Matrix<typename return_type<T_y, T_loc>::type,
115 Eigen::Dynamic, 1> y_minus_mu(size_y);
116 for (
int j = 0; j < size_y; j++)
117 y_minus_mu(j) = y_vec[i](j) - mu_vec[i](j);
120 lp -= 0.5*sum_lp_vec;
125 template <
typename T_y,
typename T_loc,
typename T_covar>
129 return multi_normal_prec_log<false>(y, mu, Sigma);
size_t max_size_mvt(const T1 &x1, const T2 &x2)
fvar< T > trace_quad_form(const Eigen::Matrix< fvar< T >, RA, CA > &A, const Eigen::Matrix< fvar< T >, RB, CB > &B)
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
scalar_type_helper< is_vector< T >::value, T >::type type
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
return_type< T_y, T_loc, T_covar >::type multi_normal_prec_log(const T_y &y, const T_loc &mu, const T_covar &Sigma)
bool check_ldlt_factor(const char *function, const char *name, LDLT_factor< T, R, C > &A)
Return true if the argument is a valid LDLT_factor.
boost::math::tools::promote_args< typename scalar_type< T1 >::type, typename scalar_type< T2 >::type, typename scalar_type< T3 >::type, typename scalar_type< T4 >::type, typename scalar_type< T5 >::type, typename scalar_type< T6 >::type >::type type
bool check_positive(const char *function, const char *name, const T_y &y)
Return true if y is positive.
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.
const double NEG_LOG_SQRT_TWO_PI
bool check_finite(const char *function, const char *name, const T_y &y)
Return true if y is finite.
VectorViewMvt is a template expression that wraps either an Eigen::Matrix or a std::vector
bool check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is symmetric.
size_t length_mvt(const Eigen::Matrix< T, R, C > &)
T log_determinant_ldlt(LDLT_factor< T, R, C > &A)