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
18 package org.apache.commons.math.ode;
19
20 /**
21 * This class implements a second order Runge-Kutta integrator for
22 * Ordinary Differential Equations.
23 *
24 * <p>This method is an explicit Runge-Kutta method, its Butcher-array
25 * is the following one :
26 * <pre>
27 * 0 | 0 0
28 * 1/2 | 1/2 0
29 * |----------
30 * | 0 1
31 * </pre>
32 * </p>
33 *
34 * @see EulerIntegrator
35 * @see ClassicalRungeKuttaIntegrator
36 * @see GillIntegrator
37 *
38 * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $
39 * @since 1.2
40 */
41
42 public class MidpointIntegrator
43 extends RungeKuttaIntegrator {
44
45 /** Integrator method name. */
46 private static final String methodName = "midpoint";
47
48 /** Time steps Butcher array. */
49 private static final double[] c = {
50 1.0 / 2.0
51 };
52
53 /** Internal weights Butcher array. */
54 private static final double[][] a = {
55 { 1.0 / 2.0 }
56 };
57
58 /** Propagation weights Butcher array. */
59 private static final double[] b = {
60 0.0, 1.0
61 };
62
63 /** Simple constructor.
64 * Build a midpoint integrator with the given step.
65 * @param step integration step
66 */
67 public MidpointIntegrator(double step) {
68 super(c, a, b, new MidpointStepInterpolator(), step);
69 }
70
71 /** Get the name of the method.
72 * @return name of the method
73 */
74 public String getName() {
75 return methodName;
76 }
77
78 }