[ADMB Users] How to use Autodif as a regular external C++ library?
dave fournier
davef at otter-rsch.com
Sat Nov 3 10:55:16 PDT 2012
Thinking about this a bit more you should look at the shell script for
compiling for your platform. It will tell you what macros to define and what
libraries to link with for the safe and optimized versions.
Then the boiler plate you need in your C++ code is something like what I have below.
main()
{
// whatever
gradient_structure gs(100000000); // makes the data strctures for AD
int nvar=1000; // 1000 independent variablesu
dvector g(1,n); // this will hold the gradient vector
independent_variables x(1,n);
dvar_vector vx=dvar_vector(x);
// the code for evaluating the function
gradcalc(nvar,g); // calculates the gradient
cout << g << endl; // take a look at the gradient
}
More information about the Users
mailing list