Prev | Next |
class atomic_user : public CppAD::atomic_three<Base> {
...
};
atomic_user afun(ctor_arg_list)
afun(ax, ay)
ok = afun.for_type(
parameter_x, type_x, type_y
)
ok = afun.forward(
parameter_x, type_x,
need_y, order_low, order_up, taylor_x, taylor_y
)
ok = afun.reverse(
parameter_x, type_x,
order_up, taylor_x, taylor_y, partial_x, partial_y
)
ok = afun.jac_sparsity(
parameter_x, type_x, dependency, select_x select_y, pattern_out
)
ok = afun.hes_sparsity(
parameter_x, type_x, select_x select_y, pattern_out
)
ok = afun.rev_depend(
parameter_x, type_x, depend_x, depend_y
)
AD<Base>
atomic
operations
and letting CppAD do the rest.
The class
atomic_three<Base>
is used to
create a new atomic operation corresponding to a function @(@
g(x)
@)@
where the user specifies how to compute the derivatives
and sparsity patterns for @(@
g(x)
@)@.
AD<Base>
operations and variables
in the recording.
CppAD::ad_type_enum
is used to specify if an AD object is a
constant parameter
dynamic parameter
or variable
.
It has the following possible values:
ad_type_enum
| Meaning |
constant_enum | constant parameter |
dynamic_enum | dynamic parameter |
variable_enum | variable |
constant_enum < dynamic_enum < variable_enum
.
atomic_user
class.
These functions compute derivatives,
sparsity patterns, and dependency relations.
Each virtual function has a default implementation
that returns
ok == false
.
The for_type
and forward
function
(for the case
order_up == 0
) must be implemented.
Otherwise, only those functions and orders
required by the your calculations need to be implemented.
For example,
forward
for the case
order_up == 2
can just return
ok == false
unless you require
forward mode calculation of second derivatives.
afun(ax, ay)
call; i.e.,
the elements of
ax
and
ay
have type
AD<Base>
.
const CppAD::vector<Base> parameter_x
Its size is equal to
n = ax.size()
in corresponding
afun(ax, ay)
call.
j =0,...,n-1
,
if
ax[j]
is a constant
parameter,
parameter_x[j] == ax[j]
ax[j]
is a dynamic
parameter,
parameter_x[j]
value of
ax[j]
corresponding to the
previous call to new_dynamic
for the corresponding function object.
ax[j]
is a variable,
the value of
parameter_x[j]
is not specified.
See the
atomic_three_mat_mul.hpp
for an example using
parameter_x
.
n = ax.size()
in corresponding
afun(ax, ay)
call.
For
j =0,...,n-1
,
if
ax[j]
is a constant parameter,
type_x[j] == CppAD::constant_enum
if
ax[j]
is a dynamic parameter,
type_x[j] == CppAD::dynamic_enum
if
ax[j]
is a variable,
type_x[j] == CppAD::variable_enum
See the
atomic_three_mat_mul.hpp
for an example using
type_x
.
atomic_three_ctor | Atomic Function Constructor |
atomic_three_afun | Using AD Version of an Atomic Function |
atomic_three_for_type | Atomic Function Forward Type Calculation |
atomic_three_forward | Atomic Function Forward Mode |
atomic_three_reverse | Atomic Function Reverse Mode |
atomic_three_jac_sparsity | Atomic Function Jacobian Sparsity Patterns |
atomic_three_hes_sparsity | Atomic Function Hessian Sparsity Patterns |
atomic_three_rev_depend | Atomic Function Reverse Dependency Calculation |