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 decltype(
auto) B_ref =
to_ref(std::forward<TB>(B));
43 [](
auto&& D_,
auto&& A_,
auto&& B_ref_) {
44 return multiply(B_ref_, D_.transpose())
48 std::forward<TD>(D), std::forward<TA>(A),
49 std::forward<decltype(B_ref)>(B_ref));
70template <
typename EigMatD,
typename EigMatA,
typename EigMatB,
79 const auto& B_ref =
to_ref(B);
80 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.
auto multiply(Mat1 &&m1, Mat2 &&m2)
Return the product of the specified matrices.
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 make_holder(F &&func, Args &&... args)
Calls given function with given arguments.
auto trace_gen_quad_form(TD &&D, TA &&A, 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 ...