commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l..@apache.org
Subject svn commit: r670469 [3/8] - in /commons/proper/math/branches/MATH_2_0/src: experimental/org/apache/commons/math/analysis/ experimental/org/apache/commons/math/analysis/derivative/ experimental/org/apache/commons/math/function/ experimental/org/apache/c...
Date Mon, 23 Jun 2008 08:01:55 GMT
Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java?rev=670469&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java Mon Jun 23 01:01:38 2008
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.ode.events;
+
+import org.apache.commons.math.MathException;
+
+/**
+ * This exception is made available to users to report
+ * the error conditions that are triggered by {@link EventHandler}
+ * @version $Revision$ $Date$
+ * @since 2.0
+ */
+public class EventException extends MathException {
+
+    /** Serialization UID. */
+    private static final long serialVersionUID = -898215297400035290L;
+
+    /** Simple constructor.
+     * Build an exception by translating and formating a message
+     * @param specifier format specifier (to be translated)
+     * @param parts to insert in the format (no translation)
+     */
+    public EventException(final String specifier, final Object[] parts) {
+        super(specifier, parts);
+    }
+
+    /**
+     * Create an exception with a given root cause.
+     * @param cause  the exception or error that caused this exception to be thrown
+     */
+    public EventException(final Throwable cause) {
+        super(cause);
+    }
+
+}

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java?rev=670469&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java Mon Jun 23 01:01:38 2008
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.ode.events;
+
+import java.io.Serializable;
+
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.sampling.StepHandler;
+
+/** This interface represents a handler for discrete events triggered
+ * during ODE integration.
+ *
+ * <p>Some events can be triggered at discrete times as an ODE problem
+ * is solved. These occurs for example when the integration process
+ * should be stopped as some state is reached (G-stop facility) when the
+ * precise date is unknown a priori, or when the derivatives have
+ * discontinuities, or simply when the user wants to monitor some
+ * states boundaries crossings.
+ * </p>
+ * 
+ * <p>These events are defined as occurring when a <code>g</code>
+ * switching function sign changes.</p>
+ *
+ * <p>Since events are only problem-dependent and are triggered by the
+ * independent <i>time</i> variable and the state vector, they can
+ * occur at virtually any time, unknown in advance. The integrators will
+ * take care to avoid sign changes inside the steps, they will reduce
+ * the step size when such an event is detected in order to put this
+ * event exactly at the end of the current step. This guarantees that
+ * step interpolation (which always has a one step scope) is relevant
+ * even in presence of discontinuities. This is independent from the
+ * stepsize control provided by integrators that monitor the local
+ * error (this event handling feature is available for all integrators,
+ * including fixed step ones).</p>
+ *
+ * @version $Revision$ $Date$
+ * @since 1.2
+ */
+
+public interface EventHandler extends Serializable {
+
+  /** Stop indicator.
+   * <p>This value should be used as the return value of the {@link
+   * #eventOccurred eventOccurred} method when the integration should be
+   * stopped after the event ending the current step.</p>
+   */
+  public static final int STOP = 0;
+
+  /** Reset state indicator.
+   * <p>This value should be used as the return value of the {@link
+   * #eventOccurred eventOccurred} method when the integration should
+   * go on after the event ending the current step, with a new state
+   * vector (which will be retrieved thanks to the {@link #resetState
+   * resetState} method).</p>
+   */
+  public static final int RESET_STATE = 1;
+
+  /** Reset derivatives indicator.
+   * <p>This value should be used as the return value of the {@link
+   * #eventOccurred eventOccurred} method when the integration should
+   * go on after the event ending the current step, with a new derivatives
+   * vector (which will be retrieved thanks to the {@link
+   * FirstOrderDifferentialEquations#computeDerivatives} method).</p>
+   */
+  public static final int RESET_DERIVATIVES = 2;
+
+  /** Continue indicator.
+   * <p>This value should be used as the return value of the {@link
+   * #eventOccurred eventOccurred} method when the integration should go
+   * on after the event ending the current step.</p>
+   */
+  public static final int CONTINUE = 3;
+
+  /** Compute the value of the switching function.
+
+   * <p>The discrete events are generated when the sign of this 
+   * switching function changes. The integrator will take care to change
+   * the stepsize in such a way these events occur exactly at step boundaries.
+   * The switching function must be continuous in its roots neighborhood
+   * (but not necessarily smooth), as the integrator will need to find its
+   * roots to locate precisely the events.</p>
+
+   * @param t current value of the independent <i>time</i> variable
+   * @param y array containing the current value of the state vector
+   * @return value of the g switching function
+   * @exception EventException if the switching function cannot be evaluated
+   */
+  public double g(double t, double[] y) throws EventException;
+
+  /** Handle an event and choose what to do next.
+
+   * <p>This method is called when the integrator has accepted a step
+   * ending exactly on a sign change of the function, just before the
+   * step handler itself is called. It allows the user to update his
+   * internal data to acknowledge the fact the event has been handled
+   * (for example setting a flag in the {@link
+   * FirstOrderDifferentialEquations differential equations} to switch
+   * the derivatives computation in case of discontinuity), or to
+   * direct the integrator to either stop or continue integration,
+   * possibly with a reset state or derivatives.</p>
+
+   * <ul>
+   *   <li>if {@link #STOP} is returned, the step handler will be called
+   *   with the <code>isLast</code> flag of the {@link
+   *   StepHandler#handleStep handleStep} method set to true and the
+   *   integration will be stopped,</li>
+   *   <li>if {@link #RESET_STATE} is returned, the {@link #resetState
+   *   resetState} method will be called once the step handler has
+   *   finished its task, and the integrator will also recompute the
+   *   derivatives,</li>
+   *   <li>if {@link #RESET_DERIVATIVES} is returned, the integrator
+   *   will recompute the derivatives,
+   *   <li>if {@link #CONTINUE} is returned, no specific action will
+   *   be taken (apart from having called this method) and integration
+   *   will continue.</li>
+   * </ul>
+
+   * @param t current value of the independent <i>time</i> variable
+   * @param y array containing the current value of the state vector
+   * @return indication of what the integrator should do next, this
+   * value must be one of {@link #STOP}, {@link #RESET_STATE},
+   * {@link #RESET_DERIVATIVES} or {@link #CONTINUE}
+   * @exception EventException if the event occurrence triggers an error
+   */
+  public int eventOccurred(double t, double[] y) throws EventException;
+  
+  /** Reset the state prior to continue the integration.
+
+   * <p>This method is called after the step handler has returned and
+   * before the next step is started, but only when {@link
+   * #eventOccurred} has itself returned the {@link #RESET_STATE}
+   * indicator. It allows the user to reset the state vector for the
+   * next step, without perturbing the step handler of the finishing
+   * step. If the {@link #eventOccurred} never returns the {@link
+   * #RESET_STATE} indicator, this function will never be called, and it is
+   * safe to leave its body empty.</p>
+
+   * @param t current value of the independent <i>time</i> variable
+   * @param y array containing the current value of the state vector
+   * the new state should be put in the same array
+   * @exception EventException if the state cannot be reseted
+   */
+  public void resetState(double t, double[] y) throws EventException;
+
+}

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventHandler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java?rev=670469&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java Mon Jun 23 01:01:38 2008
@@ -0,0 +1,299 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.math.ode.events;
+
+import java.io.Serializable;
+
+import org.apache.commons.math.ConvergenceException;
+import org.apache.commons.math.FunctionEvaluationException;
+import org.apache.commons.math.analysis.BrentSolver;
+import org.apache.commons.math.analysis.UnivariateRealFunction;
+import org.apache.commons.math.analysis.UnivariateRealSolver;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
+
+/** This class handles the state for one {@link EventHandler
+ * event handler} during integration steps.
+ *
+ * <p>Each time the integrator proposes a step, the event handler
+ * switching function should be checked. This class handles the state
+ * of one handler during one integration step, with references to the
+ * state at the end of the preceding step. This information is used to
+ * decide if the handler should trigger an event or not during the
+ * proposed step (and hence the step should be reduced to ensure the
+ * event occurs at a bound rather than inside the step).</p>
+ *
+ * @version $Revision$ $Date$
+ * @since 1.2
+ */
+class EventState implements Serializable {
+
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = -7307007422156119622L;
+
+    /** Event handler. */
+    private final EventHandler handler;
+
+    /** Maximal time interval between events handler checks. */
+    private final double maxCheckInterval;
+
+    /** Convergence threshold for event localization. */
+    private final double convergence;
+
+    /** Upper limit in the iteration count for event localization. */
+    private final int maxIterationCount;
+
+    /** Time at the beginning of the step. */
+    private double t0;
+
+    /** Value of the events handler at the beginning of the step. */
+    private double g0;
+
+    /** Simulated sign of g0 (we cheat when crossing events). */
+    private boolean g0Positive;
+
+    /** Indicator of event expected during the step. */
+    private boolean pendingEvent;
+
+    /** Occurrence time of the pending event. */
+    private double pendingEventTime;
+
+    /** Occurrence time of the previous event. */
+    private double previousEventTime;
+
+    /** Variation direction around pending event.
+     *  (this is considered with respect to the integration direction)
+     */
+    private boolean increasing;
+
+    /** Next action indicator. */
+    private int nextAction;
+
+    /** Simple constructor.
+     * @param handler event handler
+     * @param maxCheckInterval maximal time interval between switching
+     * function checks (this interval prevents missing sign changes in
+     * case the integration steps becomes very large)
+     * @param convergence convergence threshold in the event time search
+     * @param maxIterationCount upper limit of the iteration count in
+     * the event time search
+     */
+    public EventState(final EventHandler handler, final double maxCheckInterval,
+                      final double convergence, final int maxIterationCount) {
+        this.handler           = handler;
+        this.maxCheckInterval  = maxCheckInterval;
+        this.convergence       = Math.abs(convergence);
+        this.maxIterationCount = maxIterationCount;
+
+        // some dummy values ...
+        t0                = Double.NaN;
+        g0                = Double.NaN;
+        g0Positive        = true;
+        pendingEvent      = false;
+        pendingEventTime  = Double.NaN;
+        previousEventTime = Double.NaN;
+        increasing        = true;
+        nextAction        = EventHandler.CONTINUE;
+
+    }
+
+    /** Get the underlying event handler.
+     * @return underlying event handler
+     */
+    public EventHandler getEventHandler() {
+        return handler;
+    }
+
+    /** Reinitialize the beginning of the step.
+     * @param t0 value of the independent <i>time</i> variable at the
+     * beginning of the step
+     * @param y0 array containing the current value of the state vector
+     * at the beginning of the step
+     * @exception EventException if the event handler
+     * value cannot be evaluated at the beginning of the step
+     */
+    public void reinitializeBegin(final double t0, final double[] y0)
+        throws EventException {
+        this.t0 = t0;
+        g0 = handler.g(t0, y0);
+        g0Positive = (g0 >= 0);
+    }
+
+    /** Evaluate the impact of the proposed step on the event handler.
+     * @param interpolator step interpolator for the proposed step
+     * @return true if the event handler triggers an event before
+     * the end of the proposed step (this implies the step should be
+     * rejected)
+     * @exception DerivativeException if the interpolator fails to
+     * compute the switching function somewhere within the step
+     * @exception EventException if the switching function
+     * cannot be evaluated
+     * @exception ConvergenceException if an event cannot be located
+     */
+    public boolean evaluateStep(final StepInterpolator interpolator)
+        throws DerivativeException, EventException, ConvergenceException {
+
+        try {
+
+            final double t1 = interpolator.getCurrentTime();
+            final int    n  = Math.max(1, (int) Math.ceil(Math.abs(t1 - t0) / maxCheckInterval));
+            final double h  = (t1 - t0) / n;
+
+            double ta = t0;
+            double ga = g0;
+            double tb = t0 + ((t1 > t0) ? convergence : -convergence);
+            for (int i = 0; i < n; ++i) {
+
+                // evaluate handler value at the end of the substep
+                tb += h;
+                interpolator.setInterpolatedTime(tb);
+                final double gb = handler.g(tb, interpolator.getInterpolatedState());
+
+                // check events occurrence
+                if (g0Positive ^ (gb >= 0)) {
+                    // there is a sign change: an event is expected during this step
+
+                    // variation direction, with respect to the integration direction
+                    increasing = (gb >= ga);
+
+                    final UnivariateRealSolver solver = new BrentSolver(new UnivariateRealFunction() {
+                        public double value(final double t) throws FunctionEvaluationException {
+                            try {
+                                interpolator.setInterpolatedTime(t);
+                                return handler.g(t, interpolator.getInterpolatedState());
+                            } catch (DerivativeException e) {
+                                throw new FunctionEvaluationException(t, e);
+                            } catch (EventException e) {
+                                throw new FunctionEvaluationException(t, e);
+                            }
+                        }
+                    });
+                    solver.setAbsoluteAccuracy(convergence);
+                    solver.setMaximalIterationCount(maxIterationCount);
+                    final double root = solver.solve(ta, tb);
+                    if (Double.isNaN(previousEventTime) ||
+                        (Math.abs(previousEventTime - root) > convergence)) {
+                        pendingEventTime = root;
+                        if (pendingEvent && (Math.abs(t1 - pendingEventTime) <= convergence)) {
+                            // we were already waiting for this event which was
+                            // found during a previous call for a step that was
+                            // rejected, this step must now be accepted since it
+                            // properly ends exactly at the event occurrence
+                            return false;
+                        }
+                        // either we were not waiting for the event or it has
+                        // moved in such a way the step cannot be accepted
+                        pendingEvent = true;
+                        return true;
+                    }
+
+                } else {
+                    // no sign change: there is no event for now
+                    ta = tb;
+                    ga = gb;
+                }
+
+            }
+
+            // no event during the whole step
+            pendingEvent     = false;
+            pendingEventTime = Double.NaN;
+            return false;
+
+        } catch (FunctionEvaluationException e) {
+            final Throwable cause = e.getCause();
+            if ((cause != null) && (cause instanceof DerivativeException)) {
+                throw (DerivativeException) cause;
+            } else if ((cause != null) && (cause instanceof EventException)) {
+                throw (EventException) cause;
+            }
+            throw new EventException(e);
+        }
+
+    }
+
+    /** Get the occurrence time of the event triggered in the current
+     * step.
+     * @return occurrence time of the event triggered in the current
+     * step.
+     */
+    public double getEventTime() {
+        return pendingEventTime;
+    }
+
+    /** Acknowledge the fact the step has been accepted by the integrator.
+     * @param t value of the independent <i>time</i> variable at the
+     * end of the step
+     * @param y array containing the current value of the state vector
+     * at the end of the step
+     * @exception EventException if the value of the event
+     * handler cannot be evaluated
+     */
+    public void stepAccepted(final double t, final double[] y)
+        throws EventException {
+
+        t0 = t;
+        g0 = handler.g(t, y);
+
+        if (pendingEvent) {
+            // force the sign to its value "just after the event"
+            previousEventTime = t;
+            g0Positive        = increasing;
+            nextAction        = handler.eventOccurred(t, y);
+        } else {
+            g0Positive = (g0 >= 0);
+            nextAction = EventHandler.CONTINUE;
+        }
+    }
+
+    /** Check if the integration should be stopped at the end of the
+     * current step.
+     * @return true if the integration should be stopped
+     */
+    public boolean stop() {
+        return nextAction == EventHandler.STOP;
+    }
+
+    /** Let the event handler reset the state if it wants.
+     * @param t value of the independent <i>time</i> variable at the
+     * beginning of the next step
+     * @param y array were to put the desired state vector at the beginning
+     * of the next step
+     * @return true if the integrator should reset the derivatives too
+     * @exception EventException if the state cannot be reseted by the event
+     * handler
+     */
+    public boolean reset(final double t, final double[] y)
+        throws EventException {
+
+        if (! pendingEvent) {
+            return false;
+        }
+
+        if (nextAction == EventHandler.RESET_STATE) {
+            handler.resetState(t, y);
+        }
+        pendingEvent      = false;
+        pendingEventTime  = Double.NaN;
+
+        return (nextAction == EventHandler.RESET_STATE) ||
+        (nextAction == EventHandler.RESET_DERIVATIVES);
+
+    }
+
+}

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/EventState.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/package.html?rev=670469&view=auto
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/package.html (added)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/package.html Mon Jun 23 01:01:38 2008
@@ -0,0 +1,96 @@
+<html>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+  -->
+    <!-- $Revision: 613620 $ -->
+<body>
+<p>
+This package provides classes to handle discrete events occurring during
+Ordinary Differential Equations integration.
+</p>
+
+<p>
+Discrete events detection is based on switching functions. The user provides
+a simple {@link org.apache.commons.math.ode.events.EventHandler#g g(t, y)}
+function depending on the current time and state. The integrator will monitor
+the value of the function throughout integration range and will trigger the
+event when its sign changes. The magnitude of the value is almost irrelevant,
+it should however be continuous (but not necessarily smooth) for the sake of
+root finding. The steps are shortened as needed to ensure the events occur
+at step boundaries (even if the integrator is a fixed-step integrator).
+</p>
+
+<p>
+When an event is triggered, several different options are available:
+</p>
+<ul>
+  <li>integration can be stopped (this is called a G-stop facility),</li>
+  <li>the state vector or the derivatives can be changed,</li>
+  <li>or integration can simply go on.</li>
+</ul>
+
+<p>
+The first case, G-stop, is the most common one. A typical use case is when an
+ODE must be solved up to some target state is reached, with a known value of
+the state but an unknown occurrence time. As an example, if we want to monitor
+a chemical reaction up to some predefined concentration for the first substance,
+we can use the following switching function setting:
+<pre>
+  public double g(double t, double[] y) {
+    return y[0] - targetConcentration;
+  }
+
+  public int eventOccurred(double t, double[] y) {
+    return STOP;
+  }
+</pre>
+</p>
+
+<p>
+The second case, change state vector or derivatives is encountered when dealing
+with discontinuous dynamical models. A typical case would be the motion of a
+spacecraft when thrusters are fired for orbital maneuvers. The acceleration is
+smooth as long as no maneuver are performed, depending only on gravity, drag,
+third body attraction, radiation pressure. Firing a thruster introduces a
+discontinuity that must be handled appropriately by the integrator. In such a case,
+we would use a switching function setting similar to this:
+<pre>
+  public double g(double t, double[] y) {
+    return (t - tManeuverStart) * (t - tManeuverStop);
+  }
+
+  public int eventOccurred(double t, double[] y) {
+    return RESET_DERIVATIVES;
+  }
+</pre>
+</p>
+
+<p>
+The third case is useful mainly for monitoring purposes, a simple example is:
+<pre>
+  public double g(double t, double[] y) {
+    return y[0] - y[1];
+  }
+
+  public int eventOccurred(double t, double[] y) {
+    logger.log("y0(t) and y1(t) curves cross at t = " + t);
+    return CONTINUE;
+  }
+</pre>
+</p>
+
+</body>
+</html>

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/events/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
 /**
  * This class implements the classical fourth order Runge-Kutta
@@ -73,13 +73,11 @@
    * step.
    * @param step integration step
    */
-  public ClassicalRungeKuttaIntegrator(double step) {
+  public ClassicalRungeKuttaIntegrator(final double step) {
     super(c, a, b, new ClassicalRungeKuttaStepInterpolator(), step);
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public String getName() {
     return methodName;
   }

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaIntegrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/ClassicalRungeKuttaStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,10 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
  * This class implements a step interpolator for the classical fourth
@@ -43,67 +46,56 @@
  */
 
 class ClassicalRungeKuttaStepInterpolator
-  extends RungeKuttaStepInterpolator {
-    
-  /** Simple constructor.
-   * This constructor builds an instance that is not usable yet, the
-   * {@link RungeKuttaStepInterpolator#reinitialize} method should be
-   * called before using the instance in order to initialize the
-   * internal arrays. This constructor is used only in order to delay
-   * the initialization in some cases. The {@link RungeKuttaIntegrator}
-   * class uses the prototyping design pattern to create the step
-   * interpolators by cloning an uninitialized model and latter initializing
-   * the copy.
-   */
-  public ClassicalRungeKuttaStepInterpolator() {
-  }
-
-  /** Copy constructor.
-   * @param interpolator interpolator to copy from. The copy is a deep
-   * copy: its arrays are separated from the original arrays of the
-   * instance
-   */
-  public ClassicalRungeKuttaStepInterpolator(ClassicalRungeKuttaStepInterpolator interpolator) {
-    super(interpolator);
-  }
-
-  /** Really copy the finalized instance.
-   * @return a copy of the finalized instance
-   */
-  protected StepInterpolator doCopy() {
-    return new ClassicalRungeKuttaStepInterpolator(this);
-  }
-
-  /** Compute the state at the interpolated time.
-   * This is the main processing method that should be implemented by
-   * the derived classes to perform the interpolation.
-   * @param theta normalized interpolation abscissa within the step
-   * (theta is zero at the previous time step and one at the current time step)
-   * @param oneMinusThetaH time gap between the interpolated time and
-   * the current time
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
-  protected void computeInterpolatedState(double theta,
-                                          double oneMinusThetaH)
-    throws DerivativeException {
-
-    double fourTheta = 4 * theta;
-    double s         = oneMinusThetaH / 6.0;
-    double coeff1    = s * ((-fourTheta + 5) * theta - 1);
-    double coeff23   = s * (( fourTheta - 2) * theta - 2);
-    double coeff4    = s * ((-fourTheta - 1) * theta - 1);
-
-    for (int i = 0; i < interpolatedState.length; ++i) {
-      interpolatedState[i] = currentState[i] +
-                             coeff1  * yDotK[0][i] +
-                             coeff23 * (yDotK[1][i] + yDotK[2][i]) +
-                             coeff4  * yDotK[3][i];
-     }
+    extends RungeKuttaStepInterpolator {
+
+    /** Serializable version identifier */
+    private static final long serialVersionUID = -6576285612589783992L;
 
-  }
+    /** Simple constructor.
+     * This constructor builds an instance that is not usable yet, the
+     * {@link RungeKuttaStepInterpolator#reinitialize} method should be
+     * called before using the instance in order to initialize the
+     * internal arrays. This constructor is used only in order to delay
+     * the initialization in some cases. The {@link RungeKuttaIntegrator}
+     * class uses the prototyping design pattern to create the step
+     * interpolators by cloning an uninitialized model and latter initializing
+     * the copy.
+     */
+    public ClassicalRungeKuttaStepInterpolator() {
+    }
+
+    /** Copy constructor.
+     * @param interpolator interpolator to copy from. The copy is a deep
+     * copy: its arrays are separated from the original arrays of the
+     * instance
+     */
+    public ClassicalRungeKuttaStepInterpolator(final ClassicalRungeKuttaStepInterpolator interpolator) {
+        super(interpolator);
+    }
+
+    /** {@inheritDoc} */
+    protected StepInterpolator doCopy() {
+        return new ClassicalRungeKuttaStepInterpolator(this);
+    }
+
+    /** {@inheritDoc} */
+    protected void computeInterpolatedState(final double theta,
+                                            final double oneMinusThetaH)
+        throws DerivativeException {
+
+        final double fourTheta = 4 * theta;
+        final double s         = oneMinusThetaH / 6.0;
+        final double coeff1    = s * ((-fourTheta + 5) * theta - 1);
+        final double coeff23   = s * (( fourTheta - 2) * theta - 2);
+        final double coeff4    = s * ((-fourTheta - 1) * theta - 1);
+
+        for (int i = 0; i < interpolatedState.length; ++i) {
+            interpolatedState[i] = currentState[i] +
+            coeff1  * yDotK[0][i] +
+            coeff23 * (yDotK[1][i] + yDotK[2][i]) +
+            coeff4  * yDotK[3][i];
+        }
 
-  /** Serializable version identifier */
-  private static final long serialVersionUID = -6576285612589783992L;
+    }
 
 }

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/ClassicalRungeKuttaStepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54Integrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54Integrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
 /**
  * This class implements the 5(4) Dormand-Prince integrator for Ordinary
@@ -101,9 +101,9 @@
    * @param scalAbsoluteTolerance allowed absolute error
    * @param scalRelativeTolerance allowed relative error
    */
-  public DormandPrince54Integrator(double minStep, double maxStep,
-                                   double scalAbsoluteTolerance,
-                                   double scalRelativeTolerance) {
+  public DormandPrince54Integrator(final double minStep, final double maxStep,
+                                   final double scalAbsoluteTolerance,
+                                   final double scalRelativeTolerance) {
     super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
           minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
   }
@@ -117,51 +117,41 @@
    * @param vecAbsoluteTolerance allowed absolute error
    * @param vecRelativeTolerance allowed relative error
    */
-  public DormandPrince54Integrator(double minStep, double maxStep,
-                                   double[] vecAbsoluteTolerance,
-                                   double[] vecRelativeTolerance) {
+  public DormandPrince54Integrator(final double minStep, final double maxStep,
+                                   final double[] vecAbsoluteTolerance,
+                                   final double[] vecRelativeTolerance) {
     super(true, staticC, staticA, staticB, new DormandPrince54StepInterpolator(),
           minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public String getName() {
     return methodName;
   }
 
-  /** Get the order of the method.
-   * @return order of the method
-   */
+  /** {@inheritDoc} */
   public int getOrder() {
     return 5;
   }
 
-  /** Compute the error ratio.
-   * @param yDotK derivatives computed during the first stages
-   * @param y0 estimate of the step at the start of the step
-   * @param y1 estimate of the step at the end of the step
-   * @param h  current step
-   * @return error ratio, greater than 1 if step should be rejected
-   */
-  protected double estimateError(double[][] yDotK,
-                                 double[] y0, double[] y1,
-                                 double h) {
+  /** {@inheritDoc} */
+  protected double estimateError(final double[][] yDotK,
+                                 final double[] y0, final double[] y1,
+                                 final double h) {
 
     double error = 0;
 
     for (int j = 0; j < y0.length; ++j) {
-      double errSum = e1 * yDotK[0][j] +  e3 * yDotK[2][j] +
-                      e4 * yDotK[3][j] +  e5 * yDotK[4][j] +
-                      e6 * yDotK[5][j] +  e7 * yDotK[6][j];
-
-      double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
-      double tol = (vecAbsoluteTolerance == null) ?
-                   (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
-                   (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
-      double ratio  = h * errSum / tol;
-      error += ratio * ratio;
+        final double errSum = e1 * yDotK[0][j] +  e3 * yDotK[2][j] +
+                              e4 * yDotK[3][j] +  e5 * yDotK[4][j] +
+                              e6 * yDotK[5][j] +  e7 * yDotK[6][j];
+
+        final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
+        final double tol = (vecAbsoluteTolerance == null) ?
+                           (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
+                               (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
+        final double ratio  = h * errSum / tol;
+        error += ratio * ratio;
 
     }
 

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54Integrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54StepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54StepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince54StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
  * This class represents an interpolator over the last step during an
@@ -53,7 +57,7 @@
    * copy: its arrays are separated from the original arrays of the
    * instance
    */
-  public DormandPrince54StepInterpolator(DormandPrince54StepInterpolator interpolator) {
+  public DormandPrince54StepInterpolator(final DormandPrince54StepInterpolator interpolator) {
 
     super(interpolator);
 
@@ -77,24 +81,15 @@
 
   }
 
-  /** Really copy the finalized instance.
-   * @return a copy of the finalized instance
-   */
+  /** {@inheritDoc} */
   protected StepInterpolator doCopy() {
     return new DormandPrince54StepInterpolator(this);
   }
 
 
-  /** Reinitialize the instance
-   * @param equations set of differential equations being integrated
-   * @param y reference to the integrator array holding the state at
-   * the end of the step
-   * @param yDotK reference to the integrator array holding all the
-   * intermediate slopes
-   * @param forward integration direction indicator
-   */
-  public void reinitialize(FirstOrderDifferentialEquations equations,
-                           double[] y, double[][] yDotK, boolean forward) {
+  /** {@inheritDoc} */
+  public void reinitialize(final FirstOrderDifferentialEquations equations,
+                           final double[] y, final double[][] yDotK, final boolean forward) {
     super.reinitialize(equations, y, yDotK, forward);
     v1 = null;
     v2 = null;
@@ -103,24 +98,15 @@
     vectorsInitialized = false;
   }
 
-  /** Store the current step time.
-   * @param t current time
-   */
-  public void storeTime(double t) {
+  /** {@inheritDoc} */
+  public void storeTime(final double t) {
     super.storeTime(t);
     vectorsInitialized = false;
   }
 
-  /** Compute the state at the interpolated time.
-   * @param theta normalized interpolation abscissa within the step
-   * (theta is zero at the previous time step and one at the current time step)
-   * @param oneMinusThetaH time gap between the interpolated time and
-   * the current time
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
-  protected void computeInterpolatedState(double theta,
-                                          double oneMinusThetaH)
+  /** {@inheritDoc} */
+  protected void computeInterpolatedState(final double theta,
+                                          final double oneMinusThetaH)
     throws DerivativeException {
 
     if (! vectorsInitialized) {
@@ -149,7 +135,7 @@
     }
 
     // interpolate
-    double eta = oneMinusThetaH / h;
+    final double eta = oneMinusThetaH / h;
     for (int i = 0; i < interpolatedState.length; ++i) {
       interpolatedState[i] = currentState[i] -
           eta * (v1[i] - theta * (v2[i] + theta * (v3[i] + eta * v4[i])));

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince54StepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853Integrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853Integrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853Integrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
 /**
  * This class implements the 8(5,3) Dormand-Prince integrator for Ordinary
@@ -213,9 +213,9 @@
    * @param scalAbsoluteTolerance allowed absolute error
    * @param scalRelativeTolerance allowed relative error
    */
-  public DormandPrince853Integrator(double minStep, double maxStep,
-                                    double scalAbsoluteTolerance,
-                                    double scalRelativeTolerance) {
+  public DormandPrince853Integrator(final double minStep, final double maxStep,
+                                    final double scalAbsoluteTolerance,
+                                    final double scalRelativeTolerance) {
     super(true, staticC, staticA, staticB,
           new DormandPrince853StepInterpolator(),
           minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
@@ -230,58 +230,48 @@
    * @param vecAbsoluteTolerance allowed absolute error
    * @param vecRelativeTolerance allowed relative error
    */
-  public DormandPrince853Integrator(double minStep, double maxStep,
-                                    double[] vecAbsoluteTolerance,
-                                    double[] vecRelativeTolerance) {
+  public DormandPrince853Integrator(final double minStep, final double maxStep,
+                                    final double[] vecAbsoluteTolerance,
+                                    final double[] vecRelativeTolerance) {
     super(true, staticC, staticA, staticB,
           new DormandPrince853StepInterpolator(),
           minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public String getName() {
     return methodName;
   }
 
-  /** Get the order of the method.
-   * @return order of the method
-   */
+  /** {@inheritDoc} */
   public int getOrder() {
     return 8;
   }
 
-  /** Compute the error ratio.
-   * @param yDotK derivatives computed during the first stages
-   * @param y0 estimate of the step at the start of the step
-   * @param y1 estimate of the step at the end of the step
-   * @param h  current step
-   * @return error ratio, greater than 1 if step should be rejected
-   */
-  protected double estimateError(double[][] yDotK,
-                                 double[] y0, double[] y1,
-                                 double h) {
+  /** {@inheritDoc} */
+  protected double estimateError(final double[][] yDotK,
+                                 final double[] y0, final double[] y1,
+                                 final double h) {
     double error1 = 0;
     double error2 = 0;
 
     for (int j = 0; j < y0.length; ++j) {
-      double errSum1 = e1_01 * yDotK[0][j]  + e1_06 * yDotK[5][j] +
-                       e1_07 * yDotK[6][j]  + e1_08 * yDotK[7][j] +
-                       e1_09 * yDotK[8][j]  + e1_10 * yDotK[9][j] +
-                       e1_11 * yDotK[10][j] + e1_12 * yDotK[11][j];
-      double errSum2 = e2_01 * yDotK[0][j]  + e2_06 * yDotK[5][j] +
-                       e2_07 * yDotK[6][j]  + e2_08 * yDotK[7][j] +
-                       e2_09 * yDotK[8][j]  + e2_10 * yDotK[9][j] +
-                       e2_11 * yDotK[10][j] + e2_12 * yDotK[11][j];
-
-      double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
-      double tol = (vecAbsoluteTolerance == null) ?
-                   (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
-                   (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
-      double ratio1  = errSum1 / tol;
+      final double errSum1 = e1_01 * yDotK[0][j]  + e1_06 * yDotK[5][j] +
+                             e1_07 * yDotK[6][j]  + e1_08 * yDotK[7][j] +
+                             e1_09 * yDotK[8][j]  + e1_10 * yDotK[9][j] +
+                             e1_11 * yDotK[10][j] + e1_12 * yDotK[11][j];
+      final double errSum2 = e2_01 * yDotK[0][j]  + e2_06 * yDotK[5][j] +
+                             e2_07 * yDotK[6][j]  + e2_08 * yDotK[7][j] +
+                             e2_09 * yDotK[8][j]  + e2_10 * yDotK[9][j] +
+                             e2_11 * yDotK[10][j] + e2_12 * yDotK[11][j];
+
+      final double yScale = Math.max(Math.abs(y0[j]), Math.abs(y1[j]));
+      final double tol = (vecAbsoluteTolerance == null) ?
+                         (scalAbsoluteTolerance + scalRelativeTolerance * yScale) :
+                         (vecAbsoluteTolerance[j] + vecRelativeTolerance[j] * yScale);
+      final double ratio1  = errSum1 / tol;
       error1        += ratio1 * ratio1;
-      double ratio2  = errSum2 / tol;
+      final double ratio2  = errSum2 / tol;
       error2        += ratio2 * ratio2;
     }
 

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853Integrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853StepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853StepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/DormandPrince853StepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,11 +15,15 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
-import java.io.ObjectOutput;
-import java.io.ObjectInput;
 import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
  * This class represents an interpolator over the last step during an
@@ -55,7 +59,7 @@
    * copy: its arrays are separated from the original arrays of the
    * instance
    */
-  public DormandPrince853StepInterpolator(DormandPrince853StepInterpolator interpolator) {
+  public DormandPrince853StepInterpolator(final DormandPrince853StepInterpolator interpolator) {
 
     super(interpolator);
 
@@ -67,7 +71,7 @@
 
     } else {
 
-      int dimension = interpolator.currentState.length;
+      final int dimension = interpolator.currentState.length;
 
       yDotKLast    = new double[3][];
       for (int k = 0; k < yDotKLast.length; ++k) {
@@ -88,40 +92,18 @@
 
   }
 
-  /** Really copy the finalized instance.
-   * @return a copy of the finalized instance
-   */
+  /** {@inheritDoc} */
   protected StepInterpolator doCopy() {
     return new DormandPrince853StepInterpolator(this);
   }
 
-  /** Reinitialize the instance
-   * Some embedded Runge-Kutta integrators need fewer functions
-   * evaluations than their counterpart step interpolators. So the
-   * interpolator should perform the last evaluations they need by
-   * themselves. The {@link EmbeddedRungeKuttaIntegrator
-   * EmbeddedRungeKuttaIntegrator} abstract class calls this method in
-   * order to let the step interpolator perform the evaluations it
-   * needs. These evaluations will be performed during the call to
-   * <code>doFinalize</code> if any, i.e. only if the step handler
-   * either calls the {@link AbstractStepInterpolator#finalizeStep
-   * finalizeStep} method or the {@link
-   * AbstractStepInterpolator#getInterpolatedState getInterpolatedState}
-   * method (for an interpolator which needs a finalization) or if it clones
-   * the step interpolator.
-   * @param equations set of differential equations being integrated
-   * @param y reference to the integrator array holding the state at
-   * the end of the step
-   * @param yDotK reference to the integrator array holding all the
-   * intermediate slopes
-   * @param forward integration direction indicator
-   */
-  public void reinitialize(FirstOrderDifferentialEquations equations,
-                           double[] y, double[][] yDotK, boolean forward) {
+  /** {@inheritDoc} */
+  public void reinitialize(final FirstOrderDifferentialEquations equations,
+                           final double[] y, final double[][] yDotK, final boolean forward) {
 
     super.reinitialize(equations, y, yDotK, forward);
 
-    int dimension = currentState.length;
+    final int dimension = currentState.length;
 
     yDotKLast = new double[3][];
     for (int k = 0; k < yDotKLast.length; ++k) {
@@ -137,26 +119,15 @@
 
   }
 
-  /** Store the current step time.
-   * @param t current time
-   */
-  public void storeTime(double t) {
+  /** {@inheritDoc} */
+  public void storeTime(final double t) {
     super.storeTime(t);
     vectorsInitialized = false;
   }
 
-  /** Compute the state at the interpolated time.
-   * This is the main processing method that should be implemented by
-   * the derived classes to perform the interpolation.
-   * @param theta normalized interpolation abscissa within the step
-   * (theta is zero at the previous time step and one at the current time step)
-   * @param oneMinusThetaH time gap between the interpolated time and
-   * the current time
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
-  protected void computeInterpolatedState(double theta,
-                                          double oneMinusThetaH)
+  /** {@inheritDoc} */
+  protected void computeInterpolatedState(final double theta,
+                                          final double oneMinusThetaH)
     throws DerivativeException {
 
     if (! vectorsInitialized) {
@@ -192,7 +163,7 @@
 
     }
 
-    double eta = oneMinusThetaH / h;
+    final double eta = oneMinusThetaH / h;
 
     for (int i = 0; i < interpolatedState.length; ++i) {
       interpolatedState[i] =
@@ -203,12 +174,7 @@
 
   }
  
-  /**
-   * Really finalize the step.
-   * Perform the last 3 functions evaluations (k14, k15, k16)
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
+  /** {@inheritDoc} */
   protected void doFinalize()
     throws DerivativeException {
 
@@ -218,7 +184,7 @@
     }
 
     double s;
-    double[] yTmp = new double[currentState.length];
+    final double[] yTmp = new double[currentState.length];
 
     // k14
     for (int j = 0; j < currentState.length; ++j) {
@@ -251,11 +217,8 @@
 
   }
 
-  /** Save the state of the instance.
-   * @param out stream where to save the state
-   * @exception IOException in case of write error
-   */
-  public void writeExternal(ObjectOutput out)
+  /** {@inheritDoc} */
+  public void writeExternal(final ObjectOutput out)
     throws IOException {
 
     try {
@@ -276,16 +239,13 @@
 
   }
 
-  /** Read the state of the instance.
-   * @param in stream where to read the state from
-   * @exception IOException in case of read error
-   */
-  public void readExternal(ObjectInput in)
+  /** {@inheritDoc} */
+  public void readExternal(final ObjectInput in)
     throws IOException {
 
     // read the local attributes
     yDotKLast = new double[3][];
-    int dimension = in.readInt();
+    final int dimension = in.readInt();
     yDotKLast[0] = new double[dimension];
     yDotKLast[1] = new double[dimension];
     yDotKLast[2] = new double[dimension];

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EmbeddedRungeKuttaIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EmbeddedRungeKuttaIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EmbeddedRungeKuttaIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,14 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.AdaptiveStepsizeIntegrator;
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.FirstOrderDifferentialEquations;
+import org.apache.commons.math.ode.IntegratorException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.DummyStepInterpolator;
 
 /**
  * This class implements the common part of all embedded Runge-Kutta
@@ -70,12 +77,12 @@
    * @param scalAbsoluteTolerance allowed absolute error
    * @param scalRelativeTolerance allowed relative error
    */
-  protected EmbeddedRungeKuttaIntegrator(boolean fsal,
-                                         double[] c, double[][] a, double[] b,
-                                         RungeKuttaStepInterpolator prototype,
-                                         double minStep, double maxStep,
-                                         double scalAbsoluteTolerance,
-                                         double scalRelativeTolerance) {
+  protected EmbeddedRungeKuttaIntegrator(final boolean fsal,
+                                         final double[] c, final double[][] a, final double[] b,
+                                         final RungeKuttaStepInterpolator prototype,
+                                         final double minStep, final double maxStep,
+                                         final double scalAbsoluteTolerance,
+                                         final double scalRelativeTolerance) {
 
     super(minStep, maxStep, scalAbsoluteTolerance, scalRelativeTolerance);
 
@@ -107,12 +114,12 @@
    * @param vecAbsoluteTolerance allowed absolute error
    * @param vecRelativeTolerance allowed relative error
    */
-  protected EmbeddedRungeKuttaIntegrator(boolean fsal,
-                                         double[] c, double[][] a, double[] b,
-                                         RungeKuttaStepInterpolator prototype,
-                                         double   minStep, double maxStep,
-                                         double[] vecAbsoluteTolerance,
-                                         double[] vecRelativeTolerance) {
+  protected EmbeddedRungeKuttaIntegrator(final boolean fsal,
+                                         final double[] c, final double[][] a, final double[] b,
+                                         final RungeKuttaStepInterpolator prototype,
+                                         final double   minStep, final double maxStep,
+                                         final double[] vecAbsoluteTolerance,
+                                         final double[] vecRelativeTolerance) {
 
     super(minStep, maxStep, vecAbsoluteTolerance, vecRelativeTolerance);
 
@@ -131,9 +138,7 @@
 
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public abstract String getName();
 
   /** Get the order of the method.
@@ -151,49 +156,34 @@
   /** Set the safety factor for stepsize control.
    * @param safety safety factor
    */
-  public void setSafety(double safety) {
+  public void setSafety(final double safety) {
     this.safety = safety;
   }
 
-  /** Integrate the differential equations up to the given time.
-   * <p>This method solves an Initial Value Problem (IVP).</p>
-   * <p>Since this method stores some internal state variables made
-   * available in its public interface during integration ({@link
-   * #getCurrentSignedStepsize()}), it is <em>not</em> thread-safe.</p>
-   * @param equations differential equations to integrate
-   * @param t0 initial time
-   * @param y0 initial value of the state vector at t0
-   * @param t target time for the integration
-   * (can be set to a value smaller than <code>t0</code> for backward integration)
-   * @param y placeholder where to put the state vector at each successful
-   *  step (and hence at the end of integration), can be the same object as y0
-   * @throws IntegratorException if the integrator cannot perform integration
-   * @throws DerivativeException this exception is propagated to the caller if
-   * the underlying user function triggers one
-   */
-  public void integrate(FirstOrderDifferentialEquations equations,
-                        double t0, double[] y0,
-                        double t, double[] y)
+  /** {@inheritDoc} */
+  public void integrate(final FirstOrderDifferentialEquations equations,
+                        final double t0, final double[] y0,
+                        final double t, final double[] y)
   throws DerivativeException, IntegratorException {
 
     sanityChecks(equations, t0, y0, t, y);
-    boolean forward = (t > t0);
+    final boolean forward = (t > t0);
 
     // create some internal working arrays
-    int stages = c.length + 1;
+    final int stages = c.length + 1;
     if (y != y0) {
       System.arraycopy(y0, 0, y, 0, y0.length);
     }
-    double[][] yDotK = new double[stages][];
+    final double[][] yDotK = new double[stages][];
     for (int i = 0; i < stages; ++i) {
       yDotK [i] = new double[y0.length];
     }
-    double[] yTmp = new double[y0.length];
+    final double[] yTmp = new double[y0.length];
 
     // set up an interpolator sharing the integrator arrays
     AbstractStepInterpolator interpolator;
-    if (handler.requiresDenseOutput() || (! switchesHandler.isEmpty())) {
-      RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
+    if (handler.requiresDenseOutput() || (! eventsHandlersManager.isEmpty())) {
+      final RungeKuttaStepInterpolator rki = (RungeKuttaStepInterpolator) prototype.copy();
       rki.reinitialize(equations, yTmp, yDotK, forward);
       interpolator = rki;
     } else {
@@ -219,7 +209,7 @@
         }
 
         if (firstTime) {
-          double[] scale;
+          final double[] scale;
           if (vecAbsoluteTolerance != null) {
             scale = vecAbsoluteTolerance;
           } else {
@@ -269,11 +259,11 @@
         error = estimateError(yDotK, y, yTmp, stepSize);
         if (error <= 1.0) {
 
-          // Switching functions handling
+          // Discrete events handling
           interpolator.storeTime(stepStart + stepSize);
-          if (switchesHandler.evaluateStep(interpolator)) {
+          if (eventsHandlersManager.evaluateStep(interpolator)) {
             // reject the step to match exactly the next switch time
-            hNew = switchesHandler.getEventTime() - stepStart;
+            hNew = eventsHandlersManager.getEventTime() - stepStart;
           } else {
             // accept the step
             loop = false;
@@ -281,19 +271,19 @@
 
         } else {
           // reject the step and attempt to reduce error by stepsize control
-          double factor = Math.min(maxGrowth,
-                                   Math.max(minReduction,
-                                            safety * Math.pow(error, exp)));
+          final double factor =
+              Math.min(maxGrowth,
+                       Math.max(minReduction, safety * Math.pow(error, exp)));
           hNew = filterStep(stepSize * factor, false);
         }
 
       }
 
       // the step has been accepted
-      double nextStep = stepStart + stepSize;
+      final double nextStep = stepStart + stepSize;
       System.arraycopy(yTmp, 0, y, 0, y0.length);
-      switchesHandler.stepAccepted(nextStep, y);
-      if (switchesHandler.stop()) {
+      eventsHandlersManager.stepAccepted(nextStep, y);
+      if (eventsHandlersManager.stop()) {
         lastStep = true;
       } else {
         lastStep = forward ? (nextStep >= t) : (nextStep <= t);
@@ -309,20 +299,20 @@
         System.arraycopy(yDotK[stages - 1], 0, yDotK[0], 0, y0.length);
       }
 
-      if (switchesHandler.reset(stepStart, y) && ! lastStep) {
-        // some switching function has triggered changes that
+      if (eventsHandlersManager.reset(stepStart, y) && ! lastStep) {
+        // some event handler has triggered changes that
         // invalidate the derivatives, we need to recompute them
         equations.computeDerivatives(stepStart, y, yDotK[0]);
       }
 
       if (! lastStep) {
         // stepsize control for next step
-        double  factor     = Math.min(maxGrowth,
-                                      Math.max(minReduction,
-                                               safety * Math.pow(error, exp)));
-        double  scaledH    = stepSize * factor;
-        double  nextT      = stepStart + scaledH;
-        boolean nextIsLast = forward ? (nextT >= t) : (nextT <= t);
+        final double factor = Math.min(maxGrowth,
+                                       Math.max(minReduction,
+                                                safety * Math.pow(error, exp)));
+        final double  scaledH    = stepSize * factor;
+        final double  nextT      = stepStart + scaledH;
+        final boolean nextIsLast = forward ? (nextT >= t) : (nextT <= t);
         hNew = filterStep(scaledH, nextIsLast);
       }
 
@@ -342,7 +332,7 @@
   /** Set the minimal reduction factor for stepsize control.
    * @param minReduction minimal reduction factor
    */
-  public void setMinReduction(double minReduction) {
+  public void setMinReduction(final double minReduction) {
     this.minReduction = minReduction;
   }
 
@@ -356,7 +346,7 @@
   /** Set the maximal growth factor for stepsize control.
    * @param maxGrowth maximal growth factor
    */
-  public void setMaxGrowth(double maxGrowth) {
+  public void setMaxGrowth(final double maxGrowth) {
     this.maxGrowth = maxGrowth;
   }
 

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EmbeddedRungeKuttaIntegrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
 /**
  * This class implements a simple Euler integrator for Ordinary
@@ -71,13 +71,11 @@
    * Build an Euler integrator with the given step.
    * @param step integration step
    */
-  public EulerIntegrator(double step) {
+  public EulerIntegrator(final double step) {
     super(c, a, b, new EulerStepInterpolator(), step);
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public String getName() {
     return methodName;
   }

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerIntegrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/EulerStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
  * This class implements a linear interpolator for step.
@@ -56,30 +60,19 @@
    * copy: its arrays are separated from the original arrays of the
    * instance
    */
-  public EulerStepInterpolator(EulerStepInterpolator interpolator) {
+  public EulerStepInterpolator(final EulerStepInterpolator interpolator) {
     super(interpolator);
   }
 
-  /** Really copy the finalized instance.
-   * @return a copy of the finalized instance
-   */
+  /** {@inheritDoc} */
   protected StepInterpolator doCopy() {
     return new EulerStepInterpolator(this);
   }
 
 
-  /** Compute the state at the interpolated time.
-   * This is the main processing method that should be implemented by
-   * the derived classes to perform the interpolation.
-   * @param theta normalized interpolation abscissa within the step
-   * (theta is zero at the previous time step and one at the current time step)
-   * @param oneMinusThetaH time gap between the interpolated time and
-   * the current time
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
-  protected void computeInterpolatedState(double theta,
-                                          double oneMinusThetaH)
+  /** {@inheritDoc} */
+  protected void computeInterpolatedState(final double theta,
+                                          final double oneMinusThetaH)
     throws DerivativeException {
 
     for (int i = 0; i < interpolatedState.length; ++i) {

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/EulerStepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillIntegrator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillIntegrator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillIntegrator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
 
 /**
  * This class implements the Gill fourth order Runge-Kutta
@@ -71,13 +71,11 @@
    * Build a fourth-order Gill integrator with the given step.
    * @param step integration step
    */
-  public GillIntegrator(double step) {
+  public GillIntegrator(final double step) {
     super(c, a, b, new GillStepInterpolator(), step);
   }
 
-  /** Get the name of the method.
-   * @return name of the method
-   */
+  /** {@inheritDoc} */
   public String getName() {
     return methodName;
   }

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillIntegrator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Copied: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java (from r669847, commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillStepInterpolator.java)
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java?p2=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java&p1=commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillStepInterpolator.java&r1=669847&r2=670469&rev=670469&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/GillStepInterpolator.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java Mon Jun 23 01:01:38 2008
@@ -15,7 +15,11 @@
  * limitations under the License.
  */
 
-package org.apache.commons.math.ode;
+package org.apache.commons.math.ode.nonstiff;
+
+import org.apache.commons.math.ode.DerivativeException;
+import org.apache.commons.math.ode.sampling.AbstractStepInterpolator;
+import org.apache.commons.math.ode.sampling.StepInterpolator;
 
 /**
  * This class implements a step interpolator for the Gill fourth
@@ -61,40 +65,29 @@
    * copy: its arrays are separated from the original arrays of the
    * instance
    */
-  public GillStepInterpolator(GillStepInterpolator interpolator) {
+  public GillStepInterpolator(final GillStepInterpolator interpolator) {
     super(interpolator);
   }
 
-  /** Really copy the finalized instance.
-   * @return a copy of the finalized instance
-   */
+  /** {@inheritDoc} */
   protected StepInterpolator doCopy() {
     return new GillStepInterpolator(this);
   }
 
 
-  /** Compute the state at the interpolated time.
-   * This is the main processing method that should be implemented by
-   * the derived classes to perform the interpolation.
-   * @param theta normalized interpolation abscissa within the step
-   * (theta is zero at the previous time step and one at the current time step)
-   * @param oneMinusThetaH time gap between the interpolated time and
-   * the current time
-   * @throws DerivativeException this exception is propagated to the caller if the
-   * underlying user function triggers one
-   */
-  protected void computeInterpolatedState(double theta,
-                                          double oneMinusThetaH)
+  /** {@inheritDoc} */
+  protected void computeInterpolatedState(final double theta,
+                                          final double oneMinusThetaH)
     throws DerivativeException {
 
-    double fourTheta = 4 * theta;
-    double s         = oneMinusThetaH / 6.0;
-    double soMt      = s * (1 - theta);
-    double c23       = soMt * (1 + 2 * theta);
-    double coeff1    = soMt * (1 - fourTheta);
-    double coeff2    = c23  * tMq;
-    double coeff3    = c23  * tPq;
-    double coeff4    = s * (1 + theta * (1 + fourTheta));
+    final double fourTheta = 4 * theta;
+    final double s         = oneMinusThetaH / 6.0;
+    final double soMt      = s * (1 - theta);
+    final double c23       = soMt * (1 + 2 * theta);
+    final double coeff1    = soMt * (1 - fourTheta);
+    final double coeff2    = c23  * tMq;
+    final double coeff3    = c23  * tPq;
+    final double coeff4    = s * (1 + theta * (1 + fourTheta));
 
     for (int i = 0; i < interpolatedState.length; ++i) {
       interpolatedState[i] = currentState[i] -

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GillStepInterpolator.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message