Skip to content

Commit

Permalink
var: 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 d856d49 commit f719d42
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions inst/shadow/var.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@
if (! (isvector (vecdim) && all (vecdim)) || any (rem (vecdim, 1)))
error ("var: DIM must be a positive integer scalar or vector");
endif
if (! isequal (vecdim, unique (vecdim, "stable")))
error ("var: VECDIM must contain non-repeating positive integers");
endif
if (any (vecdim > ndims (x)))
error ("var: VECDIM contains invalid dimensions");
endif
Expand Down Expand Up @@ -418,6 +421,8 @@
%!error <var: DIM must be a positive integer> var (1, [], ones (2,2))
%!error <var: DIM must be a positive integer> var (1, 0, 1.5)
%!error <var: DIM must be a positive integer> var (1, [], 0)
%!error <var: VECDIM must contain non-repeating positive integers> ...
%! var (repmat ([1:20;6:25], [5 2 6 3]), 0, [1 2 2 2])
%!error <var: VECDIM contains invalid dimensions> ...
%! var (repmat ([1:20;6:25], [5 2 6 3]), 0, [1 2 5 6])
%!error <var: VECDIM contains invalid dimensions> var ([1 2 3], 0, [1 3])
Expand Down

0 comments on commit f719d42

Please sign in to comment.