1#ifndef STAN_MATH_PRIM_FUN_TRACE_GEN_QUAD_FORM_HPP
2#define STAN_MATH_PRIM_FUN_TRACE_GEN_QUAD_FORM_HPP
32template <
typename TD,
typename TA,
typename TB,
33 typename = require_all_eigen_t<TD, TA, TB>,
34 typename = require_all_not_vt_var<TD, TA, TB>,
35 typename = require_any_not_vt_arithmetic<TD, TA, TB>>
41 const auto& B_ref =
to_ref(B);
42 return multiply(B_ref, D.transpose()).cwiseProduct(
multiply(A, B_ref)).sum();
63template <
typename EigMatD,
typename EigMatA,
typename EigMatB,
72 const auto& B_ref =
to_ref(B);
73 return (B_ref * D.transpose()).cwiseProduct(A * B_ref).sum();
require_all_t< container_type_check_base< is_eigen, value_type_t, TypeCheck, Check >... > require_all_eigen_vt
Require all of the types satisfy is_eigen.
void check_square(const char *function, const char *name, const T_y &y)
Check if the specified matrix is square.
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.
auto multiply(const Mat1 &m1, const Mat2 &m2)
Return the product of the specified matrices.
auto trace_gen_quad_form(const TD &D, const TA &A, const TB &B)
Return the trace of D times the quadratic form of B and A.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...