autodiff

C++ library enabling automatic differentiation for mathematical computations

brewmacoslinux
Try with needOr install directly
Source

About

Automatic differentiation made easier for C++

Commands

autodiff

Examples

Include autodiff header in C++ project for automatic differentiation$ clang++ -I$(brew --prefix autodiff)/include myprogram.cpp -o myprogram
Use autodiff to compute derivatives of mathematical functions automatically$ cat > derivative.cpp << 'EOF' #include <autodiff/forward/dual.hpp> using namespace autodiff; int main() { dual x = 2.0; dual y = x * x + 2*x + 1; std::cout << "f(x)=" << y.val << ", f'(x)=" << y.grad << std::endl; } EOF clang++ -I$(brew --prefix autodiff)/include derivative.cpp -o derivative && ./derivative
Link autodiff library in CMake project for gradient computation$ echo 'find_package(autodiff REQUIRED) target_link_libraries(myapp autodiff::autodiff)' >> CMakeLists.txt