# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-25 Bradley M. Bell
# ----------------------------------------------------------------------------
{xrst_begin eigen}
{xrst_spell
   cholesky
   inv
}

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

Eigen Home Page
***************
https://libeigen.gitlab.io/

Finding Eigen
*************
These example and tests will be included
and :ref:`sparse2eigen-name` will be installed if:

#. Eigen is installed on your system

#. c++14 or higher is supported by your compiler

#. *PKG_CONFIG_PATH* is such that the following command
   finds the location of the file eigen3.pc :
   ``pkg-config eigen3 --path --print-errors``

The output of the :ref:`cmake-name` command will report if these
conditions are met.


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`

Examples
********
If :ref:`eigen is found <eigen@Finding Eigen>` ,
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 eigen is found 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.

{xrst_end eigen}
