Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Source Code Generation for Automatic Differentiation using Operator Overloading

License

NotificationsYou must be signed in to change notification settings

joaoleal/CppADCodeGen

Repository files navigation

CppADCodeGen is a C++ library that extendsCppADto allow the generation of C/C++ source code for computing the derivatives ofmathematical models using Algorithmic Differentiation (AD).Since CppAD uses operator-overloading and CppADCodeGen produces source-code,the result ishybrid Automatic Differentiation.

The evaluation of differential information can be orders of magnitude fasterto compute using a compiled model than using a regular operator-overloadingstrategy.

Key Features

  • Code Generation:
    • C/C++: It can be used to compute derivatives of functions/models (seewiki) and generate libraries (seewiki).
    • Latex: Latex sources can be used to create PDF files for documentation purposes (seewiki).
    • html+MathML: tml+MathML can be used to display your algorithm in a web browser (seewiki).
    • dot source-code: dot files can be used to create images with a graph of your model(seegraphviz).
  • Support for Multiple Types: Allows the creation of CppAD models using double or float floating-point types.
  • Efficient Sparsity Handling: Supports generation of code optimized for sparse Jacobians and Hessians.
  • Differentiation index reduction of Differential Algebraic Equations (DAE) through:
    • Pantelides,
    • Soares-Secchi, and
    • Dummy Derivatives methods.
  • Statically compile generated source-code at runtime can be using an existing compiler and linkeddynamically or, alternatively,
  • Generated source-code can beJIT compilation using Clang/LLVM.

License

CppADCodeGen is available with both theEPL andGPL licenses(suitable for both open-source and closed-source commercial projects).See epl-v10.txt and gpl3.txt for a copy of the licenses.

Requirements

CppADCodeGen is a C++14 header only library, therefore there aren't many dependencies:

  • Required:
    • CppAD (2024),
    • AC++14 compiler (such as GCC and Clang),
  • Optional:
    • Clang/LLVM (only required for JIT compilation; supported versions <= v10.0), and
    • Eigen 3 (required when DAE differentiation index reduction is used).

Runtime compilation and dynamic linking:

  • Linux

It might be very easy to support other OSes, but it is not implemented yet.

Installing

General installation

Get the sources from GitHub:

git clone https://github.com/joaoleal/CppADCodeGen.git CppADCodeGen

Create a new folder to build the project:

mkdir cppadcg-build

Build the project (no compilation of C/C++ occurs, just generation of header files):

cd cppadcg-buildcmake ../CppADCodeGen

Either install the project in your system:

make install

or to some other folder:

make DESTDIR=someotherfolder install

Debian/Ubuntu

A debian installation package can be created at the root of the project.Typically, you can create the installer by just typing:

dpkg-buildpackage

It will create a debian package outside the project's folder.

Using CppADCodeGen

See thewiki.

The folder example includes some simple use cases.

Testing

Get the sources from GitHub:

git clone https://github.com/joaoleal/CppADCodeGen.git CppADCodeGen

Create a new folder for the tests:

cd make-build-debugcmake ../CppADCodeGen

Testing requiresgoogle-test (version 1.14.0) which will be downloaded from GitHub.

Then compile the tests:

make build_tests

Run the complete set of tests:

maketest

Ifvalgrind is available in your system, CppADCodeGen will also perform memory checks which canlead to a very lengthy test execution.It is possible to disable memory validations by turning off the CMake optionUSE_VALGRIND.For instance, by calling the following command before running the tests:

cmake -DUSE_VALGRIND=OFF ../CppADCodeGen

Repository Content

DirectoriesDescription
binHelper shell and sed scripts used for CppAD development.
bugDirectory containing demonstration of known bugs (may be empty).
debianDebian package creation files (Linux).
docHolds files for generation of developer documentation.
exampleCppADCodegen example files are here.
includeThe CppADCodeGen header files.
pkgconfigpkg-config support files.
pythonPretty printers for GDB (debugging).
speedContains some benchmarks for CppADCodeGen.
testContains tests for CppADCodeGen.
FilesDescription
AUTHORSStatement of authorship and copyright.
CMakeLists.txtCppADCodeGen CMake input file.
COPYINGStatement of user license to use software.
epl-v10.txtA copy of the Eclipse Public License version 1.
gpl3.txtA copy of the GNU General Public License version 3.
INSTALLPoints to this file.

[8]ページ先頭

©2009-2025 Movatter.jp