renamed the RungeKuttaFehlbergIntegrator base class to EmbeddedRungKuttaIntegrator
since it is more general than the single method designed by Fehlberg renamed some misleading private fields in the corresponding derived classes git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@592894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
79897391b4
commit
a7c2df9f2f
|
@ -70,7 +70,7 @@ public abstract class AbstractStepInterpolator
|
|||
* instance in order to initialize the internal arrays. This
|
||||
* constructor is used only in order to delay the initialization in
|
||||
* some cases. As an example, the {@link
|
||||
* RungeKuttaFehlbergIntegrator} uses the prototyping design pattern
|
||||
* EmbeddedRungeKuttaIntegrator} uses the prototyping design pattern
|
||||
* to create the step interpolators by cloning an uninitialized
|
||||
* model and latter initializing the copy.
|
||||
*/
|
||||
|
@ -296,7 +296,7 @@ public abstract class AbstractStepInterpolator
|
|||
/**
|
||||
* Finalize the step.
|
||||
|
||||
* <p>Some Runge-Kutta-Fehlberg integrators need fewer functions
|
||||
* <p>Some embedded Runge-Kutta integrators need fewer functions
|
||||
* evaluations than their counterpart step interpolators. These
|
||||
* interpolators should perform the last evaluations they need by
|
||||
* themselves only if they need them. This method triggers these
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.commons.math.ode;
|
|||
* This class implements the 5(4) Dormand-Prince integrator for Ordinary
|
||||
* Differential Equations.
|
||||
|
||||
* <p>This integrator is an embedded Runge-Kutta-Fehlberg integrator
|
||||
* <p>This integrator is an embedded Runge-Kutta integrator
|
||||
* of order 5(4) used in local extrapolation mode (i.e. the solution
|
||||
* is computed using the high order formula) with stepsize control
|
||||
* (and automatic step initialization) and continuous output. This
|
||||
|
@ -44,15 +44,15 @@ package org.apache.commons.math.ode;
|
|||
*/
|
||||
|
||||
public class DormandPrince54Integrator
|
||||
extends RungeKuttaFehlbergIntegrator {
|
||||
extends EmbeddedRungeKuttaIntegrator {
|
||||
|
||||
private static final String methodName = "Dormand-Prince 5(4)";
|
||||
|
||||
private static final double[] c = {
|
||||
private static final double[] staticC = {
|
||||
1.0/5.0, 3.0/10.0, 4.0/5.0, 8.0/9.0, 1.0, 1.0
|
||||
};
|
||||
|
||||
private static final double[][] a = {
|
||||
private static final double[][] staticA = {
|
||||
{1.0/5.0},
|
||||
{3.0/40.0, 9.0/40.0},
|
||||
{44.0/45.0, -56.0/15.0, 32.0/9.0},
|
||||
|
@ -61,7 +61,7 @@ public class DormandPrince54Integrator
|
|||
{35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0}
|
||||
};
|
||||
|
||||
private static final double[] b = {
|
||||
private static final double[] staticB = {
|
||||
35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0, 0.0
|
||||
};
|
||||
|
||||
|
@ -84,7 +84,7 @@ public class DormandPrince54Integrator
|
|||
public DormandPrince54Integrator(double minStep, double maxStep,
|
||||
double scalAbsoluteTolerance,
|
||||
double scalRelativeTolerance) {
|
||||
super(true, c, a, b, new DormandPrince54StepInterpolator(),
|
||||
super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
|
||||
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,7 @@ public class DormandPrince54Integrator
|
|||
public DormandPrince54Integrator(double minStep, double maxStep,
|
||||
double[] vecAbsoluteTolerance,
|
||||
double[] vecRelativeTolerance) {
|
||||
super(true, c, a, b, new DormandPrince54StepInterpolator(),
|
||||
super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
|
||||
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class DormandPrince54StepInterpolator
|
|||
* {@link #reinitialize} method should be called before using the
|
||||
* instance in order to initialize the internal arrays. This
|
||||
* constructor is used only in order to delay the initialization in
|
||||
* some cases. The {@link RungeKuttaFehlbergIntegrator} uses the
|
||||
* some cases. The {@link EmbeddedRungeKuttaIntegrator} uses the
|
||||
* prototyping design pattern to create the step interpolators by
|
||||
* cloning an uninitialized model and latter initializing the copy.
|
||||
*/
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.commons.math.ode;
|
|||
* This class implements the 8(5,3) Dormand-Prince integrator for Ordinary
|
||||
* Differential Equations.
|
||||
|
||||
* <p>This integrator is an embedded Runge-Kutta-Fehlberg integrator
|
||||
* <p>This integrator is an embedded Runge-Kutta integrator
|
||||
* of order 8(5,3) used in local extrapolation mode (i.e. the solution
|
||||
* is computed using the high order formula) with stepsize control
|
||||
* (and automatic step initialization) and continuous output. This
|
||||
|
@ -52,19 +52,19 @@ package org.apache.commons.math.ode;
|
|||
*/
|
||||
|
||||
public class DormandPrince853Integrator
|
||||
extends RungeKuttaFehlbergIntegrator {
|
||||
extends EmbeddedRungeKuttaIntegrator {
|
||||
|
||||
private static final String methodName = "Dormand-Prince 8 (5, 3)";
|
||||
|
||||
private static final double sqrt6 = Math.sqrt(6.0);
|
||||
|
||||
private static final double[] c = {
|
||||
private static final double[] staticC = {
|
||||
(12.0 - 2.0 * sqrt6) / 135.0, (6.0 - sqrt6) / 45.0, (6.0 - sqrt6) / 30.0,
|
||||
(6.0 + sqrt6) / 30.0, 1.0/3.0, 1.0/4.0, 4.0/13.0, 127.0/195.0, 3.0/5.0,
|
||||
6.0/7.0, 1.0, 1.0
|
||||
};
|
||||
|
||||
private static final double[][] a = {
|
||||
private static final double[][] staticA = {
|
||||
|
||||
// k2
|
||||
{(12.0 - 2.0 * sqrt6) / 135.0},
|
||||
|
@ -130,7 +130,7 @@ public class DormandPrince853Integrator
|
|||
|
||||
};
|
||||
|
||||
private static final double[] b = {
|
||||
private static final double[] staticB = {
|
||||
104257.0/1920240.0,
|
||||
0.0,
|
||||
0.0,
|
||||
|
@ -176,7 +176,7 @@ public class DormandPrince853Integrator
|
|||
public DormandPrince853Integrator(double minStep, double maxStep,
|
||||
double scalAbsoluteTolerance,
|
||||
double scalRelativeTolerance) {
|
||||
super(true, c, a, b,
|
||||
super(true, staticC, staticA, staticB,
|
||||
new DormandPrince853StepInterpolator(),
|
||||
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public class DormandPrince853Integrator
|
|||
public DormandPrince853Integrator(double minStep, double maxStep,
|
||||
double[] vecAbsoluteTolerance,
|
||||
double[] vecRelativeTolerance) {
|
||||
super(true, c, a, b,
|
||||
super(true, staticC, staticA, staticB,
|
||||
new DormandPrince853StepInterpolator(),
|
||||
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ class DormandPrince853StepInterpolator
|
|||
* {@link #reinitialize} method should be called before using the
|
||||
* instance in order to initialize the internal arrays. This
|
||||
* constructor is used only in order to delay the initialization in
|
||||
* some cases. The {@link RungeKuttaFehlbergIntegrator} uses the
|
||||
* some cases. The {@link EmbeddedRungeKuttaIntegrator} uses the
|
||||
* prototyping design pattern to create the step interpolators by
|
||||
* cloning an uninitialized model and latter initializing the copy.
|
||||
*/
|
||||
|
@ -95,11 +95,11 @@ class DormandPrince853StepInterpolator
|
|||
}
|
||||
|
||||
/** Reinitialize the instance
|
||||
* Some Runge-Kutta-Fehlberg integrators need fewer functions
|
||||
* Some embedded Runge-Kutta integrators need fewer functions
|
||||
* evaluations than their counterpart step interpolators. So the
|
||||
* interpolator should perform the last evaluations they need by
|
||||
* themselves. The {@link RungeKuttaFehlbergIntegrator
|
||||
* RungeKuttaFehlbergIntegrator} abstract class calls this method in
|
||||
* themselves. The {@link EmbeddedRungeKuttaIntegrator
|
||||
* EmbeddedRungeKuttaIntegrator} abstract class calls this method in
|
||||
* order to let the step interpolator perform the evaluations it
|
||||
* needs. These evaluations will be performed during the call to
|
||||
* <code>doFinalize</code> if any, i.e. only if the step handler
|
||||
|
|
|
@ -44,7 +44,7 @@ public class DummyStepInterpolator
|
|||
* should be called before using the instance in order to initialize
|
||||
* the internal arrays. This constructor is used only in order to delay
|
||||
* the initialization in some cases. As an example, the {@link
|
||||
* RungeKuttaFehlbergIntegrator} uses the prototyping design pattern
|
||||
* EmbeddedRungeKuttaIntegrator} uses the prototyping design pattern
|
||||
* to create the step interpolators by cloning an uninitialized
|
||||
* model and latter initializing the copy.
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
package org.apache.commons.math.ode;
|
||||
|
||||
/**
|
||||
* This class implements the common part of all Runge-Kutta-Fehlberg
|
||||
* This class implements the common part of all embedde Runge-Kutta
|
||||
* integrators for Ordinary Differential Equations.
|
||||
|
||||
* <p>These methods are embedded explicit Runge-Kutta methods with two
|
||||
|
@ -50,11 +50,11 @@ package org.apache.commons.math.ode;
|
|||
* evaluation is saved. For an <i>fsal</i> method, we have cs = 1 and
|
||||
* asi = bi for all i.</p>
|
||||
|
||||
* @version $Id: RungeKuttaFehlbergIntegrator.java 1705 2006-09-17 19:57:39Z luc $
|
||||
* @version $Id: EmbeddedRungeKuttaIntegrator.java 1705 2006-09-17 19:57:39Z luc $
|
||||
|
||||
*/
|
||||
|
||||
public abstract class RungeKuttaFehlbergIntegrator
|
||||
public abstract class EmbeddedRungeKuttaIntegrator
|
||||
extends AdaptiveStepsizeIntegrator {
|
||||
|
||||
/** Build a Runge-Kutta integrator with the given Butcher array.
|
||||
|
@ -70,7 +70,7 @@ public abstract class RungeKuttaFehlbergIntegrator
|
|||
* @param scalAbsoluteTolerance allowed absolute error
|
||||
* @param scalRelativeTolerance allowed relative error
|
||||
*/
|
||||
protected RungeKuttaFehlbergIntegrator(boolean fsal,
|
||||
protected EmbeddedRungeKuttaIntegrator(boolean fsal,
|
||||
double[] c, double[][] a, double[] b,
|
||||
RungeKuttaStepInterpolator prototype,
|
||||
double minStep, double maxStep,
|
||||
|
@ -107,7 +107,7 @@ public abstract class RungeKuttaFehlbergIntegrator
|
|||
* @param vecAbsoluteTolerance allowed absolute error
|
||||
* @param vecRelativeTolerance allowed relative error
|
||||
*/
|
||||
protected RungeKuttaFehlbergIntegrator(boolean fsal,
|
||||
protected EmbeddedRungeKuttaIntegrator(boolean fsal,
|
||||
double[] c, double[][] a, double[] b,
|
||||
RungeKuttaStepInterpolator prototype,
|
||||
double minStep, double maxStep,
|
|
@ -31,7 +31,7 @@ package org.apache.commons.math.ode;
|
|||
* integration, in order to minimize computation cost. It is
|
||||
* particularly well suited when a very high precision is needed. The
|
||||
* limit where this method becomes more efficient than high-order
|
||||
* Runge-Kutta-Fehlberg methods like {@link DormandPrince853Integrator
|
||||
* embedded Runge-Kutta methods like {@link DormandPrince853Integrator
|
||||
* Dormand-Prince 8(5,3)} depends on the problem. Results given in the
|
||||
* Hairer, Norsett and Wanner book show for example that this limit
|
||||
* occurs for accuracy around 1e-6 when integrating Saltzam-Lorenz
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.commons.math.ode;
|
|||
* This class implements the 5(4) Higham and Hall integrator for
|
||||
* Ordinary Differential Equations.
|
||||
|
||||
* <p>This integrator is an embedded Runge-Kutta-Fehlberg integrator
|
||||
* <p>This integrator is an embedded Runge-Kutta integrator
|
||||
* of order 5(4) used in local extrapolation mode (i.e. the solution
|
||||
* is computed using the high order formula) with stepsize control
|
||||
* (and automatic step initialization) and continuous output. This
|
||||
|
@ -32,15 +32,15 @@ package org.apache.commons.math.ode;
|
|||
*/
|
||||
|
||||
public class HighamHall54Integrator
|
||||
extends RungeKuttaFehlbergIntegrator {
|
||||
extends EmbeddedRungeKuttaIntegrator {
|
||||
|
||||
private static final String methodName = "Higham-Hall 5(4)";
|
||||
|
||||
private static final double[] c = {
|
||||
private static final double[] staticC = {
|
||||
2.0/9.0, 1.0/3.0, 1.0/2.0, 3.0/5.0, 1.0, 1.0
|
||||
};
|
||||
|
||||
private static final double[][] a = {
|
||||
private static final double[][] staticA = {
|
||||
{2.0/9.0},
|
||||
{1.0/12.0, 1.0/4.0},
|
||||
{1.0/8.0, 0.0, 3.0/8.0},
|
||||
|
@ -49,11 +49,11 @@ public class HighamHall54Integrator
|
|||
{1.0/12.0, 0.0, 27.0/32.0, -4.0/3.0, 125.0/96.0, 5.0/48.0}
|
||||
};
|
||||
|
||||
private static final double[] b = {
|
||||
private static final double[] staticB = {
|
||||
1.0/12.0, 0.0, 27.0/32.0, -4.0/3.0, 125.0/96.0, 5.0/48.0, 0.0
|
||||
};
|
||||
|
||||
private static final double[] e = {
|
||||
private static final double[] staticE = {
|
||||
-1.0/20.0, 0.0, 81.0/160.0, -6.0/5.0, 25.0/32.0, 1.0/16.0, -1.0/10.0
|
||||
};
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class HighamHall54Integrator
|
|||
public HighamHall54Integrator(double minStep, double maxStep,
|
||||
double scalAbsoluteTolerance,
|
||||
double scalRelativeTolerance) {
|
||||
super(false, c, a, b, new HighamHall54StepInterpolator(),
|
||||
super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
|
||||
minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class HighamHall54Integrator
|
|||
public HighamHall54Integrator(double minStep, double maxStep,
|
||||
double[] vecAbsoluteTolerance,
|
||||
double[] vecRelativeTolerance) {
|
||||
super(false, c, a, b, new HighamHall54StepInterpolator(),
|
||||
super(false, staticC, staticA, staticB, new HighamHall54StepInterpolator(),
|
||||
minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
|
||||
}
|
||||
|
||||
|
@ -117,9 +117,9 @@ public class HighamHall54Integrator
|
|||
double error = 0;
|
||||
|
||||
for (int j = 0; j < y0.length; ++j) {
|
||||
double errSum = e[0] * yDotK[0][j];
|
||||
for (int l = 1; l < e.length; ++l) {
|
||||
errSum += e[l] * yDotK[l][j];
|
||||
double errSum = staticE[0] * yDotK[0][j];
|
||||
for (int l = 1; l < staticE.length; ++l) {
|
||||
errSum += staticE[l] * yDotK[l][j];
|
||||
}
|
||||
|
||||
double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
|
||||
|
|
|
@ -35,7 +35,7 @@ class HighamHall54StepInterpolator
|
|||
* {@link AbstractStepInterpolator#reinitialize} method should be called
|
||||
* before using the instance in order to initialize the internal arrays. This
|
||||
* constructor is used only in order to delay the initialization in
|
||||
* some cases. The {@link RungeKuttaFehlbergIntegrator} uses the
|
||||
* some cases. The {@link EmbeddedRungeKuttaIntegrator} uses the
|
||||
* prototyping design pattern to create the step interpolators by
|
||||
* cloning an uninitialized model and latter initializing the copy.
|
||||
*/
|
||||
|
|
|
@ -22,11 +22,10 @@ import java.io.ObjectOutput;
|
|||
import java.io.IOException;
|
||||
|
||||
/** This class represents an interpolator over the last step during an
|
||||
* ODE integration for Runge-Kutta and Runge-Kutta-Fehlberg
|
||||
* integrators.
|
||||
* ODE integration for Runge-Kutta and embedded Runge-Kutta integrators.
|
||||
*
|
||||
* @see RungeKuttaIntegrator
|
||||
* @see RungeKuttaFehlbergIntegrator
|
||||
* @see EmbeddedRungeKuttaIntegrator
|
||||
*
|
||||
* @version $Id: RungeKuttaStepInterpolator.java 1705 2006-09-17 19:57:39Z luc $
|
||||
*
|
||||
|
@ -41,7 +40,7 @@ abstract class RungeKuttaStepInterpolator
|
|||
* instance in order to initialize the internal arrays. This
|
||||
* constructor is used only in order to delay the initialization in
|
||||
* some cases. The {@link RungeKuttaIntegrator} and {@link
|
||||
* RungeKuttaFehlbergIntegrator} classes uses the prototyping design
|
||||
* EmbeddedRungeKuttaIntegrator} classes uses the prototyping design
|
||||
* pattern to create the step interpolators by cloning an
|
||||
* uninitialized model and latter initializing the copy.
|
||||
*/
|
||||
|
@ -97,7 +96,7 @@ abstract class RungeKuttaStepInterpolator
|
|||
* than their counterpart step interpolators. So the interpolator
|
||||
* should perform the last evaluations they need by themselves. The
|
||||
* {@link RungeKuttaIntegrator RungeKuttaIntegrator} and {@link
|
||||
* RungeKuttaFehlbergIntegrator RungeKuttaFehlbergIntegrator}
|
||||
* EmbeddedRungeKuttaIntegrator EmbeddedRungeKuttaIntegrator}
|
||||
* abstract classes call this method in order to let the step
|
||||
* interpolator perform the evaluations it needs. These evaluations
|
||||
* will be performed during the call to <code>doFinalize</code> if
|
||||
|
|
|
@ -143,7 +143,7 @@ public class DormandPrince54IntegratorTest
|
|||
double scalAbsoluteTolerance = Math.pow(10.0, i);
|
||||
double scalRelativeTolerance = 0.01 * scalAbsoluteTolerance;
|
||||
|
||||
RungeKuttaFehlbergIntegrator integ =
|
||||
EmbeddedRungeKuttaIntegrator integ =
|
||||
new DormandPrince54Integrator(minStep, maxStep,
|
||||
scalAbsoluteTolerance, scalRelativeTolerance);
|
||||
TestProblemHandler handler = new TestProblemHandler(pb, integ);
|
||||
|
|
Loading…
Reference in New Issue