Renamed "UnivariateRealIntegrator" to "UnivariateIntegrator" and
"UnivariateRealIntegratorImpl" to "BaseAbstractUnivariateIntegrator".


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1239390 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gilles Sadowski 2012-02-01 23:04:20 +00:00
parent 0043cafb2e
commit 0576e96e73
11 changed files with 27 additions and 27 deletions

View File

@ -33,7 +33,7 @@ import org.apache.commons.math.util.MathUtils;
* @version $Id$ * @version $Id$
* @since 1.2 * @since 1.2
*/ */
public abstract class UnivariateRealIntegratorImpl implements UnivariateRealIntegrator { public abstract class BaseAbstractUnivariateIntegrator implements UnivariateIntegrator {
/** Default absolute accuracy. */ /** Default absolute accuracy. */
public static final double DEFAULT_ABSOLUTE_ACCURACY = 1.0e-15; public static final double DEFAULT_ABSOLUTE_ACCURACY = 1.0e-15;
@ -106,7 +106,7 @@ public abstract class UnivariateRealIntegratorImpl implements UnivariateRealInte
* @exception NumberIsTooSmallException if maximal number of iterations * @exception NumberIsTooSmallException if maximal number of iterations
* is lesser than or equal to the minimal number of iterations * is lesser than or equal to the minimal number of iterations
*/ */
protected UnivariateRealIntegratorImpl(final double relativeAccuracy, protected BaseAbstractUnivariateIntegrator(final double relativeAccuracy,
final double absoluteAccuracy, final double absoluteAccuracy,
final int minimalIterationCount, final int minimalIterationCount,
final int maximalIterationCount) final int maximalIterationCount)
@ -137,7 +137,7 @@ public abstract class UnivariateRealIntegratorImpl implements UnivariateRealInte
* @param relativeAccuracy relative accuracy of the result * @param relativeAccuracy relative accuracy of the result
* @param absoluteAccuracy absolute accuracy of the result * @param absoluteAccuracy absolute accuracy of the result
*/ */
protected UnivariateRealIntegratorImpl(final double relativeAccuracy, protected BaseAbstractUnivariateIntegrator(final double relativeAccuracy,
final double absoluteAccuracy) { final double absoluteAccuracy) {
this(relativeAccuracy, absoluteAccuracy, this(relativeAccuracy, absoluteAccuracy,
DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT); DEFAULT_MIN_ITERATIONS_COUNT, DEFAULT_MAX_ITERATIONS_COUNT);
@ -152,7 +152,7 @@ public abstract class UnivariateRealIntegratorImpl implements UnivariateRealInte
* @exception NumberIsTooSmallException if maximal number of iterations * @exception NumberIsTooSmallException if maximal number of iterations
* is lesser than or equal to the minimal number of iterations * is lesser than or equal to the minimal number of iterations
*/ */
protected UnivariateRealIntegratorImpl(final int minimalIterationCount, protected BaseAbstractUnivariateIntegrator(final int minimalIterationCount,
final int maximalIterationCount) final int maximalIterationCount)
throws NotStrictlyPositiveException, NumberIsTooSmallException { throws NotStrictlyPositiveException, NumberIsTooSmallException {
this(DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY, this(DEFAULT_RELATIVE_ACCURACY, DEFAULT_ABSOLUTE_ACCURACY,

View File

@ -51,7 +51,7 @@ import org.apache.commons.math.util.FastMath;
* @since 1.2 * @since 1.2
*/ */
public class LegendreGaussIntegrator extends UnivariateRealIntegratorImpl { public class LegendreGaussIntegrator extends BaseAbstractUnivariateIntegrator {
/** Abscissas for the 2 points method. */ /** Abscissas for the 2 points method. */
private static final double[] ABSCISSAS_2 = { private static final double[] ABSCISSAS_2 = {

View File

@ -36,7 +36,7 @@ import org.apache.commons.math.util.FastMath;
* @version $Id$ * @version $Id$
* @since 1.2 * @since 1.2
*/ */
public class RombergIntegrator extends UnivariateRealIntegratorImpl { public class RombergIntegrator extends BaseAbstractUnivariateIntegrator {
/** Maximal number of iterations for Romberg. */ /** Maximal number of iterations for Romberg. */
public static final int ROMBERG_MAX_ITERATIONS_COUNT = 32; public static final int ROMBERG_MAX_ITERATIONS_COUNT = 32;

View File

@ -35,7 +35,7 @@ import org.apache.commons.math.util.FastMath;
* @version $Id$ * @version $Id$
* @since 1.2 * @since 1.2
*/ */
public class SimpsonIntegrator extends UnivariateRealIntegratorImpl { public class SimpsonIntegrator extends BaseAbstractUnivariateIntegrator {
/** Maximal number of iterations for Simpson. */ /** Maximal number of iterations for Simpson. */
public static final int SIMPSON_MAX_ITERATIONS_COUNT = 64; public static final int SIMPSON_MAX_ITERATIONS_COUNT = 64;

View File

@ -34,7 +34,7 @@ import org.apache.commons.math.util.FastMath;
* @version $Id$ * @version $Id$
* @since 1.2 * @since 1.2
*/ */
public class TrapezoidIntegrator extends UnivariateRealIntegratorImpl { public class TrapezoidIntegrator extends BaseAbstractUnivariateIntegrator {
/** Maximum number of iterations for trapezoid. */ /** Maximum number of iterations for trapezoid. */
public static final int TRAPEZOID_MAX_ITERATIONS_COUNT = 64; public static final int TRAPEZOID_MAX_ITERATIONS_COUNT = 64;
@ -113,7 +113,7 @@ public class TrapezoidIntegrator extends UnivariateRealIntegratorImpl {
* @throws TooManyEvaluationsException if the maximal number of evaluations * @throws TooManyEvaluationsException if the maximal number of evaluations
* is exceeded. * is exceeded.
*/ */
double stage(final UnivariateRealIntegratorImpl baseIntegrator, final int n) double stage(final BaseAbstractUnivariateIntegrator baseIntegrator, final int n)
throws TooManyEvaluationsException { throws TooManyEvaluationsException {
if (n == 0) { if (n == 0) {

View File

@ -28,7 +28,7 @@ import org.apache.commons.math.exception.TooManyEvaluationsException;
* @version $Id$ * @version $Id$
* @since 1.2 * @since 1.2
*/ */
public interface UnivariateRealIntegrator { public interface UnivariateIntegrator {
/** /**
* Get the actual relative accuracy. * Get the actual relative accuracy.

View File

@ -33,7 +33,7 @@ public class LegendreGaussIntegratorTest {
@Test @Test
public void testSinFunction() { public void testSinFunction() {
UnivariateFunction f = new SinFunction(); UnivariateFunction f = new SinFunction();
UnivariateRealIntegratorImpl integrator = new LegendreGaussIntegrator(5, 1.0e-14, 1.0e-10, 2, 15); BaseAbstractUnivariateIntegrator integrator = new LegendreGaussIntegrator(5, 1.0e-14, 1.0e-10, 2, 15);
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = FastMath.PI; expected = 2; min = 0; max = FastMath.PI; expected = 2;
@ -52,11 +52,11 @@ public class LegendreGaussIntegratorTest {
@Test @Test
public void testQuinticFunction() { public void testQuinticFunction() {
UnivariateFunction f = new QuinticFunction(); UnivariateFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = UnivariateIntegrator integrator =
new LegendreGaussIntegrator(3, new LegendreGaussIntegrator(3,
UnivariateRealIntegratorImpl.DEFAULT_RELATIVE_ACCURACY, BaseAbstractUnivariateIntegrator.DEFAULT_RELATIVE_ACCURACY,
UnivariateRealIntegratorImpl.DEFAULT_ABSOLUTE_ACCURACY, BaseAbstractUnivariateIntegrator.DEFAULT_ABSOLUTE_ACCURACY,
UnivariateRealIntegratorImpl.DEFAULT_MIN_ITERATIONS_COUNT, BaseAbstractUnivariateIntegrator.DEFAULT_MIN_ITERATIONS_COUNT,
64); 64);
double min, max, expected, result; double min, max, expected, result;
@ -79,9 +79,9 @@ public class LegendreGaussIntegratorTest {
for (int n = 2; n < 6; ++n) { for (int n = 2; n < 6; ++n) {
LegendreGaussIntegrator integrator = LegendreGaussIntegrator integrator =
new LegendreGaussIntegrator(n, new LegendreGaussIntegrator(n,
UnivariateRealIntegratorImpl.DEFAULT_RELATIVE_ACCURACY, BaseAbstractUnivariateIntegrator.DEFAULT_RELATIVE_ACCURACY,
UnivariateRealIntegratorImpl.DEFAULT_ABSOLUTE_ACCURACY, BaseAbstractUnivariateIntegrator.DEFAULT_ABSOLUTE_ACCURACY,
UnivariateRealIntegratorImpl.DEFAULT_MIN_ITERATIONS_COUNT, BaseAbstractUnivariateIntegrator.DEFAULT_MIN_ITERATIONS_COUNT,
64); 64);
// an n points Gauss-Legendre integrator integrates 2n-1 degree polynoms exactly // an n points Gauss-Legendre integrator integrates 2n-1 degree polynoms exactly

View File

@ -43,7 +43,7 @@ public final class RombergIntegratorTest {
@Test @Test
public void testSinFunction() { public void testSinFunction() {
UnivariateFunction f = new SinFunction(); UnivariateFunction f = new SinFunction();
UnivariateRealIntegrator integrator = new RombergIntegrator(); UnivariateIntegrator integrator = new RombergIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = FastMath.PI; expected = 2; min = 0; max = FastMath.PI; expected = 2;
@ -67,7 +67,7 @@ public final class RombergIntegratorTest {
@Test @Test
public void testQuinticFunction() { public void testQuinticFunction() {
UnivariateFunction f = new QuinticFunction(); UnivariateFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new RombergIntegrator(); UnivariateIntegrator integrator = new RombergIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48; min = 0; max = 1; expected = -1.0/48;

View File

@ -42,7 +42,7 @@ public final class SimpsonIntegratorTest {
@Test @Test
public void testSinFunction() { public void testSinFunction() {
UnivariateFunction f = new SinFunction(); UnivariateFunction f = new SinFunction();
UnivariateRealIntegrator integrator = new SimpsonIntegrator(); UnivariateIntegrator integrator = new SimpsonIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = FastMath.PI; expected = 2; min = 0; max = FastMath.PI; expected = 2;
@ -66,7 +66,7 @@ public final class SimpsonIntegratorTest {
@Test @Test
public void testQuinticFunction() { public void testQuinticFunction() {
UnivariateFunction f = new QuinticFunction(); UnivariateFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new SimpsonIntegrator(); UnivariateIntegrator integrator = new SimpsonIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48; min = 0; max = 1; expected = -1.0/48;

View File

@ -42,7 +42,7 @@ public final class TrapezoidIntegratorTest {
@Test @Test
public void testSinFunction() { public void testSinFunction() {
UnivariateFunction f = new SinFunction(); UnivariateFunction f = new SinFunction();
UnivariateRealIntegrator integrator = new TrapezoidIntegrator(); UnivariateIntegrator integrator = new TrapezoidIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = FastMath.PI; expected = 2; min = 0; max = FastMath.PI; expected = 2;
@ -66,7 +66,7 @@ public final class TrapezoidIntegratorTest {
@Test @Test
public void testQuinticFunction() { public void testQuinticFunction() {
UnivariateFunction f = new QuinticFunction(); UnivariateFunction f = new QuinticFunction();
UnivariateRealIntegrator integrator = new TrapezoidIntegrator(); UnivariateIntegrator integrator = new TrapezoidIntegrator();
double min, max, expected, result, tolerance; double min, max, expected, result, tolerance;
min = 0; max = 1; expected = -1.0/48; min = 0; max = 1; expected = -1.0/48;

View File

@ -18,7 +18,7 @@ package org.apache.commons.math.distribution;
import org.apache.commons.math.analysis.UnivariateFunction; import org.apache.commons.math.analysis.UnivariateFunction;
import org.apache.commons.math.analysis.integration.RombergIntegrator; import org.apache.commons.math.analysis.integration.RombergIntegrator;
import org.apache.commons.math.analysis.integration.UnivariateRealIntegrator; import org.apache.commons.math.analysis.integration.UnivariateIntegrator;
import org.apache.commons.math.exception.OutOfRangeException; import org.apache.commons.math.exception.OutOfRangeException;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -156,7 +156,7 @@ public class AbstractRealDistributionTest {
return x * density(x); return x * density(x);
} }
}; };
final UnivariateRealIntegrator integrator = new RombergIntegrator(); final UnivariateIntegrator integrator = new RombergIntegrator();
return integrator.integrate(Integer.MAX_VALUE, f, x0, x4); return integrator.integrate(Integer.MAX_VALUE, f, x0, x4);
} }
@ -168,7 +168,7 @@ public class AbstractRealDistributionTest {
return x * x * density(x); return x * x * density(x);
} }
}; };
final UnivariateRealIntegrator integrator = new RombergIntegrator(); final UnivariateIntegrator integrator = new RombergIntegrator();
final double meanX2 = integrator.integrate(Integer.MAX_VALUE, final double meanX2 = integrator.integrate(Integer.MAX_VALUE,
f, x0, x4); f, x0, x4);
return meanX2 - meanX * meanX; return meanX2 - meanX * meanX;