changeset 20329:2102c4582e32

gallery: fix chebspec, cycol, gearmat, hanowa, lauchli, and pei (bug #45466) * scripts/special-matrix/gallery.m: (cycol): set default of K before the input check. (gearmat): fix logic on input check. (hanowa, lauchli, pei): fix typo on variable names. (chebspec): nicer error message for input check.
author Massimiliano Fasi <massimiliano.fasi@gmail.com>
date Thu, 02 Jul 2015 22:26:16 +0100
parents d6879b59f46f
children 557979395ca9
files scripts/special-matrix/gallery.m
diffstat 1 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/special-matrix/gallery.m	Thu Jul 02 17:11:29 2015 -0400
+++ b/scripts/special-matrix/gallery.m	Thu Jul 02 22:26:16 2015 +0100
@@ -592,7 +592,7 @@
     case (0), # do nothing
     case (1), n = n + 1;
     otherwise
-      error ("gallery: unknown K '%d' for chebspec matrix.", k);
+      error ("gallery: K should be either 0 or 1 for chebspec matrix.");
   endswitch
 
   n -= 1;
@@ -911,7 +911,7 @@
   endif
 endfunction
 
-function A = cycol (n, k)
+function A = cycol (n, k = max (round (n/4), 1))
   ## CYCOL   Matrix whose columns repeat cyclically.
   ##   A = CYCOL([M N], K) is an M-by-N matrix of the form A = B(1:M,1:N)
   ##   where B = [C C C...] and C = RANDN(M, K).  Thus A's columns repeat
@@ -934,10 +934,6 @@
   m = n(1);
   n = n(end);
 
-  if (nargin < 2)
-    k = max (round (n/4), 1);
-  endif
-
   A = randn (m, k);
   for i = 2:ceil (n/k)
     A = [A A(:,1:k)];
@@ -1215,9 +1211,9 @@
     error ("gallery: 1 to 3 arguments are required for gearmat matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for gearmat matrix.");
-  elseif (! isnumeric (i) || ! isscalar (i) || i == 0 || abs (i) <= n)
+  elseif (! isnumeric (i) || ! isscalar (i) || i == 0 || abs (i) > n)
     error ("gallery: I must be a nonzero scalar, and abs (I) <= N for gearmat matrix.");
-  elseif (! isnumeric (j) || ! isscalar (j) || i == 0 || abs (j) <= n)
+  elseif (! isnumeric (j) || ! isscalar (j) || i == 0 || abs (j) > n)
     error ("gallery: J must be a nonzero scalar, and abs (J) <= N for gearmat matrix.");
   endif
 
@@ -1271,7 +1267,7 @@
     error ("gallery: N must be an integer for hanowa matrix.");
   elseif (rem (n, 2) != 0)
     error ("gallery: N must be even for hanowa matrix.");
-  elseif (! isnumeric (lambda) || ! isscalar (lambda))
+  elseif (! isnumeric (d) || ! isscalar (d))
     error ("gallery: D must be a numeric scalar for hanowa matrix.");
   endif
 
@@ -1605,8 +1601,8 @@
     error ("gallery: 1 to 2 arguments are required for lauchli matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for lauchli matrix.")
-  elseif (! isscalar (mu))
-    error ("gallery: MU must be a scalar for lauchli matrix.")
+  elseif (! isscalar (rho))
+    error ("gallery: RHO must be a scalar for lauchli matrix.")
   endif
 
   A = (1:n)'*ones (1,n);
@@ -2015,7 +2011,7 @@
     error ("gallery: 1 to 2 arguments are required for pei matrix.");
   elseif (! isnumeric (n) || ! isscalar (n) || fix (n) != n)
     error ("gallery: N must be an integer for pei matrix.");
-  elseif (! isnumeric (w) || ! isscalar (w))
+  elseif (! isnumeric (alpha) || ! isscalar (alpha))
     error ("gallery: ALPHA must be a scalar for pei matrix.");
   endif