Automatic Differentiation
 
Loading...
Searching...
No Matches
partials_propagator.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_REV_META_PARTIALS_PROPOGATOR_HPP
2#define STAN_MATH_REV_META_PARTIALS_PROPOGATOR_HPP
3
10#include <vector>
11#include <tuple>
12
13namespace stan {
14namespace math {
15
16namespace internal {
17
18template <typename ReturnType, typename Enable, typename... Ops>
19class partials_propagator;
20
52template <typename ReturnType, typename... Ops>
53class partials_propagator<ReturnType, require_var_t<ReturnType>, Ops...> {
54 public:
55 std::tuple<
58
59 template <typename... Types>
60 explicit partials_propagator(Types&&... ops)
61 : edges_(
62 internal::ops_partials_edge<double, plain_type_t<std::decay_t<Ops>>>(
63 std::forward<Types>(ops))...) {}
64
78 inline var build(double value) {
79 var ret(value);
81 [ret](auto&& edge) mutable {
83 [operand = edge.operand(), partial = edge.partial(),
84 ret]() mutable { update_adjoints(operand, partial, ret); });
85 },
86 edges_);
87 return ret;
88 }
89};
90} // namespace internal
91} // namespace math
92} // namespace stan
93#endif
An edge holds both the operands and its associated partial derivatives.
std::tuple< internal::ops_partials_edge< double, plain_type_t< std::decay_t< Ops > > >... > edges_
var build(double value)
Build the node to be stored on the autodiff graph.
require_t< is_var< std::decay_t< T > > > require_var_t
Require type satisfies is_var.
Definition is_var.hpp:89
constexpr auto & edge(internal::partials_propagator< Types... > &x) noexcept
Access the edge of an partials_propagator
void reverse_pass_callback(F &&functor)
Puts a callback on the autodiff stack to be called in reverse pass.
constexpr void for_each(F &&f, const std::tuple<> &)
Apply a function to each element of a tuple.
Definition for_each.hpp:80
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.