1#ifndef STAN_MATH_PRIM_PROB_MULTI_GP_CHOLESKY_LPDF_HPP
2#define STAN_MATH_PRIM_PROB_MULTI_GP_CHOLESKY_LPDF_HPP
38template <
bool propto,
typename T_y,
typename T_covar,
typename T_w,
39 require_all_eigen_matrix_dynamic_t<T_y, T_covar>* =
nullptr,
40 require_eigen_col_vector_t<T_w>* =
nullptr>
45 static constexpr const char* function =
"multi_gp_cholesky_lpdf";
47 "Size of kernel scales (w)", w.size());
49 "rows of covariance parameter", L.rows());
51 const auto& y_ref =
to_ref(y);
53 const auto& L_ref =
to_ref(L);
56 const auto& w_ref =
to_ref(w);
69 lp -=
sum(
log(L_ref.diagonal())) * y.rows();
73 lp += 0.5 * y.cols() *
sum(
log(w_ref));
78 for (
int i = 0; i < y.rows(); i++) {
83 lp -= 0.5 * sum_lp_vec;
89template <
typename T_y,
typename T_covar,
typename T_w>
93 return multi_gp_cholesky_lpdf<false>(y, L, w);
return_type_t< T_y, T_covar, T_w > multi_gp_cholesky_lpdf(const T_y &y, const T_covar &L, const T_w &w)
The log of a multivariate Gaussian Process for the given y, w, and a Cholesky factor L of the kernel ...
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
fvar< T > log(const fvar< T > &x)
const double NEG_LOG_SQRT_TWO_PI
The value of minus the natural logarithm of the square root of , .
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.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
void check_cholesky_factor(const char *function, const char *name, const Mat &y)
Throw an exception if the specified matrix is not a valid Cholesky factor.
auto dot_self(const T &a)
Returns squared norm of a vector or 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.
Eigen::Matrix< value_type_t< T1 >, T1::RowsAtCompileTime, T2::ColsAtCompileTime > mdivide_left_tri_low(const T1 &A, const T2 &b)
void check_positive_finite(const char *function, const char *name, const T_y &y)
Check if y is positive and finite.
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...