1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package org.apache.commons.math.ode.nonstiff;
19
20import org.apache.commons.math.util.FastMath;
21
22
23/**
24 * This class implements the Gill fourth order Runge-Kutta
25 * integrator for Ordinary Differential Equations .
26
27 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
28 * is the following one :
29 * <pre>
30 *    0  |    0        0       0      0
31 *   1/2 |   1/2       0       0      0
32 *   1/2 | (q-1)/2  (2-q)/2    0      0
33 *    1  |    0       -q/2  (2+q)/2   0
34 *       |-------------------------------
35 *       |   1/6    (2-q)/6 (2+q)/6  1/6
36 * </pre>
37 * where q = sqrt(2)</p>
38 *
39 * @see EulerIntegrator
40 * @see ClassicalRungeKuttaIntegrator
41 * @see MidpointIntegrator
42 * @see ThreeEighthesIntegrator
43 * @version $Revision: 990655 $ $Date: 2010-08-29 23:49:40 +0200 (dim. 29 août 2010) $
44 * @since 1.2
45 */
46
47public class GillIntegrator extends RungeKuttaIntegrator {
48
49  /** Time steps Butcher array. */
50  private static final double[] STATIC_C = {
51    1.0 / 2.0, 1.0 / 2.0, 1.0
52  };
53
54  /** Internal weights Butcher array. */
55  private static final double[][] STATIC_A = {
56    { 1.0 / 2.0 },
57    { (FastMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - FastMath.sqrt(2.0)) / 2.0 },
58    { 0.0, -FastMath.sqrt(2.0) / 2.0, (2.0 + FastMath.sqrt(2.0)) / 2.0 }
59  };
60
61  /** Propagation weights Butcher array. */
62  private static final double[] STATIC_B = {
63    1.0 / 6.0, (2.0 - FastMath.sqrt(2.0)) / 6.0, (2.0 + FastMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
64  };
65
66  /** Simple constructor.
67   * Build a fourth-order Gill integrator with the given step.
68   * @param step integration step
69   */
70  public GillIntegrator(final double step) {
71    super("Gill", STATIC_C, STATIC_A, STATIC_B, new GillStepInterpolator(), step);
72  }
73
74}
75