1 # ifndef CPPAD_CORE_REVERSE_HPP
2 # define CPPAD_CORE_REVERSE_HPP
89 template <
typename Base>
90 template <
typename VectorBase>
99 size_t n = ind_taddr_.size();
102 size_t m = dep_taddr_.size();
105 CheckSimpleVector<Base, VectorBase>();
108 size_t(w.size()) == m ||
size_t(w.size()) == (m * q),
109 "Argument w to Reverse does not have length equal to\n"
110 "the dimension of the range or dimension of range times q."
114 "The first argument to Reverse must be greater than zero."
117 num_order_taylor_ >= q,
118 "Less than q Taylor coefficients are currently stored"
119 " in this ADFun object."
123 if( (q == 1) & (num_direction_taylor_ > 1) )
124 { num_order_taylor_ = 1;
125 size_t c = cap_order_taylor_;
127 capacity_order(c, r);
130 num_direction_taylor_ == 1,
131 "Reverse mode for Forward(q, r, xq) with more than one direction"
132 "\n(r > 1) is not yet supported for q > 1."
137 for(i = 0; i < num_var_tape_; i++)
138 for(j = 0; j < q; j++)
139 Partial[i * q + j] = zero;
143 for(i = 0; i < m; i++)
145 if(
size_t(w.size()) == m )
146 Partial[dep_taddr_[i] * q + q - 1] += w[i];
148 {
for(k = 0; k < q; k++)
150 Partial[ dep_taddr_[i] * q + k ] = w[i * q + k ];
168 subgraph_info_.entire_graph()
172 VectorBase value(n * q);
173 for(j = 0; j < n; j++)
182 if(
size_t(w.size()) == m )
183 {
for(k = 0; k < q; k++)
185 Partial[ind_taddr_[j] * q + q - 1 - k];
188 {
for(k = 0; k < q; k++)
190 Partial[ind_taddr_[j] * q + k];
194 "dw = f.Reverse(q, w): has a nan,\n"
195 "but none of its Taylor coefficents are nan."
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
File used to define pod_vector class.
bool hasnan(const Vector &v)
Type * data(void)
current data pointer is no longer valid after any of the following: extend, erase, operator=, and ~pod_vector. Take extreem care when using this function.
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
void reverse_sweep(size_t d, size_t n, size_t numvar, const local::player< Base > *play, size_t J, const Base *Taylor, size_t K, Base *Partial, bool *cskip_op, const pod_vector< addr_t > &var_by_load_op, const pod_vector< addr_t > &subgraph)
Compute derivative of arbitrary order forward mode Taylor coefficients.
VectorBase Reverse(size_t p, const VectorBase &v)
reverse mode sweep