Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
trace_inv_quad_form_ldlt.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__TRACE_INV_QUAD_FORM_LDLT_HPP
2 #define STAN__MATH__MATRIX__TRACE_INV_QUAD_FORM_LDLT_HPP
3 
11 
12 namespace stan {
13  namespace math {
14 
15  /*
16  * Compute the trace of an inverse quadratic form. I.E., this computes
17  * trace(B^T A^-1 B)
18  * where the LDLT_factor of A is provided.
19  */
20  template <typename T1, typename T2, int R2,int C2,int R3,int C3>
21  inline typename
22  boost::enable_if_c<!stan::is_var<T1>::value &&
24  typename boost::math::tools::promote_args<T1,T2>::type>::type
26  const Eigen::Matrix<T2,R3,C3> &B) {
27  stan::math::check_multiplicable("trace_inv_quad_form_ldlt(%1%)",A,"A",
28  B,"B",(double*)0);
29 
30  return trace(multiply(transpose(B),mdivide_left_ldlt(A,B)));
31  }
32  }
33 }
34 
35 #endif
boost::enable_if_c<!stan::is_var< T1 >::value &&!stan::is_var< T2 >::value, typename boost::math::tools::promote_args< T1, T2 >::type >::type trace_inv_quad_form_ldlt(const stan::math::LDLT_factor< T1, R2, C2 > &A, const Eigen::Matrix< T2, R3, C3 > &B)
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
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

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