Mercurial > octave
changeset 27476:b8b1bf5b2bbf
Reshape N-D arrays to 2-D arrays within rats() (bug #57003).
* pr-output.cc (Frats): Reshape N-D arrays to 2-D arrays before processing.
Add BIST test for bug #57003.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 05 Oct 2019 13:52:40 -0700 |
parents | f429338b9f85 |
children | b470734a025e |
files | libinterp/corefcn/pr-output.cc |
diffstat | 1 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/pr-output.cc Fri Oct 04 20:09:44 2019 -0700 +++ b/libinterp/corefcn/pr-output.cc Sat Oct 05 13:52:40 2019 -0700 @@ -3219,6 +3219,13 @@ if (! arg.isnumeric ()) error ("rats: X must be numeric"); + // Convert to N-D arrays to 2-D arrays for Matlab compatibility + if (arg.ndims () > 2) + { + dim_vector dv (arg.rows (), arg.numel () / arg.rows ()); + arg = arg.reshape (dv); + } + octave::unwind_protect frame; frame.protect_var (rat_string_len); @@ -3277,6 +3284,14 @@ %! format (old_fmt); %! format (old_spacing); %! end_unwind_protect + +%!test <57003> +%! x = ones (2,1,3); +%! s = rats (x,4); +%! assert (ndims (s) == 2); +%! assert (rows (s) == 2); +%! assert (columns (s) == 3); + */ DEFUN (disp, args, nargout,