changeset 21171:2935d56203a4 stable

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.
author Rik <rik@octave.org>
date Mon, 01 Feb 2016 22:59:43 -0800
parents 8b1e030d3d4f
children 5f62b5dae8b1
files scripts/gui/inputdlg.m scripts/gui/uigetfile.m scripts/optimization/fminunc.m scripts/optimization/fsolve.m scripts/optimization/lsqnonneg.m scripts/optimization/pqpnonneg.m scripts/sparse/bicg.m scripts/sparse/bicgstab.m scripts/sparse/cgs.m scripts/sparse/gmres.m scripts/sparse/qmr.m scripts/sparse/spconvert.m scripts/sparse/treeplot.m
diffstat 13 files changed, 40 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- 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);
--- 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");
--- 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
 
--- 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
 
--- 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
 
--- 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
 
--- 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));
--- 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));
--- 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));
--- 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 <A must be> gmres ({1},2)
-%!error <A must be a function or matrix> gmres ({1},2)
+%!error <A must be a function or square matrix> gmres ({1},2)
 %!error <M1 must be a function or matrix> gmres (1,2,3,4,5,{6})
 %!error <M2 must be a function or matrix> gmres (1,2,3,4,5,6,{7})
 
--- 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
--- 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
--- 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