Skip to content

Commit fd27178

Browse files
committed
Fix compatibility with nested containers
1 parent 9c36e70 commit fd27178

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

stan/math/fwd/functor/fvar_finite_diff.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
#define STAN_MATH_FWD_FUNCTOR_FVAR_FINITE_DIFF_HPP
33

44
#include <stan/math/prim/meta.hpp>
5+
#include <stan/math/prim/functor/apply_scalar_binary.hpp>
56
#include <stan/math/prim/functor/finite_diff_gradient_auto.hpp>
67
#include <stan/math/prim/fun/value_of.hpp>
78
#include <stan/math/prim/fun/sum.hpp>
8-
#include <stan/math/prim/fun/elt_multiply.hpp>
99
#include <test/unit/math/serializer.hpp>
1010

1111
namespace stan {
@@ -44,7 +44,9 @@ inline constexpr double aggregate_tangent(const FuncTangentT& tangent,
4444
template <typename FuncTangentT, typename InputArgT,
4545
require_st_fvar<InputArgT>* = nullptr>
4646
auto aggregate_tangent(const FuncTangentT& tangent, const InputArgT& arg) {
47-
return sum(elt_multiply(tangent, arg.d()));
47+
return sum(apply_scalar_binary(
48+
tangent, arg,
49+
[](const auto& x, const auto& y) { return x * y.d_; }));
4850
}
4951
} // namespace internal
5052

0 commit comments

Comments
 (0)