1 # ifndef CPPAD_CORE_FUN_CONSTRUCT_HPP
2 # define CPPAD_CORE_FUN_CONSTRUCT_HPP
244 template <
typename Base>
246 has_been_optimized_(false),
247 check_for_nan_(true) ,
248 compare_change_count_(1),
249 compare_change_number_(0),
250 compare_change_op_index_(0),
273 template <
typename Base>
275 {
size_t m = f.
Range();
293 ind_taddr_.resize(n);
310 for_jac_sparse_pack_.resize(0, 0);
316 for_jac_sparse_pack_.resize(n_set, end);
317 for(i = 0; i < num_var_tape_ ; i++)
318 { for_jac_sparse_pack_.assignment(
327 for_jac_sparse_set_.resize(0, 0);
333 for_jac_sparse_set_.resize(n_set, end);
334 for(i = 0; i < num_var_tape_; i++)
335 { for_jac_sparse_set_.assignment(
378 template <
typename Base>
379 template <
typename VectorAD>
384 "ADFun<Base>: independent variable vector has size zero."
388 "ADFun<Base>: independent variable vector has been changed."
393 "ADFun<Base>: independent variable vector has been changed."
395 size_t j, n = x.size();
397 size_t i, m = y.size();
398 for(j = 0; j < n; j++)
400 size_t(x[j].taddr_) == (j+1),
401 "ADFun<Base>: independent variable vector has been changed."
404 x[j].tape_id_ == x[0].tape_id_,
405 "ADFun<Base>: independent variable vector has been changed."
408 for(i = 0; i < m; i++)
411 "ADFun<Base>: dependent vector contains variables for"
412 "\na different tape than the independent variables."
422 check_for_nan_ =
true;
429 capacity_order(c, r);
435 for(j = 0; j < n; j++)
438 taylor_[ ind_taddr_[j] ] = x[j].value_;
445 n, num_var_tape_, cap_order_taylor_, taylor_.data(),
446 cskip_op_.data(), load_op_,
447 compare_change_count_,
448 compare_change_number_,
449 compare_change_op_index_
456 num_order_taylor_ = 1;
460 for(i = 0; i < m; i++)
461 if( taylor_[dep_taddr_[i]] != y[i].value_ ||
CppAD::isnan( y[i].value_ ) )
463 std::ostringstream buf;
464 buf <<
"A dependent variable value is not equal to "
465 <<
"its tape evaluation value," << endl
466 <<
"perhaps it is nan." << endl
467 <<
"Dependent variable value = "
468 << y[i].value_ << endl
469 <<
"Tape evaluation value = "
470 << taylor_[dep_taddr_[i]] << endl
472 << y[i].value_ - taylor_[dep_taddr_[i]] << endl
476 std::string msg_str = buf.str();
479 const char* msg_char_star = msg_str.c_str();
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
size_t end(void) const
Fetch end for this vector of sets object.
local::sparse_list for_jac_sparse_set_
Set results of the forward mode Jacobian sparsity calculations for_jac_sparse_set_.n_set() != 0 implies for_sparse_pack_ is empty.
bool has_been_optimized_
Has this ADFun object been optmized.
size_t Range(void) const
number of dependent variables
Class used to hold function objects.
size_t num_order_taylor_
number of orders stored in taylor_
size_t n_set(void) const
Fetch n_set for vector of sets object.
size_t cap_order_taylor_
maximum number of orders that will fit in taylor_
local::sparse_pack for_jac_sparse_pack_
Packed results of the forward mode Jacobian sparsity calculations. for_jac_sparse_pack_.n_set() != 0 implies other sparsity results are empty.
size_t size_independent_
Number of independent variables in this tapes reconding. Set by Independent and effectively const...
CppAD::vector< size_t > ind_taddr_
tape address for the independent variables
size_t end(void) const
Fetch end for this vector of sets object.
void resize(size_t n)
change the number of elements in this vector.
void forward0sweep(const local::player< Base > *play, std::ostream &s_out, bool print, size_t n, size_t numvar, size_t J, Base *taylor, bool *cskip_op, pod_vector< addr_t > &var_by_load_op, size_t compare_change_count, size_t &compare_change_number, size_t &compare_change_op_index)
Compute zero order forward mode Taylor coefficients.
local::player< Base > play_
the operation sequence corresponding to this object
bool isnan(const Scalar &s)
static local::ADTape< Base > * tape_ptr(void)
Pointer for the tape for this AD<Base> class and the current thread.
size_t num_var_tape_
number of variables in the recording (play_)
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Variable(const AD< Base > &x)
local::pod_vector< bool > cskip_op_
which operations can be conditionally skipped Set during forward pass of order zero ...
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
bool check_for_nan_
Check for nan's and report message to user (default value is true).
void operator=(const ADFun &f)
ADFun assignment operator.
ADFun(void)
default constructor
size_t compare_change_count_
If zero, ignoring comparison operators. Otherwise is the compare change count at which to store the o...
size_t num_direction_taylor_
number of directions stored in taylor_
Class used to hold tape that records AD<Base> operations.
size_t Domain(void) const
number of independent variables
size_t n_set(void) const
Fetch n_set for vector of sets object.
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Parameter(const AD< Base > &x)
CppAD::vector< bool > dep_parameter_
which dependent variables are actually parameters
size_t compare_change_op_index_
If compare_change_count is zero, compare_change_op_index_ is also zero. Otherwise it is the operator...
local::pod_vector< addr_t > load_op_
Variable on the tape corresponding to each vecad load operation (if zero, the operation corresponds t...
CppAD::vector< size_t > dep_taddr_
tape address and parameter flag for the dependent variables
local::pod_vector< Base > taylor_
results of the forward mode calculations
local::subgraph::subgraph_info subgraph_info_
subgraph information for this object
size_t compare_change_number_
If compare_change_count_ is zero, compare_change_number_ is also zero. Otherwise, it is set to the nu...