Changeset 12476 for issm/trunk-jpl/src/c/shared/Numerics/BrentSearch.cpp
- Timestamp:
- 06/20/12 12:15:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/shared/Numerics/BrentSearch.cpp
r9761 r12476 16 16 #include <float.h> 17 17 18 void BrentSearch( double* psearch_scalar,double* pJ,OptPars* optpars,double (*f)(double,OptArgs*), OptArgs* optargs){18 void BrentSearch(IssmDouble* psearch_scalar,IssmDouble* pJ,OptPars* optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs* optargs){ 19 19 20 20 /* This routine is optimizing a given function using Brent's method … … 22 22 23 23 /*Intermediary*/ 24 double si,gold,intervalgold,oldintervalgold;25 double parab_num,parab_den;26 double distance,cm_jump;27 double fxmax,fxmin,fxbest;28 double fx,fx1,fx2;29 double xmax,xmin,xbest;30 double x,x1,x2,xm;31 double tol1,tol2,seps;32 double tolerance=1.e-4;24 IssmDouble si,gold,intervalgold,oldintervalgold; 25 IssmDouble parab_num,parab_den; 26 IssmDouble distance,cm_jump; 27 IssmDouble fxmax,fxmin,fxbest; 28 IssmDouble fx,fx1,fx2; 29 IssmDouble xmax,xmin,xbest; 30 IssmDouble x,x1,x2,xm; 31 IssmDouble tol1,tol2,seps; 32 IssmDouble tolerance=1.e-4; 33 33 int maxiter,iter; 34 34 bool loop=true,goldenflag; … … 58 58 59 59 /*initialize optimization variables*/ 60 seps=sqrt(DBL_EPSILON); //precision of a double60 seps=sqrt(DBL_EPSILON); //precision of a IssmDouble 61 61 distance=0.0; //new_x=old_x + distance 62 62 gold=0.5*(3.0-sqrt(5.0)); //gold = 1 - golden ratio
Note:
See TracChangeset
for help on using the changeset viewer.