protected boolean bracket ( ) { // System.out.println("------------- bracket"); // the value of alpha was passed in function . setInput ( stp ) ; if ( mode != 0 ) { fp = function . computeFunction ( ) ; gp = Double . NaN ; } else { mode = 1 ; } // check for upper bounds if ( fp > valueZero + ftol * stp * derivZero ) { setModeToSection ( stprev , fprev , stp ) ; return false ; } if ( fp >= fprev ) { setModeToSection ( stprev , fprev , stp ) ; return false ; } gp = function . computeDerivative ( ) ; if ( Math . abs ( gp ) <= - gtol * derivZero ) { return true ; } // if the derivative is positive it is on the other side of the dip and has // been bracketed if ( gp >= 0 ) { setModeToSection ( stp , fp , stprev ) ; return false ; } if ( stmax <= 2 * stp - stprev ) { stprev = stp ; gprev = gp ; fprev = fp ; stp = stmax ; updated = true ; } else { // use interpolation to pick the next sample point double temp = stp ; stp = interpolate ( 2 * stp - stprev , Math . min ( stpmax , stp + t1 * ( stp - stprev ) ) ) ; stprev = temp ; gprev = gp ; fprev = fp ; updated = true ; } // see if it is taking significant steps if ( checkSmallStep ( ) ) { if ( verbose != null ) verbose . println ( "WARNING: Small steps" ) ; return true ; } return false ; }
Searches for an upper bound .