Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 82190 invoked from network); 29 Aug 2010 21:52:05 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Aug 2010 21:52:05 -0000 Received: (qmail 56506 invoked by uid 500); 29 Aug 2010 21:52:05 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 56440 invoked by uid 500); 29 Aug 2010 21:52:04 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 56433 invoked by uid 99); 29 Aug 2010 21:52:04 -0000 Received: from Unknown (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Aug 2010 21:52:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Aug 2010 21:51:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F34D52388B71; Sun, 29 Aug 2010 21:49:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r990655 [8/10] - in /commons/proper/math/branches/MATH_2_X: ./ src/main/java/org/apache/commons/math/analysis/ src/main/java/org/apache/commons/math/analysis/integration/ src/main/java/org/apache/commons/math/analysis/interpolation/ src/mai... Date: Sun, 29 Aug 2010 21:49:53 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100829214957.F34D52388B71@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/MullerSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/MullerSolverTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/MullerSolverTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/MullerSolverTest.java Sun Aug 29 21:49:40 2010 @@ -21,6 +21,7 @@ import org.apache.commons.math.analysis. import org.apache.commons.math.analysis.QuinticFunction; import org.apache.commons.math.analysis.SinFunction; import org.apache.commons.math.analysis.UnivariateRealFunction; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -48,15 +49,15 @@ public final class MullerSolverTest exte UnivariateRealSolver solver = new MullerSolver(f); double min, max, expected, result, tolerance; - min = 3.0; max = 4.0; expected = Math.PI; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + min = 3.0; max = 4.0; expected = FastMath.PI; + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(min, max); assertEquals(expected, result, tolerance); min = -1.0; max = 1.5; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(min, max); assertEquals(expected, result, tolerance); } @@ -71,20 +72,20 @@ public final class MullerSolverTest exte double min, max, expected, result, tolerance; min = -0.4; max = 0.2; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(min, max); assertEquals(expected, result, tolerance); min = 0.75; max = 1.5; expected = 1.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(min, max); assertEquals(expected, result, tolerance); min = -0.9; max = -0.2; expected = -0.5; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(min, max); assertEquals(expected, result, tolerance); } @@ -97,15 +98,15 @@ public final class MullerSolverTest exte UnivariateRealSolver solver = new MullerSolver(); double min, max, expected, result, tolerance; - min = 3.0; max = 4.0; expected = Math.PI; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + min = 3.0; max = 4.0; expected = FastMath.PI; + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -1.0; max = 1.5; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } @@ -118,15 +119,15 @@ public final class MullerSolverTest exte MullerSolver solver = new MullerSolver(); double min, max, expected, result, tolerance; - min = 3.0; max = 4.0; expected = Math.PI; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + min = 3.0; max = 4.0; expected = FastMath.PI; + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); min = -1.0; max = 1.5; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); } @@ -140,20 +141,20 @@ public final class MullerSolverTest exte double min, max, expected, result, tolerance; min = -0.4; max = 0.2; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = 0.75; max = 1.5; expected = 1.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -0.9; max = -0.2; expected = -0.5; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } @@ -167,20 +168,20 @@ public final class MullerSolverTest exte double min, max, expected, result, tolerance; min = -0.4; max = 0.2; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); min = 0.75; max = 1.5; expected = 1.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); min = -0.9; max = -0.2; expected = -0.5; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); } @@ -198,20 +199,20 @@ public final class MullerSolverTest exte double min, max, expected, result, tolerance; min = -1.0; max = 2.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -20.0; max = 10.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -50.0; max = 100.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } @@ -227,20 +228,20 @@ public final class MullerSolverTest exte double min, max, expected, result, tolerance; min = -1.0; max = 2.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); min = -20.0; max = 10.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); min = -50.0; max = 100.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve2(f, min, max); assertEquals(expected, result, tolerance); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/NewtonSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/NewtonSolverTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/NewtonSolverTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/NewtonSolverTest.java Sun Aug 29 21:49:40 2010 @@ -20,6 +20,7 @@ import org.apache.commons.math.MathExcep import org.apache.commons.math.analysis.DifferentiableUnivariateRealFunction; import org.apache.commons.math.analysis.QuinticFunction; import org.apache.commons.math.analysis.SinFunction; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -36,10 +37,10 @@ public final class NewtonSolverTest exte UnivariateRealSolver solver = new NewtonSolver(f); result = solver.solve(3, 4); - assertEquals(result, Math.PI, solver.getAbsoluteAccuracy()); + assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy()); result = solver.solve(1, 4); - assertEquals(result, Math.PI, solver.getAbsoluteAccuracy()); + assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy()); assertEquals(result, solver.getResult(), 0); assertTrue(solver.getIterationCount() > 0); @@ -54,10 +55,10 @@ public final class NewtonSolverTest exte UnivariateRealSolver solver = new NewtonSolver(); result = solver.solve(f, 3, 4); - assertEquals(result, Math.PI, solver.getAbsoluteAccuracy()); + assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy()); result = solver.solve(f, 1, 4); - assertEquals(result, Math.PI, solver.getAbsoluteAccuracy()); + assertEquals(result, FastMath.PI, solver.getAbsoluteAccuracy()); assertEquals(result, solver.getResult(), 0); assertTrue(solver.getIterationCount() > 0); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/RiddersSolverTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/RiddersSolverTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/RiddersSolverTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/RiddersSolverTest.java Sun Aug 29 21:49:40 2010 @@ -21,6 +21,7 @@ import org.apache.commons.math.analysis. import org.apache.commons.math.analysis.QuinticFunction; import org.apache.commons.math.analysis.SinFunction; import org.apache.commons.math.analysis.UnivariateRealFunction; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -46,15 +47,15 @@ public final class RiddersSolverTest ext UnivariateRealSolver solver = new RiddersSolver(f); double min, max, expected, result, tolerance; - min = 3.0; max = 4.0; expected = Math.PI; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + min = 3.0; max = 4.0; expected = FastMath.PI; + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(min, max); assertEquals(expected, result, tolerance); min = -1.0; max = 1.5; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(min, max); assertEquals(expected, result, tolerance); } @@ -67,15 +68,15 @@ public final class RiddersSolverTest ext UnivariateRealSolver solver = new RiddersSolver(); double min, max, expected, result, tolerance; - min = 3.0; max = 4.0; expected = Math.PI; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + min = 3.0; max = 4.0; expected = FastMath.PI; + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -1.0; max = 1.5; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } @@ -89,20 +90,20 @@ public final class RiddersSolverTest ext double min, max, expected, result, tolerance; min = -0.4; max = 0.2; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = 0.75; max = 1.5; expected = 1.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -0.9; max = -0.2; expected = -0.5; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } @@ -116,20 +117,20 @@ public final class RiddersSolverTest ext double min, max, expected, result, tolerance; min = -1.0; max = 2.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -20.0; max = 10.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); min = -50.0; max = 100.0; expected = 0.0; - tolerance = Math.max(solver.getAbsoluteAccuracy(), - Math.abs(expected * solver.getRelativeAccuracy())); + tolerance = FastMath.max(solver.getAbsoluteAccuracy(), + FastMath.abs(expected * solver.getRelativeAccuracy())); result = solver.solve(f, min, max); assertEquals(expected, result, tolerance); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtilsTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtilsTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolverUtilsTest.java Sun Aug 29 21:49:40 2010 @@ -22,6 +22,7 @@ import junit.framework.TestCase; import org.apache.commons.math.MathException; import org.apache.commons.math.analysis.SinFunction; import org.apache.commons.math.analysis.UnivariateRealFunction; +import org.apache.commons.math.util.FastMath; /** * @version $Revision$ $Date$ @@ -54,7 +55,7 @@ public class UnivariateRealSolverUtilsTe public void testSolveSin() throws MathException { double x = UnivariateRealSolverUtils.solve(sin, 1.0, 4.0); - assertEquals(Math.PI, x, 1.0e-4); + assertEquals(FastMath.PI, x, 1.0e-4); } public void testSolveAccuracyNull() throws MathException { @@ -71,7 +72,7 @@ public class UnivariateRealSolverUtilsTe double accuracy = 1.0e-6; double x = UnivariateRealSolverUtils.solve(sin, 1.0, 4.0, accuracy); - assertEquals(Math.PI, x, accuracy); + assertEquals(FastMath.PI, x, accuracy); } public void testSolveNoRoot() throws MathException { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexFormatAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexFormatAbstractTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexFormatAbstractTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexFormatAbstractTest.java Sun Aug 29 21:49:40 2010 @@ -23,6 +23,7 @@ import java.text.ParsePosition; import java.util.Locale; import org.apache.commons.math.util.CompositeFormat; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -337,7 +338,7 @@ public abstract class ComplexFormatAbstr public void testFormatNumber() { CompositeFormat cf = ComplexFormat.getInstance(getLocale()); - Double pi = Double.valueOf(Math.PI); + Double pi = Double.valueOf(FastMath.PI); String text = cf.format(pi); assertEquals("3" + getDecimalCharacter() + "14", text); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.complex; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.util.FastMath; import java.util.List; @@ -32,7 +33,7 @@ public class ComplexTest extends TestCas private double inf = Double.POSITIVE_INFINITY; private double neginf = Double.NEGATIVE_INFINITY; private double nan = Double.NaN; - private double pi = Math.PI; + private double pi = FastMath.PI; private Complex oneInf = new Complex(1, inf); private Complex oneNegInf = new Complex(1, neginf); private Complex infOne = new Complex(inf, 1); @@ -347,7 +348,7 @@ public class ComplexTest extends TestCas Complex z = new Complex(3, 4); Complex expected = new Complex(0.936812, -2.30551); TestUtils.assertEquals(expected, z.acos(), 1.0e-5); - TestUtils.assertEquals(new Complex(Math.acos(0), 0), + TestUtils.assertEquals(new Complex(FastMath.acos(0), 0), Complex.ZERO.acos(), 1.0e-12); } @@ -656,7 +657,7 @@ public class ComplexTest extends TestCas for (int j =0; j < 11; j++) { theta += pi /12; Complex z = ComplexUtils.polar2Complex(r, theta); - Complex sqrtz = ComplexUtils.polar2Complex(Math.sqrt(r), theta / 2); + Complex sqrtz = ComplexUtils.polar2Complex(FastMath.sqrt(r), theta / 2); TestUtils.assertEquals(sqrtz, z.sqrt(), 10e-12); } } @@ -903,25 +904,25 @@ public class ComplexTest extends TestCas assertEquals(0.0, z.getArgument(), 1.0e-12); z = new Complex(1, 1); - assertEquals(Math.PI/4, z.getArgument(), 1.0e-12); + assertEquals(FastMath.PI/4, z.getArgument(), 1.0e-12); z = new Complex(0, 1); - assertEquals(Math.PI/2, z.getArgument(), 1.0e-12); + assertEquals(FastMath.PI/2, z.getArgument(), 1.0e-12); z = new Complex(-1, 1); - assertEquals(3 * Math.PI/4, z.getArgument(), 1.0e-12); + assertEquals(3 * FastMath.PI/4, z.getArgument(), 1.0e-12); z = new Complex(-1, 0); - assertEquals(Math.PI, z.getArgument(), 1.0e-12); + assertEquals(FastMath.PI, z.getArgument(), 1.0e-12); z = new Complex(-1, -1); - assertEquals(-3 * Math.PI/4, z.getArgument(), 1.0e-12); + assertEquals(-3 * FastMath.PI/4, z.getArgument(), 1.0e-12); z = new Complex(0, -1); - assertEquals(-Math.PI/2, z.getArgument(), 1.0e-12); + assertEquals(-FastMath.PI/2, z.getArgument(), 1.0e-12); z = new Complex(1, -1); - assertEquals(-Math.PI/4, z.getArgument(), 1.0e-12); + assertEquals(-FastMath.PI/4, z.getArgument(), 1.0e-12); } @@ -929,14 +930,14 @@ public class ComplexTest extends TestCas * Verify atan2-style handling of infinite parts */ public void testGetArgumentInf() { - assertEquals(Math.PI/4, infInf.getArgument(), 1.0e-12); - assertEquals(Math.PI/2, oneInf.getArgument(), 1.0e-12); + assertEquals(FastMath.PI/4, infInf.getArgument(), 1.0e-12); + assertEquals(FastMath.PI/2, oneInf.getArgument(), 1.0e-12); assertEquals(0.0, infOne.getArgument(), 1.0e-12); - assertEquals(Math.PI/2, zeroInf.getArgument(), 1.0e-12); + assertEquals(FastMath.PI/2, zeroInf.getArgument(), 1.0e-12); assertEquals(0.0, infZero.getArgument(), 1.0e-12); - assertEquals(Math.PI, negInfOne.getArgument(), 1.0e-12); - assertEquals(-3.0*Math.PI/4, negInfNegInf.getArgument(), 1.0e-12); - assertEquals(-Math.PI/2, oneNegInf.getArgument(), 1.0e-12); + assertEquals(FastMath.PI, negInfOne.getArgument(), 1.0e-12); + assertEquals(-3.0*FastMath.PI/4, negInfNegInf.getArgument(), 1.0e-12); + assertEquals(-FastMath.PI/2, oneNegInf.getArgument(), 1.0e-12); } /** Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexUtilsTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexUtilsTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexUtilsTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/complex/ComplexUtilsTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.complex; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -29,7 +30,7 @@ public class ComplexUtilsTest extends Te private double inf = Double.POSITIVE_INFINITY; private double negInf = Double.NEGATIVE_INFINITY; private double nan = Double.NaN; - private double pi = Math.PI; + private double pi = FastMath.PI; private Complex negInfInf = new Complex(negInf, inf); private Complex infNegInf = new Complex(inf, negInf); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java Sun Aug 29 21:49:40 2010 @@ -17,6 +17,8 @@ package org.apache.commons.math.distribution; +import org.apache.commons.math.util.FastMath; + /** * Test cases for CauchyDistribution. * Extends ContinuousDistributionAbstractTest. See class javadoc for @@ -83,14 +85,14 @@ public class CauchyDistributionTest exte public void testMedian() { CauchyDistribution distribution = (CauchyDistribution) getDistribution(); - double expected = Math.random(); + double expected = FastMath.random(); distribution.setMedian(expected); assertEquals(expected, distribution.getMedian(), 0.0); } public void testScale() { CauchyDistribution distribution = (CauchyDistribution) getDistribution(); - double expected = Math.random(); + double expected = FastMath.random(); distribution.setScale(expected); assertEquals(expected, distribution.getScale(), 0.0); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java Sun Aug 29 21:49:40 2010 @@ -19,6 +19,7 @@ package org.apache.commons.math.distribu import junit.framework.TestCase; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.util.FastMath; /** * Abstract base class for {@link ContinuousDistribution} tests. @@ -223,8 +224,8 @@ public abstract class ContinuousDistribu (cumulativeTestPoints[i], cumulativeTestPoints[i]), tolerance); // check that P(a < X < b) = P(X < b) - P(X < a) - double upper = Math.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]); - double lower = Math.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]); + double upper = FastMath.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]); + double lower = FastMath.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]); double diff = distribution.cumulativeProbability(upper) - distribution.cumulativeProbability(lower); double direct = distribution.cumulativeProbability(lower, upper); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java Sun Aug 29 21:49:40 2010 @@ -16,6 +16,8 @@ */ package org.apache.commons.math.distribution; +import org.apache.commons.math.util.FastMath; + /** * Test cases for ExponentialDistribution. * Extends ContinuousDistributionAbstractTest. See class javadoc for @@ -94,8 +96,8 @@ public class ExponentialDistributionTest assertEquals(0.0, d1.density(-1e-9)); assertEquals(1.0, d1.density(0.0)); assertEquals(0.0, d1.density(1000.0)); - assertEquals(Math.exp(-1), d1.density(1.0)); - assertEquals(Math.exp(-2), d1.density(2.0)); + assertEquals(FastMath.exp(-1), d1.density(1.0)); + assertEquals(FastMath.exp(-2), d1.density(2.0)); ExponentialDistribution d2 = new ExponentialDistributionImpl(3); assertEquals(1/3.0, d2.density(0.0)); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java Sun Aug 29 21:49:40 2010 @@ -17,6 +17,7 @@ package org.apache.commons.math.distribution; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -212,8 +213,8 @@ public abstract class IntegerDistributio cumulativeTestPoints[i], cumulativeTestPoints[i + 1]), distribution.cumulativeProbability(arg, arg2), tolerance); - arg = arg - Math.random(); - arg2 = arg2 + Math.random(); + arg = arg - FastMath.random(); + arg2 = arg2 + FastMath.random(); assertEquals("Inconsistent probability for discrete range " + "[ " + arg + "," + arg2 + " ]", distribution.cumulativeProbability( Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.distribution; import org.apache.commons.math.MathException; +import org.apache.commons.math.util.FastMath; /** * Test cases for NormalDistribution. @@ -121,7 +122,7 @@ public class NormalDistributionTest exte } public void testSetMean() throws Exception { - double mu = Math.random(); + double mu = FastMath.random(); NormalDistribution distribution = (NormalDistribution) getDistribution(); distribution.setMean(mu); verifyQuantiles(); @@ -133,7 +134,7 @@ public class NormalDistributionTest exte } public void testSetStandardDeviation() throws Exception { - double sigma = 0.1d + Math.random(); + double sigma = 0.1d + FastMath.random(); NormalDistribution distribution = (NormalDistribution) getDistribution(); distribution.setStandardDeviation(sigma); assertEquals(sigma, distribution.getStandardDeviation(), 0); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java Sun Aug 29 21:49:40 2010 @@ -17,6 +17,7 @@ package org.apache.commons.math.distribution; import org.apache.commons.math.MathException; +import org.apache.commons.math.util.FastMath; /** * PoissonDistributionTest @@ -152,7 +153,7 @@ public class PoissonDistributionTest ext double x = mean * 2.0; double dx = x / 10.0; double p = Double.NaN; - double sigma = Math.sqrt(mean); + double sigma = FastMath.sqrt(mean); while (x >= 0) { try { p = dist.cumulativeProbability(x); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java Sun Aug 29 21:49:40 2010 @@ -17,6 +17,8 @@ package org.apache.commons.math.distribution; +import org.apache.commons.math.util.FastMath; + /** * Test cases for WeibullDistribution. * Extends ContinuousDistributionAbstractTest. See class javadoc for @@ -74,14 +76,14 @@ public class WeibullDistributionTest ext public void testAlpha() { WeibullDistribution distribution = (WeibullDistribution) getDistribution(); - double expected = Math.random(); + double expected = FastMath.random(); distribution.setShape(expected); assertEquals(expected, distribution.getShape(), 0.0); } public void testBeta() { WeibullDistribution distribution = (WeibullDistribution) getDistribution(); - double expected = Math.random(); + double expected = FastMath.random(); distribution.setScale(expected); assertEquals(expected, distribution.getScale(), 0.0); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/EstimatedParameterTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.estimation; import org.apache.commons.math.estimation.EstimatedParameter; +import org.apache.commons.math.util.FastMath; import junit.framework.*; @@ -67,7 +68,7 @@ public class EstimatedParameterTest } private void checkValue(double value, double expected) { - assertTrue(Math.abs(value - expected) < 1.0e-10); + assertTrue(FastMath.abs(value - expected) < 1.0e-10); } } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java Sun Aug 29 21:49:40 2010 @@ -20,6 +20,8 @@ package org.apache.commons.math.estimati import java.util.ArrayList; import java.util.HashSet; +import org.apache.commons.math.util.FastMath; + import junit.framework.TestCase; /** @@ -508,7 +510,7 @@ public class GaussNewtonEstimatorTest GaussNewtonEstimator estimator = new GaussNewtonEstimator(100, 1.0e-10, 1.0e-10); estimator.estimate(circle); double rms = estimator.getRMS(circle); - assertEquals(1.768262623567235, Math.sqrt(circle.getM()) * rms, 1.0e-10); + assertEquals(1.768262623567235, FastMath.sqrt(circle.getM()) * rms, 1.0e-10); assertEquals(69.96016176931406, circle.getRadius(), 1.0e-10); assertEquals(96.07590211815305, circle.getX(), 1.0e-10); assertEquals(48.13516790438953, circle.getY(), 1.0e-10); @@ -700,7 +702,7 @@ public class GaussNewtonEstimatorTest public double getCenterDistance() { double dx = px - circle.cx.getEstimate(); double dy = py - circle.cy.getEstimate(); - return Math.sqrt(dx * dx + dy * dy); + return FastMath.sqrt(dx * dx + dy * dy); } public double getPartialDiX() { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java Sun Aug 29 21:49:40 2010 @@ -20,6 +20,8 @@ package org.apache.commons.math.estimati import java.util.ArrayList; import java.util.HashSet; +import org.apache.commons.math.util.FastMath; + import junit.framework.TestCase; /** @@ -267,7 +269,7 @@ public class LevenbergMarquardtEstimator double initialCost = estimator.getRMS(problem); estimator.estimate(problem); assertTrue(estimator.getRMS(problem) < initialCost); - assertTrue(Math.sqrt(m.length) * estimator.getRMS(problem) > 0.6); + assertTrue(FastMath.sqrt(m.length) * estimator.getRMS(problem) > 0.6); try { estimator.getCovariances(problem); fail("an exception should have been thrown"); @@ -501,7 +503,7 @@ public class LevenbergMarquardtEstimator assertTrue(estimator.getCostEvaluations() < 10); assertTrue(estimator.getJacobianEvaluations() < 10); double rms = estimator.getRMS(circle); - assertEquals(1.768262623567235, Math.sqrt(circle.getM()) * rms, 1.0e-10); + assertEquals(1.768262623567235, FastMath.sqrt(circle.getM()) * rms, 1.0e-10); assertEquals(69.96016176931406, circle.getRadius(), 1.0e-10); assertEquals(96.07590211815305, circle.getX(), 1.0e-10); assertEquals(48.13516790438953, circle.getY(), 1.0e-10); @@ -518,8 +520,8 @@ public class LevenbergMarquardtEstimator double cx = circle.getX(); double cy = circle.getY(); double r = circle.getRadius(); - for (double d= 0; d < 2 * Math.PI; d += 0.01) { - circle.addPoint(cx + r * Math.cos(d), cy + r * Math.sin(d)); + for (double d= 0; d < 2 * FastMath.PI; d += 0.01) { + circle.addPoint(cx + r * FastMath.cos(d), cy + r * FastMath.sin(d)); } estimator = new LevenbergMarquardtEstimator(); estimator.estimate(circle); @@ -745,7 +747,7 @@ public class LevenbergMarquardtEstimator public double getCenterDistance() { double dx = px - circle.cx.getEstimate(); double dy = py - circle.cy.getEstimate(); - return Math.sqrt(dx * dx + dy * dy); + return FastMath.sqrt(dx * dx + dy * dy); } public double getPartialDiX() { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/MinpackTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/MinpackTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/MinpackTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/MinpackTest.java Sun Aug 29 21:49:40 2010 @@ -24,6 +24,7 @@ import org.apache.commons.math.estimatio import org.apache.commons.math.estimation.EstimationProblem; import org.apache.commons.math.estimation.LevenbergMarquardtEstimator; import org.apache.commons.math.estimation.WeightedMeasurement; +import org.apache.commons.math.util.FastMath; import junit.framework.*; @@ -118,11 +119,11 @@ public class MinpackTest public void testMinpackRosenbrok() { minpackTest(new RosenbrockFunction(new double[] { -1.2, 1.0 }, - Math.sqrt(24.2)), false); + FastMath.sqrt(24.2)), false); minpackTest(new RosenbrockFunction(new double[] { -12.0, 10.0 }, - Math.sqrt(1795769.0)), false); + FastMath.sqrt(1795769.0)), false); minpackTest(new RosenbrockFunction(new double[] { -120.0, 100.0 }, - 11.0 * Math.sqrt(169000121.0)), false); + 11.0 * FastMath.sqrt(169000121.0)), false); } public void testMinpackHelicalValley() { @@ -490,8 +491,8 @@ public class MinpackTest private void minpackTest(MinpackFunction function, boolean exceptionExpected) { LevenbergMarquardtEstimator estimator = new LevenbergMarquardtEstimator(); estimator.setMaxCostEval(100 * (function.getN() + 1)); - estimator.setCostRelativeTolerance(Math.sqrt(2.22044604926e-16)); - estimator.setParRelativeTolerance(Math.sqrt(2.22044604926e-16)); + estimator.setCostRelativeTolerance(FastMath.sqrt(2.22044604926e-16)); + estimator.setParRelativeTolerance(FastMath.sqrt(2.22044604926e-16)); estimator.setOrthoTolerance(2.22044604926e-16); assertTrue(function.checkTheoreticalStartCost(estimator.getRMS(function))); try { @@ -544,12 +545,12 @@ public class MinpackTest public boolean checkTheoreticalStartCost(double rms) { double threshold = costAccuracy * (1.0 + theoreticalStartCost); - return Math.abs(Math.sqrt(m) * rms - theoreticalStartCost) <= threshold; + return FastMath.abs(FastMath.sqrt(m) * rms - theoreticalStartCost) <= threshold; } public boolean checkTheoreticalMinCost(double rms) { double threshold = costAccuracy * (1.0 + theoreticalMinCost); - return Math.abs(Math.sqrt(m) * rms - theoreticalMinCost) <= threshold; + return FastMath.abs(FastMath.sqrt(m) * rms - theoreticalMinCost) <= threshold; } public boolean checkTheoreticalMinParams() { @@ -557,7 +558,7 @@ public class MinpackTest for (int i = 0; i < theoreticalMinParams.length; ++i) { double mi = theoreticalMinParams[i]; double vi = parameters[i].getEstimate(); - if (Math.abs(mi - vi) > (paramsAccuracy * (1.0 + Math.abs(mi)))) { + if (FastMath.abs(mi - vi) > (paramsAccuracy * (1.0 + FastMath.abs(mi)))) { return false; } } @@ -711,8 +712,8 @@ public class MinpackTest public LinearRank1ZeroColsAndRowsFunction(int m, int n, double x0) { super(m, buildArray(n, x0), - Math.sqrt(m + (n+1)*(n-2)*(m-2)*(m-1) * ((n+1)*(n-2)*(2*m-3) - 12) / 24.0), - Math.sqrt((m * (m + 3) - 6) / (2.0 * (2 * m - 3))), + FastMath.sqrt(m + (n+1)*(n-2)*(m-2)*(m-1) * ((n+1)*(n-2)*(2*m-3) - 12) / 24.0), + FastMath.sqrt((m * (m + 3) - 6) / (2.0 * (2 * m - 3))), null); } @@ -787,7 +788,7 @@ public class MinpackTest double x2 = parameters[1].getEstimate(); double tmpSquare = x1 * x1 + x2 * x2; double tmp1 = twoPi * tmpSquare; - double tmp2 = Math.sqrt(tmpSquare); + double tmp2 = FastMath.sqrt(tmpSquare); return new double[][] { { 100 * x2 / tmp1, -100 * x1 / tmp1, 10 }, { 10 * x1 / tmp2, 10 * x2 / tmp2, 0 }, @@ -804,12 +805,12 @@ public class MinpackTest if (x1 == 0) { tmp1 = (x2 >= 0) ? 0.25 : -0.25; } else { - tmp1 = Math.atan(x2 / x1) / twoPi; + tmp1 = FastMath.atan(x2 / x1) / twoPi; if (x1 < 0) { tmp1 += 0.5; } } - double tmp2 = Math.sqrt(x1 * x1 + x2 * x2); + double tmp2 = FastMath.sqrt(x1 * x1 + x2 * x2); return new double[] { 10.0 * (x3 - 10 * tmp1), 10.0 * (tmp2 - 1), @@ -817,7 +818,7 @@ public class MinpackTest }; } - private static final double twoPi = 2.0 * Math.PI; + private static final double twoPi = 2.0 * FastMath.PI; } @@ -856,8 +857,8 @@ public class MinpackTest }; } - private static final double sqrt5 = Math.sqrt( 5.0); - private static final double sqrt10 = Math.sqrt(10.0); + private static final double sqrt5 = FastMath.sqrt( 5.0); + private static final double sqrt10 = FastMath.sqrt(10.0); } @@ -1020,7 +1021,7 @@ public class MinpackTest for (int i = 0; i < m; ++i) { double temp = 5.0 * (i + 1) + 45.0 + x3; double tmp1 = x2 / temp; - double tmp2 = Math.exp(tmp1); + double tmp2 = FastMath.exp(tmp1); double tmp3 = x1 * tmp2 / temp; jacobian[i] = new double[] { tmp2, tmp3, -tmp1 * tmp3 }; } @@ -1034,7 +1035,7 @@ public class MinpackTest double x3 = parameters[2].getEstimate(); double[] f = new double[m]; for (int i = 0; i < m; ++i) { - f[i] = x1 * Math.exp(x2 / (5.0 * (i + 1) + 45.0 + x3)) - y[i]; + f[i] = x1 * FastMath.exp(x2 / (5.0 * (i + 1) + 45.0 + x3)) - y[i]; } return f; } @@ -1138,9 +1139,9 @@ public class MinpackTest for (int i = 0; i < m; ++i) { double tmp = (i + 1) / 10.0; jacobian[i] = new double[] { - -tmp * Math.exp(-tmp * x1), - tmp * Math.exp(-tmp * x2), - Math.exp(-i - 1) - Math.exp(-tmp) + -tmp * FastMath.exp(-tmp * x1), + tmp * FastMath.exp(-tmp * x2), + FastMath.exp(-i - 1) - FastMath.exp(-tmp) }; } return jacobian; @@ -1154,8 +1155,8 @@ public class MinpackTest double[] f = new double[m]; for (int i = 0; i < m; ++i) { double tmp = (i + 1) / 10.0; - f[i] = Math.exp(-tmp * x1) - Math.exp(-tmp * x2) - + (Math.exp(-i - 1) - Math.exp(-tmp)) * x3; + f[i] = FastMath.exp(-tmp * x1) - FastMath.exp(-tmp * x2) + + (FastMath.exp(-i - 1) - FastMath.exp(-tmp)) * x3; } return f; } @@ -1179,7 +1180,7 @@ public class MinpackTest double[][] jacobian = new double[m][]; for (int i = 0; i < m; ++i) { double t = i + 1; - jacobian[i] = new double[] { -t * Math.exp(t * x1), -t * Math.exp(t * x2) }; + jacobian[i] = new double[] { -t * FastMath.exp(t * x1), -t * FastMath.exp(t * x2) }; } return jacobian; } @@ -1191,7 +1192,7 @@ public class MinpackTest double[] f = new double[m]; for (int i = 0; i < m; ++i) { double temp = i + 1; - f[i] = 2 + 2 * temp - Math.exp(temp * x1) - Math.exp(temp * x2); + f[i] = 2 + 2 * temp - FastMath.exp(temp * x1) - FastMath.exp(temp * x2); } return f; } @@ -1218,9 +1219,9 @@ public class MinpackTest double[][] jacobian = new double[m][]; for (int i = 0; i < m; ++i) { double temp = (i + 1) / 5.0; - double ti = Math.sin(temp); - double tmp1 = x1 + temp * x2 - Math.exp(temp); - double tmp2 = x3 + ti * x4 - Math.cos(temp); + double ti = FastMath.sin(temp); + double tmp1 = x1 + temp * x2 - FastMath.exp(temp); + double tmp2 = x3 + ti * x4 - FastMath.cos(temp); jacobian[i] = new double[] { 2 * tmp1, 2 * temp * tmp1, 2 * tmp2, 2 * ti * tmp2 }; @@ -1237,8 +1238,8 @@ public class MinpackTest double[] f = new double[m]; for (int i = 0; i < m; ++i) { double temp = (i + 1) / 5.0; - double tmp1 = x1 + temp * x2 - Math.exp(temp); - double tmp2 = x3 + Math.sin(temp) * x4 - Math.cos(temp); + double tmp1 = x1 + temp * x2 - FastMath.exp(temp); + double tmp2 = x3 + FastMath.sin(temp) * x4 - FastMath.cos(temp); f[i] = tmp1 * tmp1 + tmp2 * tmp2; } return f; @@ -1410,8 +1411,8 @@ public class MinpackTest double[][] jacobian = new double[m][]; for (int i = 0; i < m; ++i) { double temp = 10.0 * i; - double tmp1 = Math.exp(-temp * x4); - double tmp2 = Math.exp(-temp * x5); + double tmp1 = FastMath.exp(-temp * x4); + double tmp2 = FastMath.exp(-temp * x5); jacobian[i] = new double[] { -1, -tmp1, -tmp2, temp * x2 * tmp1, temp * x3 * tmp2 }; @@ -1429,8 +1430,8 @@ public class MinpackTest double[] f = new double[m]; for (int i = 0; i < m; ++i) { double temp = 10.0 * i; - double tmp1 = Math.exp(-temp * x4); - double tmp2 = Math.exp(-temp * x5); + double tmp1 = FastMath.exp(-temp * x4); + double tmp2 = FastMath.exp(-temp * x5); f[i] = y[i] - (x1 + x2 * tmp1 + x3 * tmp2); } return f; @@ -1470,10 +1471,10 @@ public class MinpackTest double[][] jacobian = new double[m][]; for (int i = 0; i < m; ++i) { double temp = i / 10.0; - double tmp1 = Math.exp(-x05 * temp); - double tmp2 = Math.exp(-x06 * (temp - x09) * (temp - x09)); - double tmp3 = Math.exp(-x07 * (temp - x10) * (temp - x10)); - double tmp4 = Math.exp(-x08 * (temp - x11) * (temp - x11)); + double tmp1 = FastMath.exp(-x05 * temp); + double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09)); + double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10)); + double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11)); jacobian[i] = new double[] { -tmp1, -tmp2, @@ -1507,10 +1508,10 @@ public class MinpackTest double[] f = new double[m]; for (int i = 0; i < m; ++i) { double temp = i / 10.0; - double tmp1 = Math.exp(-x05 * temp); - double tmp2 = Math.exp(-x06 * (temp - x09) * (temp - x09)); - double tmp3 = Math.exp(-x07 * (temp - x10) * (temp - x10)); - double tmp4 = Math.exp(-x08 * (temp - x11) * (temp - x11)); + double tmp1 = FastMath.exp(-x05 * temp); + double tmp2 = FastMath.exp(-x06 * (temp - x09) * (temp - x09)); + double tmp3 = FastMath.exp(-x07 * (temp - x10) * (temp - x10)); + double tmp4 = FastMath.exp(-x08 * (temp - x11) * (temp - x11)); f[i] = y[i] - (x01 * tmp1 + x02 * tmp2 + x03 * tmp3 + x04 * tmp4); } return f; Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/estimation/WeightedMeasurementTest.java Sun Aug 29 21:49:40 2010 @@ -19,6 +19,7 @@ package org.apache.commons.math.estimati import org.apache.commons.math.estimation.EstimatedParameter; import org.apache.commons.math.estimation.WeightedMeasurement; +import org.apache.commons.math.util.FastMath; import junit.framework.*; @@ -79,7 +80,7 @@ public class WeightedMeasurementTest } private void checkValue(double value, double expected) { - assertTrue(Math.abs(value - expected) < 1.0e-10); + assertTrue(FastMath.abs(value - expected) < 1.0e-10); } private double theoretical() { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionFormatTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionFormatTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionFormatTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionFormatTest.java Sun Aug 29 21:49:40 2010 @@ -23,6 +23,8 @@ import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; +import org.apache.commons.math.util.FastMath; + import junit.framework.TestCase; public class BigFractionFormatTest extends TestCase { @@ -255,13 +257,13 @@ public class BigFractionFormatTest exten improperFormat.parse("167213075789791382630275400487886041651764456874403" + " / " + "53225575123090058458126718248444563466137046489291"); - assertEquals(Math.PI, f1.doubleValue(), 0.0); + assertEquals(FastMath.PI, f1.doubleValue(), 0.0); BigFraction f2 = properFormat.parse("3 " + "7536350420521207255895245742552351253353317406530" + " / " + "53225575123090058458126718248444563466137046489291"); - assertEquals(Math.PI, f2.doubleValue(), 0.0); + assertEquals(FastMath.PI, f2.doubleValue(), 0.0); assertEquals(f1, f2); BigDecimal pi = new BigDecimal("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068"); Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/BigFractionTest.java Sun Aug 29 21:49:40 2010 @@ -22,6 +22,7 @@ import java.math.BigInteger; import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.TestUtils; import org.apache.commons.math.exception.NullArgumentException; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -89,7 +90,7 @@ public class BigFractionTest extends Tes try { // the golden ratio is notoriously a difficult number for continuous // fraction - new BigFraction((1 + Math.sqrt(5)) / 2, 1.0e-12, 25); + new BigFraction((1 + FastMath.sqrt(5)) / 2, 1.0e-12, 25); fail("an exception should have been thrown"); } catch (ConvergenceException ce) { // expected behavior @@ -564,7 +565,7 @@ public class BigFractionTest extends Tes public void testSerial() throws FractionConversionException { BigFraction[] fractions = { new BigFraction(3, 4), BigFraction.ONE, BigFraction.ZERO, - new BigFraction(17), new BigFraction(Math.PI, 1000), + new BigFraction(17), new BigFraction(FastMath.PI, 1000), new BigFraction(-5, 2) }; for (BigFraction fraction : fractions) { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionFormatTest.java Sun Aug 29 21:49:40 2010 @@ -21,6 +21,8 @@ import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; +import org.apache.commons.math.util.FastMath; + import junit.framework.TestCase; public class FractionFormatTest extends TestCase { @@ -296,6 +298,6 @@ public class FractionFormatTest extends } public void testDoubleFormat() { - assertEquals("355 / 113", improperFormat.format(Math.PI)); + assertEquals("355 / 113", improperFormat.format(FastMath.PI)); } } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/fraction/FractionTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.fraction import org.apache.commons.math.ConvergenceException; import org.apache.commons.math.TestUtils; +import org.apache.commons.math.util.FastMath; import junit.framework.TestCase; @@ -68,7 +69,7 @@ public class FractionTest extends TestCa public void testGoldenRatio() { try { // the golden ratio is notoriously a difficult number for continuous fraction - new Fraction((1 + Math.sqrt(5)) / 2, 1.0e-12, 25); + new Fraction((1 + FastMath.sqrt(5)) / 2, 1.0e-12, 25); fail("an exception should have been thrown"); } catch (ConvergenceException ce) { // expected behavior @@ -575,7 +576,7 @@ public class FractionTest extends TestCa public void testSerial() throws FractionConversionException { Fraction[] fractions = { new Fraction(3, 4), Fraction.ONE, Fraction.ZERO, - new Fraction(17), new Fraction(Math.PI, 1000), + new Fraction(17), new Fraction(FastMath.PI, 1000), new Fraction(-5, 2) }; for (Fraction fraction : fractions) { Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/genetics/GeneticAlgorithmTestPermutations.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/genetics/GeneticAlgorithmTestPermutations.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/genetics/GeneticAlgorithmTestPermutations.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/genetics/GeneticAlgorithmTestPermutations.java Sun Aug 29 21:49:40 2010 @@ -21,6 +21,7 @@ import static org.junit.Assert.assertTru import java.util.ArrayList; import java.util.List; +import org.apache.commons.math.util.FastMath; import org.junit.Test; /** @@ -115,7 +116,7 @@ public class GeneticAlgorithmTestPermuta int value = decoded.get(i); if (value != i) { // bad position found - res += Math.abs(value - i); + res += FastMath.abs(value - i); } } // the most fitted chromosome is the one with minimal error Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/RotationTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/RotationTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/RotationTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/RotationTest.java Sun Aug 29 21:49:40 2010 @@ -22,6 +22,7 @@ import org.apache.commons.math.geometry. import org.apache.commons.math.geometry.Rotation; import org.apache.commons.math.geometry.RotationOrder; import org.apache.commons.math.geometry.Vector3D; +import org.apache.commons.math.util.FastMath; import org.apache.commons.math.util.MathUtils; import junit.framework.*; @@ -57,29 +58,29 @@ public class RotationTest public void testAxisAngle() { - Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * Math.PI / 3); + Rotation r = new Rotation(new Vector3D(10, 10, 10), 2 * FastMath.PI / 3); checkVector(r.applyTo(Vector3D.PLUS_I), Vector3D.PLUS_J); checkVector(r.applyTo(Vector3D.PLUS_J), Vector3D.PLUS_K); checkVector(r.applyTo(Vector3D.PLUS_K), Vector3D.PLUS_I); - double s = 1 / Math.sqrt(3); + double s = 1 / FastMath.sqrt(3); checkVector(r.getAxis(), new Vector3D(s, s, s)); - checkAngle(r.getAngle(), 2 * Math.PI / 3); + checkAngle(r.getAngle(), 2 * FastMath.PI / 3); try { - new Rotation(new Vector3D(0, 0, 0), 2 * Math.PI / 3); + new Rotation(new Vector3D(0, 0, 0), 2 * FastMath.PI / 3); fail("an exception should have been thrown"); } catch (ArithmeticException e) { } catch (Exception e) { fail("unexpected exception"); } - r = new Rotation(Vector3D.PLUS_K, 1.5 * Math.PI); + r = new Rotation(Vector3D.PLUS_K, 1.5 * FastMath.PI); checkVector(r.getAxis(), new Vector3D(0, 0, -1)); - checkAngle(r.getAngle(), 0.5 * Math.PI); + checkAngle(r.getAngle(), 0.5 * FastMath.PI); - r = new Rotation(Vector3D.PLUS_J, Math.PI); + r = new Rotation(Vector3D.PLUS_J, FastMath.PI); checkVector(r.getAxis(), Vector3D.PLUS_J); - checkAngle(r.getAngle(), Math.PI); + checkAngle(r.getAngle(), FastMath.PI); checkVector(Rotation.IDENTITY.getAxis(), Vector3D.PLUS_I); @@ -101,7 +102,7 @@ public class RotationTest Rotation r = new Rotation(u, v); checkVector(r.applyTo(u.scalarMultiply(v.getNorm())), v.scalarMultiply(u.getNorm())); - checkAngle(new Rotation(u, u.negate()).getAngle(), Math.PI); + checkAngle(new Rotation(u, u.negate()).getAngle(), FastMath.PI); try { new Rotation(u, Vector3D.ZERO); @@ -131,9 +132,9 @@ public class RotationTest } else { checkVector(axis, Vector3D.MINUS_K); } - checkAngle(r.getAngle(), Math.PI); + checkAngle(r.getAngle(), FastMath.PI); - double sqrt = Math.sqrt(2) / 2; + double sqrt = FastMath.sqrt(2) / 2; r = new Rotation(Vector3D.PLUS_I, Vector3D.PLUS_J, new Vector3D(0.5, 0.5, sqrt), new Vector3D(0.5, 0.5, -sqrt)); @@ -245,25 +246,25 @@ public class RotationTest double d21 = m2[2][1] - m3[2][1]; double d22 = m2[2][2] - m3[2][2]; - assertTrue(Math.abs(d00) < 6.0e-6); - assertTrue(Math.abs(d01) < 6.0e-6); - assertTrue(Math.abs(d02) < 6.0e-6); - assertTrue(Math.abs(d10) < 6.0e-6); - assertTrue(Math.abs(d11) < 6.0e-6); - assertTrue(Math.abs(d12) < 6.0e-6); - assertTrue(Math.abs(d20) < 6.0e-6); - assertTrue(Math.abs(d21) < 6.0e-6); - assertTrue(Math.abs(d22) < 6.0e-6); - - assertTrue(Math.abs(d00) > 4.0e-7); - assertTrue(Math.abs(d01) > 4.0e-7); - assertTrue(Math.abs(d02) > 4.0e-7); - assertTrue(Math.abs(d10) > 4.0e-7); - assertTrue(Math.abs(d11) > 4.0e-7); - assertTrue(Math.abs(d12) > 4.0e-7); - assertTrue(Math.abs(d20) > 4.0e-7); - assertTrue(Math.abs(d21) > 4.0e-7); - assertTrue(Math.abs(d22) > 4.0e-7); + assertTrue(FastMath.abs(d00) < 6.0e-6); + assertTrue(FastMath.abs(d01) < 6.0e-6); + assertTrue(FastMath.abs(d02) < 6.0e-6); + assertTrue(FastMath.abs(d10) < 6.0e-6); + assertTrue(FastMath.abs(d11) < 6.0e-6); + assertTrue(FastMath.abs(d12) < 6.0e-6); + assertTrue(FastMath.abs(d20) < 6.0e-6); + assertTrue(FastMath.abs(d21) < 6.0e-6); + assertTrue(FastMath.abs(d22) < 6.0e-6); + + assertTrue(FastMath.abs(d00) > 4.0e-7); + assertTrue(FastMath.abs(d01) > 4.0e-7); + assertTrue(FastMath.abs(d02) > 4.0e-7); + assertTrue(FastMath.abs(d10) > 4.0e-7); + assertTrue(FastMath.abs(d11) > 4.0e-7); + assertTrue(FastMath.abs(d12) > 4.0e-7); + assertTrue(FastMath.abs(d20) > 4.0e-7); + assertTrue(FastMath.abs(d21) > 4.0e-7); + assertTrue(FastMath.abs(d22) > 4.0e-7); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { @@ -271,9 +272,9 @@ public class RotationTest + m3[i][1] * m3[j][1] + m3[i][2] * m3[j][2]; if (i == j) { - assertTrue(Math.abs(m3tm3 - 1.0) < 1.0e-10); + assertTrue(FastMath.abs(m3tm3 - 1.0) < 1.0e-10); } else { - assertTrue(Math.abs(m3tm3) < 1.0e-10); + assertTrue(FastMath.abs(m3tm3) < 1.0e-10); } } } @@ -289,7 +290,7 @@ public class RotationTest { 0.0, -1.0, 0.0 }, { 0.0, 0.0, -1.0 } }; r = new Rotation(m4, 1.0e-7); - checkAngle(r.getAngle(), Math.PI); + checkAngle(r.getAngle(), FastMath.PI); try { double[][] m5 = { { 0.0, 0.0, 1.0 }, @@ -356,7 +357,7 @@ public class RotationTest RotationOrder.YZX, RotationOrder.ZXY, RotationOrder.ZYX }; - double[] singularCardanAngle = { Math.PI / 2, -Math.PI / 2 }; + double[] singularCardanAngle = { FastMath.PI / 2, -FastMath.PI / 2 }; for (int i = 0; i < CardanOrders.length; ++i) { for (int j = 0; j < singularCardanAngle.length; ++j) { Rotation r = new Rotation(CardanOrders[i], 0.1, singularCardanAngle[j], 0.3); @@ -376,7 +377,7 @@ public class RotationTest RotationOrder.YZY, RotationOrder.ZXZ, RotationOrder.ZYZ }; - double[] singularEulerAngle = { 0, Math.PI }; + double[] singularEulerAngle = { 0, FastMath.PI }; for (int i = 0; i < EulerOrders.length; ++i) { for (int j = 0; j < singularEulerAngle.length; ++j) { Rotation r = new Rotation(EulerOrders[i], 0.1, singularEulerAngle[j], 0.3); @@ -454,9 +455,9 @@ public class RotationTest Rotation r = new Rotation(new Vector3D(2, -3, 5), 1.7); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi), - Math.sin(lambda) * Math.cos(phi), - Math.sin(phi)); + Vector3D u = new Vector3D(FastMath.cos(lambda) * FastMath.cos(phi), + FastMath.sin(lambda) * FastMath.cos(phi), + FastMath.sin(phi)); r.applyInverseTo(r.applyTo(u)); checkVector(u, r.applyInverseTo(r.applyTo(u))); checkVector(u, r.applyTo(r.applyInverseTo(u))); @@ -466,20 +467,20 @@ public class RotationTest r = Rotation.IDENTITY; for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi), - Math.sin(lambda) * Math.cos(phi), - Math.sin(phi)); + Vector3D u = new Vector3D(FastMath.cos(lambda) * FastMath.cos(phi), + FastMath.sin(lambda) * FastMath.cos(phi), + FastMath.sin(phi)); checkVector(u, r.applyInverseTo(r.applyTo(u))); checkVector(u, r.applyTo(r.applyInverseTo(u))); } } - r = new Rotation(Vector3D.PLUS_K, Math.PI); + r = new Rotation(Vector3D.PLUS_K, FastMath.PI); for (double lambda = 0; lambda < 6.2; lambda += 0.2) { for (double phi = -1.55; phi < 1.55; phi += 0.2) { - Vector3D u = new Vector3D(Math.cos(lambda) * Math.cos(phi), - Math.sin(lambda) * Math.cos(phi), - Math.sin(phi)); + Vector3D u = new Vector3D(FastMath.cos(lambda) * FastMath.cos(phi), + FastMath.sin(lambda) * FastMath.cos(phi), + FastMath.sin(phi)); checkVector(u, r.applyInverseTo(r.applyTo(u))); checkVector(u, r.applyTo(r.applyInverseTo(u))); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/Vector3DTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/Vector3DTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/Vector3DTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/geometry/Vector3DTest.java Sun Aug 29 21:49:40 2010 @@ -18,6 +18,7 @@ package org.apache.commons.math.geometry; import org.apache.commons.math.geometry.Vector3D; +import org.apache.commons.math.util.FastMath; import junit.framework.*; @@ -29,9 +30,9 @@ public class Vector3DTest } public void testConstructors() { - double r = Math.sqrt(2) /2; - checkVector(new Vector3D(2, new Vector3D(Math.PI / 3, -Math.PI / 4)), - r, r * Math.sqrt(3), -2 * r); + double r = FastMath.sqrt(2) /2; + checkVector(new Vector3D(2, new Vector3D(FastMath.PI / 3, -FastMath.PI / 4)), + r, r * FastMath.sqrt(3), -2 * r); checkVector(new Vector3D(2, Vector3D.PLUS_I, -3, Vector3D.MINUS_K), 2, 0, 3); @@ -48,9 +49,9 @@ public class Vector3DTest public void testCoordinates() { Vector3D v = new Vector3D(1, 2, 3); - assertTrue(Math.abs(v.getX() - 1) < 1.0e-12); - assertTrue(Math.abs(v.getY() - 2) < 1.0e-12); - assertTrue(Math.abs(v.getZ() - 3) < 1.0e-12); + assertTrue(FastMath.abs(v.getX() - 1) < 1.0e-12); + assertTrue(FastMath.abs(v.getY() - 2) < 1.0e-12); + assertTrue(FastMath.abs(v.getZ() - 3) < 1.0e-12); } public void testNorm1() { @@ -60,7 +61,7 @@ public class Vector3DTest public void testNorm() { assertEquals(0.0, Vector3D.ZERO.getNorm()); - assertEquals(Math.sqrt(14), new Vector3D(1, 2, 3).getNorm(), 1.0e-12); + assertEquals(FastMath.sqrt(14), new Vector3D(1, 2, 3).getNorm(), 1.0e-12); } public void testNormInf() { @@ -80,7 +81,7 @@ public class Vector3DTest Vector3D v1 = new Vector3D(1, -2, 3); Vector3D v2 = new Vector3D(-4, 2, 0); assertEquals(0.0, Vector3D.distance(Vector3D.MINUS_I, Vector3D.MINUS_I), 0); - assertEquals(Math.sqrt(50), Vector3D.distance(v1, v2), 1.0e-12); + assertEquals(FastMath.sqrt(50), Vector3D.distance(v1, v2), 1.0e-12); assertEquals(v1.subtract(v2).getNorm(), Vector3D.distance(v1, v2), 1.0e-12); } @@ -137,13 +138,13 @@ public class Vector3DTest Vector3D v1 = new Vector3D(2, 1, -4); Vector3D v2 = new Vector3D(3, 1, -1); - assertTrue(Math.abs(Vector3D.dotProduct(v1, v2) - 11) < 1.0e-12); + assertTrue(FastMath.abs(Vector3D.dotProduct(v1, v2) - 11) < 1.0e-12); Vector3D v3 = Vector3D.crossProduct(v1, v2); checkVector(v3, 3, -10, -1); - assertTrue(Math.abs(Vector3D.dotProduct(v1, v3)) < 1.0e-12); - assertTrue(Math.abs(Vector3D.dotProduct(v2, v3)) < 1.0e-12); + assertTrue(FastMath.abs(Vector3D.dotProduct(v1, v3)) < 1.0e-12); + assertTrue(FastMath.abs(Vector3D.dotProduct(v2, v3)) < 1.0e-12); } @@ -151,14 +152,14 @@ public class Vector3DTest assertEquals(0, Vector3D.PLUS_I.getAlpha(), 1.0e-10); assertEquals(0, Vector3D.PLUS_I.getDelta(), 1.0e-10); - assertEquals(Math.PI / 2, Vector3D.PLUS_J.getAlpha(), 1.0e-10); + assertEquals(FastMath.PI / 2, Vector3D.PLUS_J.getAlpha(), 1.0e-10); assertEquals(0, Vector3D.PLUS_J.getDelta(), 1.0e-10); assertEquals(0, Vector3D.PLUS_K.getAlpha(), 1.0e-10); - assertEquals(Math.PI / 2, Vector3D.PLUS_K.getDelta(), 1.0e-10); + assertEquals(FastMath.PI / 2, Vector3D.PLUS_K.getDelta(), 1.0e-10); Vector3D u = new Vector3D(-1, 1, -1); - assertEquals(3 * Math.PI /4, u.getAlpha(), 1.0e-10); - assertEquals(-1.0 / Math.sqrt(3), Math.sin(u.getDelta()), 1.0e-10); + assertEquals(3 * FastMath.PI /4, u.getAlpha(), 1.0e-10); + assertEquals(-1.0 / FastMath.sqrt(3), FastMath.sin(u.getDelta()), 1.0e-10); } @@ -167,9 +168,9 @@ public class Vector3DTest Vector3D k = v1.normalize(); Vector3D i = k.orthogonal(); - Vector3D v2 = k.scalarMultiply(Math.cos(1.2)).add(i.scalarMultiply(Math.sin(1.2))); + Vector3D v2 = k.scalarMultiply(FastMath.cos(1.2)).add(i.scalarMultiply(FastMath.sin(1.2))); - assertTrue(Math.abs(Vector3D.angle(v1, v2) - 1.2) < 1.0e-12); + assertTrue(FastMath.abs(Vector3D.angle(v1, v2) - 1.2) < 1.0e-12); } Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java?rev=990655&r1=990654&r2=990655&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java (original) +++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/AbstractRealVectorTest.java Sun Aug 29 21:49:40 2010 @@ -20,6 +20,7 @@ package org.apache.commons.math.linear; import junit.framework.TestCase; import org.apache.commons.math.analysis.UnivariateRealFunction; import org.apache.commons.math.linear.RealVector.Entry; +import org.apache.commons.math.util.FastMath; import java.util.Iterator; import java.util.Random; @@ -98,7 +99,7 @@ public class AbstractRealVectorTest exte @Override public RealVector mapPowToSelf(double d) { for(int i=0; i