# HG changeset patch # User Rik # Date 1294609455 28800 # Node ID eb9e0b597d61eb1bfe6499239d4b0c35ae05dbca # Parent c776f063fefe4741f920f75e1dfdf4e566865c7a Use common names for variables in documentation and code for a few more m-script files. diff -r c776f063fefe -r eb9e0b597d61 scripts/ChangeLog --- a/scripts/ChangeLog Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/ChangeLog Sun Jan 09 13:44:15 2011 -0800 @@ -1,3 +1,11 @@ +2011-01-09 Rik + + * general/bicubic.m, general/nargchk.m, general/nargoutchk.m, + linear-algebra/krylov.m, linear-algebra/krylovb.m, + linear-algebra/normest.m, linear-algebra/null.m, linear-algebra/orth.m, + linear-algebra/rank.m: Use common names for variables in documentation + and code. + 2011-01-09 Rik * audio/loadaudio.m, audio/mu2lin.m, audio/saveaudio.m, diff -r c776f063fefe -r eb9e0b597d61 scripts/general/bicubic.m --- a/scripts/general/bicubic.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/general/bicubic.m Sun Jan 09 13:44:15 2011 -0800 @@ -32,7 +32,7 @@ ## Bicubic interpolation method. ## Author: Hoxide Ma -function F = bicubic (X, Y, Z, XI, YI, extrapval, spline_alpha) +function zi = bicubic (x, y, z, xi, yi, extrapval, spline_alpha) if (nargin < 1 || nargin > 7) print_usage (); @@ -48,81 +48,81 @@ extrapval = NaN; endif - if (isa (X, "single") || isa (Y, "single") || isa (Z, "single") - || isa (XI, "single") || isa (YI, "single")) + if (isa (x, "single") || isa (y, "single") || isa (z, "single") + || isa (xi, "single") || isa (yi, "single")) myeps = eps("single"); else myeps = eps; endif if (nargin <= 2) - ## bicubic (Z) or bicubic (Z, 2) + ## bicubic (z) or bicubic (z, 2) if (nargin == 1) n = 1; else - n = Y; + n = y; endif - Z = X; - X = []; - [rz, cz] = size (Z); + z = x; + x = []; + [rz, cz] = size (z); s = linspace (1, cz, (cz-1)*pow2(n)+1); t = linspace (1, rz, (rz-1)*pow2(n)+1); elseif (nargin == 3) - if (! isvector (X) || ! isvector (Y)) + if (! isvector (x) || ! isvector (y)) error ("bicubic: XI and YI must be vector"); endif - s = Y; - t = Z; - Z = X; - [rz, cz] = size (Z); + s = y; + t = z; + z = x; + [rz, cz] = size (z); elseif (nargin == 5 || nargin == 6) - [rz, cz] = size (Z) ; - if (isvector (X) && isvector (Y)) - if (rz != length (Y) || cz != length (X)) + [rz, cz] = size (z) ; + if (isvector (x) && isvector (y)) + if (rz != length (y) || cz != length (x)) error ("bicubic: length of X and Y must match the size of Z"); endif - elseif (size_equal (X, Y) && size_equal (X, Z)) - X = X(1,:); - Y = Y(:,1); + elseif (size_equal (x, y) && size_equal (x, z)) + x = x(1,:); + y = y(:,1); else error ("bicubic: X, Y and Z must be equal size matrices of same size"); endif ## Mark values outside the lookup table. - xfirst_ind = find (XI < X(1)); - xlast_ind = find (XI > X(cz)); - yfirst_ind = find (YI < Y(1)); - ylast_ind = find (YI > Y(rz)); + xfirst_ind = find (xi < x(1)); + xlast_ind = find (xi > x(cz)); + yfirst_ind = find (yi < y(1)); + ylast_ind = find (yi > y(rz)); ## Set value outside the table preliminary to min max index. - XI(xfirst_ind) = X(1); - XI(xlast_ind) = X(cz); - YI(yfirst_ind) = Y(1); - YI(ylast_ind) = Y(rz); + xi(xfirst_ind) = x(1); + xi(xlast_ind) = x(cz); + yi(yfirst_ind) = y(1); + yi(ylast_ind) = y(rz); - X = reshape (X, 1, cz); - X(cz) *= 1 + sign (X(cz))*myeps; - if (X(cz) == 0) - X(cz) = myeps; + x = reshape (x, 1, cz); + x(cz) *= 1 + sign (x(cz))*myeps; + if (x(cz) == 0) + x(cz) = myeps; endif; - XI = reshape (XI, 1, length (XI)); - [m, i] = sort ([X, XI]); + xi = reshape (xi, 1, length (xi)); + [m, i] = sort ([x, xi]); o = cumsum (i <= cz); xidx = o(find (i > cz)); - Y = reshape (Y, rz, 1); - Y(rz) *= 1 + sign (Y(rz))*myeps; - if (Y(rz) == 0) - Y(rz) = myeps; + y = reshape (y, rz, 1); + y(rz) *= 1 + sign (y(rz))*myeps; + if (y(rz) == 0) + y(rz) = myeps; endif; - YI = reshape (YI, length (YI), 1); - [m, i] = sort ([Y; YI]); + yi = reshape (yi, length (yi), 1); + [m, i] = sort ([y; yi]); o = cumsum (i <= rz); yidx = o([find(i > rz)]); ## Set s and t used follow codes. - s = xidx + ((XI .- X(xidx))./(X(xidx+1) .- X(xidx))); - t = yidx + ((YI - Y(yidx))./(Y(yidx+1) - Y(yidx))); + s = xidx + ((xi .- x(xidx))./(x(xidx+1) .- x(xidx))); + t = yidx + ((yi - y(yidx))./(y(yidx+1) - y(yidx))); else print_usage (); endif @@ -145,8 +145,8 @@ t(d) = 1.0; d = []; - p = zeros (size (Z) + 2); - p(2:rz+1,2:cz+1) = Z; + p = zeros (size (z) + 2); + p(2:rz+1,2:cz+1) = z; p(1,:) = (6*(1-a))*p(2,:) - 3*p(3,:) + (6*a-2)*p(4,:); p(rz+2,:) = (6*(1-a))*p(rz+1,:) - 3*p(rz,:) + (6*a-2)*p(rz-1,:); p(:,1) = (6*(1-a))*p(:,2) - 3*p(:,3) + (6*a-2)*p(:,4); @@ -178,22 +178,22 @@ lent = length (ct0); lens = columns (cs0); - F = zeros (lent, lens); + zi = zeros (lent, lens); for i = 1:lent it = indt(i); int = [it, it+1, it+2, it+3]; - F(i,:) = ([ct0(i),ct1(i),ct2(i),ct3(i)] + zi(i,:) = ([ct0(i),ct1(i),ct2(i),ct3(i)] * (p(int,inds) .* cs0 + p(int,inds+1) .* cs1 + p(int,inds+2) .* cs2 + p(int,inds+3) .* cs3)); endfor ## Set points outside the table to extrapval. if (! (isempty (xfirst_ind) && isempty (xlast_ind))) - F(:, [xfirst_ind, xlast_ind]) = extrapval; + zi(:, [xfirst_ind, xlast_ind]) = extrapval; endif if (! (isempty (yfirst_ind) && isempty (ylast_ind))) - F([yfirst_ind; ylast_ind], :) = extrapval; + zi([yfirst_ind; ylast_ind], :) = extrapval; endif endfunction diff -r c776f063fefe -r eb9e0b597d61 scripts/general/nargchk.m --- a/scripts/general/nargchk.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/general/nargchk.m Sun Jan 09 13:44:15 2011 -0800 @@ -30,25 +30,25 @@ ## Author: Bill Denney -function msg = nargchk (mina, maxa, narg, outtype) +function msg = nargchk (minargs, maxargs, nargs, outtype) if (nargin < 3 || nargin > 4) print_usage (); - elseif (mina > maxa) - error ("nargchk: minargs must be <= maxargs"); + elseif (minargs > maxargs) + error ("nargchk: MINARGS must be <= MAXARGS"); elseif (nargin == 3) outtype = "string"; elseif (! any (strcmpi (outtype, {"string", "struct"}))) error ("nargchk: output type must be either string or struct"); - elseif (! (isscalar (mina) && isscalar (maxa) && isscalar (narg))) - error ("nargchk: mina, maxa, and narg must be scalars"); + elseif (! (isscalar (minargs) && isscalar (maxargs) && isscalar (nargs))) + error ("nargchk: MINARGS, MAXARGS, and NARGS must be scalars"); endif msg = struct ("message", "", "identifier", ""); - if (narg < mina) + if (nargs < minargs) msg.message = "not enough input arguments"; msg.identifier = "Octave:nargchk:not-enough-inputs"; - elseif (narg > maxa) + elseif (nargs > maxargs) msg.message = "too many input arguments"; msg.identifier = "Octave:nargchk:too-many-inputs"; endif diff -r c776f063fefe -r eb9e0b597d61 scripts/general/nargoutchk.m --- a/scripts/general/nargoutchk.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/general/nargoutchk.m Sun Jan 09 13:44:15 2011 -0800 @@ -30,25 +30,25 @@ ## Author: Bill Denney -function msg = nargoutchk (mina, maxa, narg, outtype) +function msg = nargoutchk (minargs, maxargs, nargs, outtype) if (nargin < 3 || nargin > 4) print_usage (); - elseif (mina > maxa) - error ("nargoutchk: minargs must be <= maxargs"); + elseif (minargs > maxargs) + error ("nargoutchk: MINARGS must be <= MAXARGS"); elseif (nargin == 3) outtype = "string"; elseif (! any (strcmpi (outtype, {"string" "struct"}))) error ("nargoutchk: output type must be either string or struct"); - elseif (! (isscalar (mina) && isscalar (maxa) && isscalar (narg))) - error ("nargoutchk: mina, maxa, and narg must be scalars"); + elseif (! (isscalar (minargs) && isscalar (maxargs) && isscalar (nargs))) + error ("nargoutchk: MINARGS, MAXARGS, and NARGS must be scalars"); endif msg = struct ("message", "", "identifier", ""); - if (narg < mina) + if (nargs < minargs) msg.message = "not enough output arguments"; msg.identifier = "Octave:nargoutchk:not-enough-outputs"; - elseif (narg > maxa) + elseif (nargs > maxargs) msg.message = "too many output arguments"; msg.identifier = "Octave:nargoutchk:too-many-outputs"; endif diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/krylov.m --- a/scripts/linear-algebra/krylov.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/krylov.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,7 +18,7 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{u}, @var{h}, @var{nu}] =} krylov (@var{a}, @var{v}, @var{k}, @var{eps1}, @var{pflg}) +## @deftypefn {Function File} {[@var{u}, @var{h}, @var{nu}] =} krylov (@var{A}, @var{V}, @var{k}, @var{eps1}, @var{pflg}) ## Construct an orthogonal basis @var{u} of block Krylov subspace ## ## @example @@ -28,13 +28,13 @@ ## @noindent ## Using Householder reflections to guard against loss of orthogonality. ## -## If @var{v} is a vector, then @var{h} contains the Hessenberg matrix +## If @var{V} is a vector, then @var{h} contains the Hessenberg matrix ## such that @code{a*u == u*h+rk*ek'}, in which @code{rk = ## a*u(:,k)-u*h(:,k)}, and @code{ek'} is the vector ## @code{[0, 0, @dots{}, 1]} of length @code{k}. Otherwise, @var{h} is ## meaningless. ## -## If @var{v} is a vector and @var{k} is greater than +## If @var{V} is a vector and @var{k} is greater than ## @code{length(A)-1}, then @var{h} contains the Hessenberg matrix such ## that @code{a*u == u*h}. ## @@ -42,7 +42,7 @@ ## subspace (based on @var{eps1}). ## ## If @var{b} is a vector and @var{k} is greater than @var{m-1}, then -## @var{h} contains the Hessenberg decomposition of @var{a}. +## @var{h} contains the Hessenberg decomposition of @var{A}. ## ## The optional parameter @var{eps1} is the threshold for zero. The ## default value is 1e-12. diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/krylovb.m --- a/scripts/linear-algebra/krylovb.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/krylovb.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,7 +18,7 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{u}, @var{ucols}] =} krylovb (@var{a}, @var{v}, @var{k}, @var{eps1}, @var{pflg}) +## @deftypefn {Function File} {[@var{u}, @var{ucols}] =} krylovb (@var{A}, @var{V}, @var{k}, @var{eps1}, @var{pflg}) ## See @code{krylov}. ## @end deftypefn diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/normest.m --- a/scripts/linear-algebra/normest.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/normest.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,12 +18,12 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {@var{n} =} normest (@var{a}) -## @deftypefnx {Function File} {@var{n} =} normest (@var{a}, @var{tol}) +## @deftypefn {Function File} {@var{n} =} normest (@var{A}) +## @deftypefnx {Function File} {@var{n} =} normest (@var{A}, @var{tol}) ## @deftypefnx {Function File} {[@var{n}, @var{c}] =} normest (@dots{}) -## Estimate the 2-norm of the matrix @var{a} using a power series +## Estimate the 2-norm of the matrix @var{A} using a power series ## analysis. This is typically used for large matrices, where the cost -## of calculating @code{norm (@var{a})} is prohibitive and an approximation +## of calculating @code{norm (@var{A})} is prohibitive and an approximation ## to the 2-norm is acceptable. ## ## @var{tol} is the tolerance to which the 2-norm is calculated. By default diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/null.m --- a/scripts/linear-algebra/null.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/null.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,15 +18,15 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} null (@var{a}, @var{tol}) -## Return an orthonormal basis of the null space of @var{a}. +## @deftypefn {Function File} {} null (@var{A}, @var{tol}) +## Return an orthonormal basis of the null space of @var{A}. ## ## The dimension of the null space is taken as the number of singular -## values of @var{a} not greater than @var{tol}. If the argument @var{tol} +## values of @var{A} not greater than @var{tol}. If the argument @var{tol} ## is missing, it is computed as ## ## @example -## max (size (@var{a})) * max (svd (@var{a})) * eps +## max (size (@var{A})) * max (svd (@var{A})) * eps ## @end example ## @seealso{orth} ## @end deftypefn diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/orth.m --- a/scripts/linear-algebra/orth.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/orth.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,15 +18,15 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} orth (@var{a}, @var{tol}) -## Return an orthonormal basis of the range space of @var{a}. +## @deftypefn {Function File} {} orth (@var{A}, @var{tol}) +## Return an orthonormal basis of the range space of @var{A}. ## ## The dimension of the range space is taken as the number of singular -## values of @var{a} greater than @var{tol}. If the argument @var{tol} is +## values of @var{A} greater than @var{tol}. If the argument @var{tol} is ## missing, it is computed as ## ## @example -## max (size (@var{a})) * max (svd (@var{a})) * eps +## max (size (@var{A})) * max (svd (@var{A})) * eps ## @end example ## @seealso{null} ## @end deftypefn diff -r c776f063fefe -r eb9e0b597d61 scripts/linear-algebra/rank.m --- a/scripts/linear-algebra/rank.m Sun Jan 09 12:41:21 2011 -0800 +++ b/scripts/linear-algebra/rank.m Sun Jan 09 13:44:15 2011 -0800 @@ -18,19 +18,19 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {} rank (@var{a}, @var{tol}) -## Compute the rank of @var{a}, using the singular value decomposition. -## The rank is taken to be the number of singular values of @var{a} that +## @deftypefn {Function File} {} rank (@var{A}, @var{tol}) +## Compute the rank of @var{A}, using the singular value decomposition. +## The rank is taken to be the number of singular values of @var{A} that ## are greater than the specified tolerance @var{tol}. If the second ## argument is omitted, it is taken to be ## ## @example -## tol = max (size (@var{a})) * sigma(1) * eps; +## tol = max (size (@var{A})) * sigma(1) * eps; ## @end example ## ## @noindent ## where @code{eps} is machine precision and @code{sigma(1)} is the largest -## singular value of @var{a}. +## singular value of @var{A}. ## @end deftypefn ## Author: jwe