Skip to content

Commit

Permalink
std: add input chech for non-repeating positive integers in VECDIM
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0m1th3as committed Dec 15, 2022
1 parent 9f6f4a3 commit d856d49
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions inst/shadow/std.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
if (! (isvector (vecdim) && all (vecdim)) || any (rem (vecdim, 1)))
error ("std: DIM must be a positive integer scalar or vector");
endif
if (! isequal (vecdim, unique (vecdim, "stable")))
error ("std: VECDIM must contain non-repeating positive integers");
endif
if (any (vecdim > ndims (x)))
error ("std: VECDIM contains invalid dimensions");
endif
Expand Down Expand Up @@ -422,6 +425,8 @@
%!error <std: DIM must be a positive integer> std (1, [], ones (2,2))
%!error <std: DIM must be a positive integer> std (1, 0, 1.5)
%!error <std: DIM must be a positive integer> std (1, [], 0)
%!error <std: VECDIM must contain non-repeating positive integers> ...
%! std (repmat ([1:20;6:25], [5 2 6 3]), 0, [1 2 2 2])
%!error <std: VECDIM contains invalid dimensions> ...
%! std (repmat ([1:20;6:25], [5 2 6 3]), 0, [1 2 5 6])
%!error <std: VECDIM contains invalid dimensions> std ([1 2 3], 0, [1 3])
Expand Down

0 comments on commit d856d49

Please sign in to comment.