1 #ifndef STAN_MATH_PRIM_MAT_PROB_MULTI_GP_CHOLESKY_LOG_HPP
2 #define STAN_MATH_PRIM_MAT_PROB_MULTI_GP_CHOLESKY_LOG_HPP
38 template <
bool propto,
39 typename T_y,
typename T_covar,
typename T_w>
40 typename boost::math::tools::promote_args<T_y, T_covar, T_w>::type
42 <T_y, Eigen::Dynamic, Eigen::Dynamic>& y,
44 <T_covar, Eigen::Dynamic, Eigen::Dynamic>& L,
45 const Eigen::Matrix<T_w, Eigen::Dynamic, 1>& w) {
46 static const char*
function(
"multi_gp_cholesky_log");
48 typename boost::math::tools::promote_args<T_y, T_covar, T_w>::type T_lp;
53 "Size of random variable (rows y)", y.rows(),
54 "Size of kernel scales (w)", w.size());
56 "Size of random variable", y.cols(),
57 "rows of covariance parameter", L.rows());
70 lp -= L.diagonal().array().log().sum() * y.rows();
74 lp += 0.5 * y.cols() *
sum(
log(w));
79 for (
int i = 0; i < y.rows(); i++) {
80 Eigen::Matrix<T_y, Eigen::Dynamic, 1> y_row(y.row(i));
81 Eigen::Matrix<
typename boost::math::tools::promote_args
93 template <
typename T_y,
typename T_covar,
typename T_w>
95 typename boost::math::tools::promote_args<T_y, T_covar, T_w>::type
97 <T_y, Eigen::Dynamic, Eigen::Dynamic>& y,
99 <T_covar, Eigen::Dynamic, Eigen::Dynamic>& L,
100 const Eigen::Matrix<T_w, Eigen::Dynamic, 1>& w) {
101 return multi_gp_cholesky_log<false>(y, L, w);
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
fvar< T > log(const fvar< T > &x)
fvar< T > dot_self(const Eigen::Matrix< fvar< T >, R, C > &v)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
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.
Eigen::Matrix< fvar< T >, R1, C1 > mdivide_left_tri_low(const Eigen::Matrix< fvar< T >, R1, C1 > &A, const Eigen::Matrix< fvar< T >, R2, C2 > &b)
boost::math::tools::promote_args< T_y, T_covar, T_w >::type multi_gp_cholesky_log(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const Eigen::Matrix< T_covar, Eigen::Dynamic, Eigen::Dynamic > &L, const Eigen::Matrix< T_w, Eigen::Dynamic, 1 > &w)
The log of a multivariate Gaussian Process for the given y, w, and a Cholesky factor L of the kernel ...