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
This commit is contained in:
Luc Maisonobe 2011-07-10 16:51:02 +00:00
parent 4b299469ed
commit 60f99d976d
2 changed files with 10 additions and 1 deletions

View File

@ -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.StepHandler;
import org.apache.commons.math.ode.sampling.StepInterpolator; import org.apache.commons.math.ode.sampling.StepInterpolator;
import org.apache.commons.math.util.FastMath; import org.apache.commons.math.util.FastMath;
import org.apache.commons.math.util.MathUtils;
/** /**
* This class wraps an object implementing {@link FixedStepHandler} * 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) ? double nextTime = (mode == StepNormalizerMode.INCREMENT) ?
lastTime + h : lastTime + h :
(FastMath.floor(lastTime / h) + 1) * h; (FastMath.floor(lastTime / h) + 1) * h;
if (mode == StepNormalizerMode.MULTIPLES &&
MathUtils.equals(nextTime, lastTime, 1)) {
nextTime += h;
}
boolean nextInStep = isNextInStep(nextTime, interpolator); boolean nextInStep = isNextInStep(nextTime, interpolator);
while (nextInStep) { while (nextInStep) {
// Output the stored previous step. // Output the stored previous step.

View File

@ -52,12 +52,15 @@ The <action> type attribute can be add,update,fix,remove.
If the output is not quite correct, check for invisible trailing spaces! If the output is not quite correct, check for invisible trailing spaces!
--> -->
<release version="3.0" date="TBD" description="TBD"> <release version="3.0" date="TBD" description="TBD">
<action dev="luc" type="fix" issue="MATH-603" due-to="Dennis Hendriks">
Prevent step normalizer to output twice the last point in MULTIPLES mode.
</action>
<action dev="luc" type="fix" issue="MATH-596,MATH-604"> <action dev="luc" type="fix" issue="MATH-596,MATH-604">
Removed the requiresDenseOutput method from the StepHandler interface. Now integrators always 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 consider dense output is required and set up the appropriate state interpolators, so step
handlers can rely on them. handlers can rely on them.
</action> </action>
<action dev="eran" type="add" issue="MATH-599" due-to="Dennis Hendriks"> <action dev="erans" type="add" issue="MATH-599" due-to="Dennis Hendriks">
Modified "SecantSolver" to comply with the original algorithm. Added several 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 secant-based solvers. Added a way to select the side of the root with bracketing
solvers. solvers.