Automatic Differentiation
 
Loading...
Searching...
No Matches
partials_propagator.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_FWD_META_PARTIALS_PROPOGATOR_HPP
2#define STAN_MATH_FWD_META_PARTIALS_PROPOGATOR_HPP
3
15#include <vector>
16
17namespace stan {
18namespace math {
19namespace internal {
20
53template <typename ReturnType, typename... Ops>
54class partials_propagator<ReturnType, require_fvar_t<ReturnType>, Ops...> {
55 public:
57 std::tuple<
61
62 template <typename... Types>
63 explicit partials_propagator(Types&&... ops)
64 : edges_(internal::ops_partials_edge<Dx, plain_type_t<std::decay_t<Ops>>>(
65 std::forward<Types>(ops))...) {}
66
80 inline T_return_type build(Dx value) {
81 auto deriv = stan::math::apply(
82 [](auto&... args) { return sum_dx(args...); }, edges_);
83 return T_return_type(value, deriv);
84 }
85};
86
87} // namespace internal
88} // namespace math
89} // namespace stan
90#endif
An edge holds both the operands and its associated partial derivatives.
std::tuple< internal::ops_partials_edge< Dx, plain_type_t< std::decay_t< Ops > > >... > edges_
require_t< is_fvar< std::decay_t< T > > > require_fvar_t
Require type satisfies is_fvar.
Definition is_fvar.hpp:25
typename partials_type< T >::type partials_type_t
Helper alias for accessing the partial type.
T_return_type build(Dx value)
Build the node to be stored on the autodiff graph.
static constexpr auto sum_dx()
End of recursion for summing .dx() for fvar<T> ops and partials.
constexpr decltype(auto) apply(F &&f, Tuple &&t, PreArgs &&... pre_args)
Definition apply.hpp:52
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
STL namespace.
This template class represents scalars used in forward-mode automatic differentiation,...
Definition fvar.hpp:40