Skip to content
Joao Rui Leal edited this page Feb 19, 2022 · 25 revisions

Welcome to the CppADCodeGen wiki!

CppADCodeGen aims to extend the CppAD library in order to perform hybrid automatic differentiation, that is, to use operator overloading and produce source code.

Features

Some key features of this library include:

  • source code generation for any CppAD method;
  • production of human-readable source code;
  • source code generation for multiple languages;
  • elimination of any unneeded operation/variable.

A graph like representation of operations is generated independently of the source code generation methods which allows producing source code for different languages.

Advantages of using CppADCodeGen

Here are some of the advantages of using CppADCodeGen:

  • significantly faster differential information evaluation (up to 3 orders of magnitude);
  • generate a Latex file (for generating PDFs) or web page with your model;
  • number of operations reduction;
  • use CppADCodeGen to generate an operation graph and then choose at runtime to use either natively compiled code, CppAD, or Adol-C.

Disadvantages of using CppADCodeGen

There are also some disadvantages:

  • significantly longer preparation times (the model needs to be compiled, but this can be done only once);
  • not 100% of the features in CppAD are available;
  • limited support in Windows.

How to use CppADCodeGen

For most cases, when the aim is to just execute you model, the utility classes should be used to compile and execute your source code. Please see the LibGeneration page for an example. Here, C code is generated for your model and associated derivatives, compiled into a library, loaded dynamically, and then executed.

Currently, there is support for the C language, Latex, MathML, and Dot, however additional languages can be easily added in the future. Advanced user might like to see the following DirectSourceGeneration.