• 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.jacobians;
19 
20 import org.apache.commons.math.ode.DerivativeException;
21 
22 /**
23  * This interface represents a handler that should be called after
24  * each successful step.
25  *
26  * <p>The ODE integrators compute the evolution of the state vector at
27  * some grid points that depend on their own internal algorithm. Once
28  * they have found a new grid point (possibly after having computed
29  * several evaluation of the derivative at intermediate points), they
30  * provide it to objects implementing this interface. These objects
31  * typically either ignore the intermediate steps and wait for the
32  * last one, store the points in an ephemeris, or forward them to
33  * specialized processing or output methods.</p>
34  *
35  * <p>Note that is is possible to register a {@link
36  * org.apache.commons.math.ode.sampling.StepHandler classical step handler}
37  * in the low level integrator used to build a {@link FirstOrderIntegratorWithJacobians}
38  * rather than implementing this class. The step handlers registered at low level
39  * will see the big compound state whether the step handlers defined by this interface
40  * see the original state, and its jacobians in separate arrays.</p>
41  *
42  * <p>The compound state is guaranteed to contain the original state in the first
43  * elements, followed by the jacobian with respect to initial state (in row order),
44  * followed by the jacobian with respect to parameters (in row order). If for example
45  * the original state dimension is 6 and there are 3 parameters, the compound state will
46  * be a 60 elements array. The first 6 elements will be the original state, the next 36
47  * elements will be the jacobian with respect to initial state, and the remaining 18 elements
48  * will be the jacobian with respect to parameters.</p>
49  *
50  * <p>Dealing with low level step handlers is cumbersome if one really needs the jacobians
51  * in these methods, but it also prevents many data being copied back and forth between
52  * state and jacobians on one side and compound state on the other side. So for performance
53  * reasons, it is recommended to use this interface <em>only</em> if jacobians are really
54  * needed and to use lower level handlers if only state is needed.</p>
55  *
56  * @see FirstOrderIntegratorWithJacobians
57  * @see StepInterpolatorWithJacobians
58  * @version $Revision: 1073158 $ $Date: 2011-02-21 22:46:52 +0100 (lun. 21 févr. 2011) $
59  * @since 2.1
60  * @deprecated as of 2.2 the complete package is deprecated, it will be replaced
61  * in 3.0 by a completely rewritten implementation
62  */
63 @Deprecated
64 public interface StepHandlerWithJacobians {
65 
66   /** Determines whether this handler needs dense output.
67    * <p>This method allows the integrator to avoid performing extra
68    * computation if the handler does not need dense output.</p>
69    * @return true if the handler needs dense output
70    */
requiresDenseOutput()71   boolean requiresDenseOutput();
72 
73   /** Reset the step handler.
74    * Initialize the internal data as required before the first step is
75    * handled.
76    */
reset()77   void reset();
78 
79   /**
80    * Handle the last accepted step
81    * @param interpolator interpolator for the last accepted step. For
82    * efficiency purposes, the various integrators reuse the same
83    * object on each call, so if the instance wants to keep it across
84    * all calls (for example to provide at the end of the integration a
85    * continuous model valid throughout the integration range, as the
86    * {@link org.apache.commons.math.ode.ContinuousOutputModel
87    * ContinuousOutputModel} class does), it should build a local copy
88    * using the clone method of the interpolator and store this copy.
89    * Keeping only a reference to the interpolator and reusing it will
90    * result in unpredictable behavior (potentially crashing the application).
91    * @param isLast true if the step is the last one
92    * @throws DerivativeException this exception is propagated to the
93    * caller if the underlying user function triggers one
94    */
handleStep(StepInterpolatorWithJacobians interpolator, boolean isLast)95   void handleStep(StepInterpolatorWithJacobians interpolator, boolean isLast) throws DerivativeException;
96 
97 }
98