You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by er...@apache.org on 2018/02/28 02:45:52 UTC
[3/5] [math] MATH-1416: Depend on "Commons Numbers".
MATH-1416: Depend on "Commons Numbers".
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/56b28f34
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/56b28f34
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/56b28f34
Branch: refs/heads/master
Commit: 56b28f34d934efa0db1b753e83161fe12f8e44b1
Parents: db37a6d
Author: Gilles <er...@apache.org>
Authored: Wed Feb 28 02:41:47 2018 +0100
Committer: Gilles <er...@apache.org>
Committed: Wed Feb 28 02:41:47 2018 +0100
----------------------------------------------------------------------
.../math4/analysis/solvers/LaguerreSolver.java | 4 +--
.../analysis/solvers/LaguerreSolverTest.java | 37 ++++++++++++++++++--
2 files changed, 36 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/56b28f34/src/main/java/org/apache/commons/math4/analysis/solvers/LaguerreSolver.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/analysis/solvers/LaguerreSolver.java b/src/main/java/org/apache/commons/math4/analysis/solvers/LaguerreSolver.java
index ab01885..f0ecdc8 100644
--- a/src/main/java/org/apache/commons/math4/analysis/solvers/LaguerreSolver.java
+++ b/src/main/java/org/apache/commons/math4/analysis/solvers/LaguerreSolver.java
@@ -16,9 +16,9 @@
*/
package org.apache.commons.math4.analysis.solvers;
+import org.apache.commons.numbers.complex.Complex;
+import org.apache.commons.numbers.complex.ComplexUtils;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
-import org.apache.commons.math4.complex.Complex;
-import org.apache.commons.math4.complex.ComplexUtils;
import org.apache.commons.math4.exception.NoBracketingException;
import org.apache.commons.math4.exception.NoDataException;
import org.apache.commons.math4.exception.NullArgumentException;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/56b28f34/src/test/java/org/apache/commons/math4/analysis/solvers/LaguerreSolverTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/analysis/solvers/LaguerreSolverTest.java b/src/test/java/org/apache/commons/math4/analysis/solvers/LaguerreSolverTest.java
index 6100710..caee1cc 100644
--- a/src/test/java/org/apache/commons/math4/analysis/solvers/LaguerreSolverTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/solvers/LaguerreSolverTest.java
@@ -16,10 +16,10 @@
*/
package org.apache.commons.math4.analysis.solvers;
-import org.apache.commons.math4.TestUtils;
+import org.apache.commons.numbers.complex.Complex;
+import org.apache.commons.numbers.core.Precision;
import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math4.analysis.solvers.LaguerreSolver;
-import org.apache.commons.math4.complex.Complex;
import org.apache.commons.math4.exception.NoBracketingException;
import org.apache.commons.math4.exception.NumberIsTooLargeException;
import org.apache.commons.math4.util.FastMath;
@@ -129,7 +129,7 @@ public final class LaguerreSolverTest {
new Complex(0.5, -0.5 * FastMath.sqrt(3.0)) }) {
final double tolerance = FastMath.max(solver.getAbsoluteAccuracy(),
FastMath.abs(expected.abs() * solver.getRelativeAccuracy()));
- TestUtils.assertContains(result, expected, tolerance);
+ assertContains(result, expected, tolerance);
}
}
@@ -157,4 +157,35 @@ public final class LaguerreSolverTest {
// expected
}
}
+
+ /**
+ * Fails iff values does not contain a number within epsilon of z.
+ *
+ * @param msg message to return with failure
+ * @param values complex array to search
+ * @param z value sought
+ * @param epsilon tolerance
+ */
+ private static void assertContains(String msg, Complex[] values,
+ Complex z, double epsilon) {
+ for (Complex value : values) {
+ if (Precision.equals(value.getReal(), z.getReal(), epsilon) &&
+ Precision.equals(value.getImaginary(), z.getImaginary(), epsilon)) {
+ return;
+ }
+ }
+ Assert.fail(msg + " Unable to find " + z);
+ }
+
+ /**
+ * Fails iff values does not contain a number within epsilon of z.
+ *
+ * @param values complex array to search
+ * @param z value sought
+ * @param epsilon tolerance
+ */
+ private static void assertContains(Complex[] values,
+ Complex z, double epsilon) {
+ assertContains(null, values, z, epsilon);
+ }
}