Author: luc
Date: Sat Aug 18 18:11:11 2012
New Revision: 1374632
URL: http://svn.apache.org/viewvc?rev=1374632&view=rev
Log:
use the new function objects were possible in tests.
Removed:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/Expm1Function.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SinFunction.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SincFunction.java
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/QuinticFunction.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SumSincFunction.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/XMinus5Function.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/RombergIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/SimpsonIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegratorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/DividedDifferenceInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/NevilleInterpolatorTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolverAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BisectionSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BrentSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolver2Test.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/NewtonSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/RiddersSolverTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/BrentOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/UnivariateMultiStartOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastCosineTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastSineTransformerTest.java
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/QuinticFunction.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/QuinticFunction.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/QuinticFunction.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/QuinticFunction.java
Sat Aug 18 18:11:11 2012
@@ -16,12 +16,15 @@
*/
package org.apache.commons.math3.analysis;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import
org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiable;
+
/**
* Auxiliary class for testing solvers.
*
* @version $Id$
*/
-public class QuinticFunction implements DifferentiableUnivariateFunction {
+public class QuinticFunction implements UnivariateDifferentiable {
/* Evaluate quintic.
* @see org.apache.commons.math3.UnivariateFunction#value(double)
@@ -30,11 +33,8 @@ public class QuinticFunction implements
return (x-1)*(x-0.5)*x*(x+0.5)*(x+1);
}
- public UnivariateFunction derivative() {
- return new UnivariateFunction() {
- public double value(double x) {
- return (5*x*x-3.75)*x*x+0.25;
- }
- };
+ public DerivativeStructure value(DerivativeStructure t) {
+ return
t.subtract(1).multiply(t.subtract(0.5)).multiply(t).multiply(t.add(0.5)).multiply(t.add(1));
}
+
}
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SumSincFunction.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SumSincFunction.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SumSincFunction.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/SumSincFunction.java
Sat Aug 18 18:11:11 2012
@@ -16,13 +16,15 @@
*/
package org.apache.commons.math3.analysis;
+import org.apache.commons.math3.analysis.function.Sinc;
+
/**
* Auxiliary class for testing optimizers.
*
* @version $Id$
*/
public class SumSincFunction implements DifferentiableMultivariateFunction {
- private static final DifferentiableUnivariateFunction sinc = new
SincFunction();
+ private static final DifferentiableUnivariateFunction sinc = new Sinc();
private static final UnivariateFunction sincDeriv = sinc.derivative();
/**
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/XMinus5Function.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/XMinus5Function.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/XMinus5Function.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/XMinus5Function.java
Sat Aug 18 18:11:11 2012
@@ -16,12 +16,15 @@
*/
package org.apache.commons.math3.analysis;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import
org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiable;
+
/**
* Auxiliary class for testing solvers.
*
* @version $Id$
*/
-public class XMinus5Function implements DifferentiableUnivariateFunction {
+public class XMinus5Function implements UnivariateDifferentiable {
/* Evaluate x - 5 fuction.
* @see org.apache.commons.math3.UnivariateFunction#value(double)
@@ -30,13 +33,8 @@ public class XMinus5Function implements
return x - 5;
}
- /* First derivative of x - 5 function
- */
- public UnivariateFunction derivative() {
- return new UnivariateFunction() {
- public double value(double x) {
- return 1.0;
- }
- };
+ public DerivativeStructure value(DerivativeStructure t) {
+ return t.subtract(5);
}
+
}
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegratorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegratorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegratorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/IterativeLegendreGaussIntegratorTest.java
Sat Aug 18 18:11:11 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math3.analysi
import java.util.Random;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;
@@ -32,7 +32,7 @@ public class IterativeLegendreGaussInteg
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
BaseAbstractUnivariateIntegrator integrator
= new IterativeLegendreGaussIntegrator(5, 1.0e-14, 1.0e-10, 2, 15);
double min, max, expected, result, tolerance;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegratorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegratorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegratorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/LegendreGaussIntegratorTest.java
Sat Aug 18 18:11:11 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math3.analysi
import java.util.Random;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.analysis.polynomials.PolynomialFunction;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
import org.apache.commons.math3.util.FastMath;
@@ -32,7 +32,7 @@ public class LegendreGaussIntegratorTest
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
BaseAbstractUnivariateIntegrator integrator = new
LegendreGaussIntegrator(5, 1.0e-14, 1.0e-10, 2, 15);
double min, max, expected, result, tolerance;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/RombergIntegratorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/RombergIntegratorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/RombergIntegratorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/RombergIntegratorTest.java
Sat Aug 18 18:11:11 2012
@@ -17,8 +17,8 @@
package org.apache.commons.math3.analysis.integration;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.util.FastMath;
@@ -42,7 +42,7 @@ public final class RombergIntegratorTest
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateIntegrator integrator = new RombergIntegrator();
double min, max, expected, result, tolerance;
@@ -97,7 +97,7 @@ public final class RombergIntegratorTest
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
try {
// bad interval
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/SimpsonIntegratorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/SimpsonIntegratorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/SimpsonIntegratorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/SimpsonIntegratorTest.java
Sat Aug 18 18:11:11 2012
@@ -17,8 +17,8 @@
package org.apache.commons.math3.analysis.integration;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.util.FastMath;
@@ -41,7 +41,7 @@ public final class SimpsonIntegratorTest
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateIntegrator integrator = new SimpsonIntegrator();
double min, max, expected, result, tolerance;
@@ -96,7 +96,7 @@ public final class SimpsonIntegratorTest
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
try {
// bad interval
new SimpsonIntegrator().integrate(1000, f, 1, -1);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegratorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegratorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegratorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/integration/TrapezoidIntegratorTest.java
Sat Aug 18 18:11:11 2012
@@ -17,8 +17,8 @@
package org.apache.commons.math3.analysis.integration;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.util.FastMath;
@@ -41,7 +41,7 @@ public final class TrapezoidIntegratorTe
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateIntegrator integrator = new TrapezoidIntegrator();
double min, max, expected, result, tolerance;
@@ -97,7 +97,7 @@ public final class TrapezoidIntegratorTe
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
try {
// bad interval
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/DividedDifferenceInterpolatorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/DividedDifferenceInterpolatorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/DividedDifferenceInterpolatorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/DividedDifferenceInterpolatorTest.java
Sat Aug 18 18:11:11 2012
@@ -16,10 +16,10 @@
*/
package org.apache.commons.math3.analysis.interpolation;
-import org.apache.commons.math3.exception.NonMonotonicSequenceException;
-import org.apache.commons.math3.analysis.Expm1Function;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Expm1;
+import org.apache.commons.math3.analysis.function.Sin;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -48,7 +48,7 @@ public final class DividedDifferenceInte
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateInterpolator interpolator = new
DividedDifferenceInterpolator();
double x[], y[], z, expected, result, tolerance;
@@ -80,7 +80,7 @@ public final class DividedDifferenceInte
*/
@Test
public void testExpm1Function() {
- UnivariateFunction f = new Expm1Function();
+ UnivariateFunction f = new Expm1();
UnivariateInterpolator interpolator = new
DividedDifferenceInterpolator();
double x[], y[], z, expected, result, tolerance;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/NevilleInterpolatorTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/NevilleInterpolatorTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/NevilleInterpolatorTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/interpolation/NevilleInterpolatorTest.java
Sat Aug 18 18:11:11 2012
@@ -16,10 +16,10 @@
*/
package org.apache.commons.math3.analysis.interpolation;
-import org.apache.commons.math3.exception.NonMonotonicSequenceException;
-import org.apache.commons.math3.analysis.Expm1Function;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Expm1;
+import org.apache.commons.math3.analysis.function.Sin;
+import org.apache.commons.math3.exception.NonMonotonicSequenceException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -48,7 +48,7 @@ public final class NevilleInterpolatorTe
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateInterpolator interpolator = new NevilleInterpolator();
double x[], y[], z, expected, result, tolerance;
@@ -80,7 +80,7 @@ public final class NevilleInterpolatorTe
*/
@Test
public void testExpm1Function() {
- UnivariateFunction f = new Expm1Function();
+ UnivariateFunction f = new Expm1();
UnivariateInterpolator interpolator = new NevilleInterpolator();
double x[], y[], z, expected, result, tolerance;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolverAbstractTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolverAbstractTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolverAbstractTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BaseSecantSolverAbstractTest.java
Sat Aug 18 18:11:11 2012
@@ -17,11 +17,11 @@
package org.apache.commons.math3.analysis.solvers;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.XMinus5Function;
-import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -51,7 +51,7 @@ public abstract class BaseSecantSolverAb
// The sinus function is behaved well around the root at pi. The second
// order derivative is zero, which means linear approximating methods
// still converge quadratically.
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
double result;
UnivariateSolver solver = getSolver();
@@ -136,7 +136,7 @@ public abstract class BaseSecantSolverAb
@Test
public void testBadEndpoints() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = getSolver();
try { // bad interval
solver.solve(100, f, 1, -1);
@@ -160,7 +160,7 @@ public abstract class BaseSecantSolverAb
@Test
public void testSolutionLeftSide() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = getSolver();
double left = -1.5;
double right = 0.05;
@@ -179,7 +179,7 @@ public abstract class BaseSecantSolverAb
@Test
public void testSolutionRightSide() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = getSolver();
double left = -1.5;
double right = 0.05;
@@ -197,7 +197,7 @@ public abstract class BaseSecantSolverAb
}
@Test
public void testSolutionBelowSide() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = getSolver();
double left = -1.5;
double right = 0.05;
@@ -216,7 +216,7 @@ public abstract class BaseSecantSolverAb
@Test
public void testSolutionAboveSide() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = getSolver();
double left = -1.5;
double right = 0.05;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BisectionSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BisectionSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BisectionSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BisectionSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -17,8 +17,8 @@
package org.apache.commons.math3.analysis.solvers;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -29,7 +29,7 @@ import org.junit.Test;
public final class BisectionSolverTest {
@Test
public void testSinZero() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
double result;
BisectionSolver solver = new BisectionSolver();
@@ -84,7 +84,7 @@ public final class BisectionSolverTest {
@Test
public void testMath369() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
BisectionSolver solver = new BisectionSolver();
Assert.assertEquals(FastMath.PI, solver.solve(100, f, 3.0, 3.2, 3.1),
solver.getAbsoluteAccuracy());
}
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BracketingNthOrderBrentSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -20,9 +20,10 @@ package org.apache.commons.math3.analysi
import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math3.analysis.QuinticFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import
org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiable;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
-import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -106,39 +107,39 @@ public final class BracketingNthOrderBre
// 80 digits and checked with emacs (only the first 20 digits are
reproduced here)
compare(new TestFunction(0.0, -2, 2) {
@Override
- public double value(double x) { return FastMath.sin(x) - 0.5
* x; }
- @Override
- public double derivative(double x) { return FastMath.cos(x) - 0.5;
}
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.sin().subtract(x.multiply(0.5));
+ }
});
compare(new TestFunction(6.3087771299726890947, -5, 10) {
@Override
- public double value(double x) { return FastMath.pow(x, 5) + x
- 10000; }
- @Override
- public double derivative(double x) { return 5 * FastMath.pow(x, 4)
+ 1; }
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.pow(5).add(x).subtract(10000);
+ }
});
compare(new TestFunction(9.6335955628326951924, 0.001, 10) {
@Override
- public double value(double x) { return FastMath.sqrt(x) - 1 /
x - 3; }
- @Override
- public double derivative(double x) { return 0.5 / FastMath.sqrt(x)
+ 1 / (x * x); }
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.sqrt().subtract(x.reciprocal()).subtract(3);
+ }
});
compare(new TestFunction(2.8424389537844470678, -5, 5) {
@Override
- public double value(double x) { return FastMath.exp(x) + x -
20; }
- @Override
- public double derivative(double x) { return FastMath.exp(x) + 1; }
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.exp().add(x).subtract(20);
+ }
});
compare(new TestFunction(8.3094326942315717953, 0.001, 10) {
@Override
- public double value(double x) { return FastMath.log(x) +
FastMath.sqrt(x) - 5; }
- @Override
- public double derivative(double x) { return 1 / x + 0.5 /
FastMath.sqrt(x); }
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.log().add(x.sqrt()).subtract(5);
+ }
});
compare(new TestFunction(1.4655712318767680266, -0.5, 1.5) {
@Override
- public double value(double x) { return (x - 1) * x * x - 1; }
- @Override
- public double derivative(double x) { return (3 * x - 2) * x; }
+ public DerivativeStructure value(DerivativeStructure x) {
+ return x.subtract(1).multiply(x).multiply(x).subtract(1);
+ }
});
}
@@ -147,20 +148,33 @@ public final class BracketingNthOrderBre
compare(f, f.getRoot(), f.getMin(), f.getMax());
}
- private void compare(DifferentiableUnivariateFunction f,
+ private void compare(final UnivariateDifferentiable f,
double root, double min, double max) {
+ DifferentiableUnivariateFunction df = new
DifferentiableUnivariateFunction() {
+ public double value(double x) {
+ return f.value(x);
+ }
+
+ public UnivariateFunction derivative() {
+ return new UnivariateFunction() {
+ public double value(double x) {
+ return f.value(new DerivativeStructure(1, 1, 0,
x)).getPartialDerivative(1);
+ }
+ };
+ }
+ };
NewtonSolver newton = new NewtonSolver(1.0e-12);
BracketingNthOrderBrentSolver bracketing =
new BracketingNthOrderBrentSolver(1.0e-12, 1.0e-12, 1.0e-18,
5);
double resultN;
try {
- resultN = newton.solve(100, f, min, max);
+ resultN = newton.solve(100, df, min, max);
} catch (TooManyEvaluationsException tmee) {
resultN = Double.NaN;
}
double resultB;
try {
- resultB = bracketing.solve(100, f, min, max);
+ resultB = bracketing.solve(100, df, min, max);
} catch (TooManyEvaluationsException tmee) {
resultB = Double.NaN;
}
@@ -169,7 +183,7 @@ public final class BracketingNthOrderBre
Assert.assertTrue(bracketing.getEvaluations() <
newton.getEvaluations());
}
- private static abstract class TestFunction implements
DifferentiableUnivariateFunction {
+ private static abstract class TestFunction implements
UnivariateDifferentiable {
private final double root;
private final double min;
@@ -193,18 +207,12 @@ public final class BracketingNthOrderBre
return max;
}
- public abstract double value(double x);
-
- public abstract double derivative(double x);
-
- public UnivariateFunction derivative() {
- return new UnivariateFunction() {
- public double value(double x) {
- return derivative(x);
- }
- };
+ public double value(final double x) {
+ return value(new DerivativeStructure(0, 0, x)).getValue();
}
+ public abstract DerivativeStructure value(final DerivativeStructure t);
+
}
}
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BrentSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BrentSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BrentSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/BrentSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -16,19 +16,19 @@
*/
package org.apache.commons.math3.analysis.solvers;
+import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
+import org.apache.commons.math3.analysis.FunctionUtils;
import org.apache.commons.math3.analysis.MonitoredFunction;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
-import org.apache.commons.math3.analysis.FunctionUtils;
-import org.apache.commons.math3.analysis.function.Sqrt;
-import org.apache.commons.math3.analysis.function.Inverse;
import org.apache.commons.math3.analysis.function.Constant;
-import org.apache.commons.math3.util.FastMath;
-import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.analysis.function.Inverse;
+import org.apache.commons.math3.analysis.function.Sin;
+import org.apache.commons.math3.analysis.function.Sqrt;
import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
+import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -49,7 +49,7 @@ public final class BrentSolverTest {
// The sinus function is behaved well around the root at pi. The second
// order derivative is zero, which means linar approximating methods
will
// still converge quadratically.
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
double result;
UnivariateSolver solver = new BrentSolver();
// Somewhat benign interval. The function is monotone.
@@ -162,7 +162,7 @@ public final class BrentSolverTest {
@Test
public void testRootEndpoints() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
BrentSolver solver = new BrentSolver();
// endpoint is root
@@ -181,7 +181,7 @@ public final class BrentSolverTest {
@Test
public void testBadEndpoints() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
BrentSolver solver = new BrentSolver();
try { // bad interval
solver.solve(100, f, 1, -1);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolver2Test.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolver2Test.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolver2Test.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolver2Test.java
Sat Aug 18 18:11:11 2012
@@ -16,12 +16,12 @@
*/
package org.apache.commons.math3.analysis.solvers;
-import org.apache.commons.math3.analysis.Expm1Function;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.analysis.function.Expm1;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -45,7 +45,7 @@ public final class MullerSolver2Test {
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new MullerSolver2();
double min, max, expected, result, tolerance;
@@ -97,7 +97,7 @@ public final class MullerSolver2Test {
*/
@Test
public void testExpm1Function() {
- UnivariateFunction f = new Expm1Function();
+ UnivariateFunction f = new Expm1();
UnivariateSolver solver = new MullerSolver2();
double min, max, expected, result, tolerance;
@@ -125,7 +125,7 @@ public final class MullerSolver2Test {
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new MullerSolver2();
try {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/MullerSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -16,12 +16,12 @@
*/
package org.apache.commons.math3.analysis.solvers;
-import org.apache.commons.math3.analysis.Expm1Function;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.analysis.function.Expm1;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NoBracketingException;
+import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -45,7 +45,7 @@ public final class MullerSolverTest {
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new MullerSolver();
double min, max, expected, result, tolerance;
@@ -99,7 +99,7 @@ public final class MullerSolverTest {
*/
@Test
public void testExpm1Function() {
- UnivariateFunction f = new Expm1Function();
+ UnivariateFunction f = new Expm1();
UnivariateSolver solver = new MullerSolver();
double min, max, expected, result, tolerance;
@@ -127,7 +127,7 @@ public final class MullerSolverTest {
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new MullerSolver();
try {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/NewtonSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/NewtonSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/NewtonSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/NewtonSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -18,7 +18,10 @@ package org.apache.commons.math3.analysi
import org.apache.commons.math3.analysis.DifferentiableUnivariateFunction;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
+import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.differentiation.DerivativeStructure;
+import
org.apache.commons.math3.analysis.differentiation.UnivariateDifferentiable;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -33,7 +36,7 @@ public final class NewtonSolverTest {
*/
@Test
public void testSinZero() {
- DifferentiableUnivariateFunction f = new SinFunction();
+ DifferentiableUnivariateFunction f = new Sin();
double result;
NewtonSolver solver = new NewtonSolver();
@@ -51,7 +54,22 @@ public final class NewtonSolverTest {
*/
@Test
public void testQuinticZero() {
- DifferentiableUnivariateFunction f = new QuinticFunction();
+ final UnivariateDifferentiable q = new QuinticFunction();
+ DifferentiableUnivariateFunction f = new
DifferentiableUnivariateFunction() {
+
+ public double value(double x) {
+ return q.value(x);
+ }
+
+ public UnivariateFunction derivative() {
+ return new UnivariateFunction() {
+ public double value(double x) {
+ return q.value(new DerivativeStructure(1, 1, 0,
x)).getPartialDerivative(1);
+ }
+ };
+ }
+
+ };
double result;
NewtonSolver solver = new NewtonSolver();
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/RiddersSolverTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/RiddersSolverTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/RiddersSolverTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/RiddersSolverTest.java
Sat Aug 18 18:11:11 2012
@@ -16,13 +16,13 @@
*/
package org.apache.commons.math3.analysis.solvers;
-import org.apache.commons.math3.analysis.Expm1Function;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.util.FastMath;
+import org.apache.commons.math3.analysis.function.Expm1;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NoBracketingException;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
+import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -43,7 +43,7 @@ public final class RiddersSolverTest {
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new RiddersSolver();
double min, max, expected, result, tolerance;
@@ -93,7 +93,7 @@ public final class RiddersSolverTest {
*/
@Test
public void testExpm1Function() {
- UnivariateFunction f = new Expm1Function();
+ UnivariateFunction f = new Expm1();
UnivariateSolver solver = new RiddersSolver();
double min, max, expected, result, tolerance;
@@ -121,7 +121,7 @@ public final class RiddersSolverTest {
*/
@Test
public void testParameters() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateSolver solver = new RiddersSolver();
try {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/analysis/solvers/UnivariateSolverUtilsTest.java
Sat Aug 18 18:11:11 2012
@@ -17,10 +17,10 @@
package org.apache.commons.math3.analysis.solvers;
-import org.apache.commons.math3.exception.MathIllegalArgumentException;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.QuinticFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
import org.junit.Test;
@@ -30,7 +30,7 @@ import org.junit.Test;
*/
public class UnivariateSolverUtilsTest {
- protected UnivariateFunction sin = new SinFunction();
+ protected UnivariateFunction sin = new Sin();
@Test(expected=MathIllegalArgumentException.class)
public void testSolveNull() {
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/BrentOptimizerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/BrentOptimizerTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/BrentOptimizerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/BrentOptimizerTest.java
Sat Aug 18 18:11:11 2012
@@ -17,14 +17,14 @@
package org.apache.commons.math3.optimization.univariate;
+import org.apache.commons.math3.analysis.QuinticFunction;
+import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.exception.NumberIsTooLargeException;
import org.apache.commons.math3.exception.NumberIsTooSmallException;
import org.apache.commons.math3.exception.TooManyEvaluationsException;
-import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
-import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.optimization.GoalType;
import org.apache.commons.math3.optimization.ConvergenceChecker;
+import org.apache.commons.math3.optimization.GoalType;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.commons.math3.util.FastMath;
import org.junit.Assert;
@@ -37,7 +37,7 @@ public final class BrentOptimizerTest {
@Test
public void testSinMin() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateOptimizer optimizer = new BrentOptimizer(1e-10, 1e-14);
Assert.assertEquals(3 * Math.PI / 2, optimizer.optimize(200, f,
GoalType.MINIMIZE, 4, 5).getPoint(),1e-8);
Assert.assertTrue(optimizer.getEvaluations() <= 50);
@@ -55,7 +55,7 @@ public final class BrentOptimizerTest {
@Test
public void testSinMinWithValueChecker() {
- final UnivariateFunction f = new SinFunction();
+ final UnivariateFunction f = new Sin();
final ConvergenceChecker<UnivariatePointValuePair> checker = new
SimpleUnivariateValueChecker(1e-5, 1e-14);
// The default stopping criterion of Brent's algorithm should not
// pass, but the search will stop at the given relative tolerance
@@ -148,7 +148,7 @@ public final class BrentOptimizerTest {
@Test
public void testMinEndpoints() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateOptimizer optimizer = new BrentOptimizer(1e-8, 1e-14);
// endpoint is minimum
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/UnivariateMultiStartOptimizerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/UnivariateMultiStartOptimizerTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/UnivariateMultiStartOptimizerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/optimization/univariate/UnivariateMultiStartOptimizerTest.java
Sat Aug 18 18:11:11 2012
@@ -18,20 +18,19 @@
package org.apache.commons.math3.optimization.univariate;
import org.apache.commons.math3.analysis.QuinticFunction;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
-import org.apache.commons.math3.optimization.univariate.BrentOptimizer;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.optimization.GoalType;
import org.apache.commons.math3.random.JDKRandomGenerator;
import org.apache.commons.math3.util.FastMath;
-import org.junit.Test;
import org.junit.Assert;
+import org.junit.Test;
public class UnivariateMultiStartOptimizerTest {
@Test
public void testSinMin() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
UnivariateOptimizer underlying = new BrentOptimizer(1e-10, 1e-14);
JDKRandomGenerator g = new JDKRandomGenerator();
g.setSeed(44428400075l);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastCosineTransformerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastCosineTransformerTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastCosineTransformerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastCosineTransformerTest.java
Sat Aug 18 18:11:11 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math3.transfo
import java.util.Arrays;
import java.util.Collection;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.analysis.function.Sinc;
import org.apache.commons.math3.exception.MathIllegalStateException;
import org.apache.commons.math3.util.FastMath;
@@ -218,7 +218,7 @@ public final class FastCosineTransformer
@Test
public void testParameters()
throws Exception {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
FastCosineTransformer transformer;
transformer = new
FastCosineTransformer(DctNormalization.STANDARD_DCT_I);
@@ -250,7 +250,7 @@ public final class FastCosineTransformer
/** Test of transformer for the sine function. */
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
FastCosineTransformer transformer;
transformer = new
FastCosineTransformer(DctNormalization.STANDARD_DCT_I);
double min, max, result[], tolerance = 1E-12;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastFourierTransformerTest.java
Sat Aug 18 18:11:11 2012
@@ -18,7 +18,6 @@ package org.apache.commons.math3.transfo
import java.util.Random;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.analysis.function.Sinc;
@@ -453,7 +452,7 @@ public final class FastFourierTransforme
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
FastFourierTransformer transformer;
transformer = new FastFourierTransformer(DftNormalization.STANDARD);
Complex result[]; int N = 1 << 8;
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastSineTransformerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastSineTransformerTest.java?rev=1374632&r1=1374631&r2=1374632&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastSineTransformerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/transform/FastSineTransformerTest.java
Sat Aug 18 18:11:11 2012
@@ -19,8 +19,8 @@ package org.apache.commons.math3.transfo
import java.util.Arrays;
import java.util.Collection;
-import org.apache.commons.math3.analysis.SinFunction;
import org.apache.commons.math3.analysis.UnivariateFunction;
+import org.apache.commons.math3.analysis.function.Sin;
import org.apache.commons.math3.analysis.function.Sinc;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.exception.MathIllegalStateException;
@@ -247,7 +247,7 @@ public final class FastSineTransformerTe
*/
@Test
public void testSinFunction() {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
FastSineTransformer transformer;
transformer = new FastSineTransformer(DstNormalization.STANDARD_DST_I);
double min, max, result[], tolerance = 1E-12; int N = 1 << 8;
@@ -272,7 +272,7 @@ public final class FastSineTransformerTe
*/
@Test
public void testParameters() throws Exception {
- UnivariateFunction f = new SinFunction();
+ UnivariateFunction f = new Sin();
FastSineTransformer transformer;
transformer = new FastSineTransformer(DstNormalization.STANDARD_DST_I);