    001    /*
    002     * Licensed to the Apache Software Foundation (ASF) under one or more
    003     * contributor license agreements.  See the NOTICE file distributed with
    004     * this work for additional information regarding copyright ownership.
    005     * The ASF licenses this file to You under the Apache License, Version 2.0
    006     * (the "License"); you may not use this file except in compliance with
    007     * the License.  You may obtain a copy of the License at
    008     *
    009     *      http://www.apache.org/licenses/LICENSE-2.0
    010     *
    011     * Unless required by applicable law or agreed to in writing, software
    012     * distributed under the License is distributed on an "AS IS" BASIS,
    013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    014     * See the License for the specific language governing permissions and
    015     * limitations under the License.
    016     */
    017
    018    package org.apache.commons.math3.ode.nonstiff;
    019
    020    import org.apache.commons.math3.util.FastMath;
    021
    022
    023    /**
    024     * This class implements the Gill fourth order Runge-Kutta
    025     * integrator for Ordinary Differential Equations .
    026
    027     * <p>This method is an explicit Runge-Kutta method, its Butcher-array
    028     * is the following one :
    029     * <pre>
    030     *    0  |    0        0       0      0
    031     *   1/2 |   1/2       0       0      0
    032     *   1/2 | (q-1)/2  (2-q)/2    0      0
    033     *    1  |    0       -q/2  (2+q)/2   0
    034     *       |-------------------------------
    035     *       |   1/6    (2-q)/6 (2+q)/6  1/6
    036     * </pre>
    037     * where q = sqrt(2)</p>
    038     *
    039     * @see EulerIntegrator
    040     * @see ClassicalRungeKuttaIntegrator
    041     * @see MidpointIntegrator
    042     * @see ThreeEighthesIntegrator
    043     * @version $Id: GillIntegrator.java 1416643 2012-12-03 19:37:14Z tn $
    044     * @since 1.2
    045     */
    046
    047    public class GillIntegrator extends RungeKuttaIntegrator {
    048
    049      /** Time steps Butcher array. */
    050      private static final double[] STATIC_C = {
    051        1.0 / 2.0, 1.0 / 2.0, 1.0
    052      };
    053
    054      /** Internal weights Butcher array. */
    055      private static final double[][] STATIC_A = {
    056        { 1.0 / 2.0 },
    057        { (FastMath.sqrt(2.0) - 1.0) / 2.0, (2.0 - FastMath.sqrt(2.0)) / 2.0 },
    058        { 0.0, -FastMath.sqrt(2.0) / 2.0, (2.0 + FastMath.sqrt(2.0)) / 2.0 }
    059      };
    060
    061      /** Propagation weights Butcher array. */
    062      private static final double[] STATIC_B = {
    063        1.0 / 6.0, (2.0 - FastMath.sqrt(2.0)) / 6.0, (2.0 + FastMath.sqrt(2.0)) / 6.0, 1.0 / 6.0
    064      };
    065
    066      /** Simple constructor.
    067       * Build a fourth-order Gill integrator with the given step.
    068       * @param step integration step
    069       */
    070      public GillIntegrator(final double step) {
    071        super("Gill", STATIC_C, STATIC_A, STATIC_B, new GillStepInterpolator(), step);
    072      }
    073
    074    }