CoDiPack (Code Differentiation Package) is a tool for gradient evaluation in computer programs. It supports the features:
The design principle for CoDiPack is that it is easy to use. However, it also gives experienced AD developers the full access to all the data structures.
The Scientific Computing Group at the TU Kaiserslautern develops CoDiPack and will enhance and extend CoDiPack in the future.
CoDiPack is a header only library. The only file the user needs to include is
codi.hpp. The only other requirement is a c++11 compliant compiler where one usually needs to specify '–std=c++11' in compiler arguments. CoDiPack is tested with gcc and the intel compiler.
codi.hpp defines several datatypes. The most important ones are:
The full type list of the file 'codi.hpp' is:
The reverse types support various use cases. The regular type codi::RealReverse is the most used type and provides the most common use case. This type can be used in c-like memory operation like memset and memcpy. The 'Index' variant of the reverse type uses an indexing scheme that reuses freed indices and therefore reduces the amount of memory that is needed. This type is no longer compatible with c-like memory operations. The 'Primal' variants implement a different strategy for storing the data. Instead of storing the partial derivatives for each statement, they store the primal values. This change reduces the required memory of the 'Primal' types. The 'Unchecked' variant is also an implementation of the reverse mode of AD but it should only be used by experienced users. This type performs no bounds checking for the memory access. For each type there is also a type with single precession e.g. codi::RealForwardFloat. The 'Vec' variant implements the vector mode of the corresponding AD type. The dimension is fixed and can be defined via the template argument.
A very small and simple example for the usage of the RealForward type is the code:
It is compiled with
for the gcc compiler or with
for the intel compiler.
Please visit the tutorial page for further information.