You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ah...@apache.org on 2022/07/15 16:28:58 UTC
[commons-math] 02/02: Use Complex.ZERO.
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-math.git
commit 0bf33a4fc13474835414a24c80d50cc7710eaf49
Author: aherbert <ah...@apache.org>
AuthorDate: Fri Jul 15 17:28:33 2022 +0100
Use Complex.ZERO.
This does not change the equals comparison. Note that this will not
detect sign differences, e.g. (0.0, 0.0) == (-0.0, 0.0) and a tolerance
may be required for more robustness.
---
.../apache/commons/math4/legacy/analysis/solvers/LaguerreSolver.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolver.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolver.java
index e0dcc37b7..24afe0b7f 100644
--- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolver.java
+++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/analysis/solvers/LaguerreSolver.java
@@ -368,7 +368,8 @@ public class LaguerreSolver extends AbstractPolynomialSolver {
final Complex denominator = dplus.abs() > dminus.abs() ? dplus : dminus;
// Perturb z if denominator is zero, for instance,
// p(x) = x^3 + 1, z = 0.
- if (denominator.equals(Complex.ofCartesian(0.0, 0.0))) {
+ // This uses exact equality to zero. A tolerance may be required here.
+ if (denominator.equals(Complex.ZERO)) {
z = z.add(Complex.ofCartesian(absoluteAccuracy, absoluteAccuracy));
oldz = Complex.ofCartesian(Double.POSITIVE_INFINITY,
Double.POSITIVE_INFINITY);