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
7#include <vector>
8#include <type_traits>
9#include <tuple>
10
11namespace stan {
12namespace math {
13
14template <typename Op1 = double, typename Op2 = double, typename Op3 = double,
15 typename Op4 = double, typename Op5 = double, typename Op6 = double,
16 typename Op7 = double, typename Op8 = double,
17 typename T_return_type
18 = return_type_t<Op1, Op2, Op3, Op4, Op5, Op6, Op7, Op8>>
19class operands_and_partials; // Forward declaration
20
21namespace internal {
22
43template <typename ViewElt, typename Op, typename Enable = void>
45
55template <typename ViewElt, typename Op>
57 public:
58 static constexpr double operands_{0};
59 ops_partials_edge() = default;
60
61 template <typename T,
63 std::decay_t<T>,
64 std::decay_t<ops_partials_edge<
65 ViewElt, Op, require_st_arithmetic<Op>>>>* = nullptr>
66 constexpr explicit ops_partials_edge(T&& /* op */) noexcept {}
67
72 static constexpr double operand() noexcept {
73 return static_cast<double>(0.0);
74 }
75
80 static constexpr double partial() noexcept {
81 return static_cast<double>(0.0);
82 }
87 static constexpr double dx() noexcept { return static_cast<double>(0); }
92 static constexpr int size() noexcept { return 0; } // reverse mode
93};
94
95template <typename ViewElt, typename Op>
96constexpr double
97 ops_partials_edge<ViewElt, Op, require_st_arithmetic<Op>>::operands_;
98
99} // namespace internal
100
139template <typename Op1, typename Op2, typename Op3, typename Op4, typename Op5,
140 typename Op6, typename Op7, typename Op8, typename T_return_type>
142 public:
143 explicit operands_and_partials(const Op1& /* op1 */) noexcept {}
144 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */) noexcept {}
145 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
146 const Op3& /* op3 */) noexcept {}
147 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
148 const Op3& /* op3 */, const Op4& /* op4 */) noexcept {}
149 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
150 const Op3& /* op3 */, const Op4& /* op4 */,
151 const Op5& /* op5 */) noexcept {}
152 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
153 const Op3& /* op3 */, const Op4& /* op4 */,
154 const Op5& /* op5 */, const Op6& /* op6 */) noexcept {}
155 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
156 const Op3& /* op3 */, const Op4& /* op4 */,
157 const Op5& /* op5 */, const Op6& /* op6 */,
158 const Op7& /* op7 */) noexcept {}
159 operands_and_partials(const Op1& /* op1 */, const Op2& /* op2 */,
160 const Op3& /* op3 */, const Op4& /* op4 */,
161 const Op5& /* op5 */, const Op6& /* op6 */,
162 const Op7& /* op7 */, const Op8& /* op8 */) noexcept {}
163
177 inline double build(double value) const noexcept { return value; }
178
183 static constexpr double operand() noexcept {
184 return static_cast<double>(0.0);
185 }
186
191 static constexpr double partial() noexcept {
192 return static_cast<double>(0.0);
193 }
198 static constexpr double dx() noexcept { return static_cast<double>(0); }
203 static constexpr int size() noexcept { return 0; } // reverse mode
204};
205
206} // namespace math
207} // namespace stan
208#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.
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.
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
static constexpr double operand() noexcept
Get the operand for the edge.
static constexpr int size() noexcept
Return the size of the operand for the edge.
static constexpr double partial() noexcept
Get the partial for the edge.
operands_and_partials(const Op1 &, const Op2 &, const Op3 &, const Op4 &, const Op5 &, const Op6 &, const Op7 &) noexcept
static constexpr double dx() noexcept
Return the tangent for the edge.
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.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...