# HG changeset patch # User Rik # Date 1476911087 25200 # Node ID 34bf558de12711e98baf4b20ac5f7942b4480d0e # Parent 23941beb44cda7ad239682955dbe0cba26eff045 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. diff -r 23941beb44cd -r 34bf558de127 scripts/ode/private/integrate_adaptive.m --- 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