You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2010/08/29 23:49:53 UTC
svn commit: r990655 [9/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...
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/EigenDecompositionImplTest.java Sun Aug 29 21:49:40 2010
@@ -22,6 +22,7 @@ import java.util.Random;
import junit.framework.TestCase;
+import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
public class EigenDecompositionImplTest extends TestCase {
@@ -377,11 +378,11 @@ public class EigenDecompositionImplTest
});
EigenDecomposition ed = new EigenDecompositionImpl(indefinite, MathUtils.SAFE_MIN);
checkEigenValues((new double[] {2, 1, -1}), ed, 1E-12);
- double isqrt3 = 1/Math.sqrt(3.0);
+ double isqrt3 = 1/FastMath.sqrt(3.0);
checkEigenVector((new double[] {isqrt3,isqrt3,-isqrt3}), ed, 1E-12);
- double isqrt2 = 1/Math.sqrt(2.0);
+ double isqrt2 = 1/FastMath.sqrt(2.0);
checkEigenVector((new double[] {0.0,-isqrt2,-isqrt2}), ed, 1E-12);
- double isqrt6 = 1/Math.sqrt(6.0);
+ double isqrt6 = 1/FastMath.sqrt(6.0);
checkEigenVector((new double[] {2*isqrt6,-isqrt6,isqrt6}), ed, 1E-12);
}
/**
@@ -408,7 +409,7 @@ public class EigenDecompositionImplTest
boolean found = false;
int i = 0;
while (!found && i < searchArray.length) {
- if (Math.abs(value - searchArray[i]) < tolerance) {
+ if (FastMath.abs(value - searchArray[i]) < tolerance) {
found = true;
}
i++;
@@ -441,11 +442,11 @@ public class EigenDecompositionImplTest
while (matching && j < searchMatrix.getRowDimension()) {
double colEntry = searchMatrix.getEntry(j, i);
// Use the first entry where both are non-zero as scalar
- if (Math.abs(multiplier - 1.0) <= Math.ulp(1.0) && Math.abs(colEntry) > 1E-14
- && Math.abs(column[j]) > 1e-14) {
+ if (FastMath.abs(multiplier - 1.0) <= FastMath.ulp(1.0) && FastMath.abs(colEntry) > 1E-14
+ && FastMath.abs(column[j]) > 1e-14) {
multiplier = colEntry / column[j];
}
- if (Math.abs(column[j] * multiplier - colEntry) > tolerance) {
+ if (FastMath.abs(column[j] * multiplier - colEntry) > tolerance) {
matching = false;
}
j++;
@@ -508,7 +509,7 @@ public class EigenDecompositionImplTest
for (final double dataIJ : dataI) {
norm2 += dataIJ * dataIJ;
}
- final double inv = 1.0 / Math.sqrt(norm2);
+ final double inv = 1.0 / FastMath.sqrt(norm2);
for (int j = 0; j < size; ++j) {
dataI[j] *= inv;
}
@@ -523,7 +524,7 @@ public class EigenDecompositionImplTest
public static RealMatrix createDiagonalMatrix(final double[] diagonal,
final int rows, final int columns) {
final double[][] dData = new double[rows][columns];
- for (int i = 0; i < Math.min(rows, columns); ++i) {
+ for (int i = 0; i < FastMath.min(rows, columns); ++i) {
dData[i][i] = diagonal[i];
}
return MatrixUtils.createRealMatrix(dData);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/RealMatrixImplTest.java Sun Aug 29 21:49:40 2010
@@ -19,6 +19,7 @@ package org.apache.commons.math.linear;
import junit.framework.TestCase;
import org.apache.commons.math.TestUtils;
+import org.apache.commons.math.util.FastMath;
/**
* Test cases for the {@link RealMatrixImpl} class.
@@ -153,8 +154,8 @@ public final class RealMatrixImplTest ex
public void testFrobeniusNorm() {
RealMatrixImpl m = new RealMatrixImpl(testData);
RealMatrixImpl m2 = new RealMatrixImpl(testData2);
- assertEquals("testData Frobenius norm", Math.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
- assertEquals("testData2 Frobenius norm", Math.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
+ assertEquals("testData Frobenius norm", FastMath.sqrt(117.0), m.getFrobeniusNorm(), entryTolerance);
+ assertEquals("testData2 Frobenius norm", FastMath.sqrt(52.0), m2.getFrobeniusNorm(), entryTolerance);
}
/** test m-n = m + -n */
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/SparseRealVectorTest.java Sun Aug 29 21:49:40 2010
@@ -24,6 +24,7 @@ import junit.framework.TestCase;
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.TestUtils;
import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.util.FastMath;
/**
* Test cases for the {@link OpenMapRealVector} class.
@@ -1187,7 +1188,7 @@ public class SparseRealVectorTest extend
v.setEntry(0, 0);
assertEquals(v, new OpenMapRealVector(new double[] { 0, 1, 2 }));
- assertNotSame(v, new OpenMapRealVector(new double[] { 0, 1, 2 + Math.ulp(2)}));
+ assertNotSame(v, new OpenMapRealVector(new double[] { 0, 1, 2 + FastMath.ulp(2)}));
assertNotSame(v, new OpenMapRealVector(new double[] { 0, 1, 2, 3 }));
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/linear/TriDiagonalTransformerTest.java Sun Aug 29 21:49:40 2010
@@ -19,6 +19,8 @@ package org.apache.commons.math.linear;
import java.util.Arrays;
+import org.apache.commons.math.util.FastMath;
+
import junit.framework.TestCase;
public class TriDiagonalTransformerTest extends TestCase {
@@ -129,7 +131,7 @@ public class TriDiagonalTransformerTest
{ 0.0, -0.2581988897471611, 0.6364346693566009, -0.027289660803112598, -0.7263191580755246 }
},
new double[] { 1, 4.4, 1.433099579242636, -0.89537362758743, 2.062274048344794 },
- new double[] { -Math.sqrt(15), -3.0832882879592476, 0.6082710842351517, 1.1786086405912128 });
+ new double[] { -FastMath.sqrt(15), -3.0832882879592476, 0.6082710842351517, 1.1786086405912128 });
}
public void testMatricesValues3() {
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/ContinuousOutputModelTest.java Sun Aug 29 21:49:40 2010
@@ -28,6 +28,7 @@ import org.apache.commons.math.ode.nonst
import org.apache.commons.math.ode.nonstiff.DormandPrince853Integrator;
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class ContinuousOutputModelTest
extends TestCase {
@@ -101,7 +102,7 @@ public class ContinuousOutputModelTest
FirstOrderIntegrator integ1 =
new DormandPrince853Integrator(0, 1.0, 1.0e-8, 1.0e-8);
integ1.addStepHandler(cm1);
- integ1.integrate(problem, Math.PI, new double[] { -1.0, 0.0 },
+ integ1.integrate(problem, FastMath.PI, new double[] { -1.0, 0.0 },
0, new double[2]);
// integrate backward from 2π to π
@@ -109,8 +110,8 @@ public class ContinuousOutputModelTest
FirstOrderIntegrator integ2 =
new DormandPrince853Integrator(0, 0.1, 1.0e-12, 1.0e-12);
integ2.addStepHandler(cm2);
- integ2.integrate(problem, 2.0 * Math.PI, new double[] { 1.0, 0.0 },
- Math.PI, new double[2]);
+ integ2.integrate(problem, 2.0 * FastMath.PI, new double[] { 1.0, 0.0 },
+ FastMath.PI, new double[2]);
// merge the two half circles
ContinuousOutputModel cm = new ContinuousOutputModel();
@@ -119,14 +120,14 @@ public class ContinuousOutputModelTest
cm.append(cm1);
// check circle
- assertEquals(2.0 * Math.PI, cm.getInitialTime(), 1.0e-12);
+ assertEquals(2.0 * FastMath.PI, cm.getInitialTime(), 1.0e-12);
assertEquals(0, cm.getFinalTime(), 1.0e-12);
assertEquals(cm.getFinalTime(), cm.getInterpolatedTime(), 1.0e-12);
- for (double t = 0; t < 2.0 * Math.PI; t += 0.1) {
+ for (double t = 0; t < 2.0 * FastMath.PI; t += 0.1) {
cm.setInterpolatedTime(t);
double[] y = cm.getInterpolatedState();
- assertEquals(Math.cos(t), y[0], 1.0e-7);
- assertEquals(Math.sin(t), y[1], 1.0e-7);
+ assertEquals(FastMath.cos(t), y[0], 1.0e-7);
+ assertEquals(FastMath.sin(t), y[1], 1.0e-7);
}
}
@@ -174,7 +175,7 @@ public class ContinuousOutputModelTest
}
public void checkValue(double value, double reference) {
- assertTrue(Math.abs(value - reference) < 1.0e-10);
+ assertTrue(FastMath.abs(value - reference) < 1.0e-10);
}
@Override
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/FirstOrderConverterTest.java Sun Aug 29 21:49:40 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.ode.First
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.SecondOrderDifferentialEquations;
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
+import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@@ -46,11 +47,11 @@ public class FirstOrderConverterTest
double previousError = Double.NaN;
for (int i = 0; i < 10; ++i) {
- double step = Math.pow(2.0, -(i + 1));
+ double step = FastMath.pow(2.0, -(i + 1));
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, step)
- - Math.sin(4.0);
+ - FastMath.sin(4.0);
if (i > 0) {
- assertTrue(Math.abs(error) < Math.abs(previousError));
+ assertTrue(FastMath.abs(error) < FastMath.abs(previousError));
}
previousError = error;
@@ -60,15 +61,15 @@ public class FirstOrderConverterTest
public void testSmallStep()
throws DerivativeException, IntegratorException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 1.0e-4)
- - Math.sin(4.0);
- assertTrue(Math.abs(error) < 1.0e-10);
+ - FastMath.sin(4.0);
+ assertTrue(FastMath.abs(error) < 1.0e-10);
}
public void testBigStep()
throws DerivativeException, IntegratorException {
double error = integrateWithSpecifiedStep(4.0, 0.0, 1.0, 0.5)
- - Math.sin(4.0);
- assertTrue(Math.abs(error) > 0.1);
+ - FastMath.sin(4.0);
+ assertTrue(FastMath.abs(error) > 0.1);
}
private static class Equations
@@ -101,8 +102,8 @@ public class FirstOrderConverterTest
double step)
throws DerivativeException, IntegratorException {
double[] y0 = new double[2];
- y0[0] = Math.sin(omega * t0);
- y0[1] = omega * Math.cos(omega * t0);
+ y0[0] = FastMath.sin(omega * t0);
+ y0[1] = omega * FastMath.cos(omega * t0);
ClassicalRungeKuttaIntegrator i = new ClassicalRungeKuttaIntegrator(step);
double[] y = new double[2];
i.integrate(new FirstOrderConverter(new Equations(1, omega)), t0, y0, t, y);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem1.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem1.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem1.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem1.java Sun Aug 29 21:49:40 2010
@@ -17,6 +17,8 @@
package org.apache.commons.math.ode;
+import org.apache.commons.math.util.FastMath;
+
/**
* This class is used in the junit tests for the ODE integrators.
@@ -79,7 +81,7 @@ public TestProblem1 copy() {
@Override
public double[] computeTheoreticalState(double t) {
- double c = Math.exp (t0 - t);
+ double c = FastMath.exp (t0 - t);
for (int i = 0; i < n; ++i) {
y[i] = c * y0[i];
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem2.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem2.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem2.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem2.java Sun Aug 29 21:49:40 2010
@@ -17,6 +17,8 @@
package org.apache.commons.math.ode;
+import org.apache.commons.math.util.FastMath;
+
/**
* This class is used in the junit tests for the ODE integrators.
@@ -81,7 +83,7 @@ public TestProblem2 copy() {
@Override
public double[] computeTheoreticalState(double t) {
double t2 = t * t;
- double c = t2 + 2 * (Math.exp (-0.5 * t2) - 1);
+ double c = t2 + 2 * (FastMath.exp (-0.5 * t2) - 1);
for (int i = 0; i < n; ++i) {
y[i] = c;
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem3.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem3.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem3.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem3.java Sun Aug 29 21:49:40 2010
@@ -17,6 +17,8 @@
package org.apache.commons.math.ode;
+import org.apache.commons.math.util.FastMath;
+
/**
* This class is used in the junit tests for the ODE integrators.
@@ -53,7 +55,7 @@ public class TestProblem3
public TestProblem3(double e) {
super();
this.e = e;
- double[] y0 = { 1 - e, 0, 0, Math.sqrt((1+e)/(1-e)) };
+ double[] y0 = { 1 - e, 0, 0, FastMath.sqrt((1+e)/(1-e)) };
setInitialConditions(0.0, y0);
setFinalConditions(20.0);
double[] errorScale = { 1.0, 1.0, 1.0, 1.0 };
@@ -89,7 +91,7 @@ public TestProblem3 copy() {
// current radius
double r2 = y[0] * y[0] + y[1] * y[1];
- double invR3 = 1 / (r2 * Math.sqrt(r2));
+ double invR3 = 1 / (r2 * FastMath.sqrt(r2));
// compute the derivatives
yDot[0] = y[2];
@@ -106,23 +108,23 @@ public TestProblem3 copy() {
double E = t;
double d = 0;
double corr = 999.0;
- for (int i = 0; (i < 50) && (Math.abs(corr) > 1.0e-12); ++i) {
- double f2 = e * Math.sin(E);
+ for (int i = 0; (i < 50) && (FastMath.abs(corr) > 1.0e-12); ++i) {
+ double f2 = e * FastMath.sin(E);
double f0 = d - f2;
- double f1 = 1 - e * Math.cos(E);
+ double f1 = 1 - e * FastMath.cos(E);
double f12 = f1 + f1;
corr = f0 * f12 / (f1 * f12 - f0 * f2);
d -= corr;
E = t + d;
}
- double cosE = Math.cos(E);
- double sinE = Math.sin(E);
+ double cosE = FastMath.cos(E);
+ double sinE = FastMath.sin(E);
y[0] = cosE - e;
- y[1] = Math.sqrt(1 - e * e) * sinE;
+ y[1] = FastMath.sqrt(1 - e * e) * sinE;
y[2] = -sinE / (1 - e * cosE);
- y[3] = Math.sqrt(1 - e * e) * cosE / (1 - e * cosE);
+ y[3] = FastMath.sqrt(1 - e * e) * cosE / (1 - e * cosE);
return y;
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem4.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem4.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem4.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblem4.java Sun Aug 29 21:49:40 2010
@@ -18,6 +18,7 @@
package org.apache.commons.math.ode;
import org.apache.commons.math.ode.events.EventHandler;
+import org.apache.commons.math.util.FastMath;
/**
* This class is used in the junit tests for the ODE integrators.
@@ -50,7 +51,7 @@ public class TestProblem4
public TestProblem4() {
super();
a = 1.2;
- double[] y0 = { Math.sin(a), Math.cos(a) };
+ double[] y0 = { FastMath.sin(a), FastMath.cos(a) };
setInitialConditions(0.0, y0);
setFinalConditions(15);
double[] errorScale = { 1.0, 0.0 };
@@ -87,9 +88,9 @@ public TestProblem4 copy() {
@Override
public double[] computeTheoreticalState(double t) {
- double sin = Math.sin(t + a);
- double cos = Math.cos(t + a);
- y[0] = Math.abs(sin);
+ double sin = FastMath.sin(t + a);
+ double cos = FastMath.cos(t + a);
+ y[0] = FastMath.abs(sin);
y[1] = (sin >= 0) ? cos : -cos;
return y;
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblemHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblemHandler.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblemHandler.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/TestProblemHandler.java Sun Aug 29 21:49:40 2010
@@ -21,6 +21,7 @@ import org.apache.commons.math.ode.Deriv
import org.apache.commons.math.ode.ODEIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
/**
* This class is used to handle steps for the test problems
@@ -75,11 +76,11 @@ public class TestProblemHandler
throws DerivativeException {
double start = integrator.getCurrentStepStart();
- if (Math.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
+ if (FastMath.abs((start - problem.getInitialTime()) / integrator.getCurrentSignedStepsize()) > 0.001) {
// multistep integrators do not handle the first steps themselves
// so we have to make sure the integrator we look at has really started its work
if (!Double.isNaN(expectedStepStart)) {
- maxTimeError = Math.max(maxTimeError, Math.abs(start - expectedStepStart));
+ maxTimeError = FastMath.max(maxTimeError, FastMath.abs(start - expectedStepStart));
}
expectedStepStart = start + integrator.getCurrentSignedStepsize();
}
@@ -93,8 +94,8 @@ public class TestProblemHandler
double[] interpolatedY = interpolator.getInterpolatedState();
double[] theoreticalY = problem.computeTheoreticalState(cT);
for (int i = 0; i < interpolatedY.length; ++i) {
- double error = Math.abs(interpolatedY[i] - theoreticalY[i]);
- lastError = Math.max(error, lastError);
+ double error = FastMath.abs(interpolatedY[i] - theoreticalY[i]);
+ lastError = FastMath.max(error, lastError);
}
lastTime = cT;
}
@@ -109,8 +110,8 @@ public class TestProblemHandler
// update the errors
for (int i = 0; i < interpolatedY.length; ++i) {
- double error = errorScale[i] * Math.abs(interpolatedY[i] - theoreticalY[i]);
- maxValueError = Math.max(error, maxValueError);
+ double error = errorScale[i] * FastMath.abs(interpolatedY[i] - theoreticalY[i]);
+ maxValueError = FastMath.max(error, maxValueError);
}
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobiansTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobiansTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobiansTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/jacobians/FirstOrderIntegratorWithJacobiansTest.java Sun Aug 29 21:49:40 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.ode.First
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math.stat.descriptive.SummaryStatistics;
+import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -84,8 +85,8 @@ public class FirstOrderIntegratorWithJac
Assert.assertTrue(residualsP0.getStandardDeviation() < 0.004);
Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) > 0.04);
Assert.assertTrue((residualsP1.getMax() - residualsP1.getMin()) < 0.05);
- Assert.assertTrue(residualsP1.getStandardDeviation() > 0.006);
- Assert.assertTrue(residualsP1.getStandardDeviation() < 0.007);
+ Assert.assertTrue(residualsP1.getStandardDeviation() > 0.007);
+ Assert.assertTrue(residualsP1.getStandardDeviation() < 0.008);
}
@Test
@@ -159,7 +160,7 @@ public class FirstOrderIntegratorWithJac
Circle circle = new Circle(y, 1.0, 1.0, 0.1);
double[][] dydy0 = new double[2][2];
double[][] dydp = new double[2][3];
- double t = 18 * Math.PI;
+ double t = 18 * FastMath.PI;
FirstOrderIntegratorWithJacobians extInt =
new FirstOrderIntegratorWithJacobians(integ, circle);
extInt.integrate(0, y, circle.exactDyDp(0), t, y, dydy0, dydp);
@@ -186,7 +187,7 @@ public class FirstOrderIntegratorWithJac
final Circle circle = new Circle(y, 1.0, 1.0, 0.1);
double[][] dydy0 = new double[2][2];
double[][] dydp = new double[2][3];
- double t = 18 * Math.PI;
+ double t = 18 * FastMath.PI;
final FirstOrderIntegratorWithJacobians extInt =
new FirstOrderIntegratorWithJacobians(integ, circle);
extInt.addStepHandler(new StepHandlerWithJacobians() {
@@ -250,7 +251,7 @@ public class FirstOrderIntegratorWithJac
final Circle circle = new Circle(y, 1.0, 1.0, 0.1);
double[][] dydy0 = new double[2][2];
double[][] dydp = new double[2][3];
- double t = 18 * Math.PI;
+ double t = 18 * FastMath.PI;
final FirstOrderIntegratorWithJacobians extInt =
new FirstOrderIntegratorWithJacobians(integ, circle);
extInt.addEventHandler(new EventHandlerWithJacobians() {
@@ -272,7 +273,7 @@ public class FirstOrderIntegratorWithJac
}
}, 10.0, 1.0e-10, 1000);
double stopTime = extInt.integrate(0, y, circle.exactDyDp(0), t, y, dydy0, dydp);
- Assert.assertTrue(stopTime < 5.0 * Math.PI);
+ Assert.assertTrue(stopTime < 5.0 * FastMath.PI);
}
private static class Brusselator implements ParameterizedODE, ODEWithJacobians {
@@ -367,8 +368,8 @@ public class FirstOrderIntegratorWithJac
}
public double[] exactY(double t) {
- double cos = Math.cos(omega * t);
- double sin = Math.sin(omega * t);
+ double cos = FastMath.cos(omega * t);
+ double sin = FastMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] {
@@ -378,8 +379,8 @@ public class FirstOrderIntegratorWithJac
}
public double[][] exactDyDy0(double t) {
- double cos = Math.cos(omega * t);
- double sin = Math.sin(omega * t);
+ double cos = FastMath.cos(omega * t);
+ double sin = FastMath.sin(omega * t);
return new double[][] {
{ cos, -sin },
{ sin, cos }
@@ -387,8 +388,8 @@ public class FirstOrderIntegratorWithJac
}
public double[][] exactDyDp(double t) {
- double cos = Math.cos(omega * t);
- double sin = Math.sin(omega * t);
+ double cos = FastMath.cos(omega * t);
+ double sin = FastMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[][] {
@@ -398,8 +399,8 @@ public class FirstOrderIntegratorWithJac
}
public double[] exactYDot(double t) {
- double oCos = omega * Math.cos(omega * t);
- double oSin = omega * Math.sin(omega * t);
+ double oCos = omega * FastMath.cos(omega * t);
+ double oSin = omega * FastMath.sin(omega * t);
double dx0 = y0[0] - cx;
double dy0 = y0[1] - cy;
return new double[] {
@@ -409,8 +410,8 @@ public class FirstOrderIntegratorWithJac
}
public double[][] exactDyDy0Dot(double t) {
- double oCos = omega * Math.cos(omega * t);
- double oSin = omega * Math.sin(omega * t);
+ double oCos = omega * FastMath.cos(omega * t);
+ double oSin = omega * FastMath.sin(omega * t);
return new double[][] {
{ -oSin, -oCos },
{ oCos, -oSin }
@@ -418,8 +419,8 @@ public class FirstOrderIntegratorWithJac
}
public double[][] exactDyDpDot(double t) {
- double cos = Math.cos(omega * t);
- double sin = Math.sin(omega * t);
+ double cos = FastMath.cos(omega * t);
+ double sin = FastMath.sin(omega * t);
double oCos = omega * cos;
double oSin = omega * sin;
double dx0 = y0[0] - cx;
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsBashforthIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.TestProblem5;
import org.apache.commons.math.ode.TestProblem6;
import org.apache.commons.math.ode.TestProblemHandler;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class AdamsBashforthIntegratorTest {
@@ -70,7 +71,7 @@ public class AdamsBashforthIntegratorTes
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = Math.pow(10.0, i);
+ double scalAbsoluteTolerance = FastMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, minStep, maxStep,
@@ -118,7 +119,7 @@ public class AdamsBashforthIntegratorTes
public void backward() throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double range = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
FirstOrderIntegrator integ = new AdamsBashforthIntegrator(4, 0, range, 1.0e-12, 1.0e-12);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -135,7 +136,7 @@ public class AdamsBashforthIntegratorTes
@Test
public void polynomial() throws DerivativeException, IntegratorException {
TestProblem6 pb = new TestProblem6();
- double range = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
for (int nSteps = 1; nSteps < 8; ++nSteps) {
AdamsBashforthIntegrator integ =
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/AdamsMoultonIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.TestProblem5;
import org.apache.commons.math.ode.TestProblem6;
import org.apache.commons.math.ode.TestProblemHandler;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class AdamsMoultonIntegratorTest {
@@ -70,7 +71,7 @@ public class AdamsMoultonIntegratorTest
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = Math.pow(10.0, i);
+ double scalAbsoluteTolerance = FastMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, minStep, maxStep,
@@ -118,7 +119,7 @@ public class AdamsMoultonIntegratorTest
public void backward() throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double range = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
FirstOrderIntegrator integ = new AdamsMoultonIntegrator(4, 0, range, 1.0e-12, 1.0e-12);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -135,7 +136,7 @@ public class AdamsMoultonIntegratorTest
@Test
public void polynomial() throws DerivativeException, IntegratorException {
TestProblem6 pb = new TestProblem6();
- double range = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double range = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
for (int nSteps = 1; nSteps < 7; ++nSteps) {
AdamsMoultonIntegrator integ =
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.ClassicalRungeKuttaIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class ClassicalRungeKuttaIntegratorTest
extends TestCase {
@@ -69,7 +70,7 @@ public class ClassicalRungeKuttaIntegrat
double finalT = integrator.integrate(ode, t0, y0, tEvent, y);
Assert.assertEquals(tEvent, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * Math.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
integrator.addEventHandler(new EventHandler() {
@@ -89,7 +90,7 @@ public class ClassicalRungeKuttaIntegrat
finalT = integrator.integrate(ode, t0, y0, tEvent + 120, y);
Assert.assertEquals(tEvent + 120, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * Math.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
}
@@ -137,7 +138,7 @@ public class ClassicalRungeKuttaIntegrat
for (int i = 4; i < 10; ++i) {
TestProblemAbstract pb = problems[k].copy();
- double step = (pb.getFinalTime() - pb.getInitialTime()) * Math.pow(2.0, -i);
+ double step = (pb.getFinalTime() - pb.getInitialTime()) * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -156,7 +157,7 @@ public class ClassicalRungeKuttaIntegrat
double error = handler.getMaximalValueError();
if (i > 4) {
- assertTrue(error < Math.abs(previousError));
+ assertTrue(error < FastMath.abs(previousError));
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
@@ -208,7 +209,7 @@ public class ClassicalRungeKuttaIntegrat
throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double step = Math.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new ClassicalRungeKuttaIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54IntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -31,6 +31,7 @@ import org.apache.commons.math.ode.nonst
import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@@ -86,7 +87,7 @@ public class DormandPrince54IntegratorTe
TestProblemAbstract pb = new TestProblem5();
double minStep = 1.25;
- double maxStep = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
double scalAbsoluteTolerance = 6.0e-4;
double scalRelativeTolerance = 6.0e-4;
@@ -147,7 +148,7 @@ public class DormandPrince54IntegratorTe
if (isLast) {
lastSeen = true;
double h = interpolator.getCurrentTime() - interpolator.getPreviousTime();
- assertTrue(Math.abs(h) < minStep);
+ assertTrue(FastMath.abs(h) < minStep);
}
}
@@ -168,7 +169,7 @@ public class DormandPrince54IntegratorTe
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = Math.pow(10.0, i);
+ double scalAbsoluteTolerance = FastMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
EmbeddedRungeKuttaIntegrator integ =
@@ -333,10 +334,10 @@ public class DormandPrince54IntegratorTe
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = Math.abs(interpolator.getCurrentTime()
+ double step = FastMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = Math.abs(step);
+ minStep = FastMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -34,6 +34,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class DormandPrince54StepInterpolatorTest {
@@ -120,13 +121,13 @@ public class DormandPrince54StepInterpol
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = Math.abs(tB - tA) / 2;
+ double halfStep = FastMath.abs(tB - tA) / 2;
assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- assertTrue(Math.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853IntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -31,6 +31,7 @@ import org.apache.commons.math.ode.nonst
import org.apache.commons.math.ode.sampling.DummyStepHandler;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@@ -71,7 +72,7 @@ public class DormandPrince853IntegratorT
double finalT = integrator.integrate(ode, t0, y0, tEvent, y);
Assert.assertEquals(tEvent, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * Math.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
integrator.setInitialStepSize(60.0);
@@ -92,7 +93,7 @@ public class DormandPrince853IntegratorT
finalT = integrator.integrate(ode, t0, y0, tEvent + 120, y);
Assert.assertEquals(tEvent + 120, finalT, 5.0e-6);
for (int i = 0; i < y.length; ++i) {
- Assert.assertEquals(y0[i] * Math.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
+ Assert.assertEquals(y0[i] * FastMath.exp(k[i] * (finalT - t0)), y[i], 1.0e-9);
}
}
@@ -160,7 +161,7 @@ public class DormandPrince853IntegratorT
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = Math.pow(10.0, i);
+ double scalAbsoluteTolerance = FastMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new DormandPrince853Integrator(minStep, maxStep,
@@ -383,10 +384,10 @@ public class DormandPrince853IntegratorT
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = Math.abs(interpolator.getCurrentTime()
+ double step = FastMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = Math.abs(step);
+ minStep = FastMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -34,6 +34,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class DormandPrince853StepInterpolatorTest {
@@ -120,13 +121,13 @@ public class DormandPrince853StepInterpo
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = Math.abs(tB - tA) / 2;
+ double halfStep = FastMath.abs(tB - tA) / 2;
assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- assertTrue(Math.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -32,6 +32,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.EulerIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class EulerIntegratorTest
extends TestCase {
@@ -64,7 +65,7 @@ public class EulerIntegratorTest
TestProblemAbstract pb = problems[k].copy();
double step = (pb.getFinalTime() - pb.getInitialTime())
- * Math.pow(2.0, -i);
+ * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -82,7 +83,7 @@ public class EulerIntegratorTest
double error = handler.getMaximalValueError();
if (i > 4) {
- assertTrue(error < Math.abs(previousError));
+ assertTrue(error < FastMath.abs(previousError));
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
@@ -136,7 +137,7 @@ public class EulerIntegratorTest
throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double step = Math.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new EulerIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.TestProblem3;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class EulerStepInterpolatorTest {
@@ -50,7 +51,7 @@ public class EulerStepInterpolatorTest {
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -81,13 +82,13 @@ public class EulerStepInterpolatorTest {
interpolator.setInterpolatedTime(interpolator.getPreviousTime());
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y0[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y0[i]) < 1.0e-10);
}
interpolator.setInterpolatedTime(interpolator.getCurrentTime());
result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -106,15 +107,15 @@ public class EulerStepInterpolatorTest {
interpolator.setInterpolatedTime(0.1);
double[] result = interpolator.getInterpolatedState();
- assertTrue(Math.abs(result[0] - 0.1) < 1.0e-10);
- assertTrue(Math.abs(result[1] - 1.2) < 1.0e-10);
- assertTrue(Math.abs(result[2] + 2.2) < 1.0e-10);
+ assertTrue(FastMath.abs(result[0] - 0.1) < 1.0e-10);
+ assertTrue(FastMath.abs(result[1] - 1.2) < 1.0e-10);
+ assertTrue(FastMath.abs(result[2] + 2.2) < 1.0e-10);
interpolator.setInterpolatedTime(0.5);
result = interpolator.getInterpolatedState();
- assertTrue(Math.abs(result[0] - 0.5) < 1.0e-10);
- assertTrue(Math.abs(result[1] - 2.0) < 1.0e-10);
- assertTrue(Math.abs(result[2] + 3.0) < 1.0e-10);
+ assertTrue(FastMath.abs(result[0] - 0.5) < 1.0e-10);
+ assertTrue(FastMath.abs(result[1] - 2.0) < 1.0e-10);
+ assertTrue(FastMath.abs(result[2] + 3.0) < 1.0e-10);
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GillIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.GillIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class GillIntegratorTest
extends TestCase {
@@ -65,7 +66,7 @@ public class GillIntegratorTest
TestProblemAbstract pb = problems[k].copy();
double step = (pb.getFinalTime() - pb.getInitialTime())
- * Math.pow(2.0, -i);
+ * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -83,7 +84,7 @@ public class GillIntegratorTest
double error = handler.getMaximalValueError();
if (i > 5) {
- assertTrue(error < Math.abs(previousError));
+ assertTrue(error < FastMath.abs(previousError));
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
@@ -135,7 +136,7 @@ public class GillIntegratorTest
throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double step = Math.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new GillIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -30,6 +30,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.GraggBulirschStoerIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@@ -74,8 +75,8 @@ public class GraggBulirschStoerIntegrato
try {
TestProblem5 pb = new TestProblem5();
- double minStep = 0.1 * Math.abs(pb.getFinalTime() - pb.getInitialTime());
- double maxStep = Math.abs(pb.getFinalTime() - pb.getInitialTime());
+ double minStep = 0.1 * FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
+ double maxStep = FastMath.abs(pb.getFinalTime() - pb.getInitialTime());
double[] vecAbsoluteTolerance = { 1.0e-20, 1.0e-21 };
double[] vecRelativeTolerance = { 1.0e-20, 1.0e-21 };
@@ -126,7 +127,7 @@ public class GraggBulirschStoerIntegrato
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double absTolerance = Math.pow(10.0, i);
+ double absTolerance = FastMath.pow(10.0, i);
double relTolerance = absTolerance;
FirstOrderIntegrator integ =
@@ -336,10 +337,10 @@ public class GraggBulirschStoerIntegrato
public void handleStep(StepInterpolator interpolator,
boolean isLast) {
- double step = Math.abs(interpolator.getCurrentTime()
+ double step = FastMath.abs(interpolator.getCurrentTime()
- interpolator.getPreviousTime());
if (firstTime) {
- minStep = Math.abs(step);
+ minStep = FastMath.abs(step);
maxStep = minStep;
firstTime = false;
} else {
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -34,6 +34,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class GraggBulirschStoerStepInterpolatorTest {
@@ -122,13 +123,13 @@ public class GraggBulirschStoerStepInter
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = Math.abs(tB - tA) / 2;
+ double halfStep = FastMath.abs(tB - tA) / 2;
assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- assertTrue(Math.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54IntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -34,6 +34,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.events.EventHandler;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class HighamHall54IntegratorTest
extends TestCase {
@@ -114,7 +115,7 @@ public class HighamHall54IntegratorTest
TestProblem1 pb = new TestProblem1();
double minStep = 0;
double maxStep = pb.getFinalTime() - pb.getInitialTime();
- double scalAbsoluteTolerance = Math.pow(10.0, i);
+ double scalAbsoluteTolerance = FastMath.pow(10.0, i);
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
FirstOrderIntegrator integ = new HighamHall54Integrator(minStep, maxStep,
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/HighamHall54StepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -34,6 +34,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.ode.sampling.StepInterpolatorTestUtils;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class HighamHall54StepInterpolatorTest {
@@ -120,13 +121,13 @@ public class HighamHall54StepInterpolato
StepInterpolator cloned = interpolator.copy();
double tA = cloned.getPreviousTime();
double tB = cloned.getCurrentTime();
- double halfStep = Math.abs(tB - tA) / 2;
+ double halfStep = FastMath.abs(tB - tA) / 2;
assertEquals(interpolator.getPreviousTime(), tA, 1.0e-12);
assertEquals(interpolator.getCurrentTime(), tB, 1.0e-12);
for (int i = 0; i < 10; ++i) {
double t = (i * tB + (9 - i) * tA) / 9;
interpolator.setInterpolatedTime(t);
- assertTrue(Math.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
+ assertTrue(FastMath.abs(cloned.getInterpolatedTime() - t) > (halfStep / 10));
cloned.setInterpolatedTime(t);
assertEquals(t, cloned.getInterpolatedTime(), 1.0e-12);
double[] referenceState = interpolator.getInterpolatedState();
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/MidpointIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -32,6 +32,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.MidpointIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class MidpointIntegratorTest
extends TestCase {
@@ -64,7 +65,7 @@ public class MidpointIntegratorTest
TestProblemAbstract pb = problems[k].copy();
double step = (pb.getFinalTime() - pb.getInitialTime())
- * Math.pow(2.0, -i);
+ * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
integ.addStepHandler(handler);
@@ -82,7 +83,7 @@ public class MidpointIntegratorTest
double error = handler.getMaximalValueError();
if (i > 4) {
- assertTrue(error < Math.abs(previousError));
+ assertTrue(error < FastMath.abs(previousError));
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
@@ -136,7 +137,7 @@ public class MidpointIntegratorTest
throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double step = Math.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new MidpointIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/nonstiff/ThreeEighthesIntegratorTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.ode.event
import org.apache.commons.math.ode.nonstiff.ThreeEighthesIntegrator;
import org.apache.commons.math.ode.sampling.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator;
+import org.apache.commons.math.util.FastMath;
public class ThreeEighthesIntegratorTest
extends TestCase {
@@ -65,7 +66,7 @@ public class ThreeEighthesIntegratorTest
TestProblemAbstract pb = problems[k].copy();
double step = (pb.getFinalTime() - pb.getInitialTime())
- * Math.pow(2.0, -i);
+ * FastMath.pow(2.0, -i);
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
@@ -83,7 +84,7 @@ public class ThreeEighthesIntegratorTest
double error = handler.getMaximalValueError();
if (i > 4) {
- assertTrue(error < Math.abs(previousError));
+ assertTrue(error < FastMath.abs(previousError));
}
previousError = error;
assertEquals(0, handler.getMaximalTimeError(), 1.0e-12);
@@ -135,7 +136,7 @@ public class ThreeEighthesIntegratorTest
throws DerivativeException, IntegratorException {
TestProblem5 pb = new TestProblem5();
- double step = Math.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
+ double step = FastMath.abs(pb.getFinalTime() - pb.getInitialTime()) * 0.001;
FirstOrderIntegrator integ = new ThreeEighthesIntegrator(step);
TestProblemHandler handler = new TestProblemHandler(pb, integ);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java Sun Aug 29 21:49:40 2010
@@ -30,6 +30,7 @@ import java.io.IOException;
import org.apache.commons.math.ode.DerivativeException;
import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class DummyStepInterpolatorTest {
@@ -45,7 +46,7 @@ public class DummyStepInterpolatorTest {
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -63,13 +64,13 @@ public class DummyStepInterpolatorTest {
interpolator.setInterpolatedTime(0.1);
double[] result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
interpolator.setInterpolatedTime(0.5);
result = interpolator.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
@@ -98,7 +99,7 @@ public class DummyStepInterpolatorTest {
dsi.setInterpolatedTime(0.5);
double[] result = dsi.getInterpolatedState();
for (int i = 0; i < result.length; ++i) {
- assertTrue(Math.abs(result[i] - y[i]) < 1.0e-10);
+ assertTrue(FastMath.abs(result[i] - y[i]) < 1.0e-10);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepInterpolatorTestUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepInterpolatorTestUtils.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepInterpolatorTestUtils.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepInterpolatorTestUtils.java Sun Aug 29 21:49:40 2010
@@ -22,6 +22,7 @@ import org.apache.commons.math.ode.Deriv
import org.apache.commons.math.ode.FirstOrderIntegrator;
import org.apache.commons.math.ode.IntegratorException;
import org.apache.commons.math.ode.TestProblemAbstract;
+import org.apache.commons.math.util.FastMath;
public class StepInterpolatorTestUtils {
@@ -41,7 +42,7 @@ public class StepInterpolatorTestUtils {
final double h = 0.001 * (interpolator.getCurrentTime() - interpolator.getPreviousTime());
final double t = interpolator.getCurrentTime() - 300 * h;
- if (Math.abs(h) < 10 * Math.ulp(t)) {
+ if (FastMath.abs(h) < 10 * FastMath.ulp(t)) {
return;
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/ode/sampling/StepNormalizerTest.java Sun Aug 29 21:49:40 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.ode.TestP
import org.apache.commons.math.ode.nonstiff.DormandPrince54Integrator;
import org.apache.commons.math.ode.sampling.FixedStepHandler;
import org.apache.commons.math.ode.sampling.StepNormalizer;
+import org.apache.commons.math.util.FastMath;
import junit.framework.*;
@@ -89,7 +90,7 @@ public class StepNormalizerTest
}
public void checkValue(double value, double reference) {
- assertTrue(Math.abs(value - reference) < 1.0e-10);
+ assertTrue(FastMath.abs(value - reference) < 1.0e-10);
}
public void setLastSeen(boolean lastSeen) {
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/MultiStartUnivariateRealOptimizerTest.java Sun Aug 29 21:49:40 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.analysis.
import org.apache.commons.math.analysis.UnivariateRealFunction;
import org.apache.commons.math.optimization.univariate.BrentOptimizer;
import org.apache.commons.math.random.JDKRandomGenerator;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class MultiStartUnivariateRealOptimizerTest {
@@ -43,8 +44,8 @@ public class MultiStartUnivariateRealOpt
double[] optima = minimizer.getOptima();
double[] optimaValues = minimizer.getOptimaValues();
for (int i = 1; i < optima.length; ++i) {
- double d = (optima[i] - optima[i-1]) / (2 * Math.PI);
- assertTrue (Math.abs(d - Math.rint(d)) < 1.0e-8);
+ double d = (optima[i] - optima[i-1]) / (2 * FastMath.PI);
+ assertTrue (FastMath.abs(d - FastMath.rint(d)) < 1.0e-8);
assertEquals(-1.0, f.value(optima[i]), 1.0e-10);
assertEquals(f.value(optima[i]), optimaValues[i], 1.0e-10);
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/MultiDirectionalTest.java Sun Aug 29 21:49:40 2010
@@ -24,6 +24,7 @@ import org.apache.commons.math.optimizat
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
+import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -84,7 +85,7 @@ public class MultiDirectionalTest {
public double value(double[] variables) throws FunctionEvaluationException {
final double x = variables[0];
final double y = variables[1];
- return ((x == 0) || (y == 0)) ? 0 : (Math.atan(x) * Math.atan(x + 2) * Math.atan(y) * Math.atan(y) / (x * y));
+ return ((x == 0) || (y == 0)) ? 0 : (FastMath.atan(x) * FastMath.atan(x + 2) * FastMath.atan(y) * FastMath.atan(y) / (x * y));
}
};
@@ -238,7 +239,7 @@ public class MultiDirectionalTest {
public double value(double[] point) {
final double x = point[0], y = point[1];
final double twoS2 = 2.0 * std * std;
- return 1.0 / (twoS2 * Math.PI) * Math.exp(-(x * x + y * y) / twoS2);
+ return 1.0 / (twoS2 * FastMath.PI) * FastMath.exp(-(x * x + y * y) / twoS2);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/direct/NelderMeadTest.java Sun Aug 29 21:49:40 2010
@@ -38,6 +38,7 @@ import org.apache.commons.math.optimizat
import org.apache.commons.math.optimization.RealPointValuePair;
import org.apache.commons.math.optimization.SimpleRealPointChecker;
import org.apache.commons.math.optimization.SimpleScalarValueChecker;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class NelderMeadTest {
@@ -97,7 +98,7 @@ public class NelderMeadTest {
public double value(double[] variables) throws FunctionEvaluationException {
final double x = variables[0];
final double y = variables[1];
- return ((x == 0) || (y == 0)) ? 0 : (Math.atan(x) * Math.atan(x + 2) * Math.atan(y) * Math.atan(y) / (x * y));
+ return ((x == 0) || (y == 0)) ? 0 : (FastMath.atan(x) * FastMath.atan(x + 2) * FastMath.atan(y) * FastMath.atan(y) / (x * y));
}
};
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/CurveFitterTest.java Sun Aug 29 21:49:40 2010
@@ -20,6 +20,7 @@ package org.apache.commons.math.optimiza
import org.apache.commons.math.FunctionEvaluationException;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer;
+import org.apache.commons.math.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -94,7 +95,7 @@ public class CurveFitterTest {
double c = parameters[2];
double d = parameters[3];
- return d + ((a - d) / (1 + Math.pow(x / c, b)));
+ return d + ((a - d) / (1 + FastMath.pow(x / c, b)));
}
public double[] gradient(double x, double[] parameters) {
@@ -105,17 +106,17 @@ public class CurveFitterTest {
double d = parameters[3];
double[] gradients = new double[4];
- double den = 1 + Math.pow(x / c, b);
+ double den = 1 + FastMath.pow(x / c, b);
// derivative with respect to a
gradients[0] = 1 / den;
// derivative with respect to b
// in the reported (invalid) issue, there was a sign error here
- gradients[1] = -((a - d) * Math.pow(x / c, b) * Math.log(x / c)) / (den * den);
+ gradients[1] = -((a - d) * FastMath.pow(x / c, b) * FastMath.log(x / c)) / (den * den);
// derivative with respect to c
- gradients[2] = (b * Math.pow(x / c, b - 1) * (x / (c * c)) * (a - d)) / (den * den);
+ gradients[2] = (b * FastMath.pow(x / c, b - 1) * (x / (c * c)) * (a - d)) / (den * den);
// derivative with respect to d
gradients[3] = 1 - (1 / den);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/HarmonicFitterTest.java Sun Aug 29 21:49:40 2010
@@ -24,6 +24,7 @@ import java.util.Random;
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer;
+import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
import org.junit.Test;
@@ -45,7 +46,7 @@ public class HarmonicFitterTest {
assertEquals(f.getPhase(), MathUtils.normalizeAngle(fitted.getPhase(), f.getPhase()), 1.0e-13);
for (double x = -1.0; x < 1.0; x += 0.01) {
- assertTrue(Math.abs(f.value(x) - fitted.value(x)) < 1.0e-13);
+ assertTrue(FastMath.abs(f.value(x) - fitted.value(x)) < 1.0e-13);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/fitting/PolynomialFitterTest.java Sun Aug 29 21:49:40 2010
@@ -27,6 +27,7 @@ import org.apache.commons.math.optimizat
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.general.GaussNewtonOptimizer;
import org.apache.commons.math.optimization.general.LevenbergMarquardtOptimizer;
+import org.apache.commons.math.util.FastMath;
import org.junit.Test;
public class PolynomialFitterTest {
@@ -46,8 +47,8 @@ public class PolynomialFitterTest {
PolynomialFunction fitted = fitter.fit();
for (double x = -1.0; x < 1.0; x += 0.01) {
- double error = Math.abs(p.value(x) - fitted.value(x)) /
- (1.0 + Math.abs(p.value(x)));
+ double error = FastMath.abs(p.value(x) - fitted.value(x)) /
+ (1.0 + FastMath.abs(p.value(x)));
assertEquals(0.0, error, 1.0e-6);
}
@@ -72,10 +73,10 @@ public class PolynomialFitterTest {
PolynomialFunction fitted = fitter.fit();
for (double x = -1.0; x < 1.0; x += 0.01) {
- double error = Math.abs(p.value(x) - fitted.value(x)) /
- (1.0 + Math.abs(p.value(x)));
- maxError = Math.max(maxError, error);
- assertTrue(Math.abs(error) < 0.1);
+ double error = FastMath.abs(p.value(x) - fitted.value(x)) /
+ (1.0 + FastMath.abs(p.value(x)));
+ maxError = FastMath.max(maxError, error);
+ assertTrue(FastMath.abs(error) < 0.1);
}
}
assertTrue(maxError > 0.01);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/GaussNewtonOptimizerTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.optimizat
import org.apache.commons.math.optimization.SimpleVectorialPointChecker;
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
import org.apache.commons.math.optimization.VectorialPointValuePair;
+import org.apache.commons.math.util.FastMath;
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
@@ -411,7 +412,7 @@ extends TestCase {
optimizer.optimize(circle, new double[] { 0, 0, 0, 0, 0 },
new double[] { 1, 1, 1, 1, 1 },
new double[] { 98.680, 47.345 });
- assertEquals(1.768262623567235, Math.sqrt(circle.getN()) * optimizer.getRMS(), 1.0e-10);
+ assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) * optimizer.getRMS(), 1.0e-10);
Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
assertEquals(69.96016175359975, circle.getRadius(center), 1.0e-10);
assertEquals(96.07590209601095, center.x, 1.0e-10);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=990655&r1=990654&r2=990655&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java Sun Aug 29 21:49:40 2010
@@ -33,6 +33,7 @@ import org.apache.commons.math.linear.Re
import org.apache.commons.math.optimization.OptimizationException;
import org.apache.commons.math.optimization.SimpleVectorialValueChecker;
import org.apache.commons.math.optimization.VectorialPointValuePair;
+import org.apache.commons.math.util.FastMath;
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
@@ -211,7 +212,7 @@ public class LevenbergMarquardtOptimizer
LevenbergMarquardtOptimizer optimizer = new LevenbergMarquardtOptimizer();
optimizer.optimize(problem, problem.target, new double[] { 1, 1, 1 }, new double[] { 0, 0, 0 });
- assertTrue(Math.sqrt(problem.target.length) * optimizer.getRMS() > 0.6);
+ assertTrue(FastMath.sqrt(problem.target.length) * optimizer.getRMS() > 0.6);
try {
optimizer.getCovariances();
fail("an exception should have been thrown");
@@ -409,7 +410,7 @@ public class LevenbergMarquardtOptimizer
assertTrue(optimizer.getEvaluations() < 10);
assertTrue(optimizer.getJacobianEvaluations() < 10);
double rms = optimizer.getRMS();
- assertEquals(1.768262623567235, Math.sqrt(circle.getN()) * rms, 1.0e-10);
+ assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) * rms, 1.0e-10);
Point2D.Double center = new Point2D.Double(optimum.getPointRef()[0], optimum.getPointRef()[1]);
assertEquals(69.96016176931406, circle.getRadius(center), 1.0e-10);
assertEquals(96.07590211815305, center.x, 1.0e-10);
@@ -425,8 +426,8 @@ public class LevenbergMarquardtOptimizer
// add perfect measurements and check errors are reduced
double r = circle.getRadius(center);
- for (double d= 0; d < 2 * Math.PI; d += 0.01) {
- circle.addPoint(center.x + r * Math.cos(d), center.y + r * Math.sin(d));
+ for (double d= 0; d < 2 * FastMath.PI; d += 0.01) {
+ circle.addPoint(center.x + r * FastMath.cos(d), center.y + r * FastMath.sin(d));
}
double[] target = new double[circle.getN()];
Arrays.fill(target, 0.0);