> > URL: http://svn.apache.org/viewvc?rev=995035&view=rev > > Log: > > Removed strict equality comparison. > > In some rare cases, strict equality comparison is desired (I don't know > if it is the case here). In these cases, findbugs can be configured to > ignore these cases, see the findbugs-exclude-filter.xml file for an example.
I don't know whether it is one of those rare cases. The algorithm description in ALGOL uses the "=" sign while the FORTRAN implementation (in the appendix) works around the problem by inversing the checks: 170 IF ((FU.GT.FW).AND.(W.NE.X)) GO TO 180 V = W FV = FW W = U FW = FU GO TO 10 180 etc. > > Modified: > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java > > URL: > > http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java?rev=995035&r1=995034&r2=995035&view=diff > > ============================================================================== > > --- > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java > > (original) > > +++ > > commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/univariate/BrentOptimizer.java > > Wed Sep 8 12:51:38 2010 > > @@ -17,6 +17,7 @@ > > package org.apache.commons.math.optimization.univariate; > > > > import org.apache.commons.math.FunctionEvaluationException; > > +import org.apache.commons.math.util.MathUtils; > > import org.apache.commons.math.util.FastMath; > > import org.apache.commons.math.exception.NumberIsTooSmallException; > > import org.apache.commons.math.exception.NotStrictlyPositiveException; > > @@ -219,12 +220,15 @@ public class BrentOptimizer extends Abst > > } else { > > b = u; > > } > > - if (fu <= fw || w == x) { > > + if (fu <= fw || > > + MathUtils.equals(w, x)) { > > v = w; > > fv = fw; > > w = u; > > fw = fu; > > - } else if (fu <= fv || v == x || v == w) { > > + } else if (fu <= fv || > > + MathUtils.equals(v, x) || > > + MathUtils.equals(v, w)) { > > v = u; > > fv = fu; > > } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org