changeset 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 2e9f17872f36
children f4af02a9a6fc
files libinterp/corefcn/data.cc scripts/general/accumarray.m scripts/general/gradient.m scripts/general/num2str.m scripts/image/ntsc2rgb.m scripts/linear-algebra/condest.m scripts/linear-algebra/expm.m scripts/linear-algebra/onenormest.m scripts/plot/draw/isocolors.m scripts/plot/draw/isonormals.m scripts/plot/draw/isosurface.m scripts/plot/draw/private/__errcomm__.m scripts/plot/draw/private/__interp_cube__.m scripts/plot/draw/private/__marching_cube__.m scripts/plot/draw/private/__stem__.m scripts/plot/draw/stairs.m scripts/set/private/validsetargs.m scripts/set/unique.m scripts/sparse/bicg.m scripts/sparse/bicgstab.m scripts/sparse/cgs.m scripts/sparse/gmres.m scripts/sparse/qmr.m
diffstat 23 files changed, 98 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/data.cc	Wed Feb 11 23:03:51 2015 -0800
+++ b/libinterp/corefcn/data.cc	Thu Feb 12 18:34:56 2015 +0100
@@ -3743,18 +3743,19 @@
 }
 
 /*
-%!assert (isvector (1))
-%!assert (isvector ([1; 2; 3]))
+%!assert (isvector (1), true)
+%!assert (isvector ([1; 2; 3]), true)
+%!assert (isvector ([1, 2, 3]), true)
 %!assert (isvector ([]), false)
 %!assert (isvector ([1, 2; 3, 4]), false)
 
-%!assert (isvector ("t"))
-%!assert (isvector ("test"))
+%!assert (isvector ("t"), true)
+%!assert (isvector ("test"), true)
 %!assert (isvector (["test"; "ing"]), false)
 
 %!test
 %! s.a = 1;
-%! assert (isvector (s));
+%! assert (isvector (s), true);
 
 %% Test input validation
 %!error isvector ()
@@ -3764,7 +3765,7 @@
 DEFUN (isrow, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Function File} {} isrow (@var{x})\n\
-Return true if @var{x} is a row vector.\n\
+Return true if @var{x} is a row vector 1xN with nonnegative N.\n\
 @seealso{iscolumn, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
@@ -3788,13 +3789,23 @@
 %!assert (isrow ([]), false)
 %!assert (isrow ([1, 2; 3, 4]), false)
 
-%!assert (isrow ("t"))
-%!assert (isrow ("test"))
+%!assert (isrow (ones (1, 0)), true)
+%!assert (isrow (ones (1, 1)), true)
+%!assert (isrow (ones (1, 2)), true)
+%!assert (isrow (ones (1, 1, 1)), true)
+%!assert (isrow (ones (1, 1, 1, 1)), true)
+
+%!assert (isrow (ones (0, 0)), false)
+%!assert (isrow (ones (1, 1, 0)), false)
+
+
+%!assert (isrow ("t"), true)
+%!assert (isrow ("test"), true)
 %!assert (isrow (["test"; "ing"]), false)
 
 %!test
 %! s.a = 1;
-%! assert (isrow (s));
+%! assert (isrow (s), true);
 
 %% Test input validation
 %!error isrow ()
@@ -3804,7 +3815,7 @@
 DEFUN (iscolumn, args, ,
   "-*- texinfo -*-\n\
 @deftypefn {Function File} {} iscolumn (@var{x})\n\
-Return true if @var{x} is a column vector.\n\
+Return true if @var{x} is a column vector Nx1 with nonnegative N.\n\
 @seealso{isrow, isscalar, isvector, ismatrix}\n\
 @end deftypefn")
 {
@@ -3823,15 +3834,24 @@
 
 /*
 %!assert (iscolumn ([1, 2, 3]), false)
-%!assert (iscolumn ([1; 2; 3]))
-%!assert (iscolumn (1))
+%!assert (iscolumn ([1; 2; 3]), true)
+%!assert (iscolumn (1), true)
 %!assert (iscolumn ([]), false)
 %!assert (iscolumn ([1, 2; 3, 4]), false)
 
-%!assert (iscolumn ("t"))
+%!assert (iscolumn ("t"), true)
 %!assert (iscolumn ("test"), false)
 %!assert (iscolumn (["test"; "ing"]), false)
 
+%!assert (iscolumn (ones (0, 1)), true)
+%!assert (iscolumn (ones (1, 1)), true)
+%!assert (iscolumn (ones (2, 1)), true)
+%!assert (iscolumn (ones (1, 1, 1)), true)
+%!assert (iscolumn (ones (1, 1, 1, 1)), true)
+
+%!assert (iscolumn (ones (0, 0)), false)
+%!assert (iscolumn (ones (0, 1, 0)), false)
+
 %!test
 %! s.a = 1;
 %! assert (iscolumn (s));
@@ -3844,10 +3864,7 @@
 DEFUN (ismatrix, args, ,
        "-*- texinfo -*-\n\
 @deftypefn {Built-in Function} {} ismatrix (@var{a})\n\
-Return true if @var{a} is a numeric, logical, or character matrix.\n\
-Scalars (1x1 matrices) and vectors (@nospell{1xN} or @nospell{Nx1} matrices)\n\
-are subsets of the more general N-dimensional matrix and @code{ismatrix}\n\
-will return true for these objects as well.\n\
+Return true if @var{a} is has exactly two nonnegative dimensions.\n\
 @seealso{isscalar, isvector, iscell, isstruct, issparse, isa}\n\
 @end deftypefn")
 {
@@ -3855,11 +3872,8 @@
 
   if (args.length () == 1)
     {
-      octave_value arg = args(0);
-
-      retval = arg.is_matrix_type ()
-               || arg.is_scalar_type ()
-               || arg.is_range ();
+      dim_vector sz = args(0).dims ();
+      retval = (sz.length () == 2) && (sz(0) >= 0) && (sz(1) >= 0);
     }
   else
     print_usage ();
@@ -3868,24 +3882,28 @@
 }
 
 /*
-%!assert (ismatrix ([]))
-%!assert (ismatrix (1))
-%!assert (ismatrix ([1, 2, 3]))
-%!assert (ismatrix ([1, 2; 3, 4]))
-%!assert (ismatrix (zeros (3, 2, 4)))
-
-%!assert (ismatrix (single ([])))
-%!assert (ismatrix (single (1)))
-%!assert (ismatrix (single ([1, 2, 3])))
-%!assert (ismatrix (single ([1, 2; 3, 4])))
-
-%!assert (ismatrix ("t"))
-%!assert (ismatrix ("test"))
-%!assert (ismatrix (["test"; "ing"]))
+%!assert (ismatrix ([]), true)
+%!assert (ismatrix (1), true)
+%!assert (ismatrix ([1, 2, 3]), true)
+%!assert (ismatrix ([1, 2; 3, 4]), true)
+
+%!assert (ismatrix (zeros (0)), true)
+%!assert (ismatrix (zeros (0, 0)), true)
+%!assert (ismatrix (zeros (0, 0, 0)), false)
+%!assert (ismatrix (zeros (3, 2, 4)), false)
+
+%!assert (ismatrix (single ([])), true)
+%!assert (ismatrix (single (1)), true)
+%!assert (ismatrix (single ([1, 2, 3])), true)
+%!assert (ismatrix (single ([1, 2; 3, 4])), true)
+
+%!assert (ismatrix ("t"), true)
+%!assert (ismatrix ("test"), true)
+%!assert (ismatrix (["test"; "ing"]), true)
 
 %!test
 %! s.a = 1;
-%! assert (ismatrix (s), false);
+%! assert (ismatrix (s), true);
 
 %!error ismatrix ()
 %!error ismatrix ([1, 2; 3, 4], 2)
--- a/scripts/general/accumarray.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/general/accumarray.m	Thu Feb 12 18:34:56 2015 +0100
@@ -239,7 +239,7 @@
       endif
 
       ## Convert multidimensional subscripts.
-      if (ismatrix (subs))
+      if (isnumeric (subs))
         subs = num2cell (subs, 1);
       endif
       subs = sub2ind (sz, subs{:}); # creates index cache
--- a/scripts/general/gradient.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/general/gradient.m	Thu Feb 12 18:34:56 2015 +0100
@@ -71,7 +71,7 @@
   endif
 
   nargout_with_ans = max (1,nargout);
-  if (ismatrix (m))
+  if (isnumeric (m))
     [varargout{1:nargout_with_ans}] = matrix_gradient (m, varargin{:});
   elseif (isa (m, "function_handle"))
     [varargout{1:nargout_with_ans}] = handle_gradient (m, varargin{:});
--- a/scripts/general/num2str.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/general/num2str.m	Thu Feb 12 18:34:56 2015 +0100
@@ -71,7 +71,7 @@
 
   if (nargin != 1 && nargin != 2)
     print_usage ();
-  elseif (! ismatrix (x))
+  elseif (! (isnumeric (x) || islogical (x) || ischar (x)))
     error ("num2str: X must be a numeric, logical, or character array");
   endif
 
--- a/scripts/image/ntsc2rgb.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/image/ntsc2rgb.m	Thu Feb 12 18:34:56 2015 +0100
@@ -50,7 +50,7 @@
   endif
 
   ## If we have an image convert it into a color map.
-  if (ismatrix (yiq) && ndims (yiq) == 3)
+  if (isnumeric (yiq) && ndims (yiq) == 3)
     is_image = true;
     sz = size (yiq);
     yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)];
--- a/scripts/linear-algebra/condest.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/linear-algebra/condest.m	Thu Feb 12 18:34:56 2015 +0100
@@ -124,7 +124,7 @@
   have_t = false;
   have_solve = false;
 
-  if (ismatrix (varargin{1}))
+  if (isnumeric (varargin{1}))
     A = varargin{1};
     if (! issquare (A))
       error ("condest: matrix must be square");
--- a/scripts/linear-algebra/expm.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/linear-algebra/expm.m	Thu Feb 12 18:34:56 2015 +0100
@@ -77,7 +77,7 @@
     print_usage ();
   endif
 
-  if (! ismatrix (A) || ! issquare (A))
+  if (! isnumeric (A) || ! issquare (A))
     error ("expm: A must be a square matrix");
   endif
 
--- a/scripts/linear-algebra/onenormest.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/linear-algebra/onenormest.m	Thu Feb 12 18:34:56 2015 +0100
@@ -103,7 +103,7 @@
   default_t = 5;
   itmax = 10;
 
-  if (ismatrix (varargin{1}))
+  if (isnumeric (varargin{1}))
     [n, nc] = size (varargin{1});
     if (n != nc)
       error ("onenormest: matrix must be square");
--- a/scripts/plot/draw/isocolors.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/isocolors.m	Thu Feb 12 18:34:56 2015 +0100
@@ -133,7 +133,7 @@
     otherwise
       print_usage ();
   endswitch
-  if (ismatrix (vp) && columns (vp) == 3)
+  if (isnumeric (vp) && columns (vp) == 3)
     pa = [];
     v = vp;
   elseif ( ishandle (vp) )
--- a/scripts/plot/draw/isonormals.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/isonormals.m	Thu Feb 12 18:34:56 2015 +0100
@@ -122,7 +122,7 @@
     otherwise
       print_usage ();
   endswitch
-  if (ismatrix (vp) && columns (vp) == 3)
+  if (isnumeric (vp) && columns (vp) == 3)
     pa = [];
     v = vp;
   elseif (ishandle (vp))
--- a/scripts/plot/draw/isosurface.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/isosurface.m	Thu Feb 12 18:34:56 2015 +0100
@@ -134,7 +134,7 @@
     z = varargin{3};
     val = varargin{4};
     iso = varargin{5};
-    if (nargin >= 6 && ismatrix (varargin{6}))
+    if (nargin >= 6 && isnumeric (varargin{6}))
       colors = varargin{6};
       calc_colors = true;
     endif
--- a/scripts/plot/draw/private/__errcomm__.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/private/__errcomm__.m	Thu Feb 12 18:34:56 2015 +0100
@@ -37,7 +37,7 @@
   k = 1;
   while (k <= nargs)
     arg = varargin{k++};
-    if (! ismatrix (arg))
+    if (! isnumeric (arg))
       error ("%s: data argument %d must be numeric", caller, k-1);
     endif
     if (isvector (arg))
@@ -52,7 +52,7 @@
         retval(end+1,1) = __errplot__(arg, hax, data{1:ndata});
         break;
       endif
-      if (! ismatrix (arg))
+      if (! isnumeric (arg))
         error ("%s: data argument %d must be numeric", caller, k-1);
       endif
       if (isvector (arg))
--- a/scripts/plot/draw/private/__interp_cube__.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/private/__interp_cube__.m	Thu Feb 12 18:34:56 2015 +0100
@@ -24,8 +24,8 @@
 ## @end deftypefn
 
 function [Vxyz, idx, frac] = __interp_cube__ (x, y, z, val, v, req = "values" )
-  if (ismatrix (x) && ndims (x) == 3 && ismatrix (y) && ndims (y) == 3
-       && ismatrix (z) && ndims (z) == 3 && size_equal (x, y, z, val))
+  if (isnumeric (x) && ndims (x) == 3 && isnumeric (y) && ndims (y) == 3
+       && isnumeric (z) && ndims (z) == 3 && size_equal (x, y, z, val))
     x = squeeze (x(1,:,1))(:);
     y = squeeze (y(:,1,1))(:);
     z = squeeze (z(1,1,:))(:);
--- a/scripts/plot/draw/private/__marching_cube__.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/private/__marching_cube__.m	Thu Feb 12 18:34:56 2015 +0100
@@ -98,7 +98,7 @@
     print_usage ();
   endif
 
-  if (!ismatrix (xx) || !ismatrix (yy) || !ismatrix (zz) || !ismatrix (c) || ...
+  if (!isnumeric (xx) || !isnumeric (yy) || !isnumeric (zz) || !isnumeric (c) || ...
     ndims (xx) != 3 || ndims (yy) != 3 || ndims (zz) != 3 || ndims (c) != 3)
     error ("__marching_cube__: XX, YY, ZZ, C must be matrices of dim 3");
   endif
@@ -116,7 +116,7 @@
   endif
 
   if (nargin == 6)
-    if ( !ismatrix (colors) || ndims (colors) != 3 || size (colors) != size (c) )
+    if ( !isnumeric (colors) || ndims (colors) != 3 || size (colors) != size (c) )
       error ( "COLORS must be a matrix of dim 3 and of same size as C" );
     endif
     calc_cols = true;
--- a/scripts/plot/draw/private/__stem__.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/private/__stem__.m	Thu Feb 12 18:34:56 2015 +0100
@@ -239,7 +239,7 @@
         y = repmat ([1:nr]', 1, nc);
       endif
     endif
-    if (! (ismatrix (x) && ismatrix (y) && ismatrix (z)))
+    if (! (isnumeric (x) && isnumeric (y) && isnumeric (z)))
       error ("stem3: X, Y, and Z must be numeric");
     endif
   else
@@ -250,7 +250,7 @@
         x = 1:rows (y);
       endif
     endif
-    if (! (ismatrix (x) && ismatrix (y)))
+    if (! (isnumeric (x) && isnumeric (y)))
       error ("stem: X and Y must be numeric");
     endif
   endif
--- a/scripts/plot/draw/stairs.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/plot/draw/stairs.m	Thu Feb 12 18:34:56 2015 +0100
@@ -99,7 +99,7 @@
   if (nargin == 2 || ischar (varargin{2}))
     y = varargin{1};
     varargin(1) = [];
-    if (! ismatrix (y) || ndims (y) > 2)
+    if (! isnumeric (y) || ndims (y) > 2)
       error ("stairs: Y must be a numeric 2-D vector or matrix");
     endif
     if (isvector (y))
@@ -110,7 +110,7 @@
     x = varargin{1};
     y = varargin{2};
     varargin(1:2) = [];
-    if (! ismatrix (x) || ! ismatrix (y) || ndims (x) > 2 || ndims (y) > 2)
+    if (! isnumeric (x) || ! isnumeric (y) || ndims (x) > 2 || ndims (y) > 2)
       error ("stairs: X and Y must be numeric 2-D vectors or matrices");
     endif
   endif
@@ -122,7 +122,7 @@
 
   if (isvector (y))
     y = y(:);
-  elseif (ismatrix (y) && vec_x)
+  elseif (isnumeric (y) && vec_x)
     x = repmat (x, [1, columns(y)]);
   endif
 
--- a/scripts/set/private/validsetargs.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/set/private/validsetargs.m	Thu Feb 12 18:34:56 2015 +0100
@@ -21,6 +21,8 @@
 
 function [x, y] = validsetargs (caller, x, y, byrows_arg)
 
+  isallowedarraytype = @(x) isnumeric (x) || ischar (x) || islogical (x);
+
   if (nargin == 3)
     icx = iscellstr (x);
     icy = iscellstr (y);
@@ -32,7 +34,7 @@
       elseif (! (icx && icy))
         error ("%s: cell array of strings cannot be combined with a nonstring value", caller);
       endif
-    elseif (! (ismatrix (x) && ismatrix (y)))
+    elseif (! (isallowedarraytype (x) && isallowedarraytype (y)))
       error ("%s: A and B must be arrays or cell arrays of strings", caller);
     endif
   elseif (nargin == 4)
@@ -42,7 +44,7 @@
 
     if (iscell (x) || iscell (y))
       error ('%s: cells not supported with "rows"', caller);
-    elseif (! (ismatrix (x) && ismatrix (y)))
+    elseif (! (isallowedarraytype (x) && isallowedarraytype (y)))
       error ("%s: A and B must be arrays or cell arrays of strings", caller);
     else
       if (ndims (x) > 2 || ndims (y) > 2)
--- a/scripts/set/unique.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/set/unique.m	Thu Feb 12 18:34:56 2015 +0100
@@ -46,8 +46,8 @@
 
   if (nargin < 1)
     print_usage ();
-  elseif (! (ismatrix (x) || iscellstr (x)))
-    error ("unique: X must be a matrix or cell array of strings");
+  elseif (! (isnumeric (x) || islogical (x) || ischar (x) || iscellstr (x)))
+    error ("unique: X must be an array or cell array of strings");
   endif
 
   if (nargin > 1)
@@ -216,7 +216,7 @@
 
 %% Test input validation
 %!error unique ()
-%!error <X must be a matrix or cell array of strings> unique ({1})
+%!error <X must be an array or cell array of strings> unique ({1})
 %!error <options must be strings> unique (1, 2)
 %!error <cannot specify both "first" and "last"> unique (1, "first", "last")
 %!error <invalid option> unique (1, "middle")
--- a/scripts/sparse/bicg.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/sparse/bicg.m	Thu Feb 12 18:34:56 2015 +0100
@@ -81,7 +81,7 @@
       fun = str2func (A);
       Ax  = @(x) feval (fun, x, "notransp");
       Atx = @(x) feval (fun, x, "transp");
-    elseif (ismatrix (A))
+    elseif (isnumeric (A) && ismatrix (A))
       Ax  = @(x) A  * x;
       Atx = @(x) A' * x;
     elseif (isa (A, "function_handle"))
@@ -107,7 +107,7 @@
       fun = str2func (M1);
       M1m1x  = @(x) feval (fun, x, "notransp");
       M1tm1x = @(x) feval (fun, x, "transp");
-    elseif (ismatrix (M1))
+    elseif (isnumeric (M1) && ismatrix (M1))
       M1m1x  = @(x) M1  \ x;
       M1tm1x = @(x) M1' \ x;
     elseif (isa (M1, "function_handle"))
@@ -125,7 +125,7 @@
       fun = str2func (M2);
       M2m1x  = @(x) feval (fun, x, "notransp");
       M2tm1x = @(x) feval (fun, x, "transp");
-    elseif (ismatrix (M2))
+    elseif (isnumeric (M2) && ismatrix (M2))
       M2m1x  = @(x) M2  \ x;
       M2tm1x = @(x) M2' \ x;
     elseif (isa (M2, "function_handle"))
--- a/scripts/sparse/bicgstab.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/sparse/bicgstab.m	Thu Feb 12 18:34:56 2015 +0100
@@ -77,7 +77,7 @@
 
     if (ischar (A))
       A = str2func (A);
-    elseif (ismatrix (A))
+    elseif (isnumeric(A) && ismatrix (A))
       Ax  = @(x) A  * x;
     elseif (isa (A, "function_handle"))
       Ax  = @(x) feval (A, x);
@@ -98,7 +98,7 @@
       M1m1x = @(x) x;
     elseif (ischar (M1))
       M1m1x = str2func (M1);
-    elseif (ismatrix (M1))
+    elseif (isnumeric(M1) && ismatrix (M1))
       M1m1x = @(x) M1  \ x;
     elseif (isa (M1, "function_handle"))
       M1m1x = @(x) feval (M1, x);
@@ -111,7 +111,7 @@
       M2m1x = @(x) x;
     elseif (ischar (M2))
       M2m1x = str2func (M2);
-    elseif (ismatrix (M2))
+    elseif (isnumeric(M2) && ismatrix (M2))
       M2m1x = @(x) M2  \ x;
     elseif (isa (M2, "function_handle"))
       M2m1x = @(x) feval (M2, x);
--- a/scripts/sparse/cgs.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/sparse/cgs.m	Thu Feb 12 18:34:56 2015 +0100
@@ -76,7 +76,7 @@
 
     if (ischar (A))
       A = str2func (A);
-    elseif (ismatrix (A))
+    elseif (isnumeric (A) && ismatrix (A))
       Ax = @(x) A * x;
     elseif (isa (A, "function_handle"))
       Ax = @(x) feval (A, x);
@@ -97,7 +97,7 @@
       M1m1x = @(x) x;
     elseif (ischar (M1))
       M1m1x = str2func (M1);
-    elseif (ismatrix (M1))
+    elseif (isnumeric (M1) && ismatrix (M1))
       M1m1x = @(x) M1 \ x;
     elseif (isa (M1, "function_handle"))
       M1m1x = @(x) feval (M1, x);
@@ -109,7 +109,7 @@
       M2m1x = @(x) x;
     elseif (ischar (M2))
       M2m1x = str2func (M2);
-    elseif (ismatrix (M2))
+    elseif (isnumeric (M2) && ismatrix (M2))
       M2m1x = @(x) M2 \ x;
     elseif (isa (M2, "function_handle"))
       M2m1x = @(x) feval (M2, x);
--- a/scripts/sparse/gmres.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/sparse/gmres.m	Thu Feb 12 18:34:56 2015 +0100
@@ -80,7 +80,7 @@
 
   if (ischar (A))
     Ax = str2func (A);
-  elseif (ismatrix (A))
+  elseif (isnumeric (A) && ismatrix (A))
     Ax = @(x) A*x;
   elseif (isa (A, "function_handle"))
     Ax = A;
@@ -104,7 +104,7 @@
     M1m1x = @(x) x;
   elseif (ischar (M1))
     M1m1x = str2func (M1);
-  elseif (ismatrix (M1))
+  elseif (isnumeric (M1) && ismatrix (M1))
     M1m1x = @(x) M1 \ x;
   elseif (isa (M1, "function_handle"))
     M1m1x = M1;
@@ -116,7 +116,7 @@
     M2m1x = @(x) x;
   elseif (ischar (M2))
     M2m1x = str2func (M2);
-  elseif (ismatrix (M2))
+  elseif (isnumeric (M2) && ismatrix (M2))
     M2m1x = @(x) M2 \ x;
   elseif (isa (M2, "function_handle"))
     M2m1x = M2;
--- a/scripts/sparse/qmr.m	Wed Feb 11 23:03:51 2015 -0800
+++ b/scripts/sparse/qmr.m	Thu Feb 12 18:34:56 2015 +0100
@@ -98,7 +98,7 @@
     elseif (isa (A, "function_handle"))
       Ax  = @(x) feval (A, x, "notransp");
       Atx = @(x) feval (A, x, "transp");
-    elseif (ismatrix (A))
+    elseif (isnumeric (A) && ismatrix (A))
       Ax  = @(x) A  * x;
       Atx = @(x) A' * x;
     else
@@ -124,7 +124,7 @@
     elseif (isa (M1, "function_handle"))
       M1m1x  = @(x) feval (M1, x, "notransp");
       M1tm1x = @(x) feval (M1, x, "transp");
-    elseif (ismatrix (M1))
+    elseif (isnumeric (M1) && ismatrix (M1))
       M1m1x  = @(x) M1  \ x;
       M1tm1x = @(x) M1' \ x;
     else
@@ -142,7 +142,7 @@
     elseif (isa (M2, "function_handle"))
       M2m1x  = @(x) feval (M2, x, "notransp");
       M2tm1x = @(x) feval (M2, x, "transp");
-    elseif (ismatrix (M2))
+    elseif (isnumeric (M2) && ismatrix (M2))
       M2m1x  = @(x) M2  \ x;
       M2tm1x = @(x) M2' \ x;
     else