changeset 20815:a260a6acb70f

fix test failures introduced by a22d8a2eb0e5 * scripts/ode/private/integrate_adaptive.m: fix stepping backwards, fix invocation of OutputFcn, fix text of some error messages * scripts/ode/private/integrate_const.m: remove use of option OutputSave * scripts/ode/private/integrate_n_steps.m: remove use of option OutputSave
author Carlo de Falco <carlo.defalco@polimi.it>
date Sun, 11 Oct 2015 23:09:01 +0200
parents d30fc2c11455
children f9c991dc5c1a
files scripts/ode/private/integrate_adaptive.m scripts/ode/private/integrate_const.m scripts/ode/private/integrate_n_steps.m
diffstat 3 files changed, 36 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ode/private/integrate_adaptive.m
+++ b/scripts/ode/private/integrate_adaptive.m
@@ -121,9 +121,8 @@
     solution.vcntcycles++;
 
     if (options.vhavenonnegative)
-      x(nn,end) = abs (x(nn,end));
-      y(nn,end) = abs (y(nn,end));
-      y_est(nn,end) = abs (y_est(nn,end));
+      x_new(nn, end) = abs (x_new(nn, end)); 
+      x_est(nn, end) = abs (x_est(nn, end));
     endif
 
     err = AbsRel_Norm (x_new, x_old, options.AbsTol, options.RelTol,
@@ -138,8 +137,8 @@
       ## if output time steps are fixed
       if (fixed_times)
 
-        t_caught = find ((tspan(iout:end) > t_old)
-                         & (tspan(iout:end) <= t_new));
+        t_caught = find ((dir * tspan(iout:end) > dir * t_old)
+                         & (dir * tspan(iout:end) <= dir * t_new));
         t_caught = t_caught + iout - 1;
 
         if (! isempty (t_caught))
@@ -184,13 +183,16 @@
             vcnt = options.Refine + 1;
             vapproxtime = linspace (t_old, t_new, vcnt);
             vapproxvals = interp1 ([t_old, t(t_caught), t_new],
-                                   [x_old, x(:, t_caught), x_new],
-                                   vapproxtime, 'linear');
+                                   [x_old, x(:, t_caught), x_new] .',
+                                   vapproxtime, 'linear') .';
             if (options.vhaveoutputselection)
-              vapproxvals = vapproxvals(options.OutputSel);
+              vapproxvals = vapproxvals(options.OutputSel, :);
             endif
-            vpltret = feval (options.OutputFcn, vapproxtime,
-                             vapproxvals, [], options.vfunarguments{:});
+            for ii = 1:numel (vapproxtime)
+              vpltret = feval (options.OutputFcn, vapproxtime(ii),
+                               vapproxvals(:, ii), [],
+                               options.vfunarguments{:});
+            endfor
             if (vpltret)  # Leave main loop
               solution.vunhandledtermination = false;
               break;
@@ -226,13 +228,15 @@
           vcnt = options.Refine + 1;
           vapproxtime = linspace (t_old, t_new, vcnt);
           vapproxvals = interp1 ([t_old, t_new],
-                                 [x_old, x_new],
-                                 vapproxtime, 'linear');
+                                 [x_old, x_new] .',
+                                 vapproxtime, 'linear') .';
           if (options.vhaveoutputselection)
-            vapproxvals = vapproxvals(options.OutputSel);
+            vapproxvals = vapproxvals(options.OutputSel, :);
           endif
-          vpltret = feval (options.OutputFcn, vapproxtime,
-                           vapproxvals, [], options.vfunarguments{:});
+          for ii = 1:numel (vapproxtime)
+            vpltret = feval (options.OutputFcn, vapproxtime(ii),
+                             vapproxvals(:, ii), [], options.vfunarguments{:});
+          endfor
           if (vpltret)  # Leave main loop
             solution.vunhandledtermination = false;
             break;
@@ -283,19 +287,20 @@
   if (dir * t(end) < dir * tspan(end))
     if (solution.vunhandledtermination == true)
       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. ",
-              " Try to reduce the value of 'InitialStep'",
+             [" 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. ", ...
+              " Try to reduce the value of 'InitialStep'", ...
               " and/or 'MaxStep' with the command 'odeset'.\n"],
              t(end), tspan(end));
     else
       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",
-                " returned 'true' or the @event function returned",
+               ["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", ...
+                " returned 'true' or the @event function returned", ...
                 " 'true'.\n"],
                t(end), tspan(end));
     endif
--- a/scripts/ode/private/integrate_const.m
+++ b/scripts/ode/private/integrate_const.m
@@ -180,11 +180,10 @@
       endwhile
     endif
 
-    if (mod (solution.vcntloop-1, options.OutputSave) == 0)
-      x = [x,u(:,2:end)];
-      t = [t;z(2:end)];
-      solution.vcntsave = solution.vcntsave + 1;    
-    endif
+
+    x = [x,u(:,2:end)];
+    t = [t;z(2:end)];
+    solution.vcntsave = solution.vcntsave + 1;
     solution.vcntloop = solution.vcntloop + 1;
     vcntiter = 0;
       
--- a/scripts/ode/private/integrate_n_steps.m
+++ b/scripts/ode/private/integrate_n_steps.m
@@ -129,11 +129,9 @@
     z = [t(end);s];
     u = [x(:,end),y];
 
-    if (mod (solution.vcntloop-1, options.OutputSave) == 0)
-      x = [x,u(:,2:end)];
-      t = [t;z(2:end)];
-      solution.vcntsave = solution.vcntsave + 1;    
-    endif
+    x = [x,u(:,2:end)];
+    t = [t;z(2:end)];
+    solution.vcntsave = solution.vcntsave + 1;    
     solution.vcntloop = solution.vcntloop + 1;
     vcntiter = 0;