Mercurial > octave-nkf
comparison scripts/set/private/validsetargs.m @ 19734:00e31f316a3a
Fix Matlab incompatibility of "ismatrix" (bug #42422).
* data.cc (isvector): new tests
* data.cc (isrow): documentation improved, new tests
* data.cc (iscolumn): documentation improved, new tests
* data.cc (ismatrix): is matrix now only checks the dimension due to Matlab
compatibility, documentation improved, new tests
* accumarray.m: use more appropriate function, than ismatrix
* gradient.m: use more appropriate function, than ismatrix
* num2str.m: use more appropriate functions, than ismatrix
* ntsc2rgb.m: use more appropriate function, than ismatrix
* condest.m: use more appropriate function, than ismatrix
* expm.m: use more appropriate function, than ismatrix
* onenormest.m: use more appropriate function, than ismatrix
* isocolors.m: use more appropriate function, than ismatrix
* isonormals.m: use more appropriate function, than ismatrix
* isosurface.m: use more appropriate function, than ismatrix
* __errcomm__.m: use more appropriate function, than ismatrix
* __interp_cube__.m: use more appropriate function, than ismatrix
* __marching_cube__.m: use more appropriate function, than ismatrix
* __stem__.m: use more appropriate function, than ismatrix
* stairs.m: use more appropriate function, than ismatrix
* validsetargs.m: use more appropriate functions, than ismatrix
* unique.m: use more appropriate functions, than ismatrix
* bicg.m: additional tests for numerical value
* bicgstab.m: additional tests for numerical value
* cgs.m: additional tests for numerical value
* gmres.m: additional tests for numerical value
* qmr.m: additional tests for numerical value
author | Kai T. Ohlhus <k.ohlhus@gmail.com> |
---|---|
date | Thu, 12 Feb 2015 18:34:56 +0100 |
parents | 4197fc428c7d |
children | e59a44fa74ff |
comparison
equal
deleted
inserted
replaced
19733:2e9f17872f36 | 19734:00e31f316a3a |
---|---|
19 | 19 |
20 ## Validate arguments for binary set operation. | 20 ## Validate arguments for binary set operation. |
21 | 21 |
22 function [x, y] = validsetargs (caller, x, y, byrows_arg) | 22 function [x, y] = validsetargs (caller, x, y, byrows_arg) |
23 | 23 |
24 isallowedarraytype = @(x) isnumeric (x) || ischar (x) || islogical (x); | |
25 | |
24 if (nargin == 3) | 26 if (nargin == 3) |
25 icx = iscellstr (x); | 27 icx = iscellstr (x); |
26 icy = iscellstr (y); | 28 icy = iscellstr (y); |
27 if (icx || icy) | 29 if (icx || icy) |
28 if (icx && ischar (y)) | 30 if (icx && ischar (y)) |
30 elseif (icy && ischar (x)) | 32 elseif (icy && ischar (x)) |
31 x = cellstr (x); | 33 x = cellstr (x); |
32 elseif (! (icx && icy)) | 34 elseif (! (icx && icy)) |
33 error ("%s: cell array of strings cannot be combined with a nonstring value", caller); | 35 error ("%s: cell array of strings cannot be combined with a nonstring value", caller); |
34 endif | 36 endif |
35 elseif (! (ismatrix (x) && ismatrix (y))) | 37 elseif (! (isallowedarraytype (x) && isallowedarraytype (y))) |
36 error ("%s: A and B must be arrays or cell arrays of strings", caller); | 38 error ("%s: A and B must be arrays or cell arrays of strings", caller); |
37 endif | 39 endif |
38 elseif (nargin == 4) | 40 elseif (nargin == 4) |
39 if (! strcmpi (byrows_arg, "rows")) | 41 if (! strcmpi (byrows_arg, "rows")) |
40 error ("%s: invalid option: %s", caller, byrows_arg); | 42 error ("%s: invalid option: %s", caller, byrows_arg); |
41 endif | 43 endif |
42 | 44 |
43 if (iscell (x) || iscell (y)) | 45 if (iscell (x) || iscell (y)) |
44 error ('%s: cells not supported with "rows"', caller); | 46 error ('%s: cells not supported with "rows"', caller); |
45 elseif (! (ismatrix (x) && ismatrix (y))) | 47 elseif (! (isallowedarraytype (x) && isallowedarraytype (y))) |
46 error ("%s: A and B must be arrays or cell arrays of strings", caller); | 48 error ("%s: A and B must be arrays or cell arrays of strings", caller); |
47 else | 49 else |
48 if (ndims (x) > 2 || ndims (y) > 2) | 50 if (ndims (x) > 2 || ndims (y) > 2) |
49 error ('%s: A and B must be 2-dimensional matrices for "rows"', caller); | 51 error ('%s: A and B must be 2-dimensional matrices for "rows"', caller); |
50 elseif (columns (x) != columns (y) && ! (isempty (x) || isempty (y))) | 52 elseif (columns (x) != columns (y) && ! (isempty (x) || isempty (y))) |