AutoDiff is a small utility library that provides floating point expressions with automatic differentiation support.
Installation
To build AutoDiff from source you will need a C++14 compiler and CMake.
Usage
Here's a simple usage example to get you started:
#include <AutoDiff.hpp>
#include <cstdio>
int main() {
const auto g = AutoDiff::DFloat::val(9.81);
const auto t = AutoDiff::DFloat::var(10.0);
const auto z = g / 2.0 * pow(t, 2.0);
std::printf("z = %g\n", z.value());
const auto z1 = z.derive(t);
std::printf("z' = %g\n", z1.value());
const auto z2 = z1.derive(t);
std::printf("z'' = %g\n", z2.value());
return 0;
}
The output from the program should be this:
z = 490.5
z' = 98.1
z'' = 9.81