# HG changeset patch # User John W. Eaton # Date 1454450771 18000 # Node ID 3be6a07e8bad31ef1bb86718b487055976fbf46a # Parent a10f60e13243c231e07ae2970bbe4781331cca56# Parent 5ecdcc6320d904a388bb8e69238bdb771d4e90fa maint: Periodic merge of stable to default. diff -r a10f60e13243 -r 3be6a07e8bad scripts/general/cart2pol.m --- a/scripts/general/cart2pol.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/general/cart2pol.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2000-2015 Kai Habel +## Copyright (C) 2000-2016 Kai Habel ## ## This file is part of Octave. ## @@ -49,26 +49,26 @@ endif if (nargin == 1) - if (ismatrix (x) && (columns (x) == 2 || columns (x) == 3)) - if (columns (x) == 3) - z = x(:,3); - endif - y = x(:,2); - x = x(:,1); - else + if (! (isnumeric (x) && ismatrix (x) + && (columns (x) == 2 || columns (x) == 3))) error ("cart2pol: matrix input must have 2 or 3 columns [X, Y (, Z)]"); endif + if (columns (x) == 3) + z = x(:,3); + endif + y = x(:,2); + x = x(:,1); elseif (nargin == 2) - if (! ((ismatrix (x) && ismatrix (y)) + if (! ((isnumeric (x) && isnumeric (y)) && (size_equal (x, y) || isscalar (x) || isscalar (y)))) - error ("cart2pol: arguments must be matrices of same size, or scalar"); + error ("cart2pol: X, Y must be numeric arrays of the same size, or scalar"); endif elseif (nargin == 3) - if (! ((ismatrix (x) && ismatrix (y) && ismatrix (z)) + if (! ((isnumeric (x) && isnumeric (y) && isnumeric (z)) && (size_equal (x, y) || isscalar (x) || isscalar (y)) && (size_equal (x, z) || isscalar (x) || isscalar (z)) && (size_equal (y, z) || isscalar (y) || isscalar (z)))) - error ("cart2pol: arguments must be matrices of same size, or scalar"); + error ("cart2pol: X, Y, Z must be numeric arrays of the same size, or scalar"); endif endif @@ -142,3 +142,41 @@ %! P = [0, 0, 0; pi/4, sqrt(2), 1; pi/4, 2*sqrt(2), 2]; %! assert (cart2pol (C), P, sqrt (eps)); +%!test +%! x = zeros (1, 1, 1, 2); +%! x(1, 1, 1, 2) = sqrt (2); +%! y = x; +%! [t, r] = cart2pol (x, y); +%! T = zeros (1, 1, 1, 2); +%! T(1, 1, 1, 2) = pi/4; +%! R = zeros (1, 1, 1, 2); +%! R(1, 1, 1, 2) = 2; +%! assert (t, T, eps); +%! assert (r, R, eps); + +%!test +%! [x, y, Z] = meshgrid ([0, 1], [0, 1], [0, 1]); +%! [t, r, z] = cart2pol (x, y, Z); +%! T(:, :, 1) = [0, 0; pi/2, pi/4]; +%! T(:, :, 2) = T(:, :, 1); +%! R = sqrt (x.^2 + y.^2); +%! assert (t, T, eps); +%! assert (r, R, eps); +%! assert (z, Z); + +## Test input validation +%!error cart2pol () +%!error cart2pol (1,2,3,4) +%!error cart2pol ({1,2,3}) +%!error cart2pol (ones (3,3,2)) +%!error cart2pol ([1]) +%!error cart2pol ([1,2,3,4]) +%!error cart2pol ({1,2,3}, [1,2,3]) +%!error cart2pol ([1,2,3], {1,2,3}) +%!error cart2pol (ones (3,3,3), ones (3,2,3)) +%!error cart2pol ({1,2,3}, [1,2,3], [1,2,3]) +%!error cart2pol ([1,2,3], {1,2,3}, [1,2,3]) +%!error cart2pol ([1,2,3], [1,2,3], {1,2,3}) +%!error cart2pol (ones (3,3,3), 1, ones (3,2,3)) +%!error cart2pol (ones (3,3,3), ones (3,2,3), 1) + diff -r a10f60e13243 -r 3be6a07e8bad scripts/general/cart2sph.m --- a/scripts/general/cart2sph.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/general/cart2sph.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2000-2015 Kai Habel +## Copyright (C) 2000-2016 Kai Habel ## ## This file is part of Octave. ## @@ -48,19 +48,18 @@ endif if (nargin == 1) - if (ismatrix (x) && columns (x) == 3) - z = x(:,3); - y = x(:,2); - x = x(:,1); - else + if (! (isnumeric (x) && ismatrix (x) && columns (x) == 3)) error ("cart2sph: matrix input must have 3 columns [X, Y, Z]"); endif - elseif (nargin == 3) - if (! ((ismatrix (x) && ismatrix (y) && ismatrix (z)) + z = x(:,3); + y = x(:,2); + x = x(:,1); + else + if (! ((isnumeric (x) && isnumeric (y) && isnumeric (z)) && (size_equal (x, y) || isscalar (x) || isscalar (y)) && (size_equal (x, z) || isscalar (x) || isscalar (z)) && (size_equal (y, z) || isscalar (y) || isscalar (z)))) - error ("cart2sph: X, Y, Z must be matrices of the same size, or scalar"); + error ("cart2sph: X, Y, Z must be numeric arrays of the same size, or scalar"); endif endif @@ -116,3 +115,27 @@ %! S = [0, 0, 0; 0, pi/4, sqrt(2); 0, pi/4, 2*sqrt(2)]; %! assert (cart2sph (C), S, eps); +%!test +%! [x, y, z] = meshgrid ([0, 1], [0, 1], [0, 1]); +%! [t, p, r] = cart2sph (x, y, z); +%! T(:, :, 1) = [0, 0; pi/2, pi/4]; +%! T(:, :, 2) = T(:, :, 1); +%! P(:, :, 1) = zeros (2, 2); +%! P(:, :, 2) = [pi/2, pi/4; pi/4, acos(sqrt(2/3))]; +%! R = sqrt (x .^ 2 + y .^ 2 + z .^ 2); +%! assert (t, T, eps); +%! assert (p, P, eps); +%! assert (r, R, eps); + +## Test input validation +%!error cart2sph () +%!error cart2sph (1,2) +%!error cart2sph (1,2,3,4) +%!error cart2sph ({1,2,3}) +%!error cart2sph (ones (3,3,2)) +%!error cart2sph ([1,2,3,4]) +%!error cart2sph ({1,2,3}, [1,2,3], [1,2,3]) +%!error cart2sph ([1,2,3], {1,2,3}, [1,2,3]) +%!error cart2sph ([1,2,3], [1,2,3], {1,2,3}) +%!error cart2sph (ones (3,3,3), 1, ones (3,2,3)) +%!error cart2sph (ones (3,3,3), ones (3,2,3), 1) diff -r a10f60e13243 -r 3be6a07e8bad scripts/general/interp2.m --- a/scripts/general/interp2.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/general/interp2.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2000-2015 Kai Habel +## Copyright (C) 2000-2016 Kai Habel ## Copyright (C) 2009 Jaroslav Hajek ## ## This file is part of Octave. @@ -105,7 +105,7 @@ method(1) = []; endif method = validatestring (method, ... - {"nearest", "linear", "pchip", "cubic", "spline"}); + {"nearest", "linear", "pchip", "cubic", "spline"}); ## Read numeric input switch (nargs) @@ -123,7 +123,7 @@ endswitch ## Type checking - if (! isnumeric (Z) || isscalar (Z) || ! ismatrix (Z) || ndims (Z) != 2) + if (! isnumeric (Z) || isscalar (Z) || ! ismatrix (Z)) error ("interp2: Z must be a 2-D matrix"); endif if (! isempty (n) && ! (isscalar (n) && n >= 0 && n == fix (n))) @@ -563,8 +563,8 @@ %!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol) ## Test input validation -%!error interp2 (1, 1, 1, 1, 1, 2) #only 5 numeric inputs -%!error interp2 (1, 1, 1, 1, 1, 2, 2) #only 5 numeric inputs +%!error interp2 (1, 1, 1, 1, 1, 2) # only 5 numeric inputs +%!error interp2 (1, 1, 1, 1, 1, 2, 2) # only 5 numeric inputs %!error interp2 ({1}) %!error interp2 (1,1,1) %!error interp2 (ones (2,2,2)) diff -r a10f60e13243 -r 3be6a07e8bad scripts/general/pol2cart.m --- a/scripts/general/pol2cart.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/general/pol2cart.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2000-2015 Kai Habel +## Copyright (C) 2000-2016 Kai Habel ## ## This file is part of Octave. ## @@ -49,26 +49,26 @@ endif if (nargin == 1) - if (ismatrix (theta) && (columns (theta) == 2 || columns (theta) == 3)) - if (columns (theta) == 3) - z = theta(:,3); - endif - r = theta(:,2); - theta = theta(:,1); - else + if (! (isnumeric (theta) && ismatrix (theta) + && (columns (theta) == 2 || columns (theta) == 3))) error ("pol2cart: matrix input must have 2 or 3 columns [THETA, R (, Z)]"); endif + if (columns (theta) == 3) + z = theta(:,3); + endif + r = theta(:,2); + theta = theta(:,1); elseif (nargin == 2) - if (! ((ismatrix (theta) && ismatrix (r)) + if (! ((isnumeric (theta) && isnumeric (r)) && (size_equal (theta, r) || isscalar (theta) || isscalar (r)))) - error ("pol2cart: arguments must be matrices of same size, or scalar"); + error ("pol2cart: THETA, R must be numeric arrays of the same size, or scalar"); endif elseif (nargin == 3) - if (! ((ismatrix (theta) && ismatrix (r) && ismatrix (z)) + if (! ((isnumeric (theta) && isnumeric (r) && isnumeric (z)) && (size_equal (theta, r) || isscalar (theta) || isscalar (r)) && (size_equal (theta, z) || isscalar (theta) || isscalar (z)) && (size_equal (r, z) || isscalar (r) || isscalar (z)))) - error ("pol2cart: arguments must be matrices of same size, or scalar"); + error ("pol2cart: THETA, R, Z must be numeric arrays of the same size, or scalar"); endif endif @@ -142,3 +142,43 @@ %! C = [0, 0, 0; 1, 1, 1; 2, 2, 2]; %! assert (pol2cart (P), C, sqrt (eps)); +%!test +%! r = ones (1, 1, 1, 2); +%! r(1, 1, 1, 2) = 2; +%! t = pi/2 * r; +%! [x, y] = pol2cart (t, r); +%! X = zeros (1, 1, 1, 2); +%! X(1, 1, 1, 2) = -2; +%! Y = zeros (1, 1, 1, 2); +%! Y(1, 1, 1, 1) = 1; +%! assert (x, X, 2*eps); +%! assert (y, Y, 2*eps); + +%!test +%! [t, r, Z] = meshgrid ([0, pi/2], [1, 2], [0, 1]); +%! [x, y, z] = pol2cart (t, r, Z); +%! X = zeros(2, 2, 2); +%! X(:, 1, 1) = [1; 2]; +%! X(:, 1, 2) = [1; 2]; +%! Y = zeros(2, 2, 2); +%! Y(:, 2, 1) = [1; 2]; +%! Y(:, 2, 2) = [1; 2]; +%! assert (x, X, eps); +%! assert (y, Y, eps); +%! assert (z, Z); + +## Test input validation +%!error pol2cart () +%!error pol2cart (1,2,3,4) +%!error pol2cart ({1,2,3}) +%!error pol2cart (ones (3,3,2)) +%!error pol2cart ([1]) +%!error pol2cart ([1,2,3,4]) +%!error pol2cart ({1,2,3}, [1,2,3]) +%!error pol2cart ([1,2,3], {1,2,3}) +%!error pol2cart (ones (3,3,3), ones (3,2,3)) +%!error pol2cart ({1,2,3}, [1,2,3], [1,2,3]) +%!error pol2cart ([1,2,3], {1,2,3}, [1,2,3]) +%!error pol2cart ([1,2,3], [1,2,3], {1,2,3}) +%!error pol2cart (ones (3,3,3), 1, ones (3,2,3)) +%!error pol2cart (ones (3,3,3), ones (3,2,3), 1) diff -r a10f60e13243 -r 3be6a07e8bad scripts/general/sph2cart.m --- a/scripts/general/sph2cart.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/general/sph2cart.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2000-2015 Kai Habel +## Copyright (C) 2000-2016 Kai Habel ## ## This file is part of Octave. ## @@ -48,19 +48,18 @@ endif if (nargin == 1) - if (ismatrix (theta) && columns (theta) == 3) - r = theta(:,3); - phi = theta(:,2); - theta = theta(:,1); - else + if (! (isnumeric (theta) && ismatrix (theta) && columns (theta) == 3)) error ("sph2cart: matrix input must have 3 columns [THETA, PHI, R]"); endif - elseif (nargin == 3) - if (! ((ismatrix (theta) && ismatrix (phi) && ismatrix (r)) + r = theta(:,3); + phi = theta(:,2); + theta = theta(:,1); + else + if (! ((isnumeric (theta) && isnumeric (phi) && isnumeric (r)) && (size_equal (theta, phi) || isscalar (theta) || isscalar (phi)) && (size_equal (theta, r) || isscalar (theta) || isscalar (r)) && (size_equal (phi, r) || isscalar (phi) || isscalar (r)))) - error ("sph2cart: THETA, PHI, and R must be matrices of the same size, or scalar"); + error ("sph2cart: THETA, PHI, R must be numeric arrays of the same size, or scalar"); endif endif @@ -116,3 +115,29 @@ %! C = [ 1, 0, 0; 0, 1, 0; -1, 0, 0]; %! assert (sph2cart (S), C, eps); +%!test +%! [t, p, r] = meshgrid ([0, pi/2], [0, pi/2], [0, 1]); +%! [x, y, z] = sph2cart (t, p, r); +%! X = zeros(2, 2, 2); +%! X(1, 1, 2) = 1; +%! Y = zeros(2, 2, 2); +%! Y(1, 2, 2) = 1; +%! Z = zeros(2, 2, 2); +%! Z(2, :, 2) = [1 1]; +%! assert (x, X, eps); +%! assert (y, Y, eps); +%! assert (z, Z); + +## Test input validation +%!error sph2cart () +%!error sph2cart (1,2) +%!error sph2cart (1,2,3,4) +%!error sph2cart ({1,2,3}) +%!error sph2cart (ones (3,3,2)) +%!error sph2cart ([1,2,3,4]) +%!error sph2cart ({1,2,3}, [1,2,3], [1,2,3]) +%!error sph2cart ([1,2,3], {1,2,3}, [1,2,3]) +%!error sph2cart ([1,2,3], [1,2,3], {1,2,3}) +%!error sph2cart (ones (3,3,3), 1, ones (3,2,3)) +%!error sph2cart (ones (3,3,3), ones (3,2,3), 1) + diff -r a10f60e13243 -r 3be6a07e8bad scripts/gui/inputdlg.m --- a/scripts/gui/inputdlg.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/gui/inputdlg.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/gui/uigetfile.m --- a/scripts/gui/uigetfile.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/gui/uigetfile.m Tue Feb 02 17:06:11 2016 -0500 @@ -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: "Position" must be a 2-element vector'); diff -r a10f60e13243 -r 3be6a07e8bad scripts/optimization/fminunc.m --- a/scripts/optimization/fminunc.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/optimization/fminunc.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/optimization/fsolve.m --- a/scripts/optimization/fsolve.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/optimization/fsolve.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/optimization/lsqnonneg.m --- a/scripts/optimization/lsqnonneg.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/optimization/lsqnonneg.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/optimization/pqpnonneg.m --- a/scripts/optimization/pqpnonneg.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/optimization/pqpnonneg.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/plot/draw/isosurface.m --- a/scripts/plot/draw/isosurface.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/plot/draw/isosurface.m Tue Feb 02 17:06:11 2016 -0500 @@ -1,4 +1,4 @@ -## Copyright (C) 2009-2015 Martin Helm +## Copyright (C) 2009-2016 Martin Helm ## ## This file is part of Octave. ## @@ -145,7 +145,7 @@ [n2, n1, n3] = size (val); [x, y, z] = meshgrid (1:n1, 1:n2, 1:n3); iso = varargin{2}; - if (nargin >= 3 && ismatrix (varargin{3})) + if (nargin >= 3 && isnumeric (varargin{3})) colors = varargin{3}; calc_colors = true; endif @@ -232,3 +232,9 @@ %! assert (size (v), [3 3]); %! assert (size (c), [3 1]); +%!test +%! [f, v, c] = isosurface (val, .3, y); +%! assert (size (f), [1 3]); +%! assert (size (v), [3 3]); +%! assert (size (c), [3 1]); + diff -r a10f60e13243 -r 3be6a07e8bad scripts/sparse/bicg.m --- a/scripts/sparse/bicg.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/bicg.m Tue Feb 02 17:06:11 2016 -0500 @@ -81,7 +81,7 @@ 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")) @@ -115,7 +115,7 @@ M1m1x = @(x) feval (M1, x, "notransp"); M1tm1x = @(x) feval (M1, x, "transp"); else - error ("bicg: preconditioner must be a function or matrix"); + error ("bicg: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -132,7 +132,7 @@ M2m1x = @(x) feval (M2, x, "notransp"); M2tm1x = @(x) feval (M2, x, "transp"); else - error ("bicg: preconditioner must be a function or matrix"); + error ("bicg: preconditioner M2 must be a function or matrix"); endif Pm1x = @(x) M2m1x (M1m1x (x)); diff -r a10f60e13243 -r 3be6a07e8bad scripts/sparse/bicgstab.m --- a/scripts/sparse/bicgstab.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/bicgstab.m Tue Feb 02 17:06:11 2016 -0500 @@ -76,7 +76,7 @@ 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); @@ -101,7 +101,7 @@ elseif (isa (M1, "function_handle")) M1m1x = @(x) feval (M1, x); else - error ("bicgstab: preconditioner must be a function or matrix"); + error ("bicgstab: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -113,7 +113,7 @@ elseif (isa (M2, "function_handle")) M2m1x = @(x) feval (M2, x); else - error ("bicgstab: preconditioner must be a function or matrix"); + error ("bicgstab: preconditioner M2 must be a function or matrix"); endif precon = @(x) M2m1x (M1m1x (x)); diff -r a10f60e13243 -r 3be6a07e8bad scripts/sparse/cgs.m --- a/scripts/sparse/cgs.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/cgs.m Tue Feb 02 17:06:11 2016 -0500 @@ -74,7 +74,7 @@ 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); @@ -99,7 +99,7 @@ elseif (isa (M1, "function_handle")) M1m1x = @(x) feval (M1, x); else - error ("cgs: preconditioner must be a function or matrix"); + error ("cgs: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -111,7 +111,7 @@ elseif (isa (M2, "function_handle")) M2m1x = @(x) feval (M2, x); else - error ("cgs: preconditioner must be a function or matrix"); + error ("cgs: preconditioner M2 must be a function or matrix"); endif precon = @(x) M2m1x (M1m1x (x)); diff -r a10f60e13243 -r 3be6a07e8bad scripts/sparse/gmres.m --- a/scripts/sparse/gmres.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/gmres.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/sparse/qmr.m --- a/scripts/sparse/qmr.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/qmr.m Tue Feb 02 17:06:11 2016 -0500 @@ -97,7 +97,7 @@ 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 @@ -128,7 +128,7 @@ M1m1x = @(x) M1 \ x; M1tm1x = @(x) M1' \ x; else - error ("qmr: preconditioner must be a function or matrix"); + error ("qmr: preconditioner M1 must be a function or matrix"); endif if (nargin < 6 || isempty (M2)) @@ -145,10 +145,9 @@ M2m1x = @(x) M2 \ x; M2tm1x = @(x) M2' \ x; else - error ("qmr: preconditioner must 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 a10f60e13243 -r 3be6a07e8bad scripts/sparse/spconvert.m --- a/scripts/sparse/spconvert.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/spconvert.m Tue Feb 02 17:06:11 2016 -0500 @@ -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 a10f60e13243 -r 3be6a07e8bad scripts/sparse/treeplot.m --- a/scripts/sparse/treeplot.m Tue Feb 02 16:53:01 2016 -0500 +++ b/scripts/sparse/treeplot.m Tue Feb 02 17:06:11 2016 -0500 @@ -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