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
10#include <type_traits>
11
12namespace stan {
13namespace math {
14
30template <typename EigMat1, typename EigMat2,
31 require_all_eigen_t<EigMat1, EigMat2>* = nullptr,
32 require_any_vt_var<EigMat1, EigMat2>* = nullptr>
33inline auto quad_form_sym(const EigMat1& A, const EigMat2& B) {
34 check_multiplicable("quad_form_sym", "A", A, "B", B);
35 const auto& A_ref = to_ref(A);
36 check_symmetric("quad_form_sym", "A", A_ref);
37 return quad_form(A_ref, B, true);
38}
39
40} // namespace math
41} // namespace stan
42#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 ...