# HG changeset patch # User Carlo de Falco # Date 1477167102 -7200 # Sat Oct 22 22:11:42 2016 +0200 # Branch stable # Node ID 28fe2cdb71cfe869871b510663953b2160f3b330 # Parent bc61ed076549ed7f085604da347ba8b2621e41b9 ode solvers: use ordinary transpose instead of Hermitian conjugate (bug #49410) * scripts/ode/ode{23,45}.m: use ordinary transpose instead of Hermitian conjugate. * scripts/ode/private/runge_kutta_interpolate.m: use ordinary transpose instead of Hermitian conjugate. diff --git a/scripts/ode/ode23.m b/scripts/ode/ode23.m --- a/scripts/ode/ode23.m +++ b/scripts/ode/ode23.m @@ -233,7 +233,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 @@ -256,8 +256,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 @@ -479,6 +479,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 = ode23 (@(x,y) 1, [0 1], 1i); +%! assert (imag (sol.y), ones (size (sol.y))) +%! [x, y] = ode23 (@(x,y) 1, [0 1], 1i); +%! assert (imag (y), ones (size (y))) + ## Test input validation %!error ode23 () %!error ode23 (1) diff --git a/scripts/ode/ode45.m b/scripts/ode/ode45.m --- a/scripts/ode/ode45.m +++ b/scripts/ode/ode45.m @@ -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) diff --git a/scripts/ode/private/runge_kutta_interpolate.m b/scripts/ode/private/runge_kutta_interpolate.m --- a/scripts/ode/private/runge_kutta_interpolate.m +++ b/scripts/ode/private/runge_kutta_interpolate.m @@ -22,7 +22,7 @@ switch (order) case 1 - u_interp = interp1 (z, u', t, "linear"); + u_interp = interp1 (z, u.', t, "linear"); case 2 if (! isempty (k_vals))