view test/bug-53599.tst @ 31623:59422a6fbd91 stable

mean.m: Accept large DIM inputs and calculate Matlab-compatible output (bug #63411) * mean.m: Accept large DIM inputs by removing any dimensions larger than the dimensions of the input array. Use vectorized operations, rather than for loop, for this input validation. Pre-declare output array before for loop for performance. Use ipermute() after calculations to return correctly-dimensioned result (checked with Matlab). Change BIST tests results to match correct behavior.
author Rik <rik@octave.org>
date Fri, 02 Dec 2022 21:34:15 -0800
parents 332a6ccac881
children
line wrap: on
line source

%!function rval = sggval (val)
%!  global gval;
%!  if (nargin == 1)
%!    gval = val;
%!  else
%!    rval = gval;
%!  endif
%!endfunction

%!test <*53599>
%! global gval;
%! assert (isempty (gval))
%! sggval (13);
%! assert (sggval (), 13);
%! assert (gval, 13);
%! clear global gval
%! assert (sggval (), [])
%! gval = 42;
%! assert (sggval (), []);
%! clear gval
%! global gval;
%! gval = 42;
%! assert (sggval (), 42);
%! clear -global gval;  # cleanup after test