------------------------------------
lines 5-246 of file: user_guide.xrst
------------------------------------
{xrst_begin user_guide}
{xrst_spell
adolc
autodiff
fadbad
openmp
org
posix
sacado
templated
}
{xrst_comment BEGIN: Before changing see new_release.sh and check_version.sh}
CppAD User's Manual
###################
.. image:: {xrst_dir coin.png}
License
*******
CppAD is distributed by
`COIN-OR `_
with the Eclipse Public License
`EPL-2.0 `_
or the GNU General Public License
`GPL-2.0-or-later `_
Git Repository
**************
``_
Versions
********
.. list-table::
:widths: auto
* - This version
- cppad-20250209
* - Documentation for latest version
- `latest `_
* - Documentation for most recent stable version
- `stable-2025 `_
* - Most recent release of this stable version
- `release-2025 `_
{xrst_comment END: Before changing see new_release.sh and check_version.sh}
Other Links
***********
.. list-table::
:widths: auto
* - :ref:`install-name`
- :ref:`get_started`
- :ref:`whats_new-name`
- :ref:`addon-name`
- `project manager `_
Algorithmic Differentiation
***************************
We refer to the automatic creation of an algorithm that
computes derivative values from an algorithm that computes function values
as *Algorithmic Differentiation* ,
also referred to as *Automatic Differentiation* or just AD.
A brief introduction to AD can be found in
`wikipedia `_.
The web site
`autodiff.org `_
is dedicated to research about, and promoting the use of, AD.
Features
********
Operator Overloading
====================
CppAD uses operator overloading of the C++ template class :ref:`AD-name`
to compute derivatives of algorithms defined using AD objects; see
the :ref:`introduction-name` for a description of how this is accomplished.
Base Type
=========
The operator overloading uses a templated base type that
can be user defined; see :ref:`base_require-name` .
The required definitions for ``AD`` and
``AD`` are included as part of CppAD.
Recording Operations
====================
A sequence of ``AD`` < *Base* >
:ref:`operations`
can be recorded and stored in an
:ref:`AD function object` .
This object can then be used to evaluate
function values and arbitrary order derivatives,
and sparsity patterns of derivative values using the *Base* type.
Multi-Threading
===============
CppAD supports an arbitrary :ref:`multi threading` environment.
Examples are provided using Boost threads, Posix threads, and Openmp threads.
Optimizing Operations Sequences
===============================
During the recording of a function,
the :ref:`Independent-name` variables are know and a forward dependency
analysis is used to determine which operations should be recorded.
Once the :ref:`Dependent-name` variables are determined,
a reverse dependency analysis can be preformed.
This :ref:`optimize-name` routine uses a reverse dependency analysis,
and other techniques,
to remove unnecessary operations.
Dynamic Parameters
==================
CppAD enables one to specify a vector of
:ref:`glossary@Parameter@Dynamic` parameters.
The value of the function and derivatives can depend on these parameters,
but no derivatives are taken with respect to these parameters.
This enables CppAD to reduce the derivative calculations; e.g.,
the derivative of variable times a variable has two terms
while a variable times a parameter only has one.
Derivative Calculations
=======================
Arbitrary order
:ref:`Forward-name` and :ref:`Reverse-name`
mode derivative calculations
can be preformed using an ``ADFun`` object.
Easy to user drivers that compute the
entire :ref:`Jacobian-name` and a specific :ref:`Hessian-name` are included.
Sparsity
========
Both forward and reverse mode can be used to calculation the sparsity
pattern for Jacobians and Hessians; see :ref:`sparsity_pattern-name` .
Where a Jacobian or Hessian is sparse,
both forward and reverse mode can be combined with the sparsity pattern
to speed up the calculation of
:ref:`sparse derivatives` .
In addition, a :ref:`subgraph` method,
that does not require a sparsity pattern, can be used
to speed up these derivative calculations.
Recording Derivative Operations
===============================
A ``ADFun`` object can be converted into an object that
evaluates derivatives using the type ``AD`` < *Base* > ; see :ref:`base2ad-name` .
This enables one to record new functions that
are expressed using derivatives of other functions.
Atomic Functions
================
User defined derivative calculations for arbitrary functions
can also be included in
a recording using :ref:`atomic functions` .
A special :ref:`checkpoint` class is included
which allows one to record a function and reuse it as
an atomic operation in other functions.
There also is a special interface for user defined unary
:ref:`discrete functions` ; i.e.,
functions that depend on the
:ref:`independent variables`
but which have identically zero derivatives (e.g., a step function).
Logical Comparisons
===================
Logical comparisons can be included in an operation sequence
using AD :ref:`conditional expressions` .
Vectors
=======
The CppAD API allows one to use any
:ref:`SimpleVector-name` class.
The preprocessor symbol :ref:`CPPAD_TESTVECTOR`
is template vector class which is used for correctness testing.
Many of the correctness tests use this template vector class
which you can choose during the :ref:`cmake-name` configuration command.
Software Engineering
********************
CppAD is developed using the software engineering procedures described
on the project manager's
`software `_
web page.
Testing
*******
Correctness
===========
There is an extensive set of correctness tests; see :ref:`cmake_check-name` .
Speed
=====
A set of programs for doing :ref:`speed-name` comparisons between
`Adolc `_,
CppAD,
`Fadbad `_,
and
`Sacado `_
are included.
Utilities
*********
CppAD includes a set of C++ :ref:`utilities` that are useful
for general operator overloaded numerical methods.
Release Notes
*************
This :ref:`whats_new-name` for a list of recent extensions and bug fixes.
Example
*******
The file :ref:`get_started.cpp-name`
contains an example and test of using CppAD to compute
the derivative of a polynomial.
There are many other
:ref:`examples` .
All of the examples are also correctness tests,
which ensures that they work properly.
Contents
********
{xrst_toc_table
xrst/install/install.xrst
xrst/theory/theory.xrst
include/cppad/core/user_ad.hpp
include/cppad/core/ad_fun.hpp
xrst/preprocessor.xrst
xrst/multi_thread.xrst
include/cppad/utility/xrst/utility.xrst
include/cppad/ipopt/solve.hpp
xrst/example.xrst
speed/speed.xrst
}
{xrst_end user_guide}