changeset 29039:1aa69571a313

Use 1-based indexing for "ie" variable in ode15i/s (bug #59063). * __ode15__.cc (integrate): Add 1.0 to "ie" variable to change from zero-based to 1-based indexing. * ode15i.m, ode15s.m: Adapt BISTs.
author Rik <rik@octave.org>
date Mon, 07 Sep 2020 20:06:35 -0700
parents bf62eeabf6d1
children 05b8ad7b67e8
files libinterp/dldfcn/__ode15__.cc scripts/ode/ode15i.m scripts/ode/ode15s.m
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/dldfcn/__ode15__.cc	Fri Nov 06 14:38:21 2020 +0100
+++ b/libinterp/dldfcn/__ode15__.cc	Mon Sep 07 20:06:35 2020 -0700
@@ -748,7 +748,8 @@
 
       }
 
-    return ovl (tout, output, te, ye, ie);
+    // Index of Events (ie) variable must use 1-based indexing
+    return ovl (tout, output, te, ye, ie + 1.0);
   }
 
   bool
--- a/scripts/ode/ode15i.m	Fri Nov 06 14:38:21 2020 +0100
+++ b/scripts/ode/ode15i.m	Mon Sep 07 20:06:35 2020 -0700
@@ -504,7 +504,7 @@
 %! opt = odeset ("Events", @ff);
 %! sol = ode15i (@rob, [0, 100], [1; 0; 0], [-1e-4; 1e-4; 0], opt);
 %! assert (isfield (sol, "ie"));
-%! assert (sol.ie, [0;1]);
+%! assert (sol.ie, [1; 2]);
 %! assert (isfield (sol, "xe"));
 %! assert (isfield (sol, "ye"));
 %! assert (sol.x(end), 10, 1);
@@ -514,7 +514,9 @@
 %! opt = odeset ("Events", @ff);
 %! [t, y, te, ye, ie] = ode15i (@rob, [0, 100], [1; 0; 0],
 %!                              [-1e-4; 1e-4; 0], opt);
-%! assert ([t(end), te', ie'], [10, 10, 10, 0, 1], [1, 0.2, 0.2, 0, 0]);
+%! assert (t(end), 10, 1);
+%! assert (te, [10; 10], 0.2);
+%! assert (ie, [1; 2]);
 
 ## Initial solutions as row vectors
 %!testif HAVE_SUNDIALS
--- a/scripts/ode/ode15s.m	Fri Nov 06 14:38:21 2020 +0100
+++ b/scripts/ode/ode15s.m	Mon Sep 07 20:06:35 2020 -0700
@@ -715,7 +715,7 @@
 %!               "MStateDependence", "none");
 %! sol = ode15s (@rob, [0, 100], [1; 0; 0], opt);
 %! assert (isfield (sol, "ie"));
-%! assert (sol.ie, [0;1]);
+%! assert (sol.ie, [1; 2]);
 %! assert (isfield (sol, "xe"));
 %! assert (isfield (sol, "ye"));
 %! assert (sol.x(end), 10, 1);
@@ -725,7 +725,9 @@
 %! opt = odeset ("Events", @feve, "Mass", @massdensefunstate,
 %!               "MStateDependence", "none");
 %! [t, y, te, ye, ie] = ode15s (@rob, [0, 100], [1; 0; 0], opt);
-%! assert ([t(end), te', ie'], [10, 10, 10, 0, 1], [1, 0.5, 0.5, 0, 0]);
+%! assert (t(end), 10, 1);
+%! assert (te, [10; 10], 0.5);
+%! assert (ie, [1; 2]);
 
 ## Initial solution as row vector
 %!testif HAVE_SUNDIALS