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
14#include <vector>
15
16namespace stan {
17namespace math {
18namespace internal {
19
52template <typename ReturnType, typename... Ops>
53class partials_propagator<ReturnType, require_fvar_t<ReturnType>, Ops...> {
54 public:
56 std::tuple<
60
61 template <typename... Types>
62 explicit partials_propagator(Types&&... ops)
63 : edges_(internal::ops_partials_edge<Dx, plain_type_t<std::decay_t<Ops>>>(
64 std::forward<Types>(ops))...) {}
65
79 inline T_return_type build(Dx value) {
80 auto deriv = stan::math::apply(
81 [](auto&... args) { return sum_dx(args...); }, edges_);
82 return T_return_type(value, deriv);
83 }
84};
85
86} // namespace internal
87} // namespace math
88} // namespace stan
89#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:37
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:51
typename plain_type< std::decay_t< 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