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 2016/01/06 14:50:34 UTC
[18/50] [abbrv] [math] Set up a shared interface for Butcher arrays
used by integrators.
Set up a shared interface for Butcher arrays used by integrators.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/a2718fc3
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/a2718fc3
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/a2718fc3
Branch: refs/heads/master
Commit: a2718fc3a9bc54d5932214b07514446a2fe4c5bf
Parents: 87edfd2
Author: Luc Maisonobe <lu...@apache.org>
Authored: Wed Jan 6 12:41:27 2016 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Wed Jan 6 12:41:27 2016 +0100
----------------------------------------------------------------------
.../ClassicalRungeKuttaFieldIntegrator.java | 6 +--
.../DormandPrince54FieldIntegrator.java | 6 +--
.../DormandPrince853FieldIntegrator.java | 6 +--
.../DormandPrince853FieldStepInterpolator.java | 2 +-
.../EmbeddedRungeKuttaFieldIntegrator.java | 18 +-------
.../ode/nonstiff/EulerFieldIntegrator.java | 6 +--
.../ode/nonstiff/FieldButcherArrayProvider.java | 46 ++++++++++++++++++++
.../math4/ode/nonstiff/GillFieldIntegrator.java | 6 +--
.../nonstiff/HighamHall54FieldIntegrator.java | 6 +--
.../ode/nonstiff/LutherFieldIntegrator.java | 6 +--
.../ode/nonstiff/MidpointFieldIntegrator.java | 6 +--
.../ode/nonstiff/RungeKuttaFieldIntegrator.java | 18 +-------
.../nonstiff/ThreeEighthesFieldIntegrator.java | 6 +--
...ractRungeKuttaFieldStepInterpolatorTest.java | 28 ++++++------
14 files changed, 91 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
index 4bb0f61..a09c1fa 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ClassicalRungeKuttaFieldIntegrator.java
@@ -62,7 +62,7 @@ public class ClassicalRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 3);
c[0] = getField().getOne().multiply(0.5);
c[1] = c[0];
@@ -72,7 +72,7 @@ public class ClassicalRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T[][] a = MathArrays.buildArray(getField(), 3, -1);
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
@@ -88,7 +88,7 @@ public class ClassicalRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 4);
b[0] = fraction(1, 6);
b[1] = fraction(1, 3);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java
index a12453d..743dbe4 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince54FieldIntegrator.java
@@ -130,7 +130,7 @@ public class DormandPrince54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 6);
c[0] = fraction(1, 5);
c[1] = fraction(3, 10);
@@ -143,7 +143,7 @@ public class DormandPrince54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T[][] a = MathArrays.buildArray(getField(), 6, -1);
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
@@ -174,7 +174,7 @@ public class DormandPrince54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 7);
b[0] = fraction( 35, 384);
b[1] = getField().getZero();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java
index de5adda..6c754d7 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldIntegrator.java
@@ -191,7 +191,7 @@ public class DormandPrince853FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T sqrt6 = getField().getOne().multiply(6).sqrt();
@@ -218,7 +218,7 @@ public class DormandPrince853FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T sqrt6 = getField().getOne().multiply(6).sqrt();
@@ -371,7 +371,7 @@ public class DormandPrince853FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 16);
b[ 0] = fraction(104257, 1929240);
b[ 1] = getField().getZero();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
index 5c548a3..6487ccf 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/DormandPrince853FieldStepInterpolator.java
@@ -52,7 +52,7 @@ class DormandPrince853FieldStepInterpolator<T extends RealFieldElement<T>>
super(field, forward, mapper);
// interpolation weights
- d = MathArrays.buildArray(getField(), 4, 16);
+ d = MathArrays.buildArray(getField(), 7, 16);
// this row is the same as the b array
d[0][ 0] = fraction(104257, 1929240);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java
index 1f3e87c..13bb070 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EmbeddedRungeKuttaFieldIntegrator.java
@@ -68,7 +68,8 @@ import org.apache.commons.math4.util.MathUtils;
*/
public abstract class EmbeddedRungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
- extends AdaptiveStepsizeFieldIntegrator<T> {
+ extends AdaptiveStepsizeFieldIntegrator<T>
+ implements FieldButcherArrayProvider<T> {
/** Index of the pre-computed derivative for <i>fsal</i> methods. */
private final int fsal;
@@ -180,21 +181,6 @@ public abstract class EmbeddedRungeKuttaFieldIntegrator<T extends RealFieldEleme
return getField().getOne().multiply(p).divide(q);
}
- /** Get the time steps from Butcher array (without the first zero).
- * @return time steps from Butcher array (without the first zero
- */
- protected abstract T[] getC();
-
- /** Get the internal weights from Butcher array (without the first empty row).
- * @return internal weights from Butcher array (without the first empty row)
- */
- protected abstract T[][] getA();
-
- /** Get the external weights for the high order method from Butcher array.
- * @return external weights for the high order method from Butcher array
- */
- protected abstract T[] getB();
-
/** Create an interpolator.
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java
index c28e3fe..96403e5 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/EulerFieldIntegrator.java
@@ -64,19 +64,19 @@ public class EulerFieldIntegrator<T extends RealFieldElement<T>> extends RungeKu
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
return MathArrays.buildArray(getField(), 0);
}
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
return MathArrays.buildArray(getField(), 0, 0);
}
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 1);
b[0] = getField().getOne();
return b;
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/FieldButcherArrayProvider.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/FieldButcherArrayProvider.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/FieldButcherArrayProvider.java
new file mode 100644
index 0000000..69b38bc
--- /dev/null
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/FieldButcherArrayProvider.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math4.ode.nonstiff;
+
+import org.apache.commons.math4.RealFieldElement;
+
+/** This interface represents an integrator based on Butcher arrays.
+ * @see RungeKuttaFieldIntegrator
+ * @see EmbeddedRungeKuttaFieldIntegrator
+ * @param <T> the type of the field elements
+ * @since 3.6
+ */
+
+public interface FieldButcherArrayProvider<T extends RealFieldElement<T>> {
+
+ /** Get the time steps from Butcher array (without the first zero).
+ * @return time steps from Butcher array (without the first zero
+ */
+ T[] getC();
+
+ /** Get the internal weights from Butcher array (without the first empty row).
+ * @return internal weights from Butcher array (without the first empty row)
+ */
+ T[][] getA();
+
+ /** Get the external weights for the high order method from Butcher array.
+ * @return external weights for the high order method from Butcher array
+ */
+ T[] getB();
+
+}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java
index cf1ce89..6996d05 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/GillFieldIntegrator.java
@@ -62,7 +62,7 @@ public class GillFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 3);
c[0] = fraction(1, 2);
c[1] = c[0];
@@ -72,7 +72,7 @@ public class GillFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T two = getField().getZero().add(2);
final T sqrtTwo = two.sqrt();
@@ -92,7 +92,7 @@ public class GillFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T two = getField().getZero().add(2);
final T sqrtTwo = two.sqrt();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java
index c04e9c6..0e0c3b8 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/HighamHall54FieldIntegrator.java
@@ -105,7 +105,7 @@ public class HighamHall54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 6);
c[0] = fraction(2, 9);
c[1] = fraction(1, 3);
@@ -118,7 +118,7 @@ public class HighamHall54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T[][] a = MathArrays.buildArray(getField(), 6, -1);
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
@@ -149,7 +149,7 @@ public class HighamHall54FieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 7);
b[0] = fraction( 1, 12);
b[1] = getField().getZero();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java
index 84acede..b8d78d9 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/LutherFieldIntegrator.java
@@ -71,7 +71,7 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T q = getField().getZero().add(21).sqrt();
final T[] c = MathArrays.buildArray(getField(), 6);
c[0] = getField().getOne();
@@ -85,7 +85,7 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T q = getField().getZero().add(21).sqrt();
final T[][] a = MathArrays.buildArray(getField(), 6, -1);
for (int i = 0; i < a.length; ++i) {
@@ -117,7 +117,7 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 7);
b[0] = fraction( 1, 20);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java
index a32a961..2a2e5e6 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/MidpointFieldIntegrator.java
@@ -59,7 +59,7 @@ public class MidpointFieldIntegrator<T extends RealFieldElement<T>> extends Rung
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 1);
c[0] = getField().getOne().multiply(0.5);
return c;
@@ -67,7 +67,7 @@ public class MidpointFieldIntegrator<T extends RealFieldElement<T>> extends Rung
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T[][] a = MathArrays.buildArray(getField(), 1, 1);
a[0][0] = fraction(1, 2);
return a;
@@ -75,7 +75,7 @@ public class MidpointFieldIntegrator<T extends RealFieldElement<T>> extends Rung
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 2);
b[0] = getField().getZero();
b[1] = getField().getOne();
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java
index d6f9026..3a5f9aa 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/RungeKuttaFieldIntegrator.java
@@ -58,7 +58,8 @@ import org.apache.commons.math4.util.MathArrays;
*/
public abstract class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
- extends AbstractFieldIntegrator<T> {
+ extends AbstractFieldIntegrator<T>
+ implements FieldButcherArrayProvider<T> {
/** Time steps from Butcher array (without the first zero). */
private final T[] c;
@@ -96,21 +97,6 @@ public abstract class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
return getField().getZero().add(p).divide(q);
}
- /** Get the time steps from Butcher array (without the first zero).
- * @return time steps from Butcher array (without the first zero
- */
- protected abstract T[] getC();
-
- /** Get the internal weights from Butcher array (without the first empty row).
- * @return internal weights from Butcher array (without the first empty row)
- */
- protected abstract T[][] getA();
-
- /** Get the external weights for the high order method from Butcher array.
- * @return external weights for the high order method from Butcher array
- */
- protected abstract T[] getB();
-
/** Create an interpolator.
* @param forward integration direction indicator
* @param mapper equations mapper for the all equations
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java
index e5bd0bc..b826290 100644
--- a/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/ode/nonstiff/ThreeEighthesFieldIntegrator.java
@@ -61,7 +61,7 @@ public class ThreeEighthesFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getC() {
+ public T[] getC() {
final T[] c = MathArrays.buildArray(getField(), 3);
c[0] = fraction(1, 3);
c[1] = c[0].add(c[0]);
@@ -71,7 +71,7 @@ public class ThreeEighthesFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[][] getA() {
+ public T[][] getA() {
final T[][] a = MathArrays.buildArray(getField(), 3, -1);
for (int i = 0; i < a.length; ++i) {
a[i] = MathArrays.buildArray(getField(), i + 1);
@@ -87,7 +87,7 @@ public class ThreeEighthesFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
- protected T[] getB() {
+ public T[] getB() {
final T[] b = MathArrays.buildArray(getField(), 4);
b[0] = fraction(1, 8);
b[1] = fraction(3, 8);
http://git-wip-us.apache.org/repos/asf/commons-math/blob/a2718fc3/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java
index a692717..6dfdeab 100644
--- a/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java
+++ b/src/test/java/org/apache/commons/math4/ode/nonstiff/AbstractRungeKuttaFieldStepInterpolatorTest.java
@@ -140,10 +140,10 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest {
RungeKuttaFieldStepInterpolator<T> interpolator = createInterpolator(field, t1 > t0,
new FieldExpandableODE<T>(eqn).getMapper());
// get the Butcher arrays from the field integrator
- RungeKuttaFieldIntegrator<T> fieldIntegrator = createFieldIntegrator(field, interpolator);
- T[][] a = fieldIntegrator.getA();
- T[] b = fieldIntegrator.getB();
- T[] c = fieldIntegrator.getC();
+ FieldButcherArrayProvider<T> provider = createButcherArrayProvider(field, interpolator);
+ T[][] a = provider.getA();
+ T[] b = provider.getB();
+ T[] c = provider.getC();
// store initial state
T t = field.getZero().add(t0);
@@ -259,25 +259,23 @@ public abstract class AbstractRungeKuttaFieldStepInterpolatorTest {
}
- private <T extends RealFieldElement<T>> RungeKuttaFieldIntegrator<T>
- createFieldIntegrator(final Field<T> field, final RungeKuttaFieldStepInterpolator<T> interpolator) {
- RungeKuttaFieldIntegrator<T> integrator = null;
+ private <T extends RealFieldElement<T>> FieldButcherArrayProvider<T>
+ createButcherArrayProvider(final Field<T> field, final RungeKuttaFieldStepInterpolator<T> provider) {
+ FieldButcherArrayProvider<T> integrator = null;
try {
- String interpolatorName = interpolator.getClass().getName();
+ String interpolatorName = provider.getClass().getName();
String integratorName = interpolatorName.replaceAll("StepInterpolator", "Integrator");
@SuppressWarnings("unchecked")
- Class<RungeKuttaFieldIntegrator<T>> clz = (Class<RungeKuttaFieldIntegrator<T>>) Class.forName(integratorName);
+ Class<FieldButcherArrayProvider<T>> clz = (Class<FieldButcherArrayProvider<T>>) Class.forName(integratorName);
try {
integrator = clz.getConstructor(Field.class, RealFieldElement.class).
- newInstance(field, field.getOne());
+ newInstance(field, field.getOne());
} catch (NoSuchMethodException nsme) {
try {
integrator = clz.getConstructor(Field.class,
- RealFieldElement.class,
- RealFieldElement.class,
- RealFieldElement.class).
- newInstance(field, field.getZero().add(0.001),
- field.getOne(), field.getOne(), field.getOne());
+ Double.TYPE, Double.TYPE,
+ Double.TYPE, Double.TYPE).
+ newInstance(field, 0.001, 1.0, 1.0, 1.0);
} catch (NoSuchMethodException e) {
Assert.fail(e.getLocalizedMessage());
}