1234567891011121314151617181920212223242526272829
#include "nr3.h" #include "mins_ndim.h" #include "mins.h" #include <iostream> int main() { struct Funcd { Doub operator() (VecDoub_I &x) { return x[0]*x[0]+x[1]*x[1]; } void df(VecDoub_I &x, VecDoub_O &deriv) { deriv[0]=2.0*x[0]; deriv[1]=2.0*x[1]; } }; Funcd funcd; Frprmn<Funcd> frprmn(funcd); VecDoub p; p[0]=1; p[1]=1; p=frprmn.minimize(p); }