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 018package org.apache.commons.math4.legacy.ode.nonstiff; 019 020 021/** 022 * This class implements a second order Runge-Kutta integrator for 023 * Ordinary Differential Equations. 024 * 025 * <p>This method is an explicit Runge-Kutta method, its Butcher-array 026 * is the following one : 027 * <pre> 028 * 0 | 0 0 029 * 1/2 | 1/2 0 030 * |---------- 031 * | 0 1 032 * </pre> 033 * 034 * @see EulerIntegrator 035 * @see ClassicalRungeKuttaIntegrator 036 * @see GillIntegrator 037 * @see ThreeEighthesIntegrator 038 * @see LutherIntegrator 039 * 040 * @since 1.2 041 */ 042 043public class MidpointIntegrator extends RungeKuttaIntegrator { 044 045 /** Time steps Butcher array. */ 046 private static final double[] STATIC_C = { 047 1.0 / 2.0 048 }; 049 050 /** Internal weights Butcher array. */ 051 private static final double[][] STATIC_A = { 052 { 1.0 / 2.0 } 053 }; 054 055 /** Propagation weights Butcher array. */ 056 private static final double[] STATIC_B = { 057 0.0, 1.0 058 }; 059 060 /** Simple constructor. 061 * Build a midpoint integrator with the given step. 062 * @param step integration step 063 */ 064 public MidpointIntegrator(final double step) { 065 super("midpoint", STATIC_C, STATIC_A, STATIC_B, new MidpointStepInterpolator(), step); 066 } 067}