/* test_optm3.c */ #include #include "optm3.h" #include "spiral.h" #undef abs #define abs(a) ((a)<0.0? (-(a)):(a)) static double f(double x, double y, double z); int main(int argc, char *argv[]) { double X[3]; /* three parameters being optimized */ int n = 3; /* size */ int i; double final; int cnt; int limit = 600; int maxcnt; double step; double tol = 0.001; printf("test_optm3.c running\n"); X[0] = 2.0; X[1] = 2.0; X[2] = 2.0; final = 1000.0; /* just big to start */ cnt = 0; maxcnt = 1; /* get return every iteration */ step = 0.05; while(cnt tol) { optm3(&X[0], &X[1], &X[2], /* initial and returned optimum */ &final, /* returned value, err */ &cnt, maxcnt, /* number and max of evaluations */ 0.001, /* get v to this tolerance */ &step, 0.000001, /* start and minimum xyz step size */ -5.0, 5.0, /* range for x */ -5.0, 5.0, /* range for y */ -5.0, 5.0, /* range for z */ f); /* function to be evaluated */ printf("cnt=%d, err=%g, X[0]=%10.7f, X[1]=%10.7f, X[2]=%10.7f \n", cnt, final, X[0], X[1], X[2]); } if(cnt