Automatic Differentiation
 
Loading...
Searching...
No Matches
quad_form_sym.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_FUN_QUAD_FORM_SYM_HPP
2#define STAN_MATH_REV_FUN_QUAD_FORM_SYM_HPP
3
11#include <type_traits>
12
13namespace stan {
14namespace math {
15
31template <typename EigMat1, typename EigMat2,
32 require_all_eigen_t<EigMat1, EigMat2>* = nullptr,
33 require_any_vt_var<EigMat1, EigMat2>* = nullptr>
34inline auto quad_form_sym(const EigMat1& A, const EigMat2& B) {
35 check_multiplicable("quad_form_sym", "A", A, "B", B);
36 const auto& A_ref = to_ref(A);
37 check_symmetric("quad_form_sym", "A", A_ref);
38 return quad_form(A_ref, B, true);
39}
40
41} // namespace math
42} // namespace stan
43#endif
void check_symmetric(const char *function, const char *name, const matrix_cl< T > &y)
Check if the matrix_cl is symmetric.
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.
promote_scalar_t< return_type_t< EigMat1, EigMat2 >, EigMat2 > quad_form(const EigMat1 &A, const EigMat2 &B)
Return the quadratic form .
Definition quad_form.hpp:31
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:17
promote_scalar_t< return_type_t< EigMat1, EigMat2 >, EigMat2 > quad_form_sym(const EigMat1 &A, const EigMat2 &B)
Return the quadratic form of a symmetric matrix.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...