Automatic Differentiation
 
Loading...
Searching...
No Matches
operands_and_partials.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_FUNCTOR_OPERANDS_AND_PARTIALS_HPP
2#define STAN_MATH_PRIM_FUNCTOR_OPERANDS_AND_PARTIALS_HPP
3
8#include <vector>
9#include <type_traits>
10#include <tuple>
11
12namespace stan {
13namespace math {
14
15template <typename Op1 = double, typename Op2 = double, typename Op3 = double,
16 typename Op4 = double, typename Op5 = double, typename Op6 = double,
17 typename Op7 = double, typename Op8 = double,
18 typename T_return_type
19 = return_type_t<Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8>>
20class operands_and_partials; // Forward declaration
21
22namespace internal {
23
44template <typename ViewElt, typename Op, typename Enable = void>
46
56template <typename ViewElt, typename Op>
58 public:
59 using inner_op = std::conditional_t<is_eigen<value_type_t<Op>>::value,
70 static constexpr double operands_{0};
71 ops_partials_edge() = default;
72
73 template <typename T,
75 std::decay_t<T>,
76 std::decay_t<ops_partials_edge<
77 ViewElt, Op, require_st_arithmetic<Op>>>>* = nullptr>
78 constexpr explicit ops_partials_edge(T&& /* op */) noexcept {}
79
84 static constexpr double operand() noexcept {
85 return static_cast<double>(0.0);
86 }
87
92 static constexpr double partial() noexcept {
93 return static_cast<double>(0.0);
94 }
99 static constexpr double dx() noexcept { return static_cast<double>(0); }
104 static constexpr int size() noexcept { return 0; } // reverse mode
105};
106
107template <typename ViewElt, typename Op>
108constexpr double
109 ops_partials_edge<ViewElt, Op, require_st_arithmetic<Op>>::operands_;
110
111} // namespace internal
112
151template <typename Op1, typename Op2, typename Op3, typename Op4, typename Op5,
152 typename Op6, typename Op7, typename Op8, typename T_return_type>
154 public:
155 explicit operands_and_partials(const Op1& /* op1 */) noexcept {}
156 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */) noexcept {}
157 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
158 const Op3& /* op3 */) noexcept {}
159 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
160 const Op3& /* op3 */, const Op4& /* op4 */) noexcept {}
161 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
162 const Op3& /* op3 */, const Op4& /* op4 */,
163 const Op5& /* op5 */) noexcept {}
164 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
165 const Op3& /* op3 */, const Op4& /* op4 */,
166 const Op5& /* op5 */, const Op6& /* op6 */) noexcept {}
167 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
168 const Op3& /* op3 */, const Op4& /* op4 */,
169 const Op5& /* op5 */, const Op6& /* op6 */,
170 const Op7& /* op7 */) noexcept {}
171 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
172 const Op3& /* op3 */, const Op4& /* op4 */,
173 const Op5& /* op5 */, const Op6& /* op6 */,
174 const Op7& /* op7 */, const Op8& /* op8 */) noexcept {}
175
189 inline double build(double value) const noexcept { return value; }
190
191 // These will always be 0 size base template instantiations (above).
200};
201
202} // namespace math
203} // namespace stan
204#endif
static constexpr double dx() noexcept
Return the tangent for the edge.
static constexpr int size() noexcept
Return the size of the operand for the edge.
partials_t partials_
The partials_ are always called in if statements that will be removed by the dead code elimination pa...
std::conditional_t< is_eigen< value_type_t< Op > >::value, value_type_t< Op >, Op > inner_op
static constexpr double operand() noexcept
Get the operand for the edge.
static constexpr double partial() noexcept
Get the partial for the edge.
An edge holds both the operands and its associated partial derivatives.
internal::ops_partials_edge< double, std::decay_t< Op2 > > edge2_
internal::ops_partials_edge< double, std::decay_t< Op7 > > edge7_
internal::ops_partials_edge< double, std::decay_t< Op4 > > edge4_
operands_and_partials(const Op1 &, const Op2 &, const Op3 &) noexcept
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &) noexcept
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &) noexcept
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &, const Op7 &, const Op8 &) noexcept
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &) noexcept
operands_and_partials(const Op1 &, const Op2 &) noexcept
internal::ops_partials_edge< double, std::decay_t< Op6 > > edge6_
internal::ops_partials_edge< double, std::decay_t< Op1 > > edge1_
internal::ops_partials_edge< double, std::decay_t< Op8 > > edge8_
internal::ops_partials_edge< double, std::decay_t< Op5 > > edge5_
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &, const Op7 &) noexcept
internal::ops_partials_edge< double, std::decay_t< Op3 > > edge3_
This template builds partial derivatives with respect to a set of operands.
require_t< std::is_arithmetic< scalar_type_t< std::decay_t< T > > > > require_st_arithmetic
Require scalar type satisfies std::is_arithmetic.
require_not_t< std::is_same< std::decay_t< T >, std::decay_t< S > > > require_not_same_t
Require types T and S does not satisfy std::is_same.
double build(double value) const noexcept
Build the node to be stored on the autodiff graph.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...