Prev Next

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
User Defined Atomic AD Functions


atomic_user afun(ctor_arg_list)
ok = afun.forward(pqvxvytxty)
ok = afun.reverse(qtxtypxpy)
ok = afun.for_sparse_jac(qrs)
ok = afun.rev_sparse_jac(qrs)
ok = afun.for_sparse_hes(vxrsh)
ok = afun.rev_sparse_hes(vxstqruv)

In some cases, the user knows how to compute derivatives of a function @[@ y = f(x) \; {\rm where} \; f : B^n \rightarrow B^m @]@ more efficiently than by coding it using AD<Base> atomic operations and letting CppAD do the rest. In this case atomic_base<Base> can use the user code for @(@ f(x) @)@, and its derivatives, as AD<Base> atomic operations.

Virtual Functions
User defined derivatives are implemented by defining the following virtual functions in the base_atomic class: forward , reverse , for_sparse_jac , rev_sparse_jac , and rev_sparse_hes . These virtual functions have a default implementation that returns ok == false . The forward function, for the case q == 0 , must be implemented. Otherwise, only those functions required by the your calculations need to be implemented. For example, forward for the case q == 2 can just return ok == false unless you require forward mode calculation of second derivatives.

atomic_ctorAtomic Function Constructor
atomic_optionSet Atomic Function Options
atomic_afunUsing AD Version of Atomic Function
atomic_forwardAtomic Forward Mode
atomic_reverseAtomic Reverse Mode
atomic_for_sparse_jacAtomic Forward Jacobian Sparsity Patterns
atomic_rev_sparse_jacAtomic Reverse Jacobian Sparsity Patterns
atomic_for_sparse_hesAtomic Forward Hessian Sparsity Patterns
atomic_rev_sparse_hesAtomic Reverse Hessian Sparsity Patterns
atomic_base_clearFree Static Variables
atomic_get_started.cppGetting Started with Atomic Operations: Example and Test
atomic_norm_sq.cppAtomic Euclidean Norm Squared: Example and Test
atomic_reciprocal.cppReciprocal as an Atomic Operation: Example and Test
atomic_set_sparsity.cppAtomic Sparsity with Set Patterns: Example and Test
atomic_tangent.cppTan and Tanh as User Atomic Operations: Example and Test
atomic_eigen_mat_mul.cppAtomic Eigen Matrix Multiply: Example and Test
atomic_eigen_mat_inv.cppAtomic Eigen Matrix Inverse: Example and Test
atomic_eigen_cholesky.cppAtomic Eigen Cholesky Factorization: Example and Test
atomic_mat_mul.cppUser Atomic Matrix Multiply: Example and Test


Getting Started
The file atomic_get_started.cpp contains an example and test that shows the minimal amount of information required to create a user defined atomic operation.

Scalar Function
The file atomic_reciprocal.cpp contains an example and test where the user provides the code for computing derivatives. This example is simple because the domain and range are scalars.

Vector Range
The file atomic_tangent.cpp contains another example where the user provides the code for computing derivatives. This example is more complex because the range has two components.

Hessian Sparsity Patterns
The file atomic_rev_sparse_hes.cpp contains an minimal example where the user provides the code for computing Hessian sparsity patterns.

General Case
The file atomic_mat_mul.cpp contains a more general example where the user provides the code for computing derivatives. This example is more complex because both the domain and range dimensions are arbitrary.
Input File: omh/atomic_base.omh