~ubuntu-branches/ubuntu/trusty/commons-math/trusty

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java

  • Committer: Bazaar Package Importer
  • Author(s): Damien Raude-Morvan
  • Date: 2010-04-05 23:33:02 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100405233302-gpqlceked76nw28a
Tags: 2.1-1
* New upstream release.
* Bump Standards-Version to 3.8.4: no changes needed
* Bump debhelper to >= 7
* Switch to 3.0 (quilt) source format:
  - Remove B-D on quilt
  - Add d/source/format
  - Remove d/README.source

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
 *  volume 6, no 1, 1980, pp. 19-26
41
41
 * </pre></p>
42
42
 *
43
 
 * @version $Revision: 786881 $ $Date: 2009-06-20 14:53:08 -0400 (Sat, 20 Jun 2009) $
 
43
 * @version $Revision: 810196 $ $Date: 2009-09-01 15:47:46 -0400 (Tue, 01 Sep 2009) $
44
44
 * @since 1.2
45
45
 */
46
46
 
50
50
  private static final String METHOD_NAME = "Dormand-Prince 5(4)";
51
51
 
52
52
  /** Time steps Butcher array. */
53
 
  private static final double[] staticC = {
 
53
  private static final double[] STATIC_C = {
54
54
    1.0/5.0, 3.0/10.0, 4.0/5.0, 8.0/9.0, 1.0, 1.0
55
55
  };
56
56
 
57
57
  /** Internal weights Butcher array. */
58
 
  private static final double[][] staticA = {
 
58
  private static final double[][] STATIC_A = {
59
59
    {1.0/5.0},
60
60
    {3.0/40.0, 9.0/40.0},
61
61
    {44.0/45.0, -56.0/15.0, 32.0/9.0},
65
65
  };
66
66
 
67
67
  /** Propagation weights Butcher array. */
68
 
  private static final double[] staticB = {
 
68
  private static final double[] STATIC_B = {
69
69
    35.0/384.0, 0.0, 500.0/1113.0, 125.0/192.0, -2187.0/6784.0, 11.0/84.0, 0.0
70
70
  };
71
71
 
72
72
  /** Error array, element 1. */
73
 
  private static final double e1 =     71.0 / 57600.0;
 
73
  private static final double E1 =     71.0 / 57600.0;
74
74
 
75
75
  // element 2 is zero, so it is neither stored nor used
76
76
 
77
77
  /** Error array, element 3. */
78
 
  private static final double e3 =    -71.0 / 16695.0;
 
78
  private static final double E3 =    -71.0 / 16695.0;
79
79
 
80
80
  /** Error array, element 4. */
81
 
  private static final double e4 =     71.0 / 1920.0;
 
81
  private static final double E4 =     71.0 / 1920.0;
82
82
 
83
83
  /** Error array, element 5. */
84
 
  private static final double e5 = -17253.0 / 339200.0;
 
84
  private static final double E5 = -17253.0 / 339200.0;
85
85
 
86
86
  /** Error array, element 6. */
87
 
  private static final double e6 =     22.0 / 525.0;
 
87
  private static final double E6 =     22.0 / 525.0;
88
88
 
89
89
  /** Error array, element 7. */
90
 
  private static final double e7 =     -1.0 / 40.0;
 
90
  private static final double E7 =     -1.0 / 40.0;
91
91
 
92
92
  /** Simple constructor.
93
93
   * Build a fifth order Dormand-Prince integrator with the given step bounds
101
101
  public DormandPrince54Integrator(final double minStep, final double maxStep,
102
102
                                   final double scalAbsoluteTolerance,
103
103
                                   final double scalRelativeTolerance) {
104
 
    super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
 
104
    super(METHOD_NAME, true, STATIC_C, STATIC_A, STATIC_B, new DormandPrince54StepInterpolator(),
105
105
          minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
106
106
  }
107
107
 
117
117
  public DormandPrince54Integrator(final double minStep, final double maxStep,
118
118
                                   final double[] vecAbsoluteTolerance,
119
119
                                   final double[] vecRelativeTolerance) {
120
 
    super(METHOD_NAME, true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
 
120
    super(METHOD_NAME, true, STATIC_C, STATIC_A, STATIC_B, new DormandPrince54StepInterpolator(),
121
121
          minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
122
122
  }
123
123
 
136
136
    double error = 0;
137
137
 
138
138
    for (int j = 0; j < y0.length; ++j) {
139
 
        final double errSum = e1 * yDotK[0][j] +  e3 * yDotK[2][j] +
140
 
                              e4 * yDotK[3][j] +  e5 * yDotK[4][j] +
141
 
                              e6 * yDotK[5][j] +  e7 * yDotK[6][j];
 
139
        final double errSum = E1 * yDotK[0][j] +  E3 * yDotK[2][j] +
 
140
                              E4 * yDotK[3][j] +  E5 * yDotK[4][j] +
 
141
                              E6 * yDotK[5][j] +  E7 * yDotK[6][j];
142
142
 
143
143
        final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
144
144
        final double tol = (vecAbsoluteTolerance == null) ?