Automatic Differentiation
 
Loading...
Searching...
No Matches
trace_dot.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_FUN_TRACE_DOT_HPP
2#define STAN_MATH_FWD_FUN_TRACE_DOT_HPP
3
8
9namespace stan {
10namespace math {
11
26template <typename EigMat1, typename EigMat2,
27 require_all_eigen_t<EigMat1, EigMat2>* = nullptr,
28 require_any_vt_fvar<EigMat1, EigMat2>* = nullptr>
29inline return_type_t<EigMat1, EigMat2> trace_dot(EigMat1&& A, EigMat2&& B) {
30 check_size_match("trace_dot", "A.cols()", A.cols(), "B.rows()", B.rows());
31 check_size_match("trace_dot", "A.rows()", A.rows(), "B.cols()", B.cols());
32 return trace(multiply(std::forward<EigMat1>(A), std::forward<EigMat2>(B)));
33}
34
35} // namespace math
36} // namespace stan
37#endif
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
return_type_t< EigMat1, EigMat2 > trace_dot(EigMat1 &&A, EigMat2 &&B)
Compute the trace of the product of two matrices with forward-mode autodiff support.
Definition trace_dot.hpp:29
value_type_t< T > trace(const T &m)
Calculates trace (sum of diagonal) of given kernel generator expression.
Definition trace.hpp:22
auto multiply(const Mat1 &m1, const Mat2 &m2)
Return the product of the specified matrices.
Definition multiply.hpp:19
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...