# HG changeset patch # User Carlo de Falco # Date 1444584027 -7200 # Node ID 43822bda4f6539e0db0c6e7dee0180a1dc894865 # Parent a22d8a2eb0e50e188929b36a793599f15ffe6d40 fix indexing bug introduced with a22d8a2eb0e5 * scripts/ode/private/integrate_adaptive.m: add offset to indices into tspan. diff -r a22d8a2eb0e5 -r 43822bda4f65 scripts/ode/private/integrate_adaptive.m --- a/scripts/ode/private/integrate_adaptive.m Sun Oct 11 18:44:58 2015 +0200 +++ b/scripts/ode/private/integrate_adaptive.m Sun Oct 11 19:20:27 2015 +0200 @@ -140,11 +140,15 @@ t_caught = find ((tspan(iout:end) > t_old) & (tspan(iout:end) <= t_new)); + t_caught = t_caught + iout - 1; + if (! isempty (t_caught)) t(t_caught) = tspan(t_caught); iout = max (t_caught); - x(:, t_caught) = interpolate ([t_old, t_new], [x_old, x_new], - t(t_caught)); + x(:, t_caught) = ... + ode_rk_interpolate (order, [t_old t_new], [x_old x_new], + tspan(t_caught), new_k_vals, dt, + options.vfunarguments{:}); istep++; @@ -274,8 +278,8 @@ ## Check if integration of the ode has been successful if (dir * t(end) < dir * tspan(end)) if (solution.vunhandledtermination == true) - error ("integrate_adaptive: InvalidArgument", - ["Solving has not been successful. The iterative", + error ("integrate_adaptive:unexpected_termination", + [" Solving has not been successful. The iterative", " integration loop exited at time t = %f", " before endpoint at tend = %f was reached. This may", " happen if the stepsize grows too small. ", @@ -283,7 +287,7 @@ " and/or 'MaxStep' with the command 'odeset'.\n"], t(end), tspan(end)); else - warning ("integrate_adaptive: InvalidArgument", + warning ("integrate_adaptive:unexpected_termination", ["Solver has been stopped by a call of 'break' in the main", " iteration loop at time t = %f before endpoint at tend = %f ", " was reached. This may happen because the @odeplot function", @@ -293,8 +297,8 @@ endif endif - ## Remove not-requested values of time and solution - solution.t = t; + ## Set up return structure + solution.t = t(:); solution.x = x.'; endfunction