Automatic Differentiation
 
Loading...
Searching...
No Matches
partials_propagator.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUNCTOR_PARTIALS_PROPOGATOR_HPP
2#define STAN_MATH_PRIM_FUNCTOR_PARTIALS_PROPOGATOR_HPP
3
9#include <vector>
10#include <type_traits>
11#include <tuple>
12
13namespace stan {
14namespace math {
15
16namespace internal {
17
18template <typename ReturnType, typename Enable, typename... Ops>
20
50template <typename ReturnType, typename... Ops>
51class partials_propagator<ReturnType, require_arithmetic_t<ReturnType>,
52 Ops...> {
53 public:
54 template <typename... Types>
55 explicit partials_propagator(Types&&... /* ops */) noexcept {}
56
70 inline static double build(double value) noexcept { return value; }
71 std::tuple<internal::ops_partials_edge<double, std::decay_t<Ops>>...> edges_;
72};
73
74} // namespace internal
75
82template <std::size_t I, class... Types>
83inline constexpr auto& edge(
85 return std::get<I>(x.edges_);
86};
87
94template <std::size_t I, class... Types>
95inline constexpr auto& partials(
97 return std::get<I>(x.edges_).partials_;
98};
99
106template <std::size_t I, class... Types>
107inline constexpr auto& partials_vec(
109 return std::get<I>(x.edges_).partials_vec_;
110};
111
118template <typename... Ops>
119inline auto make_partials_propagator(Ops&&... ops) {
120 using return_type = return_type_t<Ops...>;
123 std::forward<Ops>(ops)...);
124}
125
126} // namespace math
127} // namespace stan
128#endif
std::tuple< internal::ops_partials_edge< double, std::decay_t< Ops > >... > edges_
require_t< std::is_arithmetic< std::decay_t< T > > > require_arithmetic_t
Require type satisfies std::is_arithmetic.
static double build(double value) noexcept
Build the node to be stored on the autodiff graph.
typename return_type< Ts... >::type return_type_t
Convenience type for the return type of the specified template parameters.
constexpr auto & edge(internal::partials_propagator< Types... > &x) noexcept
Access the edge of an partials_propagator
constexpr auto & partials(internal::partials_propagator< Types... > &x) noexcept
Access the partials for an edge of an partials_propagator
constexpr auto & partials_vec(internal::partials_propagator< Types... > &x) noexcept
Access the partials_vec for an edge of a partials_propagator
auto make_partials_propagator(Ops &&... ops)
Construct an partials_propagator.
typename plain_type< T >::type plain_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
Template metaprogram to calculate the base scalar return type resulting from promoting all the scalar...