# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------
{xrst_begin adolc}
{xrst_spell
   bashrc
   cygdrive
}

Including Adolc Examples and Tests
##################################

Adolc Home Page
***************
https://projects.coin-or.org/ADOL-C

Purpose
*******
CppAD includes examples and tests that can use the AD package Adolc.
The includes speed comparison with other AD packages; see
:ref:`speed_adolc-name` .
It also includes examples that combine Adolc with
CppAD; see

.. csv-table::
   :widths: auto

   base_adolc.hpp,:ref:`base_adolc.hpp-title`
   mul_level_adolc.cpp,:ref:`mul_level_adolc.cpp-title`
   mul_level_adolc_ode.cpp,:ref:`mul_level_adolc_ode.cpp-title`

include_adolc
*************
If Adolc is installed on your system, you can
specify ``include_adolc=true`` on the
:ref:`cmake-name` command line.
The value of ``PKG_CONFIG_PATH`` must be such that the command

   ``pkg-config adolc --path --print-errors``

finds the location of the file ``adolc.pc`` .
Note that CppAD assumes adolc has been configured with
its sparse matrix computations enabled; i.e, using

   ``--with-colpack`` = *adolc_prefix*

In other words ColPack is installed and
with the same prefix as ACOL-C; see
:ref:`get_colpack.sh-name` .

Examples
********
If you specify :ref:`cmake@include_adolc` on the cmake command
line, you will be able to run the Adolc examples listed above
by executing the following commands starting in the
:ref:`download@Distribution Directory` :

| |tab| ``cd build/example``
| |tab| ``make check_example``

If you do this,
you will see an indication that the examples
``mul_level_adolc`` and ``mul_level_adolc_ode``
have passed their correctness check.

Speed Tests
***********
If you include *adolc_prefix* on the :ref:`cmake-name` command line,
you will be able to run the Adolc speed correctness tests
by executing the following commands starting in the
:ref:`download@Distribution Directory` :

| |tab| ``cd build/speed/adolc``
| |tab| ``make check_speed_adolc``

After executing ``make check_speed_adolc`` ,
you can run a specific Adolc speed tests
by executing the command ``./speed_adolc`` ;
see :ref:`speed_main-name` for the meaning of the command line
options to this program.

Unix
****
If you are using Unix,
you may have to add
*adolc_prefix* to ``LD_LIBRARY_PATH`` .
For example, if you use the ``bash`` shell to run your programs,
you could include

| |tab| ``LD_LIBRARY_PATH`` = *adolc_prefix* / ``lib:$`` { ``LD_LIBRARY_PATH`` }
| |tab| ``export LD_LIBRARY_PATH``

in your ``$HOME/.bashrc`` file.

Cygwin
******
If you are using Cygwin,
you may have to add to following lines to the file
``.bashrc`` in your home directory:

| |tab| ``PATH`` = *adolc_prefix* / ``bin:$`` { ``PATH`` }
| |tab| ``export PATH``

in order for Adolc to run properly.
If *adolc_prefix* begins with a disk specification,
you must use the Cygwin format for the disk specification.
For example,
if ``d:/adolc_base`` is the proper directory,
``/cygdrive/d/adolc_base`` should be used for *adolc_prefix* .

get_adolc
*********
If you are using Unix, you can download and install
a copy of Adolc using :ref:`get_adolc.sh-name` .
The corresponding install prefix is
``build/prefix`` .

{xrst_end adolc}
