[Pomp-commits] r589 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 11 13:28:38 CET 2012


Author: kingaa
Date: 2012-01-11 13:28:38 +0100 (Wed, 11 Jan 2012)
New Revision: 589

Modified:
   pkg/src/euler.c
Log:
- bug fix: inappropriate choice of number of steps in some circumstances


Modified: pkg/src/euler.c
===================================================================
--- pkg/src/euler.c	2012-01-10 07:41:25 UTC (rev 588)
+++ pkg/src/euler.c	2012-01-11 12:28:38 UTC (rev 589)
@@ -32,12 +32,8 @@
   double tol = sqrt(DOUBLE_EPS);
   int nstep;
   // nstep will be the number of discrete-time steps to take in going from t1 to t2.
-  if (t1+dt > t2) {
-    nstep = 0;
-  } else {
-    nstep = (int) ceil((t2-t1)/dt/(1+tol));
-  }
-  return nstep;
+  nstep = (int) floor((t2-t1)/dt/(1-tol));
+  return (nstep > 0) ? nstep : 0;
 }
 
 // take Euler-Poisson steps of size at most deltat from t1 to t2



More information about the pomp-commits mailing list