Automatic Differentiation
 
Loading...
Searching...
No Matches
elt_multiply.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUN_ELT_MULTIPLY_HPP
2#define STAN_MATH_PRIM_FUN_ELT_MULTIPLY_HPP
3
9
10namespace stan {
11namespace math {
12
24template <typename Mat1, typename Mat2,
25 require_all_eigen_t<Mat1, Mat2>* = nullptr,
26 require_all_not_st_var<Mat1, Mat2>* = nullptr>
27inline auto elt_multiply(Mat1&& m1, Mat2&& m2) {
28 decltype(auto) m1_ref = to_ref(std::forward<Mat1>(m1));
29 decltype(auto) m2_ref = to_ref(std::forward<Mat2>(m2));
30 check_matching_dims("elt_multiply", "m1", m1_ref, "m2", m2_ref);
31 return make_holder(
32 [](auto&& m1_, auto&& m2_) { return m1_.cwiseProduct(m2_); },
33 std::forward<decltype(m1_ref)>(m1_ref),
34 std::forward<decltype(m2_ref)>(m2_ref));
35}
36
48template <typename Scalar1, typename Scalar2,
50inline auto elt_multiply(const Scalar1& a, const Scalar2& b) {
51 return a * b;
52}
53
66template <typename T1, typename T2, require_any_matrix_t<T1, T2>* = nullptr,
67 require_any_stan_scalar_t<T1, T2>* = nullptr>
68inline auto elt_multiply(T1&& A, T2&& B) {
69 return multiply(std::forward<T1>(A), std::forward<T2>(B));
70}
71
72} // namespace math
73} // namespace stan
74
75#endif
elt_multiply_< as_operation_cl_t< T_a >, as_operation_cl_t< T_b > > elt_multiply(T_a &&a, T_b &&b)
require_all_t< is_stan_scalar< std::decay_t< Types > >... > require_all_stan_scalar_t
Require all of the types satisfy is_stan_scalar.
auto multiply(Mat1 &&m1, Mat2 &&m2)
Return the product of the specified matrices.
Definition multiply.hpp:20
void check_matching_dims(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the two containers have the same dimensions.
auto make_holder(F &&func, Args &&... args)
Calls given function with given arguments.
Definition holder.hpp:481
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
Definition to_ref.hpp:18
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...