This is an automated email from the ASF dual-hosted git repository.

aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-numbers.git

commit abba5dabdd6d800f915a4147af7987ecb9b2d20d
Author: aherbert <[email protected]>
AuthorDate: Thu Dec 16 16:32:51 2021 +0000

    Remove dependency on Precision
    
    Since this was used to compare to zero the method can be more simply
    implemented:
    
    Precision.equals(b, 0) == Math.abs(b) <= Double.MIN_VALUE
---
 commons-numbers-rootfinder/pom.xml                          |  7 -------
 .../org/apache/commons/numbers/rootfinder/BrentSolver.java  | 13 +++++++++++--
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/commons-numbers-rootfinder/pom.xml 
b/commons-numbers-rootfinder/pom.xml
index 43ebe4f..f797818 100644
--- a/commons-numbers-rootfinder/pom.xml
+++ b/commons-numbers-rootfinder/pom.xml
@@ -40,11 +40,4 @@
     <numbers.parent.dir>${basedir}/..</numbers.parent.dir>
   </properties>
 
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-numbers-core</artifactId>
-    </dependency>
-  </dependencies>
-
 </project>
diff --git 
a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java
 
b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java
index ad58019..ad80fa5 100644
--- 
a/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java
+++ 
b/commons-numbers-rootfinder/src/main/java/org/apache/commons/numbers/rootfinder/BrentSolver.java
@@ -17,7 +17,6 @@
 package org.apache.commons.numbers.rootfinder;
 
 import java.util.function.DoubleUnaryOperator;
-import org.apache.commons.numbers.core.Precision;
 
 /**
  * This class implements the <a 
href="http://mathworld.wolfram.com/BrentsMethod.html";>
@@ -185,7 +184,7 @@ public class BrentSolver {
             final double m = 0.5 * (c - b);
 
             if (Math.abs(m) <= tol ||
-                Precision.equals(fb, 0))  {
+                equalsZero(fb))  {
                 return b;
             }
             if (Math.abs(e) < tol ||
@@ -249,4 +248,14 @@ public class BrentSolver {
             }
         }
     }
+
+    /**
+     * Return true if the value is within 1 ULP of zero.
+     *
+     * @param value Value
+     * @return true if zero within a 1 ULP tolerance
+     */
+    private static boolean equalsZero(double value) {
+        return Math.abs(value) <= Double.MIN_VALUE;
+    }
 }

Reply via email to