# HG changeset patch # User Rik # Date 1454396383 28800 # Node ID 2935d56203a4c583facaba4622a272b8f4792263 # Parent 8b1e030d3d4f7445db19b519e40d770ac624b77a Fix regressions caused by ismatrix definition change (partial fix bug #47036). * inputdlg.m: Test that linespec isnumeric. * uigetfile.m: Check that position property value isnumeric. * fminunc.m: Check that x0 isnumeric. * fsolve.m: Check that x0 isnumeric. * lsqnonneg.m: Check that inputs C & D are both isnumeric and ismatrix. * pqpnonneg.m: Check that inputs C & D are both isnumeric and ismatrix. * bicg.m: Check input A issquare. Rephrase error messages. * bicgstab.m: Check input A issquare. Rephrase error messages. * cgs.m: Check input A issquare. Rephrase error messages. * gmres.m: Check input A issquare. Rephrase error messages. Change BIST test to match new error message. * qmr.m: Check input A issquare. Rephrase error messages. * spconvert.m: Check nargin first. Simplify input validation. Wrap long error message to < 80 chars. * treeplot.m: Simplify input validation. diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/gui/inputdlg.m --- a/scripts/gui/inputdlg.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/gui/inputdlg.m Mon Feb 01 22:59:43 2016 -0800 @@ -93,6 +93,10 @@ ## r1 1 10 first text field is 1x10 ## r2 2 20 second text field is 2x20 ## r3 3 30 third text field is 3x30 + if (! isnumeric (linespec)) + error ("inputdlg: ROWSCOLS must be numeric"); + endif + if (isscalar (linespec)) ## only scalar value in lineTo, copy from linespec and add defaults rowscols = zeros (numel (prompt), 2); diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/gui/uigetfile.m --- a/scripts/gui/uigetfile.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/gui/uigetfile.m Mon Feb 01 22:59:43 2016 -0800 @@ -157,7 +157,7 @@ prop = varargin{i}; val = varargin{i + 1}; if (strcmpi (prop, "position")) - if (ismatrix (val) && length (val) == 2) + if (isnumeric (val) && length (val) == 2) outargs{4} = val; else error ("uigetfile: expecting 2-element vector for position argument"); diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/optimization/fminunc.m --- a/scripts/optimization/fminunc.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/optimization/fminunc.m Mon Feb 01 22:59:43 2016 -0800 @@ -105,7 +105,7 @@ return; endif - if (nargin < 2 || nargin > 3 || ! ismatrix (x0)) + if (nargin < 2 || nargin > 3 || ! isnumeric (x0)) print_usage (); endif diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/optimization/fsolve.m --- a/scripts/optimization/fsolve.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/optimization/fsolve.m Mon Feb 01 22:59:43 2016 -0800 @@ -146,7 +146,7 @@ return; endif - if (nargin < 2 || nargin > 3 || ! ismatrix (x0)) + if (nargin < 2 || nargin > 3 || ! isnumeric (x0)) print_usage (); endif diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/optimization/lsqnonneg.m --- a/scripts/optimization/lsqnonneg.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/optimization/lsqnonneg.m Mon Feb 01 22:59:43 2016 -0800 @@ -87,7 +87,9 @@ endif if (nargin < 2 || nargin > 4 - || ! (ismatrix (c) && ismatrix (d) && isstruct (options))) + || ! (isnumeric (c) && ismatrix (c)) + || ! (isnumeric (d) && ismatrix (d)) + || ! isstruct (options)) print_usage (); endif diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/optimization/pqpnonneg.m --- a/scripts/optimization/pqpnonneg.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/optimization/pqpnonneg.m Mon Feb 01 22:59:43 2016 -0800 @@ -79,7 +79,9 @@ endif if (nargin < 2 || nargin > 4 - || ! (ismatrix (c) && ismatrix (d) && isstruct (options))) + || ! (isnumeric (c) && ismatrix (c)) + || ! (isnumeric (d) && ismatrix (d)) + || ! isstruct (options)) print_usage (); endif diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/bicg.m --- a/scripts/sparse/bicg.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/bicg.m Mon Feb 01 22:59:43 2016 -0800 @@ -81,15 +81,14 @@ fun = str2func (A); Ax = @(x) feval (fun, x, "notransp"); Atx = @(x) feval (fun, x, "transp"); - elseif (isnumeric (A) && ismatrix (A)) + elseif (isnumeric (A) && issquare (A)) Ax = @(x) A * x; Atx = @(x) A' * x; elseif (isa (A, "function_handle")) Ax = @(x) feval (A, x, "notransp"); Atx = @(x) feval (A, x, "transp"); else - error (["bicg: first argument is expected to " ... - "be a function or a square matrix"]); + error ("bicg: A must be a function or square matrix"); endif if (nargin < 3 || isempty (tol)) @@ -116,8 +115,7 @@ M1m1x = @(x) feval (M1, x, "notransp"); M1tm1x = @(x) feval (M1, x, "transp"); else - error (["bicg: preconditioner is expected to " ... - "be a function or matrix"]); + error ("bicg: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -134,8 +132,7 @@ M2m1x = @(x) feval (M2, x, "notransp"); M2tm1x = @(x) feval (M2, x, "transp"); else - error (["bicg: preconditioner is expected to " ... - "be a function or matrix"]); + error ("bicg: preconditioner M2 must be a function or matrix"); endif Pm1x = @(x) M2m1x (M1m1x (x)); diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/bicgstab.m --- a/scripts/sparse/bicgstab.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/bicgstab.m Mon Feb 01 22:59:43 2016 -0800 @@ -76,13 +76,12 @@ if (ischar (A)) A = str2func (A); - elseif (isnumeric(A) && ismatrix (A)) + elseif (isnumeric(A) && issquare (A)) Ax = @(x) A * x; elseif (isa (A, "function_handle")) Ax = @(x) feval (A, x); else - error (["bicgstab: first argument is expected " ... - "to be a function or a square matrix"]); + error ("bicgstab: A must be a function or square matrix"); endif if (nargin < 3 || isempty (tol)) @@ -102,8 +101,7 @@ elseif (isa (M1, "function_handle")) M1m1x = @(x) feval (M1, x); else - error (["bicgstab: preconditioner is " ... - "expected to be a function or matrix"]); + error ("bicgstab: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -115,8 +113,7 @@ elseif (isa (M2, "function_handle")) M2m1x = @(x) feval (M2, x); else - error (["bicgstab: preconditioner is "... - "expected to be a function or matrix"]); + error ("bicgstab: preconditioner M2 must be a function or matrix"); endif precon = @(x) M2m1x (M1m1x (x)); diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/cgs.m --- a/scripts/sparse/cgs.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/cgs.m Mon Feb 01 22:59:43 2016 -0800 @@ -74,13 +74,12 @@ if (ischar (A)) A = str2func (A); - elseif (isnumeric (A) && ismatrix (A)) + elseif (isnumeric (A) && issquare (A)) Ax = @(x) A * x; elseif (isa (A, "function_handle")) Ax = @(x) feval (A, x); else - error (["cgs: first argument is expected to "... - "be a function or a square matrix"]); + error ("cgs: A must be a function or square matrix"); endif if (nargin < 3 || isempty (tol)) @@ -100,7 +99,7 @@ elseif (isa (M1, "function_handle")) M1m1x = @(x) feval (M1, x); else - error ("cgs: preconditioner is expected to be a function or matrix"); + error ("cgs: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -112,7 +111,7 @@ elseif (isa (M2, "function_handle")) M2m1x = @(x) feval (M2, x); else - error ("cgs: preconditioner is expected to be a function or matrix"); + error ("cgs: preconditioner M2 must be a function or matrix"); endif precon = @(x) M2m1x (M1m1x (x)); diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/gmres.m --- a/scripts/sparse/gmres.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/gmres.m Mon Feb 01 22:59:43 2016 -0800 @@ -79,12 +79,12 @@ if (ischar (A)) Ax = str2func (A); - elseif (isnumeric (A) && ismatrix (A)) + elseif (isnumeric (A) && issquare (A)) Ax = @(x) A*x; elseif (isa (A, "function_handle")) Ax = A; else - error ("gmres: A must be a function or matrix"); + error ("gmres: A must be a function or square matrix"); endif if (nargin < 3 || isempty (restart)) @@ -230,7 +230,7 @@ %!error gmres (1) %!error gmres (1,2,3,4,5,6,7,8,9) %!error gmres ({1},2) -%!error gmres ({1},2) +%!error gmres ({1},2) %!error gmres (1,2,3,4,5,{6}) %!error gmres (1,2,3,4,5,6,{7}) diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/qmr.m --- a/scripts/sparse/qmr.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/qmr.m Mon Feb 01 22:59:43 2016 -0800 @@ -97,12 +97,11 @@ elseif (isa (A, "function_handle")) Ax = @(x) feval (A, x, "notransp"); Atx = @(x) feval (A, x, "transp"); - elseif (isnumeric (A) && ismatrix (A)) + elseif (isnumeric (A) && issquare (A)) Ax = @(x) A * x; Atx = @(x) A' * x; else - error (["qmr: first argument is expected to " ... - "be a function or a square matrix"]); + error ("qmr: A must be a function or square matrix"); endif if (nargin < 3 || isempty (tol)) @@ -129,8 +128,7 @@ M1m1x = @(x) M1 \ x; M1tm1x = @(x) M1' \ x; else - error (["qmr: preconditioner is expected to " ... - "be a function or matrix"]); + error ("qmr: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -147,11 +145,9 @@ M2m1x = @(x) M2 \ x; M2tm1x = @(x) M2' \ x; else - error (["qmr: preconditioner is expected to " ... - "be a function or matrix"]); + error ("qmr: preconditioner M2 must be a function or matrix"); endif - if (nargin < 7 || isempty (x0)) x = zeros (size (b)); else diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/spconvert.m --- a/scripts/sparse/spconvert.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/spconvert.m Mon Feb 01 22:59:43 2016 -0800 @@ -30,13 +30,18 @@ function s = spconvert (m) + if (nargin != 1) + print_usage (); + endif + if (issparse (m)) s = m; else sz = size (m); - if (nargin != 1 || ! ismatrix (m) || ! isreal (m) + if (! ismatrix (m) || ! isreal (m) || length (sz) != 2 || (sz(2) != 3 && sz(2) != 4)) - error ("spconvert: argument must be sparse or real matrix with 3 or 4 columns"); + error (["spconvert: argument must be sparse or real matrix" ... + "with 3 or 4 columns"]); elseif (sz(2) == 3) s = sparse (m(:,1), m(:,2), m(:,3)); else diff -r 8b1e030d3d4f -r 2935d56203a4 scripts/sparse/treeplot.m --- a/scripts/sparse/treeplot.m Sat Jan 30 07:55:18 2016 -0800 +++ b/scripts/sparse/treeplot.m Mon Feb 01 22:59:43 2016 -0800 @@ -37,8 +37,7 @@ print_usage (); endif - if (! ismatrix (tree) || rows (tree) != 1 || ! isnumeric (tree) - || ! isvector (tree) || any (tree > length (tree))) + if (! isnumeric (tree) || ! isrow (tree) || any (tree > length (tree))) error ("treeplot: TREE must be a vector of predecessors"); endif