index 8a4948c..4c58735 100644 --- AmberTools/src/sff/conjgrad.c +++ AmberTools/src/sff/conjgrad.c @@ -43,6 +43,7 @@ int conjgrad( REAL_T x[], int *n, REAL_T *f, int ret_val; REAL_T r__1, r__2, r__3; REAL_T dgrad; + REAL_T tconjgrad1, t1, t2; REAL_T gama, beta, fmin, gmin, dfpr, gnew; REAL_T step, work, finit, ginit, gsqrd, gspln; @@ -53,6 +54,9 @@ int conjgrad( REAL_T x[], int *n, REAL_T *f, int iterfm, iterrs, iretry, ier; int ncopy; + t1 = seconds(); + tconjgrad1 = t1; + /* All arrays, even the x array, will be indexed from 1 to *n. */ --x; @@ -85,10 +89,18 @@ int conjgrad( REAL_T x[], int *n, REAL_T *f, niterm1 = niter - 1; + t2 = seconds(); + *tconjgradOther += t2 - t1; + t1 = t2; + *f = ( *func )( &x[ 1 ], &g[ 1 ], &niterm1 ); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ + t2 = seconds(); + *tconjgradMME += t2 - t1; + t1 = t2; + if (niter >= 2) { goto L30; } @@ -117,7 +129,7 @@ int conjgrad( REAL_T x[], int *n, REAL_T *f, } else { fch = *f - fmin; - if (fch < (REAL_T)0. || (fch == (REAL_T)0. && gnew / gmin >= (REAL_T)-1.)) { + if (fch < (REAL_T)0. || fch == (REAL_T)0. && gnew / gmin >= (REAL_T)-1.) { fmin = *f; gsqrd = sum; nfopt = niter; @@ -260,6 +272,9 @@ int conjgrad( REAL_T x[], int *n, REAL_T *f, if( ier == 0 ) ret_val = niter; else ret_val = ier; + t2 = seconds(); + *tconjgradOther += t2 - t1; + *tconjgrad += t2 - tconjgrad1; return ret_val; }