1 #ifndef STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MATRIX_NORMAL_HPP
2 #define STAN__PROB__DISTRIBUTIONS__MULTIVARIATE__CONTINUOUS__MATRIX_NORMAL_HPP
38 template <
bool propto,
39 typename T_y,
typename T_Mu,
typename T_Sigma,
typename T_D>
40 typename boost::math::tools::promote_args<T_y,T_Mu,T_Sigma,T_D>::type
42 const Eigen::Matrix<T_Mu,Eigen::Dynamic,Eigen::Dynamic>& Mu,
43 const Eigen::Matrix<T_Sigma,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
44 const Eigen::Matrix<T_D,Eigen::Dynamic,Eigen::Dynamic>& D) {
45 static const char*
function =
"stan::prob::matrix_normal_prec_log(%1%)";
46 typename boost::math::tools::promote_args<T_y,T_Mu,T_Sigma,T_D>::type lp(0.0);
60 Sigma.rows(),
"Rows of Sigma",
61 Sigma.cols(),
"columns of Sigma",
67 LDLT_factor<T_Sigma,Eigen::Dynamic,Eigen::Dynamic> ldlt_Sigma(Sigma);
70 D.rows(),
"Rows of D",
71 D.cols(),
"Columns of D",
77 LDLT_factor<T_D,Eigen::Dynamic,Eigen::Dynamic> ldlt_D(D);
80 y.rows(),
"Rows of random variable",
81 Mu.rows(),
"Rows of location parameter",
84 y.cols(),
"Columns of random variable",
85 Mu.cols(),
"Columns of location parameter",
88 y.rows(),
"Rows of random variable",
89 Sigma.rows(),
"Rows of Sigma",
92 y.cols(),
"Columns of random variable",
93 D.rows(),
"Rows of D",
99 lp += NEG_LOG_SQRT_TWO_PI * y.cols() * y.rows();
115 template <
typename T_y,
typename T_Mu,
typename T_Sigma,
typename T_D>
116 typename boost::math::tools::promote_args<T_y,T_Mu,T_Sigma,T_D>::type
118 const Eigen::Matrix<T_Mu,Eigen::Dynamic,Eigen::Dynamic>& Mu,
119 const Eigen::Matrix<T_Sigma,Eigen::Dynamic,Eigen::Dynamic>& Sigma,
120 const Eigen::Matrix<T_D,Eigen::Dynamic,Eigen::Dynamic>& D) {
121 return matrix_normal_prec_log<false>(y,Mu,Sigma,D);
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 > trace_gen_quad_form(const Eigen::Matrix< fvar< T >, RD, CD > &D, const Eigen::Matrix< fvar< T >, RA, CA > &A, const Eigen::Matrix< fvar< T >, RB, CB > &B)
boost::math::tools::promote_args< T_y, T_Mu, T_Sigma, T_D >::type matrix_normal_prec_log(const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y, const Eigen::Matrix< T_Mu, Eigen::Dynamic, Eigen::Dynamic > &Mu, const Eigen::Matrix< T_Sigma, Eigen::Dynamic, Eigen::Dynamic > &Sigma, const Eigen::Matrix< T_D, Eigen::Dynamic, Eigen::Dynamic > &D)
The log of the matrix normal density for the given y, mu, Sigma and D where Sigma and D are given as ...
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.
Template metaprogram to calculate whether a summand needs to be included in a proportional (log) prob...
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R, C > subtract(const Eigen::Matrix< T1, R, C > &m1, const Eigen::Matrix< T2, R, C > &m2)
Return the result of subtracting the second specified matrix from the first specified matrix...
bool check_positive(const char *function, const T_y &y, const char *name, T_result *result)
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)
double trace_gen_quad_form(const Eigen::Matrix< double, RD, CD > &D, const Eigen::Matrix< double, RA, CA > &A, const Eigen::Matrix< double, RB, CB > &B)
Compute trace(D B^T A B).