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 2015/12/01 13:39:14 UTC
[1/2] [math] Reduced coupling between integrators and step
interpolators.
Repository: commons-math
Updated Branches:
refs/heads/field-ode 87664da98 -> e269953c4
Reduced coupling between integrators and step interpolators.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/d1d22013
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/d1d22013
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/d1d22013
Branch: refs/heads/field-ode
Commit: d1d220138af07a2e1e7dc7b9b0a4d22b5a8b249d
Parents: 87664da
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Dec 1 13:30:05 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Dec 1 13:30:05 2015 +0100
----------------------------------------------------------------------
.../ClassicalRungeKuttaFieldIntegrator.java | 2 +-
...lassicalRungeKuttaFieldStepInterpolator.java | 11 ++-
.../DormandPrince54FieldIntegrator.java | 2 +-
.../DormandPrince54FieldStepInterpolator.java | 21 +++--
.../DormandPrince853FieldIntegrator.java | 2 +-
.../DormandPrince853FieldStepInterpolator.java | 63 +++++++-------
.../ode/nonstiff/EulerFieldIntegrator.java | 2 +-
.../nonstiff/EulerFieldStepInterpolator.java | 15 ++--
.../math3/ode/nonstiff/GillFieldIntegrator.java | 2 +-
.../ode/nonstiff/GillFieldStepInterpolator.java | 11 ++-
.../nonstiff/HighamHall54FieldIntegrator.java | 2 +-
.../HighamHall54FieldStepInterpolator.java | 15 ++--
.../ode/nonstiff/LutherFieldIntegrator.java | 2 +-
.../nonstiff/LutherFieldStepInterpolator.java | 17 ++--
.../ode/nonstiff/MidpointFieldIntegrator.java | 2 +-
.../nonstiff/MidpointFieldStepInterpolator.java | 11 ++-
.../RungeKuttaFieldStepInterpolator.java | 41 ++++-----
.../nonstiff/ThreeEighthesFieldIntegrator.java | 2 +-
.../ThreeEighthesFieldStepInterpolator.java | 9 +-
.../sampling/AbstractFieldStepInterpolator.java | 89 +-------------------
20 files changed, 109 insertions(+), 212 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
index 064b56d..e5116e8 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
@@ -101,7 +101,7 @@ public class ClassicalRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
@Override
protected ClassicalRungeKuttaFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new ClassicalRungeKuttaFieldStepInterpolator<T>(this, forward, mapper);
+ return new ClassicalRungeKuttaFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java
index fc56870..74c220d 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/ClassicalRungeKuttaFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -60,14 +60,13 @@ class ClassicalRungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
extends RungeKuttaFieldStepInterpolator<T> {
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- ClassicalRungeKuttaFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ ClassicalRungeKuttaFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
@@ -92,7 +91,7 @@ class ClassicalRungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
final T time, final T theta,
final T oneMinusThetaH) {
- final T one = time.getField().getOne();
+ final T one = getField().getOne();
final T oneMinusTheta = one.subtract(theta);
final T oneMinus2Theta = one.subtract(theta.multiply(2));
final T coeffDot1 = oneMinusTheta.multiply(oneMinus2Theta);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldIntegrator.java
index 09bbc4a..2b01bdb 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldIntegrator.java
@@ -190,7 +190,7 @@ public class DormandPrince54FieldIntegrator<T extends RealFieldElement<T>>
@Override
protected DormandPrince54FieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new DormandPrince54FieldStepInterpolator<T>(this, forward, mapper);
+ return new DormandPrince54FieldStepInterpolator<T>(getField(), forward, mapper);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldStepInterpolator.java
index 23ba0e9..ca7e6c7 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince54FieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -73,15 +73,14 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
private final T d6;
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- DormandPrince54FieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ DormandPrince54FieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
- final T one = rkIntegrator.getField().getOne();
+ super(field, forward, mapper);
+ final T one = field.getOne();
a70 = one.multiply( 35.0).divide( 384.0);
a72 = one.multiply( 500.0).divide(1113.0);
a73 = one.multiply( 125.0).divide( 192.0);
@@ -131,7 +130,7 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
final T oneMinusThetaH) {
// interpolate
- final T one = theta.getField().getOne();
+ final T one = getField().getOne();
final T eta = one.subtract(theta);
final T twoTheta = theta.multiply(2);
final T dot2 = one.subtract(twoTheta);
@@ -148,7 +147,7 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
subtract(f2.multiply(a70.subtract(1))).
add(f3.multiply(a70.multiply(2).subtract(1))).
add(f4.multiply(d0));
- final T coeff1 = theta.getField().getZero();
+ final T coeff1 = getField().getZero();
final T coeff2 = f1.multiply(a72).
subtract(f2.multiply(a72)).
add(f3.multiply(a72.multiply(2))).
@@ -170,7 +169,7 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
subtract(dot2.multiply(a70.subtract(1))).
add(dot3.multiply(a70.multiply(2).subtract(1))).
add(dot4.multiply(d0));
- final T coeffDot1 = theta.getField().getZero();
+ final T coeffDot1 = getField().getZero();
final T coeffDot2 = a72.
subtract(dot2.multiply(a72)).
add(dot3.multiply(a72.multiply(2))).
@@ -201,7 +200,7 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
subtract(f2.multiply(a70.subtract(1))).
add(f3.multiply(a70.multiply(2).subtract(1))).
add(f4.multiply(d0));
- final T coeff1 = theta.getField().getZero();
+ final T coeff1 = getField().getZero();
final T coeff2 = f1.multiply(a72).
subtract(f2.multiply(a72)).
add(f3.multiply(a72.multiply(2))).
@@ -223,7 +222,7 @@ class DormandPrince54FieldStepInterpolator<T extends RealFieldElement<T>>
subtract(dot2.multiply(a70.subtract(1))).
add(dot3.multiply(a70.multiply(2).subtract(1))).
add(dot4.multiply(d0));
- final T coeffDot1 = theta.getField().getZero();
+ final T coeffDot1 = getField().getZero();
final T coeffDot2 = a72.
subtract(dot2.multiply(a72)).
add(dot3.multiply(a72.multiply(2))).
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldIntegrator.java
index 569cba4..86b3844 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldIntegrator.java
@@ -396,7 +396,7 @@ public class DormandPrince853FieldIntegrator<T extends RealFieldElement<T>>
@Override
protected DormandPrince853FieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new DormandPrince853FieldStepInterpolator<T>(this, forward, mapper);
+ return new DormandPrince853FieldStepInterpolator<T>(getField(), forward, mapper);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
index 7c1cdf5..182d8a6 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
@@ -17,9 +17,9 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
import org.apache.commons.math3.exception.MaxCountExceededException;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
import org.apache.commons.math3.util.MathArrays;
@@ -43,24 +43,23 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
private final T[][] d;
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- DormandPrince853FieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ DormandPrince853FieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
// interpolation weights
- d = MathArrays.buildArray(integrator.getField(), 4, 16);
+ d = MathArrays.buildArray(getField(), 4, 16);
// this row is the same as the b array
d[0][ 0] = fraction(104257, 1929240);
- d[0][ 1] = integrator.getField().getZero();
- d[0][ 2] = integrator.getField().getZero();
- d[0][ 3] = integrator.getField().getZero();
- d[0][ 4] = integrator.getField().getZero();
+ d[0][ 1] = getField().getZero();
+ d[0][ 2] = getField().getZero();
+ d[0][ 3] = getField().getZero();
+ d[0][ 4] = getField().getZero();
d[0][ 5] = fraction( 3399327.0, 763840.0);
d[0][ 6] = fraction( 66578432.0, 35198415.0);
d[0][ 7] = fraction( -1674902723.0, 288716400.0);
@@ -68,10 +67,10 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
d[0][ 9] = fraction( -734375.0, 4826304.0);
d[0][10] = fraction( 171414593.0, 851261400.0);
d[0][11] = fraction( 137909.0, 3084480.0);
- d[0][12] = integrator.getField().getZero();
- d[0][13] = integrator.getField().getZero();
- d[0][14] = integrator.getField().getZero();
- d[0][15] = integrator.getField().getZero();
+ d[0][12] = getField().getZero();
+ d[0][13] = getField().getZero();
+ d[0][14] = getField().getZero();
+ d[0][15] = getField().getZero();
d[1][ 0] = d[0][ 0].negate().add(1);
d[1][ 1] = d[0][ 1].negate();
@@ -108,10 +107,10 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
d[2][15] = d[0][15].multiply(2); // really 0
d[3][ 0] = fraction( -17751989329.0, 2106076560.0);
- d[3][ 1] = integrator.getField().getZero();
- d[3][ 2] = integrator.getField().getZero();
- d[3][ 3] = integrator.getField().getZero();
- d[3][ 4] = integrator.getField().getZero();
+ d[3][ 1] = getField().getZero();
+ d[3][ 2] = getField().getZero();
+ d[3][ 3] = getField().getZero();
+ d[3][ 4] = getField().getZero();
d[3][ 5] = fraction( 4272954039.0, 7539864640.0);
d[3][ 6] = fraction( -118476319744.0, 38604839385.0);
d[3][ 7] = fraction( 755123450731.0, 316657731600.0);
@@ -125,10 +124,10 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
d[3][15] = fraction( -1944542619.0, 438351368.0);
d[4][ 0] = fraction( 32941697297.0, 3159114840.0);
- d[4][ 1] = integrator.getField().getZero();
- d[4][ 2] = integrator.getField().getZero();
- d[4][ 3] = integrator.getField().getZero();
- d[4][ 4] = integrator.getField().getZero();
+ d[4][ 1] = getField().getZero();
+ d[4][ 2] = getField().getZero();
+ d[4][ 3] = getField().getZero();
+ d[4][ 4] = getField().getZero();
d[4][ 5] = fraction( 456696183123.0, 1884966160.0);
d[4][ 6] = fraction( 19132610714624.0, 115814518155.0);
d[4][ 7] = fraction( -177904688592943.0, 474986597400.0);
@@ -142,10 +141,10 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
d[4][15] = fraction( 15700361463.0, 438351368.0);
d[5][ 0] = fraction( 12627015655.0, 631822968.0);
- d[5][ 1] = integrator.getField().getZero();
- d[5][ 2] = integrator.getField().getZero();
- d[5][ 3] = integrator.getField().getZero();
- d[5][ 4] = integrator.getField().getZero();
+ d[5][ 1] = getField().getZero();
+ d[5][ 2] = getField().getZero();
+ d[5][ 3] = getField().getZero();
+ d[5][ 4] = getField().getZero();
d[5][ 5] = fraction( -72955222965.0, 188496616.0);
d[5][ 6] = fraction( -13145744952320.0, 69488710893.0);
d[5][ 7] = fraction( 30084216194513.0, 56998391688.0);
@@ -159,10 +158,10 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
d[5][15] = fraction( 5256837225.0, 438351368.0);
d[6][ 0] = fraction( -450944925.0, 17550638.0);
- d[6][ 1] = integrator.getField().getZero();
- d[6][ 2] = integrator.getField().getZero();
- d[6][ 3] = integrator.getField().getZero();
- d[6][ 4] = integrator.getField().getZero();
+ d[6][ 1] = getField().getZero();
+ d[6][ 2] = getField().getZero();
+ d[6][ 3] = getField().getZero();
+ d[6][ 4] = getField().getZero();
d[6][ 5] = fraction( -14532122925.0, 94248308.0);
d[6][ 6] = fraction( -595876966400.0, 2573655959.0);
d[6][ 7] = fraction( 188748653015.0, 527762886.0);
@@ -186,7 +185,7 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
super(interpolator);
- d = MathArrays.buildArray(integrator.getField(), 4, -1);
+ d = MathArrays.buildArray(getField(), 4, -1);
for (int i = 0; i < d.length; ++i) {
d[i] = interpolator.d[i].clone();
}
@@ -199,7 +198,7 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
* @return p/q computed in the instance field
*/
private T fraction(final double p, final double q) {
- return integrator.getField().getOne().multiply(p).divide(q);
+ return getField().getOne().multiply(p).divide(q);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldIntegrator.java
index 4c58e09..798c0e9 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldIntegrator.java
@@ -86,7 +86,7 @@ public class EulerFieldIntegrator<T extends RealFieldElement<T>> extends RungeKu
@Override
protected EulerFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new EulerFieldStepInterpolator<T>(this, forward, mapper);
+ return new EulerFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldStepInterpolator.java
index 9bff5f2..e822166 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/EulerFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -50,14 +50,13 @@ class EulerFieldStepInterpolator<T extends RealFieldElement<T>>
extends RungeKuttaFieldStepInterpolator<T> {
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- EulerFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ EulerFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
@@ -83,12 +82,12 @@ class EulerFieldStepInterpolator<T extends RealFieldElement<T>>
final T oneMinusThetaH) {
final T[] interpolatedState;
final T[] interpolatedDerivatives;
- if ((getGlobalPreviousState() != null) && (theta.getReal() <= 0.5)) {
+ if (getGlobalPreviousState() != null && theta.getReal() <= 0.5) {
interpolatedState = previousStateLinearCombination(theta.multiply(h));
- interpolatedDerivatives = derivativeLinearCombination(time.getField().getOne());
+ interpolatedDerivatives = derivativeLinearCombination(getField().getOne());
} else {
interpolatedState = currentStateLinearCombination(oneMinusThetaH.negate());
- interpolatedDerivatives = derivativeLinearCombination(time.getField().getOne());
+ interpolatedDerivatives = derivativeLinearCombination(getField().getOne());
}
return new FieldODEStateAndDerivative<T>(time, interpolatedState, interpolatedDerivatives);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldIntegrator.java
index 659eee8..53d6872 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldIntegrator.java
@@ -111,7 +111,7 @@ public class GillFieldIntegrator<T extends RealFieldElement<T>>
@Override
protected GillFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new GillFieldStepInterpolator<T>(this, forward, mapper);
+ return new GillFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldStepInterpolator.java
index 8990dc5..b9fe15a 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/GillFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
import org.apache.commons.math3.util.FastMath;
@@ -66,14 +66,13 @@ class GillFieldStepInterpolator<T extends RealFieldElement<T>>
private static final double ONE_PLUS_INV_SQRT_2 = 1 + FastMath.sqrt(0.5);
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- GillFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ GillFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
@@ -99,7 +98,7 @@ class GillFieldStepInterpolator<T extends RealFieldElement<T>>
final T time, final T theta,
final T oneMinusThetaH) {
- final T one = time.getField().getOne();
+ final T one = getField().getOne();
final T twoTheta = theta.multiply(2);
final T fourTheta2 = twoTheta.multiply(twoTheta);
final T coeffDot1 = theta.multiply(twoTheta.subtract(3)).add(1);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldIntegrator.java
index 8ee90b7..8473892 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldIntegrator.java
@@ -165,7 +165,7 @@ public class HighamHall54FieldIntegrator<T extends RealFieldElement<T>>
@Override
protected HighamHall54FieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new HighamHall54FieldStepInterpolator<T>(this, forward, mapper);
+ return new HighamHall54FieldStepInterpolator<T>(getField(), forward, mapper);
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldStepInterpolator.java
index 3f8499c..caf3bc8 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/HighamHall54FieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -36,14 +36,13 @@ class HighamHall54FieldStepInterpolator<T extends RealFieldElement<T>>
extends RungeKuttaFieldStepInterpolator<T> {
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- HighamHall54FieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ HighamHall54FieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
@@ -70,7 +69,7 @@ class HighamHall54FieldStepInterpolator<T extends RealFieldElement<T>>
final T oneMinusThetaH) {
final T bDot0 = theta.multiply(theta.multiply(theta.multiply( -10.0 ).add( 16.0 )).add(-15.0 / 2.0)).add(1);
- final T bDot1 = time.getField().getZero();
+ final T bDot1 = getField().getZero();
final T bDot2 = theta.multiply(theta.multiply(theta.multiply( 135.0 / 2.0).add(-729.0 / 8.0)).add(459.0 / 16.0));
final T bDot3 = theta.multiply(theta.multiply(theta.multiply(-120.0 ).add( 152.0 )).add(-44.0 ));
final T bDot4 = theta.multiply(theta.multiply(theta.multiply( 125.0 / 2.0).add(-625.0 / 8.0)).add(375.0 / 16.0));
@@ -81,7 +80,7 @@ class HighamHall54FieldStepInterpolator<T extends RealFieldElement<T>>
if (getGlobalPreviousState() != null && theta.getReal() <= 0.5) {
final T hTheta = h.multiply(theta);
final T b0 = hTheta.multiply(theta.multiply(theta.multiply(theta.multiply( -5.0 / 2.0).add( 16.0 / 3.0)).add(-15.0 / 4.0)).add(1));
- final T b1 = time.getField().getZero();
+ final T b1 = getField().getZero();
final T b2 = hTheta.multiply(theta.multiply(theta.multiply(theta.multiply(135.0 / 8.0).add(-243.0 / 8.0)).add(459.0 / 32.0)));
final T b3 = hTheta.multiply(theta.multiply(theta.multiply(theta.multiply(-30.0 ).add( 152.0 / 3.0)).add(-22.0 )));
final T b4 = hTheta.multiply(theta.multiply(theta.multiply(theta.multiply(125.0 / 8.0).add(-625.0 / 24.0)).add(375.0 / 32.0)));
@@ -91,7 +90,7 @@ class HighamHall54FieldStepInterpolator<T extends RealFieldElement<T>>
} else {
final T theta2 = theta.multiply(theta);
final T b0 = h.multiply( theta.multiply(theta.multiply(theta.multiply(theta.multiply(-5.0 / 2.0).add( 16.0 / 3.0)).add( -15.0 / 4.0)).add( 1.0 )).add( -1.0 / 12.0));
- final T b1 = time.getField().getZero();
+ final T b1 = getField().getZero();
final T b2 = h.multiply(theta2.multiply(theta.multiply(theta.multiply( 135.0 / 8.0 ).add(-243.0 / 8.0)).add(459.0 / 32.0)).add( -27.0 / 32.0));
final T b3 = h.multiply(theta2.multiply(theta.multiply(theta.multiply( -30.0 ).add( 152.0 / 3.0)).add(-22.0 )).add( 4.0 / 3.0));
final T b4 = h.multiply(theta2.multiply(theta.multiply(theta.multiply( 125.0 / 8.0 ).add(-625.0 / 24.0)).add(375.0 / 32.0)).add(-125.0 / 96.0));
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldIntegrator.java
index c36e5dd..6180982 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldIntegrator.java
@@ -138,7 +138,7 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
@Override
protected LutherFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new LutherFieldStepInterpolator<T>(this, forward, mapper);
+ return new LutherFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldStepInterpolator.java
index 6f643d5..57d6dfa 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/LutherFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -81,15 +81,14 @@ class LutherFieldStepInterpolator<T extends RealFieldElement<T>>
private final T d6c;
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- LutherFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ LutherFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
- final T q = rkIntegrator.getField().getOne().multiply(21).sqrt();
+ super(field, forward, mapper);
+ final T q = field.getOne().multiply(21).sqrt();
c5a = q.multiply( -49).add( -49);
c5b = q.multiply( 287).add( 392);
c5c = q.multiply( -357).add( -637);
@@ -188,7 +187,7 @@ class LutherFieldStepInterpolator<T extends RealFieldElement<T>>
// At the end, we get the b_i as polynomials in theta.
final T coeffDot1 = theta.multiply(theta.multiply(theta.multiply(theta.multiply( 21 ).add( -47 )).add( 36 )).add( -54 / 5.0)).add(1);
- final T coeffDot2 = theta.getField().getZero();
+ final T coeffDot2 = getField().getZero();
final T coeffDot3 = theta.multiply(theta.multiply(theta.multiply(theta.multiply( 112 ).add(-608 / 3.0)).add( 320 / 3.0 )).add(-208 / 15.0));
final T coeffDot4 = theta.multiply(theta.multiply(theta.multiply(theta.multiply( -567 / 5.0).add( 972 / 5.0)).add( -486 / 5.0 )).add( 324 / 25.0));
final T coeffDot5 = theta.multiply(theta.multiply(theta.multiply(theta.multiply(c5a.divide(5)).add(c5b.divide(15))).add(c5c.divide(30))).add(c5d.divide(150)));
@@ -201,7 +200,7 @@ class LutherFieldStepInterpolator<T extends RealFieldElement<T>>
final T s = theta.multiply(theta.multiply(h));
final T coeff1 = s.multiply(theta.multiply(theta.multiply(theta.multiply( 21 / 5.0).add( -47 / 4.0)).add( 12 )).add( -27 / 5.0)).add(1);
- final T coeff2 = s.getField().getZero();
+ final T coeff2 = getField().getZero();
final T coeff3 = s.multiply(theta.multiply(theta.multiply(theta.multiply( 112 / 5.0).add(-152 / 3.0)).add( 320 / 9.0 )).add(-104 / 15.0));
final T coeff4 = s.multiply(theta.multiply(theta.multiply(theta.multiply(-567 / 25.0).add( 243 / 5.0)).add( -162 / 5.0 )).add( 162 / 25.0));
final T coeff5 = s.multiply(theta.multiply(theta.multiply(theta.multiply(c5a.divide(25)).add(c5b.divide(60))).add(c5c.divide(90))).add(c5d.divide(300)));
@@ -213,7 +212,7 @@ class LutherFieldStepInterpolator<T extends RealFieldElement<T>>
final T s = oneMinusThetaH.multiply(theta);
final T coeff1 = s.multiply(theta.multiply(theta.multiply(theta.multiply( -21 / 5.0).add( 151 / 20.0)).add( -89 / 20.0)).add( 19 / 20.0)).add( -1 / 20.0);
- final T coeff2 = s.getField().getZero();
+ final T coeff2 = getField().getZero();
final T coeff3 = s.multiply(theta.multiply(theta.multiply(theta.multiply(-112 / 5.0).add( 424 / 15.0)).add( -328 / 45.0)).add( -16 / 45.0)).add(-16 / 45.0);
final T coeff4 = s.multiply(theta.multiply(theta.multiply(theta.multiply( 567 / 25.0).add( -648 / 25.0)).add( 162 / 25.0)));
final T coeff5 = s.multiply(theta.multiply(theta.multiply(theta.multiply(d5a.divide(25)).add(d5b.divide(300))).add(d5c.divide(900))).add( -49 / 180.0)).add(-49 / 180.0);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldIntegrator.java
index 3cc4c71..d3a1f2f 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldIntegrator.java
@@ -86,7 +86,7 @@ public class MidpointFieldIntegrator<T extends RealFieldElement<T>> extends Rung
@Override
protected MidpointFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new MidpointFieldStepInterpolator<T>(this, forward, mapper);
+ return new MidpointFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldStepInterpolator.java
index 943533a..bfaf69d 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/MidpointFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -52,14 +52,13 @@ class MidpointFieldStepInterpolator<T extends RealFieldElement<T>>
extends RungeKuttaFieldStepInterpolator<T> {
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- MidpointFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ MidpointFieldStepInterpolator(Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
@@ -86,7 +85,7 @@ class MidpointFieldStepInterpolator<T extends RealFieldElement<T>>
final T oneMinusThetaH) {
final T coeffDot2 = theta.multiply(2);
- final T coeffDot1 = time.getField().getOne().subtract(coeffDot2);
+ final T coeffDot1 = getField().getOne().subtract(coeffDot2);
final T[] interpolatedState;
final T[] interpolatedDerivatives;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldStepInterpolator.java
index 9a86d82..1befebc 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.sampling.AbstractFieldStepInterpolator;
import org.apache.commons.math3.util.MathArrays;
@@ -36,36 +36,25 @@ import org.apache.commons.math3.util.MathArrays;
abstract class RungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
extends AbstractFieldStepInterpolator<T> {
- /** Reference to the integrator. */
- protected AbstractFieldIntegrator<T> integrator;
+ /** Field to which the time and state vector elements belong. */
+ private final Field<T> field;
/** Slopes at the intermediate points. */
private T[][] yDotK;
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- protected RungeKuttaFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ protected RungeKuttaFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
super(forward, mapper);
- this.yDotK = null;
- this.integrator = rkIntegrator;
+ this.field = field;
+ this.yDotK = null;
}
/** Copy constructor.
-
- * <p>The copied interpolator should have been finalized before the
- * copy, otherwise the copy will not be able to perform correctly any
- * interpolation and will throw a {@link NullPointerException}
- * later. Since we don't want this constructor to throw the
- * exceptions finalization may involve and since we don't want this
- * method to modify the state of the copied interpolator,
- * finalization is <strong>not</strong> done automatically, it
- * remains under user control.</p>
-
* <p>The copy is a deep copy: its arrays are separated from the
* original arrays of the instance.</p>
@@ -75,10 +64,10 @@ abstract class RungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
RungeKuttaFieldStepInterpolator(final RungeKuttaFieldStepInterpolator<T> interpolator) {
super(interpolator);
+ field = interpolator.field;
if (yDotK != null) {
- yDotK = MathArrays.buildArray(interpolator.integrator.getField(),
- interpolator.yDotK.length, -1);
+ yDotK = MathArrays.buildArray(field, interpolator.yDotK.length, -1);
for (int k = 0; k < yDotK.length; ++k) {
yDotK[k] = interpolator.yDotK[k].clone();
}
@@ -87,10 +76,13 @@ abstract class RungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
yDotK = null;
}
- // we cannot keep any reference to the equations in the copy
- // the interpolator should have been finalized before
- integrator = null;
+ }
+ /** Get the field to which the time and state vector elements belong.
+ * @return to which the time and state vector elements belong
+ */
+ protected Field<T> getField() {
+ return field;
}
/** Store the slopes at the intermediate points.
@@ -126,8 +118,7 @@ abstract class RungeKuttaFieldStepInterpolator<T extends RealFieldElement<T>>
*/
@SuppressWarnings("unchecked")
protected T[] derivativeLinearCombination(final T ... coefficients) {
- return combine(MathArrays.buildArray(integrator.getField(), yDotK[0].length),
- coefficients);
+ return combine(MathArrays.buildArray(field, yDotK[0].length), coefficients);
}
/** Linearly combine arrays.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldIntegrator.java
index e0d5044..d298ff8 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldIntegrator.java
@@ -100,7 +100,7 @@ public class ThreeEighthesFieldIntegrator<T extends RealFieldElement<T>>
@Override
protected ThreeEighthesFieldStepInterpolator<T>
createInterpolator(final boolean forward, final FieldEquationsMapper<T> mapper) {
- return new ThreeEighthesFieldStepInterpolator<T>(this, forward, mapper);
+ return new ThreeEighthesFieldStepInterpolator<T>(getField(), forward, mapper);
}
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java
index 39cdc1c..cc346fd 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/ThreeEighthesFieldStepInterpolator.java
@@ -17,8 +17,8 @@
package org.apache.commons.math3.ode.nonstiff;
+import org.apache.commons.math3.Field;
import org.apache.commons.math3.RealFieldElement;
-import org.apache.commons.math3.ode.AbstractFieldIntegrator;
import org.apache.commons.math3.ode.FieldEquationsMapper;
import org.apache.commons.math3.ode.FieldODEStateAndDerivative;
@@ -62,14 +62,13 @@ class ThreeEighthesFieldStepInterpolator<T extends RealFieldElement<T>>
extends RungeKuttaFieldStepInterpolator<T> {
/** Simple constructor.
- * @param rkIntegrator integrator being used
+ * @param field field to which the time and state vector elements belong
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
*/
- ThreeEighthesFieldStepInterpolator(final AbstractFieldIntegrator<T> rkIntegrator,
- final boolean forward,
+ ThreeEighthesFieldStepInterpolator(final Field<T> field, final boolean forward,
final FieldEquationsMapper<T> mapper) {
- super(rkIntegrator, forward, mapper);
+ super(field, forward, mapper);
}
/** Copy constructor.
http://git-wip-us.apache.org/repos/asf/commons-math/blob/d1d22013/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
index e9d6f29..5acd00b 100644
--- a/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math3/ode/sampling/AbstractFieldStepInterpolator.java
@@ -55,9 +55,6 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
/** Soft current state. */
private FieldODEStateAndDerivative<T> softCurrentState;
- /** indicate if the step has been finalized or not. */
- private boolean finalized;
-
/** integration direction. */
private boolean forward;
@@ -75,27 +72,14 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
softPreviousState = null;
softCurrentState = null;
h = null;
- finalized = false;
this.forward = isForward;
this.mapper = equationsMapper;
}
/** Copy constructor.
-
- * <p>The copied interpolator should have been finalized before the
- * copy, otherwise the copy will not be able to perform correctly
- * any derivative computation and will throw a {@link
- * NullPointerException} later. Since we don't want this constructor
- * to throw the exceptions finalization may involve and since we
- * don't want this method to modify the state of the copied
- * interpolator, finalization is <strong>not</strong> done
- * automatically, it remains under user control.</p>
-
* <p>The copy is a deep copy: its arrays are separated from the
* original arrays of the instance.</p>
-
* @param interpolator interpolator to copy from.
-
*/
protected AbstractFieldStepInterpolator(final AbstractFieldStepInterpolator<T> interpolator) {
@@ -104,7 +88,6 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
softPreviousState = interpolator.softPreviousState;
softCurrentState = interpolator.softCurrentState;
h = interpolator.h;
- finalized = interpolator.finalized;
forward = interpolator.forward;
mapper = interpolator.mapper;
@@ -113,20 +96,13 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
/** {@inheritDoc} */
public FieldStepInterpolator<T> copy() throws MaxCountExceededException {
- // finalize the step before performing copy
- finalizeStep();
-
// create the new independent instance
return doCopy();
}
- /** Really copy the finalized instance.
- * <p>This method is called by {@link #copy()} after the
- * step has been finalized. It must perform a deep copy
- * to have an new instance completely independent for the
- * original instance.
- * @return a copy of the finalized instance
+ /** Really copy the instance.
+ * @return a copy of the instance
*/
protected abstract FieldStepInterpolator<T> doCopy();
@@ -144,16 +120,11 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
* @param state current state
*/
public void storeState(final FieldODEStateAndDerivative<T> state) {
-
globalCurrentState = state;
softCurrentState = globalCurrentState;
if (globalPreviousState != null) {
h = globalCurrentState.getTime().subtract(globalPreviousState.getTime());
}
-
- // the step is not finalized anymore
- finalized = false;
-
}
/** Restrict step range to a limited part of the global step.
@@ -240,60 +211,4 @@ public abstract class AbstractFieldStepInterpolator<T extends RealFieldElement<T
T time, T theta, T oneMinusThetaH)
throws MaxCountExceededException;
- /**
- * Finalize the step.
-
- * <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
- * extra evaluations. It can be called directly by the user step
- * handler and it is called automatically if {@link
- * #setInterpolatedTime} is called.</p>
-
- * <p>Once this method has been called, <strong>no</strong> other
- * evaluation will be performed on this step. If there is a need to
- * have some side effects between the step handler and the
- * differential equations (for example update some data in the
- * equations once the step has been done), it is advised to call
- * this method explicitly from the step handler before these side
- * effects are set up. If the step handler induces no side effect,
- * then this method can safely be ignored, it will be called
- * transparently as needed.</p>
-
- * <p><strong>Warning</strong>: since the step interpolator provided
- * to the step handler as a parameter of the {@link
- * StepHandler#handleStep handleStep} is valid only for the duration
- * of the {@link StepHandler#handleStep handleStep} call, one cannot
- * simply store a reference and reuse it later. One should first
- * finalize the instance, then copy this finalized instance into a
- * new object that can be kept.</p>
-
- * <p>This method calls the protected <code>doFinalize</code> method
- * if it has never been called during this step and set a flag
- * indicating that it has been called once. It is the <code>
- * doFinalize</code> method which should perform the evaluations.
- * This wrapping prevents from calling <code>doFinalize</code> several
- * times and hence evaluating the differential equations too often.
- * Therefore, subclasses are not allowed not reimplement it, they
- * should rather reimplement <code>doFinalize</code>.</p>
-
- * @exception MaxCountExceededException if the number of functions evaluations is exceeded
-
- */
- public final void finalizeStep() throws MaxCountExceededException {
- if (! finalized) {
- doFinalize();
- finalized = true;
- }
- }
-
- /**
- * Really finalize the step.
- * The default implementation of this method does nothing.
- * @exception MaxCountExceededException if the number of functions evaluations is exceeded
- */
- protected void doFinalize() throws MaxCountExceededException {
- }
-
}
[2/2] [math] Reactivated test.
Posted by lu...@apache.org.
Reactivated test.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/e269953c
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/e269953c
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/e269953c
Branch: refs/heads/field-ode
Commit: e269953c45baa72cb9ffe0fd1243964a1758714b
Parents: d1d2201
Author: Luc Maisonobe <lu...@apache.org>
Authored: Tue Dec 1 13:38:57 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Tue Dec 1 13:38:57 2015 +0100
----------------------------------------------------------------------
.../apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/e269953c/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java b/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
index 9ec73d2..54f0330 100644
--- a/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
+++ b/src/test/java/org/apache/commons/math3/ode/nonstiff/EulerIntegratorTest.java
@@ -58,8 +58,8 @@ public class EulerIntegratorTest {
MaxCountExceededException, NoBracketingException {
for (TestProblemAbstract pb : new TestProblemAbstract[] {
- //new TestProblem1(), new TestProblem2(), new TestProblem3(),
- new TestProblem4()//, new TestProblem5(), new TestProblem6()
+ new TestProblem1(), new TestProblem2(), new TestProblem3(),
+ new TestProblem4(), new TestProblem5(), new TestProblem6()
}) {
double previousValueError = Double.NaN;
@@ -94,7 +94,6 @@ public class EulerIntegratorTest {
}
previousTimeError = timeError;
- System.exit(1);
}
}