# 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 eigen}
{xrst_spell
   cholesky
   eigencmakeinclude
   includedir
   testvector
}

Including Eigen Examples, Tests, and sparse2eigen
#################################################

Eigen Home Page
***************
http://eigen.tuxfamily.org

Examples and Tests
******************
CppAD can include the following examples and tests that
use the linear algebra package Eigen:
{xrst_comment check list with: grep 'eigen.*\.cpp' omh/example_list.omh'}

.. csv-table::
   :widths: auto

   cppad_eigen.hpp,:ref:`cppad_eigen.hpp-title`
   eigen_array.cpp,:ref:`eigen_array.cpp-title`
   eigen_det.cpp,:ref:`eigen_det.cpp-title`
   sparse2eigen.cpp,:ref:`sparse2eigen.cpp-title`
   atomic_two_eigen_cholesky.hpp,:ref:`atomic_two_eigen_cholesky.hpp-title`
   atomic_two_eigen_mat_inv.hpp,:ref:`atomic_two_eigen_mat_inv.hpp-title`
   atomic_two_eigen_mat_mul.hpp,:ref:`atomic_two_eigen_mat_mul.hpp-title`

sparse2eigen
************
The :ref:`sparse2eigen-name` utility will only be available if
:ref:`cmake@include_eigen`
is specified on the cmake command line.

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

   ``pkg-config eigen3 --path --print-errors``

finds the location of the file ``eigen3.pc`` .

eigen_prefix
************
With Eigen it is possible to use ``-D eigen_prefix`` = *eigen_prefix*
on the cmake command line.
In this case, the sub-directory ``Eigen`` must exist in a directory

   *eigen_prefix* / *includedir*

where *include_dir* is one of the directories in the
:ref:`cmake@cmake_install_includedirs` list
of directories.

Examples
********
If you specify *include_eigencmakeinclude_eigen*
on the cmake command line,
you will be able to run the Eigen examples list 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
``eigen_array`` and ``eigen_det``
have passed their correctness check.

Test Vector
***********
If you have specified *eigen_prefix* you can choose

   ``-D cppad_testvector`` = ``eigen``

on the :ref:`cmake@CMake Command` line.
This we set the CppAD :ref:`testvector-name` to use Eigen vectors.

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

{xrst_end eigen}
