changeset 22645:34bf558de127 stable

integrate_adaptive.m: Take strcmp call out of for loop for performance. * integrate_adaptive.m: Calculate value of NormControl option just once, rather than in every loop. Fix cuddling of parenthesis to indicate indexing.
author Rik <rik@octave.org>
date Wed, 19 Oct 2016 14:04:47 -0700
parents 23941beb44cd
children 5aa36731a304
files scripts/ode/private/integrate_adaptive.m
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ode/private/integrate_adaptive.m	Wed Oct 19 12:21:27 2016 -0700
+++ b/scripts/ode/private/integrate_adaptive.m	Wed Oct 19 14:04:47 2016 -0700
@@ -116,6 +116,7 @@
   solution.unhandledtermination = true;
   ireject = 0;
 
+  NormControl = strcmp (options.NormControl, "on");
   k_vals = [];
   iout = istep = 1;
 
@@ -133,9 +134,8 @@
       x_est(nn, end) = abs (x_est(nn, end));
     endif
 
-    ## FIXME: Take strcmp out of while loop and calculate just once
     err = AbsRel_norm (x_new, x_old, options.AbsTol, options.RelTol,
-                       strcmp (options.NormControl, "on"), x_est);
+                       NormControl, x_est);
 
     ## Accept solution only if err <= 1.0
     if (err <= 1)
@@ -289,7 +289,7 @@
     err += eps;  # avoid divisions by zero
     dt *= min (facmax, max (facmin, fac * (1 / err)^(1 / (order + 1))));
     dt = dir * min (abs (dt), options.MaxStep);
-    if (! (abs (dt) > eps (t (end))))
+    if (! (abs (dt) > eps (t(end))))
       break;
     endif