inline void reverse_powpv_op( size_t d , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // convert from final result to first result i_z -= 2; // NumRes(PowpvOp) - 1; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // z_2 = exp(z_1) reverse_exp_op( d, i_z+2, i_z+1, cap_order, taylor, nc_partial, partial ); // 2DO: remove requirement that i_z * cap_order <= max addr_t value CPPAD_ASSERT_KNOWN( std::numeric_limits<addr_t>::max() >= i_z * cap_order, "cppad_tape_addr_type maximum value has been exceeded\n" "This is due to a kludge in the pow operation and should be fixed." ); // z_1 = z_0 * y addr_t adr[2]; adr[0] = addr_t( i_z * cap_order ); // offset of z_0[0] in taylor adr[1] = arg[1]; // index of y in taylor and partial // use taylor both for parameter and variable values reverse_mulpv_op( d, i_z+1, adr, taylor, cap_order, taylor, nc_partial, partial ); // z_0 = log(x) // x is a parameter }
inline void forward_atan_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation z[0] = atan( x[0] ); b[0] = Base(1.0) + x[0] * x[0]; }
inline void forward_cos_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* c = taylor + i_z * cap_order; // called z in documentation Base* s = c - cap_order; // called y in documentation c[0] = cos( x[0] ); s[0] = sin( x[0] ); }
inline void reverse_divpv_op( size_t d , size_t i_z , const size_t* arg , const Base* parameter , size_t nc_taylor , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] < i_z ); CPPAD_ASSERT_UNKNOWN( d < nc_taylor ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Arguments const Base* y = taylor + arg[1] * nc_taylor; const Base* z = taylor + i_z * nc_taylor; // Partial derivatives corresponding to arguments and result Base* py = partial + arg[1] * nc_partial; Base* pz = partial + i_z * nc_partial; // Using CondExp, it can make sense to divide by zero so do not // make it an error. size_t k; // number of indices to access size_t j = d + 1; while(j) { --j; // scale partial w.r.t z[j] pz[j] /= y[0]; for(k = 1; k <= j; k++) { pz[j-k] -= pz[j] * y[k]; py[k] -= pz[j] * z[j-k]; } py[0] -= pz[j] * z[j]; } }
inline void forward_sign_op_0( size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( i_x < i_z ); CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); // Taylor coefficients corresponding to argument and result Base x0 = *(taylor + i_x * nc_taylor); Base* z = taylor + i_z * nc_taylor; z[0] = sign(x0); }
inline void reverse_sign_op( size_t d , size_t i_z , size_t i_x , size_t nc_taylor , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( i_x < i_z ); CPPAD_ASSERT_UNKNOWN( d < nc_taylor ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // nothing to do because partials of sign are zero return; }
inline void reverse_sqrt_op( size_t d , size_t i_z , size_t i_x , size_t cap_order , const Base* taylor , size_t nc_partial , Base* partial ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SqrtOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SqrtOp) == 1 ); CPPAD_ASSERT_UNKNOWN( d < cap_order ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to result const Base* z = taylor + i_z * cap_order; Base* pz = partial + i_z * nc_partial; Base inv_z0 = Base(1) / z[0]; // number of indices to access size_t j = d; size_t k; while(j) { // scale partial w.r.t. z[j] pz[j] = azmul(pz[j], inv_z0); pz[0] -= azmul(pz[j], z[j]); px[j] += pz[j] / Base(2); for(k = 1; k < j; k++) pz[k] -= azmul(pz[j], z[j-k]); --j; } px[0] += azmul(pz[0], inv_z0) / Base(2); }
inline void forward_powvv_op( size_t p , size_t q , size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // convert from final result to first result i_z -= 2; // 2 = NumRes(PowvvOp) - 1; // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(PowvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(PowvvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); CPPAD_ASSERT_UNKNOWN( std::numeric_limits<addr_t>::max() >= i_z ); // z_0 = log(x) forward_log_op(p, q, i_z, arg[0], cap_order, taylor); // z_1 = z_0 * y addr_t adr[2]; adr[0] = addr_t( i_z ); adr[1] = arg[1]; forward_mulvv_op(p, q, i_z+1, adr, parameter, cap_order, taylor); // z_2 = exp(z_1) // final result for zero order case is exactly the same as for Base if( p == 0 ) { // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; Base* z_2 = taylor + (i_z+2) * cap_order; z_2[0] = pow(x[0], y[0]); p++; } if( p <= q ) forward_exp_op(p, q, i_z+2, i_z+1, cap_order, taylor); }
inline void reverse_abs_op( size_t d , size_t i_z , size_t i_x , size_t nc_taylor , const Base* taylor , size_t nc_partial , Base* partial ) { size_t j, k; static Base zero(0); // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( i_x < i_z ); CPPAD_ASSERT_UNKNOWN( d < nc_taylor ); CPPAD_ASSERT_UNKNOWN( d < nc_partial ); // Taylor coefficients and partials corresponding to argument const Base* x = taylor + i_x * nc_taylor; Base* px = partial + i_x * nc_partial; // Taylor coefficients and partials corresponding to result Base* pz = partial + i_z * nc_partial; // order that decides positive, negative or zero k = 0; while( (k < d) & (x[k] == zero) ) k++; if( GreaterThanZero(x[k]) ) { // partial of z w.r.t y is +1 for(j = k; j <= d; j++) px[j] += pz[j]; } else if( LessThanZero(x[k]) ) { // partial of z w.r.t y is -1 for(j = k; j <= d; j++) px[j] -= pz[j]; } }
inline void forward_sinh_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* s = taylor + i_z * cap_order; Base* c = s - cap_order; // rest of this routine is identical for the following cases: // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op // (except that there is a sign difference for hyperbolic case). size_t k; if( p == 0 ) { s[0] = sinh( x[0] ); c[0] = cosh( x[0] ); p++; } for(size_t j = p; j <= q; j++) { s[j] = Base(0); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] += Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(j); } }
inline void forward_tanh_op_0( size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(TanOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(TanOp) == 2 ); CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z ); CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * nc_taylor; Base* z = taylor + i_z * nc_taylor; // called z in documentation Base* y = z - nc_taylor; // called y in documentation z[0] = tanh( x[0] ); y[0] = z[0] * z[0]; }
inline void forward_divvv_op_0( size_t i_z , const size_t* arg , const Base* parameter , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(DivvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(DivvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[0] < i_z ); CPPAD_ASSERT_UNKNOWN( arg[1] < i_z ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * nc_taylor; Base* y = taylor + arg[1] * nc_taylor; Base* z = taylor + i_z * nc_taylor; z[0] = x[0] / y[0]; }
inline void forward_zmulpv_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ZmulpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(ZmulpvOp) == 1 ); // Paraemter value Base x = parameter[ arg[0] ]; // Taylor coefficients corresponding to arguments and result Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = azmul(x, y[0]); }
inline void reverse_sparse_jacobian_load_op( OpCode op , size_t i_z , const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , Vector_set& vecad_sparsity ) { CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); size_t i_v = combined[ arg[0] - 1 ]; CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); vecad_sparsity.binary_union(i_v, i_v, i_z, var_sparsity); return; }
inline void forward_sparse_store_op( OpCode op , const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , Vector_set& vecad_sparsity ) { CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) == 0 ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); size_t i_v = combined[ arg[0] - 1 ]; CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < var_sparsity.n_set() ); vecad_sparsity.binary_union(i_v, i_v, arg[2], var_sparsity); return; }
inline void forward_sinh_op_0( size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SinhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(SinhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z ); CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * nc_taylor; Base* s = taylor + i_z * nc_taylor; // called z in documentation Base* c = s - nc_taylor; // called y in documentation s[0] = sinh( x[0] ); c[0] = cosh( x[0] ); }
inline void forward_asin_op_0( size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AsinOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AsinOp) == 2 ); CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z ); CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * nc_taylor; Base* z = taylor + i_z * nc_taylor; Base* b = z - nc_taylor; // called y in documentation z[0] = asin( x[0] ); b[0] = sqrt( Base(1) - x[0] * x[0] ); }
inline void forward_subvv_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SubvvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(SubvvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < i_z ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* y = taylor + arg[1] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = x[0] - y[0]; }
inline void forward_divvp_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(DivvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(DivvpOp) == 1 ); // Parameter value Base y = parameter[ arg[1] ]; // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * cap_order; Base* z = taylor + i_z * cap_order; z[0] = x[0] / y; }
inline void forward_sparse_load_op( OpCode op , size_t i_z , const addr_t* arg , size_t num_combined , const size_t* combined , Vector_set& var_sparsity , Vector_set& vecad_sparsity ) { CPPAD_ASSERT_UNKNOWN( NumArg(op) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(op) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < num_combined ); size_t i_v = combined[ arg[0] - 1 ]; CPPAD_ASSERT_UNKNOWN( i_v < vecad_sparsity.n_set() ); var_sparsity.assignment(i_z, i_v, vecad_sparsity); return; }
inline void reverse_sparse_jacobian_cond_op( size_t i_z , const addr_t* arg , size_t num_par , Vector_set& sparsity ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[0]) < static_cast<size_t> (CompareNe) ); CPPAD_ASSERT_UNKNOWN( NumArg(CExpOp) == 6 ); CPPAD_ASSERT_UNKNOWN( NumRes(CExpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] != 0 ); # ifndef NDEBUG if( arg[1] & 1 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < i_z ); } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[2]) < num_par ); } if( arg[1] & 2 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < i_z ); } else { CPPAD_ASSERT_UNKNOWN( size_t(arg[3]) < num_par ); } if( ! ( arg[1] & 4 ) ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < num_par ); } if( ! ( arg[1] & 8 ) ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < num_par ); } # endif if( arg[1] & 4 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[4]) < i_z ); sparsity.binary_union(arg[4], arg[4], i_z, sparsity); } if( arg[1] & 8 ) { CPPAD_ASSERT_UNKNOWN( size_t(arg[5]) < i_z ); sparsity.binary_union(arg[5], arg[5], i_z, sparsity); } return; }
inline void forward_cos_op( size_t q , size_t p , size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(CosOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(CosOp) == 2 ); CPPAD_ASSERT_UNKNOWN( i_x + 1 < i_z ); CPPAD_ASSERT_UNKNOWN( p < nc_taylor ); CPPAD_ASSERT_UNKNOWN( q <= p ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * nc_taylor; Base* c = taylor + i_z * nc_taylor; Base* s = c - nc_taylor; // rest of this routine is identical for the following cases: // forward_sin_op, forward_cos_op, forward_sinh_op, forward_cosh_op. size_t k; if( q == 0 ) { s[0] = sin( x[0] ); c[0] = cos( x[0] ); q++; } for(size_t j = q; j <= p; j++) { s[j] = Base(0); c[j] = Base(0); for(k = 1; k <= j; k++) { s[j] += Base(k) * x[k] * c[j-k]; c[j] -= Base(k) * x[k] * s[j-k]; } s[j] /= Base(j); c[j] /= Base(j); } }
inline void forward_erf_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(ErfOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(ErfOp) == 5 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // array used to pass parameter values for sub-operations addr_t addr[2]; // convert from final result to first result i_z -= 4; // 4 = NumRes(ErfOp) - 1; // z_0 = x * x addr[0] = arg[0]; // x addr[1] = arg[0]; // x forward_mulvv_op_0(i_z+0, addr, parameter, cap_order, taylor); // z_1 = - x * x addr[0] = arg[1]; // zero addr[1] = i_z; // z_0 forward_subpv_op_0(i_z+1, addr, parameter, cap_order, taylor); // z_2 = exp( - x * x ) forward_exp_op_0(i_z+2, i_z+1, cap_order, taylor); // z_3 = (2 / sqrt(pi)) * exp( - x * x ) addr[0] = arg[2]; // 2 / sqrt(pi) addr[1] = i_z + 2; // z_2 forward_mulpv_op_0(i_z+3, addr, parameter, cap_order, taylor); // zero order Taylor coefficient for z_4 Base* x = taylor + arg[0] * cap_order; Base* z_4 = taylor + (i_z + 4) * cap_order; z_4[0] = erf(x[0]); }
inline void forward_abs_op_0( size_t i_z , size_t i_x , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( i_x < i_z ); CPPAD_ASSERT_UNKNOWN( 0 < nc_taylor ); // Taylor coefficients corresponding to argument and result Base y0 = *(taylor + i_x * nc_taylor); Base* z = taylor + i_z * nc_taylor; if( LessThanZero(y0) ) z[0] = - y0; else z[0] = y0; }
inline void forward_subvp_op_0( size_t i_z , const size_t* arg , const Base* parameter , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SubvpOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(SubvpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( arg[1] < i_z ); // Parameter value Base y = parameter[ arg[1] ]; // Taylor coefficients corresponding to arguments and result Base* x = taylor + arg[0] * nc_taylor; Base* z = taylor + i_z * nc_taylor; z[0] = x[0] - y; }
AD<Base> AD<Base>::Sign (void) const { AD<Base> result; result.value_ = sign(value_); CPPAD_ASSERT_UNKNOWN( Parameter(result) ); if( Variable(*this) ) { // add this operation to the tape CPPAD_ASSERT_UNKNOWN( NumRes(SignOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumArg(SignOp) == 1 ); ADTape<Base> *tape = tape_this(); // corresponding operand address tape->Rec_.PutArg(taddr_); // put operator in the tape result.taddr_ = tape->Rec_.PutOp(SignOp); // make result a variable result.id_ = tape->id_; } return result; }
inline void forward_abs_op( size_t p , size_t q , size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AbsOp) == 1 ); CPPAD_ASSERT_UNKNOWN( q < cap_order ); CPPAD_ASSERT_UNKNOWN( p <= q ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; for(size_t j = p; j <= q; j++) z[j] = sign(x[0]) * x[j]; }
inline void forward_subpv_op_0( size_t i_z , const addr_t* arg , const Base* parameter , size_t nc_taylor , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(SubpvOp) == 2 ); CPPAD_ASSERT_UNKNOWN( NumRes(SubpvOp) == 1 ); CPPAD_ASSERT_UNKNOWN( size_t(arg[1]) < i_z ); // Paraemter value Base x = parameter[ arg[0] ]; // Taylor coefficients corresponding to arguments and result Base* y = taylor + arg[1] * nc_taylor; Base* z = taylor + i_z * nc_taylor; z[0] = x - y[0]; }
inline void forward_store_pv_op_0( size_t i_z , const addr_t* arg , size_t num_par , size_t cap_order , Base* taylor , bool* isvar_by_ind , size_t* index_by_ind ) { size_t i_vec = arg[1]; // Because the index is a parameter, this indexing error should be // caught and reported to the user when the tape is recording. CPPAD_ASSERT_UNKNOWN( i_vec < index_by_ind[ arg[0] - 1 ] ); CPPAD_ASSERT_UNKNOWN( NumArg(StpvOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(StpvOp) == 0 ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); isvar_by_ind[ arg[0] + i_vec ] = true; index_by_ind[ arg[0] + i_vec ] = arg[2]; }
inline void forward_load_p_op_0( size_t i_z , addr_t* arg , size_t num_par , const Base* parameter , size_t nc_taylor , Base* taylor , size_t nc_combined , const bool* variable , const size_t* combined ) { size_t i_vec = arg[1]; // Because the index is a parameter, this indexing error should be // caught and reported to the user at an when the tape is recording. CPPAD_ASSERT_UNKNOWN( i_vec < combined[ arg[0] - 1 ] ); CPPAD_ASSERT_UNKNOWN( variable != CPPAD_NULL ); CPPAD_ASSERT_UNKNOWN( combined != CPPAD_NULL ); CPPAD_ASSERT_UNKNOWN( NumArg(LdpOp) == 3 ); CPPAD_ASSERT_UNKNOWN( NumRes(LdpOp) == 1 ); CPPAD_ASSERT_UNKNOWN( 0 < arg[0] ); CPPAD_ASSERT_UNKNOWN( arg[0] + i_vec < nc_combined ); size_t combined_index = arg[0] + i_vec; size_t i_y_x = combined[ combined_index ]; Base* z = taylor + i_z * nc_taylor; if( variable[ combined_index ] ) { CPPAD_ASSERT_UNKNOWN( i_y_x < i_z ); Base* y_x = taylor + i_y_x * nc_taylor; arg[2] = i_y_x; z[0] = y_x[0]; } else { CPPAD_ASSERT_UNKNOWN( i_y_x < num_par ); Base y_x = parameter[i_y_x]; arg[2] = 0; z[0] = y_x; } }