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