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/09 17:16:59 UTC
[19/50] [abbrv] [math] Fixed Butcher arrays constants for Luther
integrator.
Fixed Butcher arrays constants for Luther integrator.
Project: http://git-wip-us.apache.org/repos/asf/commons-math/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-math/commit/4a239591
Tree: http://git-wip-us.apache.org/repos/asf/commons-math/tree/4a239591
Diff: http://git-wip-us.apache.org/repos/asf/commons-math/diff/4a239591
Branch: refs/heads/MATH_3_X
Commit: 4a239591bc1965a60ba5c4b251c938133f2066f6
Parents: f3ed53f
Author: Luc Maisonobe <lu...@apache.org>
Authored: Thu Dec 3 14:21:08 2015 +0100
Committer: Luc Maisonobe <lu...@apache.org>
Committed: Thu Dec 3 14:21:08 2015 +0100
----------------------------------------------------------------------
.../ode/nonstiff/LutherFieldIntegrator.java | 38 ++++++++++----------
.../ode/nonstiff/RungeKuttaFieldIntegrator.java | 2 +-
2 files changed, 19 insertions(+), 21 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-math/blob/4a239591/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 6180982..d906703 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
@@ -60,9 +60,6 @@ import org.apache.commons.math3.util.MathArrays;
public class LutherFieldIntegrator<T extends RealFieldElement<T>>
extends RungeKuttaFieldIntegrator<T> {
- /** Square root. */
- private final T q;
-
/** Simple constructor.
* Build a fourth-order Luther integrator with the given step.
* @param field field to which the time and state vector elements belong
@@ -70,12 +67,12 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
*/
public LutherFieldIntegrator(final Field<T> field, final T step) {
super(field, "Luther", step);
- q = getField().getOne().multiply(21).sqrt();
}
/** {@inheritDoc} */
@Override
protected T[] getC() {
+ final T q = getField().getZero().add(21).sqrt();
final T[] c = MathArrays.buildArray(getField(), 6);
c[0] = getField().getOne();
c[1] = fraction(1, 2);
@@ -89,6 +86,7 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
/** {@inheritDoc} */
@Override
protected 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) {
a[i] = MathArrays.buildArray(getField(), i + 1);
@@ -98,22 +96,22 @@ public class LutherFieldIntegrator<T extends RealFieldElement<T>>
a[1][1] = fraction(1, 8);
a[2][0] = fraction(8, 27);
a[2][1] = fraction(2, 27);
- a[2][2] = fraction(8, 27);
- a[3][0] = q.multiply( 9).subtract( 21).divide( 392);
- a[3][1] = q.multiply( 8).subtract( 56).divide( 392);
- a[3][2] = q.multiply( 48).subtract(336).divide(-392);
- a[3][3] = q.multiply( 3).subtract( 63).divide( 392);
- a[4][0] = q.multiply(255).add(1155).divide(-1960);
- a[4][1] = q.multiply( 40).add( 280).divide(-1960);
- a[4][2] = q.multiply(20) .divide(-1960);
- a[4][3] = q.multiply(363).add( 63).divide( 1960);
- a[4][4] = q.multiply(392).add(2352).divide( 1960);
- a[5][0] = q.multiply(105).add( 330).divide( 180);
- a[5][1] = fraction(120, 180);
- a[5][2] = q.multiply(280).add(-200).divide( 180);
- a[5][3] = q.multiply(189).add(-126).divide(-180);
- a[5][4] = q.multiply(126).add( 686).divide(-180);
- a[5][5] = q.multiply( 70).add(-490).divide(-180);
+ a[2][2] = a[2][0];
+ a[3][0] = q.multiply( 9).add( -21).divide( 392);
+ a[3][1] = q.multiply( 8).add( -56).divide( 392);
+ a[3][2] = q.multiply( -48).add( 336).divide( 392);
+ a[3][3] = q.multiply( 3).add( -63).divide( 392);
+ a[4][0] = q.multiply(-255).add(-1155).divide(1960);
+ a[4][1] = q.multiply( -40).add( -280).divide(1960);
+ a[4][2] = q.multiply(-320) .divide(1960);
+ a[4][3] = q.multiply( 363).add( 63).divide(1960);
+ a[4][4] = q.multiply( 392).add( 2352).divide(1960);
+ a[5][0] = q.multiply( 105).add( 330).divide( 180);
+ a[5][1] = fraction(2, 3);
+ a[5][2] = q.multiply( 280).add( -200).divide( 180);
+ a[5][3] = q.multiply(-189).add( 126).divide( 180);
+ a[5][4] = q.multiply(-126).add( -686).divide( 180);
+ a[5][5] = q.multiply( -70).add( 490).divide( 180);
return a;
}
http://git-wip-us.apache.org/repos/asf/commons-math/blob/4a239591/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java
index a511ac8..befa525 100644
--- a/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java
+++ b/src/main/java/org/apache/commons/math3/ode/nonstiff/RungeKuttaFieldIntegrator.java
@@ -93,7 +93,7 @@ public abstract class RungeKuttaFieldIntegrator<T extends RealFieldElement<T>>
* @return p/q computed in the instance field
*/
protected T fraction(final int p, final int q) {
- return getField().getOne().multiply(p).divide(q);
+ return getField().getZero().add(p).divide(q);
}
/** Get the time steps from Butcher array (without the first zero).