/* optmiz.c CCMATH mathematics library source code. * * Copyright (C) 2000 Daniel A. Atkinson All rights reserved. * This code may be redistributed under the terms of the GNU library * public license (LGPL). ( See the lgpl.license file for details.) * ------------------------------------------------------------------------ */ #include #define Abs(x) ( ((x)<0.)?-(x):(x) ) static double fev(double *x,double *py,double *ps, double c,double (*func)()); int optmiz(double *x,int n,double (*func)(),double de,double test,int max) { double fs,fp,fa,fb,fc,s,sa,sb,sc; int k,m; double *pd,*ps,*py,*pg,*ph,*p,*q,*r; pd=(double *)calloc(n*(n+4),sizeof(double)); ps=pd+n; py=ps+n; pg=py+n; ph=pg+n; for(p=ph,q=ph+n*n; pfb) break; fa=fb; sa=sb; fb=fc; sb=sc; sc*=2.; } if(sc==1.){ sb=.5; for(;;){ if((fb=fev(x,py,ps,sb,func))