Stan Math Library  2.10.0
reverse mode automatic differentiation
quad_form_sym.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_MAT_FUN_QUAD_FORM_SYM_HPP
2 #define STAN_MATH_REV_MAT_FUN_QUAD_FORM_SYM_HPP
3 
4 #include <boost/utility/enable_if.hpp>
5 #include <boost/type_traits.hpp>
6 #include <stan/math/rev/core.hpp>
16 
17 namespace stan {
18  namespace math {
19 
20  template <typename TA, int RA, int CA, typename TB, int RB, int CB>
21  inline typename
22  boost::enable_if_c< boost::is_same<TA, var>::value ||
23  boost::is_same<TB, var>::value,
24  Eigen::Matrix<var, CB, CB> >::type
25  quad_form_sym(const Eigen::Matrix<TA, RA, CA>& A,
26  const Eigen::Matrix<TB, RB, CB>& B) {
27  stan::math::check_square("quad_form", "A", A);
28  stan::math::check_symmetric("quad_form_sym", "A", A);
29  stan::math::check_multiplicable("quad_form_sym",
30  "A", A,
31  "B", B);
32 
33  quad_form_vari<TA, RA, CA, TB, RB, CB> *baseVari
34  = new quad_form_vari<TA, RA, CA, TB, RB, CB>(A, B, true);
35 
36  return baseVari->_impl->C_;
37  }
38  template <typename TA, int RA, int CA, typename TB, int RB>
39  inline typename
40  boost::enable_if_c< boost::is_same<TA, var>::value ||
41  boost::is_same<TB, var>::value,
42  var >::type
43  quad_form_sym(const Eigen::Matrix<TA, RA, CA>& A,
44  const Eigen::Matrix<TB, RB, 1>& B) {
45  stan::math::check_square("quad_form", "A", A);
46  stan::math::check_symmetric("quad_form_sym", "A", A);
47  stan::math::check_multiplicable("quad_form_sym",
48  "A", A,
49  "B", B);
50 
51  quad_form_vari<TA, RA, CA, TB, RB, 1> *baseVari
52  = new quad_form_vari<TA, RA, CA, TB, RB, 1>(A, B, true);
53 
54  return baseVari->_impl->C_(0, 0);
55  }
56  }
57 }
58 
59 #endif
bool check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Return true if the matrices can be multiplied.
Eigen::Matrix< fvar< T >, CB, CB > quad_form_sym(const Eigen::Matrix< fvar< T >, RA, CA > &A, const Eigen::Matrix< double, RB, CB > &B)
bool check_symmetric(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is symmetric.
bool check_square(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, Eigen::Dynamic > &y)
Return true if the specified matrix is square.

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