I am trying to use the autodiff
package.
I tried to implement their very first example. My code follows:
#include <iostream>
// autodiff include
#include <autodiff/forward/dual.hpp>
using namespace autodiff;
// The single-variable function for which derivatives are needed
dual f(dual x)
{
return 1 + x + x*x + 1/x + log(x);
}
int main()
{
dual x = 2.0; // the input variable x
dual u = f(x); // the output variable u
double dudx = derivative(f, wrt(x), at(x)); // evaluate the derivative du/dx
std::cout << "u = " << u << std::endl; // print the evaluated output u
std::cout << "du/dx = " << dudx << std::endl; // print the evaluated derivative du/dx
}
I compile it from my Ubuntu terminal using g++ autodiff2.cpp -std=c++1z
, but I get the following error:
autodiff2.cpp:4:10: fatal error: autodiff/forward/dual.hpp: No such file or directory
4 | #include <autodiff/forward/dual.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
How can I solve this?