1 # ifndef CPPAD_CORE_OLD_ATOMIC_HPP
2 # define CPPAD_CORE_OLD_ATOMIC_HPP
788 # define CPPAD_USER_ATOMIC( \
800 const Tvector< CppAD::AD<Base> >& ax , \
801 Tvector< CppAD::AD<Base> >& ay \
803 { CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL; \
804 static CppAD::old_atomic<Base> fun( \
825 template <
class Base>
832 "Depreacted API uses user_atomic<Base>::clear()"
957 template <
class ADVector>
985 size_t n = tx.
size() / (q+1);
986 size_t m = ty.
size() / (q+1);
996 for(k = p; k <= q; k++)
997 {
for(j = 0; j < n; j++)
998 for(ell = 0; ell <= k; ell++)
999 x[ j * (k+1) + ell ] = tx[ j * (q+1) + ell ];
1000 for(i = 0; i < m; i++)
1001 for(ell = 0; ell < k; ell++)
1002 y[ i * (k+1) + ell ] = ty[ i * (q+1) + ell ];
1004 ok &=
f_(
id_, k, n, m, vx, vy, x, y);
1006 ok &=
f_(
id_, k, n, m, empty, empty, x, y);
1007 for(i = 0; i < m; i++)
1008 ty[ i * (q+1) + k ] = y[ i * (k+1) + k];
1025 size_t n = tx.
size() / (q+1);
1026 size_t m = ty.
size() / (q+1);
1027 bool ok =
r_(
id_, q, n, m, tx, ty, px, py);
1037 const vector< std::set<size_t> >& r ,
1038 vector< std::set<size_t> >& s ,
1040 {
size_t n = r.size();
1041 size_t m = s.size();
1042 bool ok =
fjs_(
id_, n, m, q, r, s);
1053 const vector< std::set<size_t> >& rt ,
1054 vector< std::set<size_t> >& st ,
1056 {
size_t n = st.size();
1057 size_t m = rt.size();
1058 bool ok =
rjs_(
id_, n, m, q, st, rt);
1071 const vector< std::set<size_t> >& r ,
1072 const vector< std::set<size_t> >& u ,
1073 vector< std::set<size_t> >& v ,
1075 {
size_t m = u.size();
1076 size_t n = v.size();
1082 bool ok =
rhs_(
id_, n, m, q, r, s, t, u, v);
bool(* F)(size_t id, size_t k, size_t n, size_t m, const vector< bool > &vx, vector< bool > &vy, const vector< Base > &tx, vector< Base > &ty)
type for user routine that computes forward mode results
bool(* R)(size_t id, size_t k, size_t n, size_t m, const vector< Base > &tx, const vector< Base > &ty, vector< Base > &px, const vector< Base > &py)
type for user routine that computes reverse mode results
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
virtual bool rev_sparse_hes(const vector< bool > &vx, const vector< bool > &s, vector< bool > &t, size_t q, const vector< std::set< size_t > > &r, const vector< std::set< size_t > > &u, vector< std::set< size_t > > &v, const vector< Base > &x)
Link from reverse Hessian sparsity sweep to old_atomic.
void operator()(size_t id, const ADVector &ax, ADVector &ay)
Implement the user call to afun(id, ax, ay).
bool(* RJS)(size_t id, size_t n, size_t m, size_t q, vector< std::set< size_t > > &r, const vector< std::set< size_t > > &s)
type for user routine that computes reverse mode Jacobian sparsity
old_atomic(const char *afun, F f, R r, FJS fjs, RJS rjs, RHS rhs)
Constructor called for each invocation of CPPAD_USER_ATOMIC.
virtual void set_old(size_t id)
Store id for next virtual function callback.
bool(* FJS)(size_t id, size_t n, size_t m, size_t q, const vector< std::set< size_t > > &r, vector< std::set< size_t > > &s)
type for user routine that computes forward mode Jacobian sparsity
virtual bool reverse(size_t q, const vector< Base > &tx, const vector< Base > &ty, vector< Base > &px, const vector< Base > &py)
Link from old_atomic to reverse mode.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
const FJS fjs_
user's implementation of forward jacobian sparsity calculations
virtual bool rev_sparse_jac(size_t q, const vector< std::set< size_t > > &rt, vector< std::set< size_t > > &st, const vector< Base > &x)
Link from reverse Jacobian sparsity sweep to old_atomic.
const RHS rhs_
user's implementation of reverse Hessian sparsity calculations
bool(* RHS)(size_t id, size_t n, size_t m, size_t q, const vector< std::set< size_t > > &r, const vector< bool > &s, vector< bool > &t, const vector< std::set< size_t > > &u, vector< std::set< size_t > > &v)
type for user routine that computes reverse mode Hessian sparsity
const F f_
user's implementation of forward mode
size_t size(void) const
number of elements currently in this vector.
link so that user_atomic<Base>::clear() still works
void operator()(const ADVector &ax, ADVector &ay, size_t id=0)
Implement the user call to afun(ax, ay) and old_atomic call to afun(ax, ay, id).
size_t id_
id value corresponding to next virtual callback
static void clear(void)
disable old_atomic<Base>::clear(void)
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
virtual bool for_sparse_jac(size_t q, const vector< std::set< size_t > > &r, vector< std::set< size_t > > &s, const vector< Base > &x)
Link from forward Jacobian sparsity sweep to old_atomic.
Class that actually implements the afun(id, ax, ay) calls.
const RJS rjs_
user's implementation of reverse jacobian sparsity calculations
File used to define the CppAD multi-threading allocator class.
const R r_
user's implementation of reverse mode
void option(enum option_enum option_value)
virtual bool forward(size_t p, size_t q, const vector< bool > &vx, vector< bool > &vy, const vector< Base > &tx, vector< Base > &ty)
Link from old_atomic to forward mode.