Discrete AD Functions
Keywords: discrete ad functions Cppad_discrete_function syntax purpose base name x y ax ay create version operation sequence derivatives parallel mode example cppadcreatediscrete deprecated 2007-07-28

| Prev | Next |  |  |  |  |  |  |

Discrete AD Functions
Syntax
`CPPAD_DISCRETE_FUNCTION(Base, name)
` `y = name(x)
` `ay = name(ax)
`
Purpose
Record the evaluation of a discrete function as part of an `AD<Base>` operation sequence . The value of a discrete function can depend on the independent variables , but its derivative is identically zero. For example, suppose that the integer part of a variable `x` is the index into an array of values.
Base
This is the base type corresponding to the operations sequence; i.e., use of the `name` with arguments of type `AD<Base>` can be recorded in an operation sequence.
name
This is the name of the function (as it is used in the source code). The user must provide a version of `name` where the argument has type `Base` . CppAD uses this to create a version of `name` where the argument has type `AD<Base>` .
x
The argument `x` has prototype `
const Base& x
` It is the value at which the user provided version of `name` is to be evaluated.
y
The result `y` has prototype `
Base y
` It is the return value for the user provided version of `name` .
ax
The argument `ax` has prototype `
const AD<Base>& ax
` It is the value at which the CppAD provided version of `name` is to be evaluated.
ay
The result `ay` has prototype `
AD<Base> ay
` It is the return value for the CppAD provided version of `name` .
Create AD Version
The preprocessor macro invocation `
CPPAD_DISCRETE_FUNCTION(Base, name)
` defines the `AD<Base>` version of `name` . This can be with in a namespace (not the `CppAD` namespace) but must be outside of any routine.
Operation Sequence
This is an AD of `Base` atomic operation and hence is part of the current AD of `Base` operation sequence .
Derivatives
During a zero order Forward operation, an ADFun object will compute the value of `name` using the user provided `Base` version of this routine. All the derivatives of `name` will be evaluated as zero.
Parallel Mode
The first call to `
ay = name(ax)
` must not be in parallel execution mode.
Example
The file tape_index.cpp contains an example and test that uses a discrete function to vary an array index during Forward mode calculations. The file interp_onetape.cpp contains an example and test that uses discrete functions to avoid retaping a calculation that requires interpolation. (The file interp_retape.cpp shows how interpolation can be done with retaping.)
CppADCreateDiscrete Deprecated 2007-07-28
The preprocessor symbol `CppADCreateDiscrete` is defined to be the same as `CPPAD_DISCRETE_FUNCTION` but its use is deprecated.

Input File: cppad/local/discrete.hpp