Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 94389 invoked from network); 2 Jun 2009 20:39:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Jun 2009 20:39:55 -0000 Received: (qmail 16282 invoked by uid 500); 2 Jun 2009 20:40:06 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 16208 invoked by uid 500); 2 Jun 2009 20:40:06 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 16199 invoked by uid 99); 2 Jun 2009 20:40:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 20:40:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Jun 2009 20:40:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3D03523888CB; Tue, 2 Jun 2009 20:39:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r781156 - /commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java Date: Tue, 02 Jun 2009 20:39:42 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090602203942.3D03523888CB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: luc Date: Tue Jun 2 20:39:41 2009 New Revision: 781156 URL: http://svn.apache.org/viewvc?rev=781156&view=rev Log: fixed an infinite loop error that occurred when an event that reset the state occurs exactly at multistep initialisation start Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java Modified: commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java?rev=781156&r1=781155&r2=781156&view=diff ============================================================================== --- commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java (original) +++ commons/proper/math/trunk/src/java/org/apache/commons/math/ode/MultistepIntegrator.java Tue Jun 2 20:39:41 2009 @@ -161,9 +161,15 @@ double stopTime = Double.NaN; do { resetTime = Double.NaN; + final double dt = (n - 0.9999) * h; + for (EventHandler handler : starter.getEventHandlers()) { + ((ResetCheckingWrapper) handler).setRange(t, Math.abs(dt)); + } store.restart(); + // we overshoot by 1/10000 step the end to make sure we don't miss the last point - stopTime = starter.integrate(equations, t, y, t + (n - 0.9999) * h, y); + stopTime = starter.integrate(equations, t, y, t + dt, y); + if (!Double.isNaN(resetTime)) { // there was an intermediate reset, we restart t = resetTime; @@ -201,6 +207,12 @@ /** Wrapped event handler. */ private final EventHandler handler; + /** Range start. */ + private double rangeStart; + + /** Range size. */ + private double rangeSize; + /** Build a new instance. * @param handler event handler to wrap */ @@ -208,10 +220,23 @@ this.handler = handler; } + /** Set the range. + * @param rangeStart range start + * @param rangeSize range size + */ + public void setRange(final double rangeStart, final double rangeSize) { + this.rangeStart = rangeStart; + this.rangeSize = rangeSize; + } + /** {@inheritDoc} */ public int eventOccurred(double t, double[] y, boolean increasing) throws EventException { final int action = handler.eventOccurred(t, y, increasing); + if (Math.abs(t - rangeStart) < 1.0e-10 * rangeSize) { + // we have encountered again an already handled reset, don't stop here + return action; + } if ((action == RESET_DERIVATIVES) || (action == RESET_STATE)) { // a singularity has been encountered // we need to restart the start phase