diff scripts/ode/ode45.m @ 22655:6b134d294d61 stable

ode solvers: use ordinary transpose instead of Hermitian conjugate (bug #49410). * ode23.m, ode45.m, ode_event_handler.m, runge_kutta_interpolate.m: Use ordinary transpose instead of Hermitian conjugate.
author Carlo de Falco <carlo.defalco@polimi.it>
date Sat, 22 Oct 2016 22:11:42 +0200
parents bc61ed076549
children 56d7d423aff9
line wrap: on
line diff
--- a/scripts/ode/ode45.m	Fri Oct 21 14:36:38 2016 -0700
+++ b/scripts/ode/ode45.m	Sat Oct 22 22:11:42 2016 +0200
@@ -224,7 +224,7 @@
   endif
   if (! isempty (odeopts.Events))   # Cleanup event function handling
     ode_event_handler (odeopts.Events, solution.t(end),
-                       solution.x(end,:)', "done", odeopts.funarguments{:});
+                       solution.x(end,:).', "done", odeopts.funarguments{:});
   endif
 
   ## Print additional information if option Stats is set
@@ -247,8 +247,8 @@
     varargout{1} = solution.t;      # Time stamps are first output argument
     varargout{2} = solution.x;      # Results are second output argument
   elseif (nargout == 1)
-    varargout{1}.x = solution.t';   # Time stamps are saved in field x (row vector)
-    varargout{1}.y = solution.x';   # Results are saved in field y (row vector)
+    varargout{1}.x = solution.t.';   # Time stamps are saved in field x (row vector)
+    varargout{1}.y = solution.x.';   # Results are saved in field y (row vector)
     varargout{1}.solver = solver;   # Solver name is saved in field solver
     if (! isempty (odeopts.Events))
       varargout{1}.ie = solution.event{2};  # Index info which event occurred
@@ -487,6 +487,12 @@
 ## test for MaxOrder option is missing
 ## test for MvPattern option is missing
 
+%!test # Check that imaginary part of solution does not get inverted
+%! sol = ode45 (@(x,y) 1, [0 1], 1i);
+%! assert (imag (sol.y), ones (size (sol.y)))
+%! [x, y] = ode45 (@(x,y) 1, [0 1], 1i);
+%! assert (imag (y), ones (size (y)))
+
 %!error ode45 ()
 %!error ode45 (1)
 %!error ode45 (1,2)