From 60f99d976da2bf63732543348c443f9d0d010c01 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sun, 10 Jul 2011 16:51:02 +0000 Subject: [PATCH] Prevent step normalizer to output twice the last point in MULTIPLES mode. JIRA: MATH-603 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1144902 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/math/ode/sampling/StepNormalizer.java | 6 ++++++ src/site/xdoc/changes.xml | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java b/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java index 1f65fa0d2..b4cbd9216 100644 --- a/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java +++ b/src/main/java/org/apache/commons/math/ode/sampling/StepNormalizer.java @@ -22,6 +22,7 @@ import org.apache.commons.math.ode.sampling.FixedStepHandler; import org.apache.commons.math.ode.sampling.StepHandler; import org.apache.commons.math.ode.sampling.StepInterpolator; import org.apache.commons.math.util.FastMath; +import org.apache.commons.math.util.MathUtils; /** * This class wraps an object implementing {@link FixedStepHandler} @@ -213,9 +214,14 @@ public class StepNormalizer implements StepHandler { } } + // Calculate next normalized step time. double nextTime = (mode == StepNormalizerMode.INCREMENT) ? lastTime + h : (FastMath.floor(lastTime / h) + 1) * h; + if (mode == StepNormalizerMode.MULTIPLES && + MathUtils.equals(nextTime, lastTime, 1)) { + nextTime += h; + } boolean nextInStep = isNextInStep(nextTime, interpolator); while (nextInStep) { // Output the stored previous step. diff --git a/src/site/xdoc/changes.xml b/src/site/xdoc/changes.xml index bc6030c11..d1f01770b 100644 --- a/src/site/xdoc/changes.xml +++ b/src/site/xdoc/changes.xml @@ -52,12 +52,15 @@ The type attribute can be add,update,fix,remove. If the output is not quite correct, check for invisible trailing spaces! --> + + Prevent step normalizer to output twice the last point in MULTIPLES mode. + Removed the requiresDenseOutput method from the StepHandler interface. Now integrators always consider dense output is required and set up the appropriate state interpolators, so step handlers can rely on them. - + Modified "SecantSolver" to comply with the original algorithm. Added several secant-based solvers. Added a way to select the side of the root with bracketing solvers.