org.apache.commons.math.ode.sampling
Class StepNormalizer

java.lang.Object
  extended by org.apache.commons.math.ode.sampling.StepNormalizer
All Implemented Interfaces:
StepHandler

public class StepNormalizer
extends java.lang.Object
implements StepHandler

This class wraps an object implementing FixedStepHandler into a StepHandler.

This wrapper allows to use fixed step handlers with general integrators which cannot guaranty their integration steps will remain constant and therefore only accept general step handlers.

The stepsize used is selected at construction time. The handleStep method of the underlying FixedStepHandler object is called at the beginning time of the integration t0 and also at times t0+h, t0+2h, ... If the integration range is an integer multiple of the stepsize, then the last point handled will be the endpoint of the integration tend, if not, the last point will belong to the interval [tend - h ; tend].

There is no constraint on the integrator, it can use any timestep it needs (time steps longer or shorter than the fixed time step and non-integer ratios are all allowed).

Since:
1.2
Version:
$Revision: 786881 $ $Date: 2009-06-20 14:53:08 -0400 (Sat, 20 Jun 2009) $
See Also:
StepHandler, FixedStepHandler

Field Summary
private  boolean forward
          Integration direction indicator.
private  double h
          Fixed time step.
private  FixedStepHandler handler
          Underlying step handler.
private  double[] lastDerivatives
          Last Derivatives vector.
private  double[] lastState
          Last State vector.
private  double lastTime
          Last step time.
 
Constructor Summary
StepNormalizer(double h, FixedStepHandler handler)
          Simple constructor.
 
Method Summary
 void handleStep(StepInterpolator interpolator, boolean isLast)
          Handle the last accepted step
 boolean requiresDenseOutput()
          Determines whether this handler needs dense output.
 void reset()
          Reset the step handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

h

private double h
Fixed time step.


handler

private final FixedStepHandler handler
Underlying step handler.


lastTime

private double lastTime
Last step time.


lastState

private double[] lastState
Last State vector.


lastDerivatives

private double[] lastDerivatives
Last Derivatives vector.


forward

private boolean forward
Integration direction indicator.

Constructor Detail

StepNormalizer

public StepNormalizer(double h,
                      FixedStepHandler handler)
Simple constructor.

Parameters:
h - fixed time step (sign is not used)
handler - fixed time step handler to wrap
Method Detail

requiresDenseOutput

public boolean requiresDenseOutput()
Determines whether this handler needs dense output. This handler needs dense output in order to provide data at regularly spaced steps regardless of the steps the integrator uses, so this method always returns true.

Specified by:
requiresDenseOutput in interface StepHandler
Returns:
always true

reset

public void reset()
Reset the step handler. Initialize the internal data as required before the first step is handled.

Specified by:
reset in interface StepHandler

handleStep

public void handleStep(StepInterpolator interpolator,
                       boolean isLast)
                throws DerivativeException
Handle the last accepted step

Specified by:
handleStep in interface StepHandler
Parameters:
interpolator - interpolator for the last accepted step. For efficiency purposes, the various integrators reuse the same object on each call, so if the instance wants to keep it across all calls (for example to provide at the end of the integration a continuous model valid throughout the integration range), it should build a local copy using the clone method and store this copy.
isLast - true if the step is the last one
Throws:
DerivativeException - this exception is propagated to the caller if the underlying user function triggers one


Copyright (c) 2003-2009 Apache Software Foundation