1dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/* 2dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Licensed to the Apache Software Foundation (ASF) under one or more 3dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * contributor license agreements. See the NOTICE file distributed with 4dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * this work for additional information regarding copyright ownership. 5dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * The ASF licenses this file to You under the Apache License, Version 2.0 6dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * (the "License"); you may not use this file except in compliance with 7dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * the License. You may obtain a copy of the License at 8dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * 9dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * http://www.apache.org/licenses/LICENSE-2.0 10dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * 11dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Unless required by applicable law or agreed to in writing, software 12dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * distributed under the License is distributed on an "AS IS" BASIS, 13dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * See the License for the specific language governing permissions and 15dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * limitations under the License. 16dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 17dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 18dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpackage org.apache.commons.math.ode.sampling; 19dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 20dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport java.io.Externalizable; 21dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 22dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondimport org.apache.commons.math.ode.DerivativeException; 23dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 24dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond/** This interface represents an interpolator over the last step 25dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * during an ODE integration. 26dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * 27dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>The various ODE integrators provide objects implementing this 28dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * interface to the step handlers. These objects are often custom 29dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * objects tightly bound to the integrator internal algorithms. The 30dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * handlers can use these objects to retrieve the state vector at 31dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * intermediate times between the previous and the current grid points 32dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * (this feature is often called dense output).</p> 33dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>One important thing to note is that the step handlers may be so 34dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * tightly bound to the integrators that they often share some internal 35dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * state arrays. This imply that one should <em>never</em> use a direct 36dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * reference to a step interpolator outside of the step handler, either 37dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * for future use or for use in another thread. If such a need arise, the 38dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * step interpolator <em>must</em> be copied using the dedicated 39dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * {@link #copy()} method. 40dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * </p> 41dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * 42dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see org.apache.commons.math.ode.FirstOrderIntegrator 43dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see org.apache.commons.math.ode.SecondOrderIntegrator 44dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see StepHandler 45dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @version $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $ 46dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 1.2 47dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 48dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 49dee0849a9704d532af0b550146cbafbaa6ee1d19Raymondpublic interface StepInterpolator extends Externalizable { 50dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 51dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 52dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Get the previous grid point time. 53dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return previous grid point time 54dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 55dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond double getPreviousTime(); 56dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 57dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 58dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Get the current grid point time. 59dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return current grid point time 60dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 61dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond double getCurrentTime(); 62dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 63dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 64dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Get the time of the interpolated point. 65dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * If {@link #setInterpolatedTime} has not been called, it returns 66dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * the current grid point time. 67dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return interpolation point time 68dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 69dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond double getInterpolatedTime(); 70dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 71dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 72dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Set the time of the interpolated point. 73dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>Setting the time outside of the current step is now allowed, but 74dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * should be used with care since the accuracy of the interpolator will 75dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * probably be very poor far from this step. This allowance has been 76dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * added to simplify implementation of search algorithms near the 77dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * step endpoints.</p> 78dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>Setting the time changes the instance internal state. If a 79dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * specific state must be preserved, a copy of the instance must be 80dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * created using {@link #copy()}.</p> 81dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @param time time of the interpolated point 82dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 83dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond void setInterpolatedTime(double time); 84dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 85dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 86dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Get the state vector of the interpolated point. 87dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>The returned vector is a reference to a reused array, so 88dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * it should not be modified and it should be copied if it needs 89dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * to be preserved across several calls.</p> 90dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return state vector at time {@link #getInterpolatedTime} 91dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see #getInterpolatedDerivatives() 92dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @exception DerivativeException if user code called from step interpolator 93dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * finalization triggers one 94dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 95dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond double[] getInterpolatedState() throws DerivativeException; 96dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 97dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** 98dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * Get the derivatives of the state vector of the interpolated point. 99dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>The returned vector is a reference to a reused array, so 100dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * it should not be modified and it should be copied if it needs 101dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * to be preserved across several calls.</p> 102dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return derivatives of the state vector at time {@link #getInterpolatedTime} 103dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see #getInterpolatedState() 104dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @exception DerivativeException if user code called from step interpolator 105dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * finalization triggers one 106dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @since 2.0 107dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 108dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond double[] getInterpolatedDerivatives() throws DerivativeException; 109dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 110dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** Check if the natural integration direction is forward. 111dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>This method provides the integration direction as specified by 112dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * the integrator itself, it avoid some nasty problems in 113dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * degenerated cases like null steps due to cancellation at step 114dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * initialization, step control or discrete events 115dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * triggering.</p> 116dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return true if the integration variable (time) increases during 117dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * integration 118dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 119dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond boolean isForward(); 120dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 121dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond /** Copy the instance. 122dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * <p>The copied instance is guaranteed to be independent from the 123dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * original one. Both can be used with different settings for 124dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * interpolated time without any side effect.</p> 125dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @return a deep copy of the instance, which can be used independently. 126dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @exception DerivativeException if user code called from step interpolator 127dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * finalization triggers one 128dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond * @see #setInterpolatedTime(double) 129dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond */ 130dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond StepInterpolator copy() throws DerivativeException; 131dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond 132dee0849a9704d532af0b550146cbafbaa6ee1d19Raymond} 133