1 # ifndef CPPAD_CORE_OPTIMIZE_HPP
2 # define CPPAD_CORE_OPTIMIZE_HPP
215 template <
class Base>
221 size_t n = ind_taddr_.size();
224 size_t i, j, m = dep_taddr_.size();
227 bool check_zero_order = num_order_taylor_ > 0;
228 if( check_zero_order )
230 for(j = 0; j < n; j++)
233 x[j] = taylor_[ ind_taddr_[j] * cap_order_taylor_ + 0];
236 for(i = 0; i < m; i++)
238 y[i] = taylor_[ dep_taddr_[i] * cap_order_taylor_ + 0];
242 for(i = 1; i < num_var_tape_; i++)
243 {
if(
abs_geq(taylor_[i*cap_order_taylor_+0] , max_taylor) )
244 max_taylor = taylor_[i*cap_order_taylor_+0];
250 local::optimize::optimize_run<Base>(options, n, dep_taddr_, &play_, &rec);
259 has_been_optimized_ =
true;
263 for_jac_sparse_pack_.resize(0, 0);
264 for_jac_sparse_set_.resize(0,0);
268 num_order_taylor_ = 0;
269 cap_order_taylor_ = 0;
273 cskip_op_.resize( play_.num_op_rec() );
276 subgraph_info_.resize(
284 if( check_zero_order )
287 check = Forward(0, x);
291 for(i = 0; i < m; i++)
292 if( !
abs_geq( eps99 * max_taylor , check[i] - y[i] ) )
293 { std::string msg =
"Error during check of f.optimize().";
294 msg +=
"\neps99 * max_taylor = " +
to_string(eps99 * max_taylor);
295 msg +=
"\ncheck[i] = " +
to_string(check[i]);
298 abs_geq( eps99 * max_taylor , check[i] - y[i] ) ,
305 num_order_taylor_ = 0;
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
static Float epsilon(void)
machine epsilon
size_t num_var_rec(void) const
Number of variables currently stored in the recording.
bool abs_geq(const std::complex< double > &x, const std::complex< double > &y)
Class used to store an operation sequence while it is being recorded (the operation sequence is copie...
std::string to_string(const Type &value)
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
Convert a player object to an optimized recorder object.
void optimize(const std::string &options="")
Optimize a player object operation sequence.