1 # ifndef CPPAD_CORE_DISCRETE_HPP
2 # define CPPAD_CORE_DISCRETE_HPP
177 # define CPPAD_DISCRETE_FUNCTION(Base, name) \
178 inline CppAD::AD<Base> name (const CppAD::AD<Base>& ax) \
180 static CppAD::discrete<Base> fun(#name, name); \
184 # define CppADCreateDiscrete CPPAD_DISCRETE_FUNCTION
193 template <
class Base>
196 template <
class Type>
200 typedef Base (*
F) (
const Base& x);
216 static std::vector<discrete *>&
List(
void)
218 static std::vector<discrete *> list;
245 "discrete: First call the function *Name is in parallel mode."
247 List().push_back(
this);
270 std::numeric_limits<addr_t>::max() >=
index_,
271 "discrete: cppad_tape_addr_type maximum not large enough"
285 static const char*
name(
size_t index)
286 {
return List()[index]->name_.c_str(); }
297 static Base
eval(
size_t index,
const Base& x)
301 return List()[index]->f_(x);
friend void parallel_ad(void)
parallel_ad needs to call List to initialize static
#define CPPAD_ASSERT_KNOWN(exp, msg)
Check that exp is true, if not print msg and terminate execution.
CPPAD_TAPE_ADDR_TYPE addr_t
static bool in_parallel(void)
Are we in a parallel execution state; i.e., is it possible that other threads are currently executing...
static const char * name(size_t index)
Name corresponding to a discrete object.
size_t NumArg(OpCode op)
Number of arguments for a specified operator.
Define the CppAD error checking macros (all of which begin with CPPAD_ASSERT_)
#define CPPAD_ASSERT_FIRST_CALL_NOT_PARALLEL
Check that the first call to a routine is not during parallel execution mode.
size_t NumRes(OpCode op)
Number of variables resulting from the specified operation.
static Base eval(size_t index, const Base &x)
Link from forward mode sweep to users routine.
Base(* F)(const Base &x)
type for the user routine that computes function values
discrete(const char *Name, F f)
Constructor called for each invocation of CPPAD_DISCRETE_FUNCTION.
CPPAD_INLINE_FRIEND_TEMPLATE_FUNCTION bool Variable(const AD< Base > &x)
static std::vector< discrete * > & List(void)
List of all objects in this class.
const F f_
user's implementation of the function for Base operations
#define CPPAD_ASSERT_UNKNOWN(exp)
Check that exp is true, if not terminate execution.
AD< Base > ad(const AD< Base > &ax) const
Implement the user call to ay = name(ax).
local::recorder< Base > Rec_
This is where the information is recorded.
Class used to hold tape that records AD<Base> operations.
File used to define the CppAD multi-threading allocator class.
const std::string name_
name of this user defined function
const size_t index_
index of this objec in the vector of all objects for this class
tape_id_t id_
Unique identifier for this tape.
local::ADTape< Base > * tape_this(void) const
Get a pointer to tape that records AD<Base> operations for the current thread.