Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
trace_gen_inv_quad_form_ldlt.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
2 #define STAN__MATH__MATRIX__TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
3 
12 
13 namespace stan {
14  namespace math {
15 
16  /*
17  * Compute the trace of an inverse quadratic form. I.E., this computes
18  * trace(D B^T A^-1 B)
19  * where D is a square matrix and the LDLT_factor of A is provided.
20  */
21  template <typename T1, typename T2, typename T3,
22  int R1,int C1,int R2,int C2,int R3,int C3>
23  inline typename
24  boost::enable_if_c<!stan::is_var<T1>::value &&
27  typename boost::math::tools::promote_args<T1,T2,T3>::type>::type
28  trace_gen_inv_quad_form_ldlt(const Eigen::Matrix<T1,R1,C1> &D,
30  const Eigen::Matrix<T3,R3,C3> &B) {
31 
32  stan::math::check_square("trace_gen_inv_quad_form_ldlt(%1%)",D,"D",
33  (double*)0);
34  stan::math::check_multiplicable("trace_gen_inv_quad_form_ldlt(%1%)",A,"A",
35  B,"B",(double*)0);
36  stan::math::check_multiplicable("trace_gen_inv_quad_form_ldlt(%1%)",B,"B",
37  D,"D",(double*)0);
38 
40  }
41 
42  }
43 }
44 #endif
Eigen::Matrix< typename boost::math::tools::promote_args< T1, T2 >::type, R1, C2 > mdivide_left_ldlt(const stan::math::LDLT_factor< T1, R1, C1 > &A, const Eigen::Matrix< T2, R2, C2 > &b)
Returns the solution of the system Ax=b given an LDLT_factor of A.
bool check_multiplicable(const char *function, const T1 &y1, const char *name1, const T2 &y2, const char *name2, T_result *result)
Eigen::Matrix< T, C, R > transpose(const Eigen::Matrix< T, R, C > &m)
Definition: transpose.hpp:12
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)
T trace(const Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > &m)
Returns the trace of the specified matrix.
Definition: trace.hpp:20
boost::enable_if_c< boost::is_arithmetic< T >::value, Eigen::Matrix< double, R, C > >::type multiply(const Eigen::Matrix< double, R, C > &m, T c)
Return specified matrix multiplied by specified scalar.
Definition: multiply.hpp:25
bool check_square(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 square.

     [ Stan Home Page ] © 2011–2014, Stan Development Team.