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 represents an interpolator over the last step during an 22 * ODE integration for the 5(4) Higham and Hall integrator. 23 * 24 * @see HighamHall54Integrator 25 * 26 * @version $Revision: 620312 $ $Date: 2008-02-10 12:28:59 -0700 (Sun, 10 Feb 2008) $ 27 * @since 1.2 28 */ 29 30 class HighamHall54StepInterpolator 31 extends RungeKuttaStepInterpolator { 32 33 /** Simple constructor. 34 * This constructor builds an instance that is not usable yet, the 35 * {@link AbstractStepInterpolator#reinitialize} method should be called 36 * before using the instance in order to initialize the internal arrays. This 37 * constructor is used only in order to delay the initialization in 38 * some cases. The {@link EmbeddedRungeKuttaIntegrator} uses the 39 * prototyping design pattern to create the step interpolators by 40 * cloning an uninitialized model and latter initializing the copy. 41 */ 42 public HighamHall54StepInterpolator() { 43 super(); 44 } 45 46 /** Copy constructor. 47 * @param interpolator interpolator to copy from. The copy is a deep 48 * copy: its arrays are separated from the original arrays of the 49 * instance 50 */ 51 public HighamHall54StepInterpolator(HighamHall54StepInterpolator interpolator) { 52 super(interpolator); 53 } 54 55 /** Really copy the finalized instance. 56 * @return a copy of the finalized instance 57 */ 58 protected StepInterpolator doCopy() { 59 return new HighamHall54StepInterpolator(this); 60 } 61 62 63 /** Compute the state at the interpolated time. 64 * @param theta normalized interpolation abscissa within the step 65 * (theta is zero at the previous time step and one at the current time step) 66 * @param oneMinusThetaH time gap between the interpolated time and 67 * the current time 68 * @throws DerivativeException this exception is propagated to the caller if the 69 * underlying user function triggers one 70 */ 71 protected void computeInterpolatedState(double theta, 72 double oneMinusThetaH) 73 throws DerivativeException { 74 75 double theta2 = theta * theta; 76 77 double b0 = h * (-1.0/12.0 + theta * (1.0 + theta * (-15.0/4.0 + theta * (16.0/3.0 + theta * -5.0/2.0)))); 78 double b2 = h * (-27.0/32.0 + theta2 * (459.0/32.0 + theta * (-243.0/8.0 + theta * 135.0/8.0))); 79 double b3 = h * (4.0/3.0 + theta2 * (-22.0 + theta * (152.0/3.0 + theta * -30.0))); 80 double b4 = h * (-125.0/96.0 + theta2 * (375.0/32.0 + theta * (-625.0/24.0 + theta * 125.0/8.0))); 81 double b5 = h * (-5.0/48.0 + theta2 * (-5.0/16.0 + theta * 5.0/12.0)); 82 83 for (int i = 0; i < interpolatedState.length; ++i) { 84 interpolatedState[i] = currentState[i] + 85 b0 * yDotK[0][i] + b2 * yDotK[2][i] + b3 * yDotK[3][i] + 86 b4 * yDotK[4][i] + b5 * yDotK[5][i]; 87 } 88 89 } 90 91 /** Serializable version identifier */ 92 private static final long serialVersionUID = -3583240427587318654L; 93 94 }