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
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
package org.apache.commons.math.ode.sampling;
20
import java.io.IOException;
21
import java.io.ObjectInput;
22
import java.io.ObjectOutput;
24
import org.apache.commons.math.ode.DerivativeException;
25
import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator;
27
/** This class is a step interpolator that does nothing.
29
* <p>This class is used when the {@link StepHandler "step handler"}
30
* set up by the user does not need step interpolation. It does not
31
* recompute the state when {@link AbstractStepInterpolator#setInterpolatedTime
32
* setInterpolatedTime} is called. This implies the interpolated state
33
* is always the state at the end of the current step.</p>
37
* @version $Revision: 782431 $ $Date: 2009-06-07 15:04:37 -0400 (Sun, 07 Jun 2009) $
41
public class DummyStepInterpolator
42
extends AbstractStepInterpolator {
44
/** Simple constructor.
45
* This constructor builds an instance that is not usable yet, the
46
* <code>AbstractStepInterpolator.reinitialize</code> protected method
47
* should be called before using the instance in order to initialize
48
* the internal arrays. This constructor is used only in order to delay
49
* the initialization in some cases. As an example, the {@link
50
* EmbeddedRungeKuttaIntegrator} uses the prototyping design pattern
51
* to create the step interpolators by cloning an uninitialized
52
* model and latter initializing the copy.
54
public DummyStepInterpolator() {
58
/** Simple constructor.
59
* @param y reference to the integrator array holding the state at
61
* @param forward integration direction indicator
63
public DummyStepInterpolator(final double[] y, final boolean forward) {
68
* @param interpolator interpolator to copy from. The copy is a deep
69
* copy: its arrays are separated from the original arrays of the
72
public DummyStepInterpolator(final DummyStepInterpolator interpolator) {
76
/** Really copy the finalized instance.
77
* @return a copy of the finalized instance
80
protected StepInterpolator doCopy() {
81
return new DummyStepInterpolator(this);
84
/** Compute the state at the interpolated time.
85
* In this class, this method does nothing: the interpolated state
86
* is always the state at the end of the current step.
87
* @param theta normalized interpolation abscissa within the step
88
* (theta is zero at the previous time step and one at the current time step)
89
* @param oneMinusThetaH time gap between the interpolated time and
91
* @throws DerivativeException this exception is propagated to the caller if the
92
* underlying user function triggers one
95
protected void computeInterpolatedStateAndDerivatives(final double theta, final double oneMinusThetaH)
96
throws DerivativeException {
97
System.arraycopy(currentState, 0, interpolatedState, 0, currentState.length);
100
/** Write the instance to an output channel.
101
* @param out output channel
102
* @exception IOException if the instance cannot be written
105
public void writeExternal(final ObjectOutput out)
107
// save the state of the base class
108
writeBaseExternal(out);
111
/** Read the instance from an input channel.
112
* @param in input channel
113
* @exception IOException if the instance cannot be read
116
public void readExternal(final ObjectInput in)
119
// read the base class
120
final double t = readBaseExternal(in);
122
// we can now set the interpolated time and state
123
setInterpolatedTime(t);
127
/** Serializable version identifier */
128
private static final long serialVersionUID = 1708010296707839488L;