Stan Math Library  2.15.0
reverse mode automatic differentiation
trace_gen_inv_quad_form_ldlt.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_MAT_FUN_TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
2 #define STAN_MATH_REV_MAT_FUN_TRACE_GEN_INV_QUAD_FORM_LDLT_HPP
3 
5 #include <stan/math/rev/core.hpp>
8 #include <boost/utility/enable_if.hpp>
12 
13 namespace stan {
14  namespace math {
15 
21  template <typename T1, int R1, int C1, typename T2, int R2, int C2,
22  typename T3, int R3, int C3>
23  inline typename
24  boost::enable_if_c<stan::is_var<T1>::value ||
26  stan::is_var<T3>::value, var>::type
27  trace_gen_inv_quad_form_ldlt(const Eigen::Matrix<T1, R1, C1> &D,
28  const LDLT_factor<T2, R2, C2> &A,
29  const Eigen::Matrix<T3, R3, C3> &B) {
30  check_square("trace_gen_inv_quad_form_ldlt", "D", D);
31  check_multiplicable("trace_gen_inv_quad_form_ldlt",
32  "A", A,
33  "B", B);
34  check_multiplicable("trace_gen_inv_quad_form_ldlt",
35  "B", B,
36  "D", D);
37 
38  trace_inv_quad_form_ldlt_impl<T2, R2, C2, T3, R3, C3> *_impl
39  = new trace_inv_quad_form_ldlt_impl<T2, R2, C2, T3, R3, C3>(D, A, B);
40 
41  return var(new trace_inv_quad_form_ldlt_vari<T2, R2, C2, T3, R3, C3>
42  (_impl));
43  }
44 
45  }
46 }
47 #endif
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:30
LDLT_factor is a thin wrapper on Eigen::LDLT to allow for reusing factorizations and efficient autodi...
Definition: LDLT_factor.hpp:63
void check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the matrices can be multiplied.
void check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Check if the specified matrix is square.
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 LDLT_factor< T2, R2, C2 > &A, const Eigen::Matrix< T3, R3, C3 > &B)

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