1 #ifndef STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MULTI_GP_HPP
2 #define STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MULTI_GP_HPP
42 template <
bool propto,
43 typename T_y,
typename T_covar,
typename T_w>
44 typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type
45 multi_gp_log(
const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
46 const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
47 const Eigen::Matrix<T_w,Eigen::Dynamic,1>& w) {
48 static const char*
function =
"stan::prob::multi_gp_log(%1%)";
49 typedef typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type T_lp;
67 Sigma.rows(),
"Rows of kernel matrix",
68 Sigma.cols(),
"columns of kernel matrix",
74 LDLT_factor<T_covar,Eigen::Dynamic,Eigen::Dynamic> ldlt_Sigma(Sigma);
78 y.rows(),
"Size of random variable (rows y)",
79 w.size(),
"Size of kernel scales (w)",
82 y.cols(),
"Size of random variable",
83 Sigma.rows(),
"rows of covariance parameter",
92 lp += NEG_LOG_SQRT_TWO_PI * y.rows() * y.cols();
100 lp += (0.5 * y.cols()) *
sum(
log(w));
104 Eigen::Matrix<T_w,Eigen::Dynamic,Eigen::Dynamic> w_mat(w.asDiagonal());
105 Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic> yT(y.transpose());
112 template <
typename T_y,
typename T_covar,
typename T_w>
114 typename boost::math::tools::promote_args<T_y,T_covar,T_w>::type
115 multi_gp_log(
const Eigen::Matrix<T_y,Eigen::Dynamic,Eigen::Dynamic>& y,
116 const Eigen::Matrix<T_covar,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
117 const Eigen::Matrix<T_w,Eigen::Dynamic,1>& w) {
118 return multi_gp_log<false>(y,Sigma,w);
boost::math::tools::promote_args< T_y, T_covar, T_w >::type multi_gp_log(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const Eigen::Matrix< T_covar, Eigen::Dynamic, Eigen::Dynamic > &Sigma, const Eigen::Matrix< T_w, Eigen::Dynamic, 1 > &w)
The log of a multivariate Gaussian Process for the given y, Sigma, and w.
bool check_positive_finite(const char *function, const T_y &y, const char *name, T_result *result)
bool check_size_match(const char *function, T_size1 i, const char *name_i, T_size2 j, const char *name_j, T_result *result)
bool check_finite(const char *function, const T_y &y, const char *name, T_result *result)
Checks if the variable y is finite.
fvar< T > sum(const Eigen::Matrix< fvar< T >, R, C > &m)
bool check_symmetric(const char *function, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const char *name, T_result *result)
Return true if the specified matrix is symmetric.
bool check_ldlt_factor(const char *function, stan::math::LDLT_factor< T, R, C > &A, const char *name, T_result *result)
Return true if the underlying matrix is positive definite.
boost::enable_if_c<!stan::is_var< T1 >::value &&!stan::is_var< T2 >::value &&!stan::is_var< T3 >::value, typename boost::math::tools::promote_args< T1, T2, T3 >::type >::type trace_gen_inv_quad_form_ldlt(const Eigen::Matrix< T1, R1, C1 > &D, const stan::math::LDLT_factor< T2, R2, C2 > &A, const Eigen::Matrix< T3, R3, C3 > &B)
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
bool check_positive(const char *function, const T_y &y, const char *name, T_result *result)
Eigen::Matrix< T, Rows, Cols > log(const Eigen::Matrix< T, Rows, Cols > &m)
Return the element-wise logarithm of the matrix or vector.
double sum(std::vector< double > &x)
bool check_not_nan(const char *function, const T_y &y, const char *name, T_result *result)
Checks if the variable y is nan.
var log_determinant_ldlt(stan::math::LDLT_factor< var, R, C > &A)
T log_determinant_ldlt(stan::math::LDLT_factor< T, R, C > &A)
boost::enable_if_c< boost::is_same< T1, var >::value||boost::is_same< T2, var >::value||boost::is_same< T3, var >::value, var >::type trace_gen_inv_quad_form_ldlt(const Eigen::Matrix< T1, R1, C1 > &D, const stan::math::LDLT_factor< T2, R2, C2 > &A, const Eigen::Matrix< T3, R3, C3 > &B)
Compute the trace of an inverse quadratic form.
fvar< T > log(const fvar< T > &x)