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__AGRAD__REV__MATRIX__TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
2 #define STAN__AGRAD__REV__MATRIX__TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
3 
5 #include <stan/agrad/rev/var.hpp>
6 #include <boost/type_traits/is_same.hpp>
7 #include <boost/utility/enable_if.hpp>
11 
12 namespace stan {
13  namespace agrad {
14 
20  template <typename T1,int R1,int C1,typename T2,int R2,int C2,typename T3,int R3,int C3>
21  inline typename
22  boost::enable_if_c<boost::is_same<T1,var>::value ||
23  boost::is_same<T2,var>::value ||
24  boost::is_same<T3,var>::value, var>::type
25  trace_gen_inv_quad_form_ldlt(const Eigen::Matrix<T1,R1,C1> &D,
27  const Eigen::Matrix<T3,R3,C3> &B)
28  {
29  stan::math::check_square("trace_gen_inv_quad_form_ldlt(%1%)",D,"D",
30  (double*)0);
31  stan::math::check_multiplicable("trace_gen_inv_quad_form_ldlt(%1%)",A,"A",
32  B,"B",(double*)0);
33  stan::math::check_multiplicable("trace_gen_inv_quad_form_ldlt(%1%)",B,"B",
34  D,"D",(double*)0);
35 
36  trace_inv_quad_form_ldlt_impl<T2,R2,C2,T3,R3,C3> *_impl = new trace_inv_quad_form_ldlt_impl<T2,R2,C2,T3,R3,C3>(D,A,B);
37 
38  return var(new trace_inv_quad_form_ldlt_vari<T2,R2,C2,T3,R3,C3>(_impl));
39  }
40 
41 
42  }
43 }
44 
45 #endif
quad_form_vari_alloc< TA, RA, CA, TB, RB, CB > * _impl
Definition: quad_form.hpp:118
bool check_multiplicable(const char *function, const T1 &y1, const char *name1, const T2 &y2, const char *name2, T_result *result)
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:27
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.
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.