1#ifndef STAN_MATH_PRIM_PROB_MULTI_NORMAL_PREC_LPDF_HPP
2#define STAN_MATH_PRIM_PROB_MULTI_NORMAL_PREC_LPDF_HPP
19template <
bool propto,
typename T_y,
typename T_loc,
typename T_covar>
21 const T_y& y,
const T_loc& mu,
const T_covar& Sigma) {
26 static constexpr const char* function =
"multi_normal_prec_lpdf";
31 if (number_of_y == 0 || number_of_mu == 0) {
41 int size_y = y_vec[0].size();
42 int size_mu = mu_vec[0].size();
44 for (
size_t i = 1, size_mvt_y =
size_mvt(y); i < size_mvt_y; i++) {
46 "Size of one of the vectors "
47 "of the random variable",
49 "Size of the first vector of "
50 "the random variable",
53 for (
size_t i = 1, size_mvt_mu =
size_mvt(mu); i < size_mvt_mu; i++) {
55 "Size of one of the vectors "
56 "of the location variable",
58 "Size of the first vector of "
59 "the location variable",
65 "size of location parameter", size_mu);
67 "rows of covariance parameter", Sigma.rows());
69 "columns of covariance parameter", Sigma.cols());
71 for (
size_t i = 0; i < size_vec; i++) {
75 const auto& Sigma_ref =
to_ref(Sigma);
94 lp_type sum_lp_vec(0.0);
95 for (
size_t i = 0; i < size_vec; i++) {
100 lp -= 0.5 * sum_lp_vec;
105template <
typename T_y,
typename T_loc,
typename T_covar>
107 const T_y& y,
const T_loc& mu,
const T_covar& Sigma) {
108 return multi_normal_prec_lpdf<false>(y, mu, Sigma);
This class provides a low-cost wrapper for situations where you either need an Eigen Vector or RowVec...
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
auto as_column_vector_or_scalar(T &&a)
as_column_vector_or_scalar of a kernel generator expression.
int64_t size_mvt(const ScalarT &)
Provides the size of a multivariate argument.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
int64_t size(const T &m)
Returns the size (number of the elements) of a matrix_cl or var_value<matrix_cl<T>>.
value_type_t< T > log_determinant_ldlt(LDLT_factor< T > &A)
Returns log(abs(det(A))) given a LDLT_factor of A.
auto make_ldlt_factor(const T &A)
Make an LDLT_factor with matrix type plain_type_t<T>
void check_consistent_sizes_mvt(const char *)
Trivial no input case, this function is a no-op.
return_type_t< T_y, T_loc, T_covar > multi_normal_prec_lpdf(const T_y &y, const T_loc &mu, const T_covar &Sigma)
const double NEG_LOG_SQRT_TWO_PI
The value of minus the natural logarithm of the square root of , .
int64_t max_size_mvt(const T1 &x1, const Ts &... xs)
Calculate the size of the largest multivariate input.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_finite(const char *function, const char *name, const T_y &y)
Return true if all values in y are finite.
void check_ldlt_factor(const char *function, const char *name, LDLT_factor< T > &A)
Raise domain error if the specified LDLT factor is invalid.
void check_not_nan(const char *function, const char *name, const T_y &y)
Check if y is not NaN.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
return_type_t< EigMat1, EigMat2 > trace_quad_form(const EigMat1 &A, const EigMat2 &B)
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...