# HG changeset patch # User jwe # Date 948271814 0 # Node ID e031284eea27befe6e0a6e771d6a97c49022bd81 # Parent 434790acb067ccfc285ffee13fa90788dcdaebf9 [project @ 2000-01-19 08:49:56 by jwe] diff --git a/scripts/general/rem.m b/scripts/general/rem.m --- a/scripts/general/rem.m +++ b/scripts/general/rem.m @@ -35,8 +35,10 @@ function retval = rem (x, y) + usage_msg = "rem (x, y)"; + if (nargin != 2) - usage ("rem (x, y)"); + usage (usage_msg); endif if (any (size (x) != size (y)) && ! (is_scalar (x) || is_scalar (y))) @@ -53,7 +55,7 @@ if (nargin == 2) retval = x - y .* fix (x ./ y); else - error ("usage: rem (x, y)"); + error (usage_msg); endif endfunction diff --git a/scripts/general/shift.m b/scripts/general/shift.m --- a/scripts/general/shift.m +++ b/scripts/general/shift.m @@ -29,7 +29,7 @@ function y = shift (x, b) if (nargin != 2) - error ("usage: shift (X, b)"); + usage ("shift (X, b)"); endif [nr, nc] = size (x); diff --git a/scripts/image/colormap.m b/scripts/image/colormap.m --- a/scripts/image/colormap.m +++ b/scripts/image/colormap.m @@ -63,10 +63,10 @@ if (! isempty (map)) if (columns (map) != 3) - error( "colormap: map must have 3 columns: [R,G,B]." ); + error ("colormap: map must have 3 columns: [R,G,B]."); endif if (min (min (map)) < 0 || max (max (map)) > 1) - error( "colormap: map must have values in [0,1]." ); + error ("colormap: map must have values in [0,1]."); endif ## Set the new color map __current_color_map__ = map; diff --git a/scripts/image/image.m b/scripts/image/image.m --- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -24,8 +24,7 @@ ## length of the colormap. If @var{zoom} is omitted, a value of 4 is ## assumed. ## @end deftypefn - -## SEE ALSO: imshow, imagesc, colormap. +## @seealso{imshow, imagesc, and colormap} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/imagesc.m b/scripts/image/imagesc.m --- a/scripts/image/imagesc.m +++ b/scripts/image/imagesc.m @@ -24,8 +24,7 @@ ## colormap. The scaled matrix is returned. If @var{zoom} is omitted, a ## value of 4 is assumed. ## @end deftypefn - -## SEE ALSO: image, imshow +## @seealso{image and imshow} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/imshow.m b/scripts/image/imshow.m --- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -34,8 +34,7 @@ ## ## @code{imshow (@var{r}, @var{g}, @var{b})} displays an RGB image. ## @end deftypefn - -## SEE ALSO: image, imagesc, colormap, gray2ind, rgb2ind. +## @seealso{image, imagesc, colormap, gray2ind, and rgb2ind} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/ind2gray.m b/scripts/image/ind2gray.m --- a/scripts/image/ind2gray.m +++ b/scripts/image/ind2gray.m @@ -23,8 +23,7 @@ ## If @var{map} is omitted, the current colormap is used to determine the ## intensities. ## @end deftypefn - -## SEE ALSO: gray2ind, rgb2ntsc, image, colormap +## @seealso{gray2ind, rgb2ntsc, image, and colormap} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/ind2rgb.m b/scripts/image/ind2rgb.m --- a/scripts/image/ind2rgb.m +++ b/scripts/image/ind2rgb.m @@ -22,8 +22,7 @@ ## Convert an indexed image to red, green, and blue color components. ## If @var{map} is omitted, the current colormap is used for the conversion. ## @end deftypefn - -## SEE ALSO: rgb2ind, image, imshow, ind2gray, gray2ind. +## @seealso{rgb2ind, image, imshow, ind2gray, and gray2ind} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/loadimage.m b/scripts/image/loadimage.m --- a/scripts/image/loadimage.m +++ b/scripts/image/loadimage.m @@ -22,8 +22,7 @@ ## Load an image file and it's associated color map from the specified ## @var{file}. The image must be stored in Octave's image format. ## @end deftypefn - -## SEE ALSO: saveimage, load, save +## @seealso{saveimage, load, and save} ## Author: Tony Richardson ## Created: July 1994 diff --git a/scripts/image/rgb2ind.m b/scripts/image/rgb2ind.m --- a/scripts/image/rgb2ind.m +++ b/scripts/image/rgb2ind.m @@ -21,9 +21,8 @@ ## @deftypefn {Function File} {[@var{x}, @var{map}] =} rgb2ind (@var{r}, @var{g}, @var{b}) ## Convert and RGB image to an Octave indexed image. ## @end deftypefn +## @seealso{ind2rgb and rgb2ntsc} -## SEE ALSO: ind2rgb, rgb2ntsc. -## ## Bugs: The color map may have duplicate entries. ## Author: Tony Richardson diff --git a/scripts/image/saveimage.m b/scripts/image/saveimage.m --- a/scripts/image/saveimage.m +++ b/scripts/image/saveimage.m @@ -52,8 +52,7 @@ ## University of British Columbia ## ## and is part of the portable bitmap utilities, - -## SEE ALSO: loadimage, save, load, colormap +## @seealso{loadimage, save, load, and colormap} ## Author: Tony Richardson ## Created: July 1994 @@ -270,7 +269,7 @@ fprintf (fid, "%%%%Pages: 1\n"); fprintf (fid, "%%%%BoundingBox: %d %d %d %d\n", fix (llx), fix (lly), fix (urx), fix (ury)); - fprintf (fid, "%%%%EndComments\n" ); + fprintf (fid, "%%%%EndComments\n"); fprintf (fid, "/readstring {\n"); fprintf (fid, " currentfile exch readhexstring pop\n"); fprintf (fid, "} bind def\n"); @@ -283,8 +282,8 @@ fprintf (fid, "%g %g scale\n", scols, srows); fprintf (fid, "%d %d %d\n", img_nr, img_nc, bps); fprintf (fid, "[ %d 0 0 -%d 0 %d ]\n", img_nr, img_nc, img_nc); - fprintf (fid, "{ picstr readstring }\n" ); - fprintf (fid, "image\n" ); + fprintf (fid, "{ picstr readstring }\n"); + fprintf (fid, "image\n"); img = map(img); @@ -292,12 +291,12 @@ fprintf (fid, fmt, img); if (rem (img_sz, 30) != 0) - fprintf (fid, "\n" ); + fprintf (fid, "\n"); endif - fprintf (fid, "grestore\n" ); - fprintf (fid, "showpage\n" ); - fprintf (fid, "%%%%Trailer\n" ); + fprintf (fid, "grestore\n"); + fprintf (fid, "showpage\n"); + fprintf (fid, "%%%%Trailer\n"); fclose (fid); else diff --git a/scripts/io/puts.m b/scripts/io/puts.m --- a/scripts/io/puts.m +++ b/scripts/io/puts.m @@ -21,8 +21,7 @@ ## @deftypefn {Function File} {} puts (@var{string}) ## Write a string to the standard output with no formatting. ## @end deftypefn - -## See also: fputs, printf, fprintf +## @seealso{fputs, printf and fprintf} ## Author: jwe diff --git a/scripts/linear-algebra/krylov.m b/scripts/linear-algebra/krylov.m --- a/scripts/linear-algebra/krylov.m +++ b/scripts/linear-algebra/krylov.m @@ -46,38 +46,49 @@ function [Uret,H,nu] = krylov(A,V,k,eps1,pflg); defeps = 1e-12; - if(nargin < 3 | nargin > 5) - usage("[U,nu] = krylov(A,V,k{,eps1,pflg})") - elseif(nargin < 5) + + if (nargin < 3 || nargin > 5) + usage ("[U, nu] = krylov (A, V, k, eps1, pflg)") + elseif (nargin < 5) pflg = 0; # default permutation flag endif + if(nargin < 4) eps1 = defeps; # default tolerance parameter endif - if(isempty(eps1)) eps1 = defeps; endif - - na = is_square(A); - if( !na ) error("A(%d x %d) must be square",rows(A),columns(A)); endif - [m,kb] = size(V); - if(m != na); - error("A(%d x %d), V(%d x %d): argument dimensions do not match", ... - na,na,m,kb) + if (isempty (eps1)) + eps1 = defeps; + endif + + na = is_square (A); + if (! na) + error ("A(%d x %d) must be square", rows (A), columns (A)); endif - if( !is_scalar(k) ) - error("krylov: third argument must be a scalar integer") + [m, kb] = size(V); + if (m != na) + error("A(%d x %d), V(%d x %d): argument dimensions do not match", + na, na, m, kb) endif - Vnrm = norm(V,Inf); + if (! is_scalar (k)) + error ("krylov: third argument must be a scalar integer"); + endif + + Vnrm = norm (V, Inf); - # check for trivial solution - if(Vnrm == 0) - Uret = []; nu = 0; return; + ## check for trivial solution + if (Vnrm == 0) + Uret = []; + nu = 0; + return; endif # identify trivial null space - abm = max(abs([A,V]')); nzidx = find(abm != 0); zidx = find(abm == 0); + abm = max (abs ([A, V]')); + nzidx = find (abm != 0); + zidx = find (abm == 0); # set up vector of pivot points pivot_vec = 1:na; @@ -85,85 +96,86 @@ iter = 0; alpha = []; nh = 0; - while (length(alpha) < na) & (columns(V) > 0) & (iter < k) + while (length(alpha) < na) && (columns(V) > 0) && (iter < k) iter++; - # get orthogonal basis of V + ## get orthogonal basis of V jj = 1; - while(jj <= columns(V) & length(alpha) < na) - nu = length(alpha)+1; # index of next Householder reflection + while (jj <= columns (V) && length (alpha) < na) + ## index of next Householder reflection + nu = length(alpha)+1; short_pv = pivot_vec(nu:na); q = V(:,jj); short_q = q(short_pv); - if(norm(short_q) < eps1) - # insignificant column; delete - nv = columns(V); - if(jj != nv) - [V(:,jj),V(:,nv)] = swap(V(:,jj),V(:,nv)); - # FIX ME: H columns should be swapped too. Not done since - # Block Hessenberg structure is lost anyway. + if (norm (short_q) < eps1) + ## insignificant column; delete + nv = columns (V); + if (jj != nv) + [V(:,jj), V(:,nv)] = swap (V(:,jj), V(:,nv)); + ## XXX FIXME XXX -- H columns should be swapped too. Not done + ## since Block Hessenberg structure is lost anyway. endif V = V(:,1:(nv-1)); - nu = nu - 1; # one less reflection - + ## one less reflection + nu--; else - # new householder reflection - if(pflg) - # locate max magnitude element in short_q - asq = abs(short_q); - maxv = max(asq); - maxidx = find(asq == maxv); + ## new householder reflection + if (pflg) + ## locate max magnitude element in short_q + asq = abs (short_q); + maxv = max (asq); + maxidx = find (asq == maxv); pivot_idx = short_pv(maxidx(1)); - # see if need to change the pivot list - if(pivot_idx != pivot_vec(nu)) + ## see if need to change the pivot list + if (pivot_idx != pivot_vec(nu)) swapidx = maxidx(1) + (nu-1); - [pivot_vec(nu),pivot_vec(swapidx)] = ... - swap(pivot_vec(nu),pivot_vec(swapidx)); + [pivot_vec(nu), pivot_vec(swapidx)] = ... + swap (pivot_vec(nu), pivot_vec(swapidx)); endif endif - # isolate portion of vector for reflection + ## isolate portion of vector for reflection idx = pivot_vec(nu:na); jdx = pivot_vec(1:nu); - [hv,av,z] = housh(q(idx),1,0); + [hv, av, z] = housh (q(idx), 1, 0); alpha(nu) = av; U(idx,nu) = hv; # reduce V per the reflection V(idx,:) = V(idx,:) - av*hv*(hv' * V(idx,:)); if(iter > 1) - # FIX ME: not done correctly for block case + ## XXX FIXME XXX -- not done correctly for block case H(nu,nu-1) = V(pivot_vec(nu),jj); endif - # advance to next column of V - jj=jj+1; + ## advance to next column of V + jj++; endif endwhile - # check for oversize V (due to full rank) - if( ( columns(V) > na ) & ( length(alpha) == na ) ) - # trim to size + ## check for oversize V (due to full rank) + if ((columns (V) > na) && (length (alpha) == na)) + ## trim to size V = V(:,1:na); - elseif( columns(V) > na ) + elseif (columns(V) > na) krylov_V = V krylov_na = na - krylov_length_alpha = length(alpha) - error("This case should never happen; submit bug report."); + krylov_length_alpha = length (alpha) + error ("This case should never happen; submit a bug report"); endif - if(columns(V) > 0) - # construct next Q and multiply - Q = zeros(size(V)); - for kk=1:columns(Q) + if (columns (V) > 0) + ## construct next Q and multiply + Q = zeros (size (V)); + for kk = 1:columns (Q) Q(pivot_vec(nu-columns(Q)+kk),kk) = 1; endfor - # apply Householder reflections + ## apply Householder reflections for ii = nu:-1:1 idx = pivot_vec(ii:na); hv = U(idx,ii); @@ -172,34 +184,36 @@ endfor endif - # multiply to get new vector; + ## multiply to get new vector; V = A*Q; - # project off of previous vectors - nu = length(alpha); - for i=1:nu - hv = U(:,i); av = alpha(i); + ## project off of previous vectors + nu = length (alpha); + for i = 1:nu + hv = U(:,i); + av = alpha(i); V = V - av*hv*(hv'*V); H(i,nu-columns(V)+(1:columns(V))) = V(pivot_vec(i),:); end endwhile - # Back out complete U matrix - # back out U matrix ; - j1 = columns(U); - for i=j1:-1:1; + ## Back out complete U matrix + ## back out U matrix ; + j1 = columns (U); + for i = j1:-1:1; idx = pivot_vec(i:na); hv = U(idx,i); av = alpha(i); - U(:,i) = zeros(na,1); + U(:,i) = zeros (na, 1); U(idx(1),i) = 1; U(idx,i:j1) = U(idx,i:j1)-av*hv*(hv'*U(idx,i:j1)); endfor - nu = length(alpha); + nu = length (alpha); Uret = U; - if( max(max( abs(Uret(zidx,:)) )) > 0) - warning("krylov: trivial null space corrupted; set pflg=1 or eps1>%e",eps1); + if (max (max (abs (Uret(zidx,:)))) > 0) + warning ("krylov: trivial null space corrupted; set pflg = 1 or eps1 > %e", + eps1); endif endfunction diff --git a/scripts/linear-algebra/norm.m b/scripts/linear-algebra/norm.m --- a/scripts/linear-algebra/norm.m +++ b/scripts/linear-algebra/norm.m @@ -60,7 +60,7 @@ function retval = norm (x, p) if (nargin < 1 || nargin > 2) - error ("usage: norm (x, p)"); + usage ("norm (x, p)"); endif if (isempty (x)) diff --git a/scripts/linear-algebra/qzhess.m b/scripts/linear-algebra/qzhess.m --- a/scripts/linear-algebra/qzhess.m +++ b/scripts/linear-algebra/qzhess.m @@ -49,7 +49,7 @@ function [aa, bb, q, z] = qzhess (a, b) if (nargin != 2) - error ("usage: [aa, bb, q, z] = qzhess (a, b)"); + usage ("[aa, bb, q, z] = qzhess (a, b)"); endif [na, ma] = size (a); diff --git a/scripts/plot/grid.m b/scripts/plot/grid.m --- a/scripts/plot/grid.m +++ b/scripts/plot/grid.m @@ -30,6 +30,8 @@ function grid (x) + usage_msg = "grid (\"on\" | \"off\")"; + if (nargin == 0) gset grid; elseif (nargin == 1) @@ -39,13 +41,13 @@ elseif (strcmp ("on", x)) gset grid; else - usage ("grid (\"on\" | \"off\")"); + usage (usage_msg); endif else error ("grid: argument must be a string"); endif else - error ("usage: grid (\"on\" | \"off\")"); + usage (usage_msg); endif endfunction diff --git a/scripts/polynomial/compan.m b/scripts/polynomial/compan.m --- a/scripts/polynomial/compan.m +++ b/scripts/polynomial/compan.m @@ -52,8 +52,8 @@ ## The eigenvalues of the companion matrix are equal to the roots of the ## polynomial. ## @end deftypefn - -## SEE ALSO: poly, roots, residue, conv, deconv, polyval, polyderiv, polyinteg +## @seealso{poly, roots, residue, conv, deconv, polyval, polyderiv, and +## polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/conv.m b/scripts/polynomial/conv.m --- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -26,8 +26,7 @@ ## If @var{a} and @var{b} are polynomial coefficient vectors, @code{conv} ## returns the coefficients of the product polynomial. ## @end deftypefn - -## SEE ALSO: deconv, poly, roots, residue, polyval, polyderiv, polyinteg +## @seealso{deconv, poly, roots, residue, polyval, polyderiv, and polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/deconv.m b/scripts/polynomial/deconv.m --- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -28,8 +28,7 @@ ## contain the coefficients of the polynomial quotient and @var{r} will be ## a remander polynomial of lowest order. ## @end deftypefn - -## SEE ALSO: conv, poly, roots, residue, polyval, polyderiv, polyinteg +## @seealso{conv, poly, roots, residue, polyval, polyderiv, and polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/polyderiv.m b/scripts/polynomial/polyderiv.m --- a/scripts/polynomial/polyderiv.m +++ b/scripts/polynomial/polyderiv.m @@ -22,9 +22,8 @@ ## Return the coefficients of the derivative of the polynomial whose ## coefficients are given by vector @var{c}. ## @end deftypefn - -## SEE ALSO: poly, polyinteg, polyreduce, roots, conv, deconv, residue, -## filter, polyval, polyvalm +## @seealso{poly, polyinteg, polyreduce, roots, conv, deconv, residue, +## filter, polyval, and polyvalm} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/polyinteg.m b/scripts/polynomial/polyinteg.m --- a/scripts/polynomial/polyinteg.m +++ b/scripts/polynomial/polyinteg.m @@ -24,9 +24,8 @@ ## ## The constant of integration is set to zero. ## @end deftypefn - -## SEE ALSO: poly, polyderiv, polyreduce, roots, conv, deconv, residue, -## filter, polyval, polyvalm +## @seealso{poly, polyderiv, polyreduce, roots, conv, deconv, residue, +## filter, polyval, and polyvalm} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/polyout.m b/scripts/polynomial/polyout.m --- a/scripts/polynomial/polyout.m +++ b/scripts/polynomial/polyout.m @@ -17,12 +17,13 @@ ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{y} =} polyout (@var{c}@{, @var{x}@}) -## write formatted polynomial +## @deftypefn {Function File} polyout (@var{c}, @var{x}) +## Write formatted polynomial ## @example ## c(x) = c(1) * x^n + ... + c(n) x + c(n+1) ## @end example -## to string @var{y} or to the screen (if @var{y} is omitted) +## and return it as a string or write it to the screen (if +## @var{nargout} is zero). ## @var{x} defaults to the string @code{"s"} ## @end deftypefn ## @seealso{polyval, polyvalm, poly, roots, conv, deconv, residue, @@ -34,17 +35,17 @@ function y = polyout (c, x) - if (nargin < 1 ) || (nargin > 2) || (nargout < 0 ) || (nargout > 1) - usage("[y = ] polyout(c,[x])"); + if (nargin < 1) || (nargin > 2) || (nargout < 0) || (nargout > 1) + usage("polyout (c, x)"); endif - if (!is_vector(c)) + if (! is_vector (c)) error("polyout: first argument must be a vector"); endif if (nargin == 1) x = "s"; - elseif( ! isstr(x) ) + elseif (! isstr(x)) error("polyout: second argument must be a string"); endif @@ -52,17 +53,27 @@ if(n > 0) n1 = n+1; - if( imag(c(1)) ) tmp = com2str(c(1)) - else tmp = num2str(c(1)); endif + if (imag (c(1))) + tmp = com2str(c(1)) + else + tmp = num2str(c(1)); + endif - for ii=2:n - if(real(c(ii)) < 0) ns = " - "; c(ii) = -c(ii); - else ns = " + "; endif + for ii = 2:n + if (real (c(ii)) < 0) + ns = " - "; + c(ii) = -c(ii); + else + ns = " + "; + endif - if( imag(c(ii)) ) nstr = sprintf("(%s)",com2str(c(ii)) ); - else nstr = num2str(c(ii)); endif + if (imag (c(ii))) + nstr = sprintf ("(%s)", com2str (c(ii))); + else + nstr = num2str (c(ii)); + endif - tmp = sprintf("%s*%s^%d%s%s",tmp,x,n1-ii,ns,nstr); + tmp = sprintf ("%s*%s^%d%s%s", tmp, x, n1-ii, ns, nstr); endfor else diff --git a/scripts/polynomial/polyreduce.m b/scripts/polynomial/polyreduce.m --- a/scripts/polynomial/polyreduce.m +++ b/scripts/polynomial/polyreduce.m @@ -22,9 +22,8 @@ ## Reduces a polynomial coefficient vector to a minimum number of terms by ## stripping off any leading zeros. ## @end deftypefn - -## SEE ALSO: poly, roots, conv, deconv, residue, filter, polyval, polyvalm, -## polyderiv, polyinteg +## @seealso{poly, roots, conv, deconv, residue, filter, polyval, +## polyvalm, polyderiv, and polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/polyval.m b/scripts/polynomial/polyval.m --- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -27,9 +27,8 @@ ## If @var{x} is a vector or matrix, the polynomial is evaluated at each of ## the elements of @var{x}. ## @end deftypefn - -## SEE ALSO: polyvalm, poly, roots, conv, deconv, residue, filter, -## polyderiv, polyinteg +## @seealso{polyvalm, poly, roots, conv, deconv, residue, filter, +## polyderiv, and polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/polyvalm.m b/scripts/polynomial/polyvalm.m --- a/scripts/polynomial/polyvalm.m +++ b/scripts/polynomial/polyvalm.m @@ -27,9 +27,8 @@ ## ## The argument @var{x} must be a square matrix. ## @end deftypefn - -## SEE ALSO: polyval, poly, roots, conv, deconv, residue, filter, -## polyderiv, polyinteg +## @seealso{polyval, poly, roots, conv, deconv, residue, filter, +## polyderiv, and polyinteg) ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/polynomial/residue.m b/scripts/polynomial/residue.m --- a/scripts/polynomial/residue.m +++ b/scripts/polynomial/residue.m @@ -100,8 +100,7 @@ ## @end example ## @end ifinfo ## @end deftypefn - -## SEE ALSO: poly, roots, conv, deconv, polyval, polyderiv, polyinteg +## @seealso{poly, roots, conv, deconv, polyval, polyderiv, and polyinteg} ## Author: Tony Richardson ## Created: June 1994 diff --git a/scripts/quaternion/quaternion.m b/scripts/quaternion/quaternion.m --- a/scripts/quaternion/quaternion.m +++ b/scripts/quaternion/quaternion.m @@ -109,7 +109,7 @@ a = [w, x, y, z]; otherwise - error ("usage: [a, b, c, d] = quaternion (w), a = quaternion (w, x, y, z)"); + usage ("[a, b, c, d] = quaternion (w) or a = quaternion (w, x, y, z)"); endswitch diff --git a/scripts/set/create_set.m b/scripts/set/create_set.m --- a/scripts/set/create_set.m +++ b/scripts/set/create_set.m @@ -35,7 +35,7 @@ function y = create_set(x) - if ( nargin != 1) + if (nargin != 1) usage ("create_set(x)"); endif diff --git a/scripts/signal/arch_fit.m b/scripts/signal/arch_fit.m --- a/scripts/signal/arch_fit.m +++ b/scripts/signal/arch_fit.m @@ -43,8 +43,8 @@ ## for the scoring algorithm. ## @end deftypefn -## Author: KH -## Description: Fit an ARCH regression model +## Author: KH +## Description: Fit an ARCH regression model function [a, b] = arch_fit (y, X, p, ITER, gamma, a0, b0) @@ -52,8 +52,8 @@ usage ("arch_fit (y, X, p, ITER, gamma, a0, b0)"); endif - if !(is_vector (y)) - error ("arch_test: y must be a vector"); + if (! (is_vector (y))) + error ("arch_test: y must be a vector"); endif T = length (y); @@ -61,9 +61,8 @@ [rx, cx] = size (X); if ((rx == 1) && (cx == 1)) X = autoreg_matrix (y, X); - elseif !(rx == T) - error (["arch_test: ", ... - "either rows (X) == length (y), or X is a scalar"]); + elseif (! (rx == T)) + error ("arch_test: either rows (X) == length (y), or X is a scalar"); endif [T, k] = size (X); diff --git a/scripts/signal/arch_rnd.m b/scripts/signal/arch_rnd.m --- a/scripts/signal/arch_rnd.m +++ b/scripts/signal/arch_rnd.m @@ -33,8 +33,8 @@ ## @end example ## @end deftypefn -## Author: KH -## Description: Simulate an ARCH process +## Author: KH +## Description: Simulate an ARCH process function y = arch_rnd (a, b, T) @@ -42,15 +42,15 @@ usage ("arch_rnd (a, b, T)"); endif - if !( (min (size (a)) == 1) && (min (size (b)) == 1) ) - error ("arch_rnd: a and b must both be scalars or vectors"); + if (! ((min (size (a)) == 1) && (min (size (b)) == 1))) + error ("arch_rnd: a and b must both be scalars or vectors"); endif - if !( is_scalar (T) && (T > 0) && (rem (T, 1) == 0) ) - error ("arch_rnd: T must be a positive integer"); + if (! (is_scalar (T) && (T > 0) && (rem (T, 1) == 0))) + error ("arch_rnd: T must be a positive integer"); endif - if !(a(1) > 0) - error ("arch_rnd: a(1) must be positive"); + if (! (a(1) > 0)) + error ("arch_rnd: a(1) must be positive"); endif ## perhaps add a test for the roots of a(z) here ... diff --git a/scripts/signal/arch_test.m b/scripts/signal/arch_test.m --- a/scripts/signal/arch_test.m +++ b/scripts/signal/arch_test.m @@ -60,8 +60,8 @@ ## If no output argument is given, the @var{p}-value is displayed. ## @end deftypefn -## Author: KH -## Description: Test for conditional heteroscedascity +## Author: KH +## Description: Test for conditional heteroscedascity function [pval, lm] = arch_test (y, X, p) @@ -69,20 +69,19 @@ error ("arch_test needs 3 input arguments"); endif - if !(is_vector (y)) - error ("arch_test: y must be a vector"); + if (! (is_vector (y))) + error ("arch_test: y must be a vector"); endif T = length (y); y = reshape (y, T, 1); [rx, cx] = size (X); if ((rx == 1) && (cx == 1)) X = autoreg_matrix (y, X); - elseif !(rx == T) - error (["arch_test: ", ... - "either rows(X) == length(y), or X is a scalar"]); + elseif (! (rx == T)) + error ("arch_test: either rows(X) == length(y), or X is a scalar"); endif - if !(is_scalar(p) && (rem(p, 1) == 0) && (p > 0)) - error ("arch_test: p must be a positive integer."); + if (! (is_scalar(p) && (rem(p, 1) == 0) && (p > 0))) + error ("arch_test: p must be a positive integer."); endif [b, v_b, e] = ols (y, X); diff --git a/scripts/signal/arma_rnd.m b/scripts/signal/arma_rnd.m --- a/scripts/signal/arma_rnd.m +++ b/scripts/signal/arma_rnd.m @@ -34,8 +34,8 @@ ## is returned. If @var{n} is omitted, @var{n} = 100 is used. ## @end deftypefn -## Author: FL -## Description: Simulate an ARMA process +## Author: FL +## Description: Simulate an ARMA process function x = arma_rnd (a, b, v, t, n) @@ -53,12 +53,12 @@ usage ("arma_rnd (a, b, v, t, n)"); endif - if ( (min (size (a)) > 1) || (min (size (b)) > 1) ) - error ("arma_rnd: a and b must not be matrices"); + if ((min (size (a)) > 1) || (min (size (b)) > 1)) + error ("arma_rnd: a and b must not be matrices"); endif if (!is_scalar (t)) - error ("arma_rnd: t must be a scalar"); + error ("arma_rnd: t must be a scalar"); endif ar = length (a); diff --git a/scripts/signal/autocor.m b/scripts/signal/autocor.m --- a/scripts/signal/autocor.m +++ b/scripts/signal/autocor.m @@ -22,8 +22,8 @@ ## computed. ## @end deftypefn -## Author: FL -## Description: Compute autocorrelations +## Author: FL +## Description: Compute autocorrelations function retval = autocor (X, h) @@ -36,7 +36,7 @@ endif if (min (retval (1,:)) != 0) - retval = retval ./ ( ones (rows (retval), 1) * retval(1, :) ); + retval = retval ./ (ones (rows (retval), 1) * retval(1,:)); endif endfunction diff --git a/scripts/signal/autocov.m b/scripts/signal/autocov.m --- a/scripts/signal/autocov.m +++ b/scripts/signal/autocov.m @@ -22,8 +22,8 @@ ## computed. ## @end deftypefn -## Author: FL -## Description: Compute autocovariances +## Author: FL +## Description: Compute autocovariances function retval = autocov (X, h) diff --git a/scripts/signal/autoreg_matrix.m b/scripts/signal/autoreg_matrix.m --- a/scripts/signal/autoreg_matrix.m +++ b/scripts/signal/autoreg_matrix.m @@ -24,8 +24,8 @@ ## in autoregressions. ## @end deftypefn -## Author: KH -## Description: Design matrix for autoregressions +## Author: KH +## Description: Design matrix for autoregressions function X = autoreg_matrix (y, k) @@ -33,8 +33,8 @@ usage ("autoreg_matrix (y, k)"); endif - if !(is_vector (y)) - error ("autoreg_matrix: y must be a vector"); + if (! (is_vector (y))) + error ("autoreg_matrix: y must be a vector"); endif T = length (y); diff --git a/scripts/signal/bartlett.m b/scripts/signal/bartlett.m --- a/scripts/signal/bartlett.m +++ b/scripts/signal/bartlett.m @@ -23,8 +23,8 @@ ## R. W. Schafer, "Discrete-Time Signal Processing". ## @end deftypefn -## Author: AW -## Description: Coefficients of the Bartlett (triangular) window +## Author: AW +## Description: Coefficients of the Bartlett (triangular) window function c = bartlett (m) @@ -32,8 +32,8 @@ usage ("bartlett (m)"); endif - if !(is_scalar (m) && (m == round (m)) && (m > 0)) - error ("bartlett: m has to be an integer > 0"); + if (! (is_scalar (m) && (m == round (m)) && (m > 0))) + error ("bartlett: m has to be an integer > 0"); endif if (m == 1) diff --git a/scripts/signal/blackman.m b/scripts/signal/blackman.m --- a/scripts/signal/blackman.m +++ b/scripts/signal/blackman.m @@ -22,8 +22,8 @@ ## R. W. Schafer, "Discrete-Time Signal Processing". ## @end deftypefn -## Author: AW -## Description: Coefficients of the Blackman window +## Author: AW +## Description: Coefficients of the Blackman window function c = blackman (m) @@ -31,8 +31,8 @@ usage ("blackman (m)"); endif - if !(is_scalar (m) && (m == round (m)) && (m > 0)) - error ("blackman: m has to be an integer > 0"); + if (! (is_scalar (m) && (m == round (m)) && (m > 0))) + error ("blackman: m has to be an integer > 0"); endif if (m == 1) diff --git a/scripts/signal/detrend.m b/scripts/signal/detrend.m --- a/scripts/signal/detrend.m +++ b/scripts/signal/detrend.m @@ -36,7 +36,7 @@ p = 1; elseif (nargin == 2) if (! (is_scalar (p) && p == round (p) && p >= 0)) - error ("detrend: p must be a nonnegative integer"); + error ("detrend: p must be a nonnegative integer"); endif else usage ("detrend (x, p)"); diff --git a/scripts/signal/diffpara.m b/scripts/signal/diffpara.m --- a/scripts/signal/diffpara.m +++ b/scripts/signal/diffpara.m @@ -35,15 +35,15 @@ ## Theory and Methods Springer 1987. ## @end deftypefn -## Author: FL -## Description: Estimate the fractional differencing parameter +## Author: FL +## Description: Estimate the fractional differencing parameter function [d, D] = diffpara (X, a, b) if ((nargin < 1) || (nargin > 3)) usage ("[d, D] = diffpara (X, a, b)"); else - if is_vector (X) + if (is_vector (X)) n = length (X); k = 1; X = reshape (X, n, 1); @@ -59,8 +59,8 @@ endif endif - if !(is_scalar (a) && is_scalar (b)) - error ("diffpara: a and b must be scalars"); + if (! (is_scalar (a) && is_scalar (b))) + error ("diffpara: a and b must be scalars"); endif D = zeros (b - a + 1, k); @@ -69,7 +69,7 @@ w = 2 * pi * (1 : n-1) / n; - x = 2 * log (abs( 1 - exp (-i*w))); + x = 2 * log (abs (1 - exp (-i*w))); y = log (periodogram (X(2:n,l))); x = center (x); diff --git a/scripts/signal/durbinlevinson.m b/scripts/signal/durbinlevinson.m --- a/scripts/signal/durbinlevinson.m +++ b/scripts/signal/durbinlevinson.m @@ -27,16 +27,16 @@ ## @var{t} of the algorithm are performed. ## @end deftypefn -## Author: FL -## Description: Perform one step of the Durbin-Levinson algorithm +## Author: FL +## Description: Perform one step of the Durbin-Levinson algorithm function [newphi, newv] = durbinlevinson (c, oldphi, oldv) - if( !((nargin == 1) || (nargin == 3)) ) + if (! ((nargin == 1) || (nargin == 3))) usage ("durbinlevinson (c, oldphi, oldv)"); endif - if( columns (c) > 1 ) + if (columns (c) > 1) c=c'; endif @@ -48,38 +48,38 @@ t = length (oldphi) + 1; if (length (c) < t+1) - error ("durbilevinson: c too small"); + error ("durbilevinson: c too small"); endif if (oldv == 0) error ("durbinlevinson: oldv = 0"); endif - if (rows (oldphi) > 1 ) + if (rows (oldphi) > 1) oldphi = oldphi'; endif newphi = zeros (1, t); - newphi(1) = ( c(t+1) - oldphi * c(2:t) ) / oldv; + newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv; for i = 2 : t newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1); endfor - newv = ( 1 - newphi(1)^2 ) * oldv; + newv = (1 - newphi(1)^2) * oldv; elseif(nargin == 1) tt = length (c)-1; oldphi = c(2) / c(1); - oldv = ( 1 - oldphi^2 ) * c(1); + oldv = (1 - oldphi^2) * c(1); for t = 2 : tt newphi = zeros (1, t); - newphi(1) = ( c(t+1) - oldphi * c(2:t) ) / oldv; + newphi(1) = (c(t+1) - oldphi * c(2:t)) / oldv; for i = 2 : t newphi(i) = oldphi(i-1) - newphi(1) * oldphi(t-i+1); endfor - newv = ( 1 - newphi(1)^2 ) * oldv; + newv = (1 - newphi(1)^2) * oldv; oldv = newv; oldphi = newphi; diff --git a/scripts/signal/fftconv.m b/scripts/signal/fftconv.m --- a/scripts/signal/fftconv.m +++ b/scripts/signal/fftconv.m @@ -39,7 +39,7 @@ endif if (! (is_vector (a) && is_vector (b))) - error ("fftconv: both a and b should be vectors"); + error ("fftconv: both a and b should be vectors"); endif la = length (a); lb = length (b); @@ -52,7 +52,7 @@ if (nargin == 2) c = fftfilt (a, b); else - if !(is_scalar (N)) + if (! (is_scalar (N))) error ("fftconv: N has to be a scalar"); endif c = fftfilt (a, b, N); diff --git a/scripts/signal/fftfilt.m b/scripts/signal/fftfilt.m --- a/scripts/signal/fftfilt.m +++ b/scripts/signal/fftfilt.m @@ -66,7 +66,7 @@ y = ifft (fft (x, N) .* fft(b, N)); else ## Use overlap-add method ... - if !(is_scalar (N)) + if (! (is_scalar (N))) error ("fftfilt: N has to be a scalar"); endif N = 2^(ceil (log (max ([N, l_b])) / log(2))); @@ -85,7 +85,7 @@ y = reshape (y(1:l_x), r_x, c_x); - ## Final cleanups: if both x and b are real respectively integer, y + ## Final cleanups: if both x and b are real respectively integer, y ## should also be if (! (any (imag (x)) || any (imag (b)))) diff --git a/scripts/signal/fractdiff.m b/scripts/signal/fractdiff.m --- a/scripts/signal/fractdiff.m +++ b/scripts/signal/fractdiff.m @@ -20,19 +20,19 @@ ## where @var{L} denotes the lag-operator and @var{d} is greater than -1. ## @end deftypefn -## Author: FL -## Description: Compute fractional differences +## Author: FL +## Description: Compute fractional differences function retval = fractdiff (x, d) N = 100; - if !is_vector (x) - error ("fractdiff: x must be a vector") + if (! is_vector (x)) + error ("fractdiff: x must be a vector") endif - if !is_scalar (d) - error ("fractdiff: d must be a scalar") + if (! is_scalar (d)) + error ("fractdiff: d must be a scalar") endif @@ -56,7 +56,7 @@ endif else - error ("fractdiff: d must be > -1"); + error ("fractdiff: d must be > -1"); endif diff --git a/scripts/signal/freqz.m b/scripts/signal/freqz.m --- a/scripts/signal/freqz.m +++ b/scripts/signal/freqz.m @@ -86,7 +86,7 @@ k = max([la, lb]); - if( n >= k) + if (n >= k) if (strcmp(region,"whole")) h = fft(postpad(b,n)) ./ fft(postpad(a,n)); w = 2*pi*[0:(n-1)]/n; diff --git a/scripts/signal/hamming.m b/scripts/signal/hamming.m --- a/scripts/signal/hamming.m +++ b/scripts/signal/hamming.m @@ -22,8 +22,8 @@ ## R. W. Schafer, "Discrete-Time Signal Processing". ## @end deftypefn -## Author: AW -## Description: Coefficients of the Hamming window +## Author: AW +## Description: Coefficients of the Hamming window function c = hamming (m) @@ -31,8 +31,8 @@ usage ("hamming (m)"); endif - if !(is_scalar (m) && (m == round (m)) && (m > 0)) - error ("hamming: m has to be an integer > 0"); + if (! (is_scalar (m) && (m == round (m)) && (m > 0))) + error ("hamming: m has to be an integer > 0"); endif if (m == 1) diff --git a/scripts/signal/hanning.m b/scripts/signal/hanning.m --- a/scripts/signal/hanning.m +++ b/scripts/signal/hanning.m @@ -22,8 +22,8 @@ ## R. W. Schafer, "Discrete-Time Signal Processing". ## @end deftypefn -## Author: AW -## Description: Coefficients of the Hanning window +## Author: AW +## Description: Coefficients of the Hanning window function c = hanning (m) @@ -31,8 +31,8 @@ usage ("hanning (m)"); endif - if !(is_scalar (m) && (m == round (m)) && (m > 0)) - error ("hanning: m has to be an integer > 0"); + if (! (is_scalar (m) && (m == round (m)) && (m > 0))) + error ("hanning: m has to be an integer > 0"); endif if (m == 1) diff --git a/scripts/signal/hurst.m b/scripts/signal/hurst.m --- a/scripts/signal/hurst.m +++ b/scripts/signal/hurst.m @@ -21,8 +21,8 @@ ## every single column. ## @end deftypefn -## Author: FL -## Description: Estimate the Hurst parameter +## Author: FL +## Description: Estimate the Hurst parameter function H = hurst (x) @@ -31,8 +31,8 @@ endif if (is_scalar (x)) - error ("hurst: x must not be a scalar") - elseif is_vector (x) + error ("hurst: x must not be a scalar") + elseif (is_vector (x)) x = reshape (x, length (x), 1); end diff --git a/scripts/signal/periodogram.m b/scripts/signal/periodogram.m --- a/scripts/signal/periodogram.m +++ b/scripts/signal/periodogram.m @@ -21,7 +21,7 @@ ## @end deftypefn ## Author: FL -## Description: Compute the periodogram +## Description: Compute the periodogram function retval = periodogram (x) diff --git a/scripts/signal/rectangle_lw.m b/scripts/signal/rectangle_lw.m --- a/scripts/signal/rectangle_lw.m +++ b/scripts/signal/rectangle_lw.m @@ -20,8 +20,8 @@ ## estimation. ## @end deftypefn -## Author: FL -## Description: Rectangular lag window +## Author: FL +## Description: Rectangular lag window function retval = rectangle_lw (n, b) diff --git a/scripts/signal/rectangle_sw.m b/scripts/signal/rectangle_sw.m --- a/scripts/signal/rectangle_sw.m +++ b/scripts/signal/rectangle_sw.m @@ -20,8 +20,8 @@ ## estimation. ## @end deftypefn -## Author: FL -## Description: Rectangular spectral window +## Author: FL +## Description: Rectangular spectral window function retval = rectangle_sw (n, b) @@ -31,7 +31,7 @@ l = (2:n)' - 1; l = 2 * pi * l / n; - retval(2:n) = sin( (2/b + 1) * l / 2 ) ./ sin (l / 2); + retval(2:n) = sin ((2/b + 1) * l / 2) ./ sin (l / 2); endfunction diff --git a/scripts/signal/sinetone.m b/scripts/signal/sinetone.m --- a/scripts/signal/sinetone.m +++ b/scripts/signal/sinetone.m @@ -23,8 +23,8 @@ ## Defaults are @var{rate} = 8000, @var{sec} = 1 and @var{ampl} = 64. ## @end deftypefn -## Author: FL -## Description: Compute a sine tone +## Author: FL +## Description: Compute a sine tone function retval = sinetone (f, r, s, a) @@ -43,11 +43,11 @@ [err, f, a] = common_size (f, a); if (err || ! is_vector (f)) - error ("sinetone: freq and ampl must be vectors of common size"); + error ("sinetone: freq and ampl must be vectors of common size"); endif - if !(is_scalar (r) && is_scalar (s)) - error ("sinetone: rate and sec must be scalars"); + if (! (is_scalar (r) && is_scalar (s))) + error ("sinetone: rate and sec must be scalars"); endif n = length (f); diff --git a/scripts/signal/sinewave.m b/scripts/signal/sinewave.m --- a/scripts/signal/sinewave.m +++ b/scripts/signal/sinewave.m @@ -22,8 +22,8 @@ ## The default value for @var{d} is 0. ## @end deftypefn -## Author: AW -## Description: Compute a sine wave +## Author: AW +## Description: Compute a sine wave function x = sinewave (m, n, d) @@ -33,6 +33,6 @@ usage ("sinewave (m, n, d)"); endif - x = sin ( ((1 : m) + d - 1) * 2 * pi / n); + x = sin (((1 : m) + d - 1) * 2 * pi / n); endfunction diff --git a/scripts/signal/spectral_adf.m b/scripts/signal/spectral_adf.m --- a/scripts/signal/spectral_adf.m +++ b/scripts/signal/spectral_adf.m @@ -27,8 +27,8 @@ ## omitted, @code{1 / sqrt (length (@var{x}))} is used. ## @end deftypefn -## Author: FL -## Description: Spectral density estimation +## Author: FL +## Description: Spectral density estimation function retval = spectral_adf (c, win, b) diff --git a/scripts/signal/spectral_xdf.m b/scripts/signal/spectral_xdf.m --- a/scripts/signal/spectral_xdf.m +++ b/scripts/signal/spectral_xdf.m @@ -26,8 +26,8 @@ ## omitted, @code{1 / sqrt (length (@var{x}))} is used. ## @end deftypefn -## Author: FL -## Description: Spectral density estimation +## Author: FL +## Description: Spectral density estimation function retval = spectral_xdf (X, win, b) diff --git a/scripts/signal/spencer.m b/scripts/signal/spencer.m --- a/scripts/signal/spencer.m +++ b/scripts/signal/spencer.m @@ -20,8 +20,8 @@ ## @var{x}. ## @end deftypefn -## Author: FL -## Description: Apply Spencer's 15-point MA filter +## Author: FL +## Description: Apply Spencer's 15-point MA filter function retval = spencer (X) diff --git a/scripts/signal/stft.m b/scripts/signal/stft.m --- a/scripts/signal/stft.m +++ b/scripts/signal/stft.m @@ -48,8 +48,8 @@ ## synthesis function. ## @end deftypefn -## Author: AW -## Description: Short-term Fourier transform +## Author: AW +## Description: Short-term Fourier transform function [Y, c] = stft(X, win, inc, coef, w_type) @@ -74,7 +74,7 @@ elseif (strcmp (w_type, "rectangle")) w_type = 3; else - error (["stft: unknown window type `", w_type, "'"]) + error ("stft: unknown window type `%s'", w_type); endif endif else @@ -88,14 +88,14 @@ X = X'; nr = nc; else - error ("stft: X must be a vector"); + error ("stft: X must be a vector"); endif endif num_coef = 2 * coef; if (win > num_coef) win = num_coef; - printf ("stft: window size adjusted to %f\n", win); + printf ("stft: window size adjusted to %f\n", win); endif num_win = fix ((nr - win) / inc); diff --git a/scripts/signal/synthesis.m b/scripts/signal/synthesis.m --- a/scripts/signal/synthesis.m +++ b/scripts/signal/synthesis.m @@ -27,8 +27,8 @@ ## @end example ## @end deftypefn -## Author: AW -## Description: Recover a signal from its short-term Fourier transform +## Author: AW +## Description: Recover a signal from its short-term Fourier transform function X = synthesis (Y, c) @@ -38,7 +38,7 @@ [nr, nc] = size (c); if (nr * nc != 3) - error ("synthesis: c must contain exactly 3 elements"); + error ("synthesis: c must contain exactly 3 elements"); endif ## not necessary, enables better reading @@ -53,7 +53,7 @@ elseif (w_type == 3) H = ones (win, 1); else - error ("synthesis: window_type must be 1, 2, or 3"); + error ("synthesis: window_type must be 1, 2, or 3"); endif Z = real (ifft (Y)); diff --git a/scripts/signal/triangle_lw.m b/scripts/signal/triangle_lw.m --- a/scripts/signal/triangle_lw.m +++ b/scripts/signal/triangle_lw.m @@ -20,8 +20,8 @@ ## estimation. ## @end deftypefn -## Author: FL -## Description: Triangular lag window +## Author: FL +## Description: Triangular lag window function retval = triangle_lw (n, b) diff --git a/scripts/signal/triangle_sw.m b/scripts/signal/triangle_sw.m --- a/scripts/signal/triangle_sw.m +++ b/scripts/signal/triangle_sw.m @@ -20,8 +20,8 @@ ## estimation. ## @end deftypefn -## Author: FL -## Description: Triangular spectral window +## Author: FL +## Description: Triangular spectral window function retval = triangle_sw (n, b) @@ -31,7 +31,7 @@ l = (2:n)' - 1; l = 2 * pi * l / n; - retval(2:n) = b * (sin (l / (2*b)) ./ sin (l / 2) ).^2; + retval(2:n) = b * (sin (l / (2*b)) ./ sin (l / 2)).^2; endfunction diff --git a/scripts/signal/yulewalker.m b/scripts/signal/yulewalker.m --- a/scripts/signal/yulewalker.m +++ b/scripts/signal/yulewalker.m @@ -23,8 +23,8 @@ ## noise, @var{v}. ## @end deftypefn -## Author: FL -## Description: Fit AR model by Yule-Walker method +## Author: FL +## Description: Fit AR model by Yule-Walker method function [a, v] = yulewalker (c) diff --git a/scripts/statistics/base/cut.m b/scripts/statistics/base/cut.m --- a/scripts/statistics/base/cut.m +++ b/scripts/statistics/base/cut.m @@ -38,7 +38,7 @@ usage ("cut (X, BREAKS)"); endif - if !is_vector (X) + if (! is_vector (X)) error ("cut: X must be a vector"); endif if is_scalar (BREAKS) diff --git a/scripts/statistics/base/ppplot.m b/scripts/statistics/base/ppplot.m --- a/scripts/statistics/base/ppplot.m +++ b/scripts/statistics/base/ppplot.m @@ -46,7 +46,7 @@ usage ("ppplot (x, dist, params)"); endif - if !is_vector (x) + if (! is_vector (x)) error ("ppplot: x must be a vector."); endif diff --git a/scripts/statistics/base/qqplot.m b/scripts/statistics/base/qqplot.m --- a/scripts/statistics/base/qqplot.m +++ b/scripts/statistics/base/qqplot.m @@ -48,7 +48,7 @@ usage ("qqplot (x, dist, params)"); endif - if !(is_vector(x)) + if (! (is_vector(x))) error ("qqplot: x must be a vector."); endif diff --git a/scripts/statistics/base/ranks.m b/scripts/statistics/base/ranks.m --- a/scripts/statistics/base/ranks.m +++ b/scripts/statistics/base/ranks.m @@ -44,7 +44,7 @@ o = ones (1, r); for i = 1 : c; p = x (:, i) * o; - y = [y, ( sum (p < p') + (sum (p == p') + 1) / 2 )']; + y = [y, (sum (p < p') + (sum (p == p') + 1) / 2)']; endfor endif diff --git a/scripts/statistics/base/table.m b/scripts/statistics/base/table.m --- a/scripts/statistics/base/table.m +++ b/scripts/statistics/base/table.m @@ -29,7 +29,7 @@ function [t, v, w] = table (x, y) if (nargin == 1) - if !(is_vector (x)) + if (! (is_vector (x))) error ("table: x must be a vector"); endif v = values (x); @@ -37,7 +37,7 @@ t(i) = sum (x == v(i) | isnan (v(i)) * isnan (x)); endfor elseif (nargin == 2) - if !(is_vector (x) && is_vector (y) && (length (x) == length (y))) + if (! (is_vector (x) && is_vector (y) && (length (x) == length (y)))) error ("table: x and y must be vectors of the same length"); endif v = values (x); diff --git a/scripts/statistics/base/values.m b/scripts/statistics/base/values.m --- a/scripts/statistics/base/values.m +++ b/scripts/statistics/base/values.m @@ -29,7 +29,7 @@ usage ("values (x)"); endif - if !(is_vector (x)) + if (! (is_vector (x))) error ("values: x must be a vector"); endif diff --git a/scripts/statistics/distributions/beta_rnd.m b/scripts/statistics/distributions/beta_rnd.m --- a/scripts/statistics/distributions/beta_rnd.m +++ b/scripts/statistics/distributions/beta_rnd.m @@ -30,10 +30,10 @@ function rnd = beta_rnd (a, b, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("beta_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("beta_rnd: c must be a positive integer"); endif [retval, a, b] = common_size (a, b, zeros (r, c)); diff --git a/scripts/statistics/distributions/binomial_rnd.m b/scripts/statistics/distributions/binomial_rnd.m --- a/scripts/statistics/distributions/binomial_rnd.m +++ b/scripts/statistics/distributions/binomial_rnd.m @@ -30,10 +30,10 @@ function rnd = binomial_rnd (n, p, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("binomial_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("binomial_rnd: c must be a positive integer"); endif [retval, n, p] = common_size (n, p, zeros (r, c)); diff --git a/scripts/statistics/distributions/cauchy_rnd.m b/scripts/statistics/distributions/cauchy_rnd.m --- a/scripts/statistics/distributions/cauchy_rnd.m +++ b/scripts/statistics/distributions/cauchy_rnd.m @@ -30,10 +30,10 @@ function rnd = cauchy_rnd (l, scale, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("cauchy_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("cauchy_rnd: c must be a positive integer"); endif [retval, l, scale] = common_size (l, scale, zeros (r, c)); diff --git a/scripts/statistics/distributions/chisquare_rnd.m b/scripts/statistics/distributions/chisquare_rnd.m --- a/scripts/statistics/distributions/chisquare_rnd.m +++ b/scripts/statistics/distributions/chisquare_rnd.m @@ -30,10 +30,10 @@ function rnd = chisquare_rnd (n, r, c) if (nargin == 3) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("chisquare_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("chisquare_rnd: c must be a positive integer"); endif [retval, n] = common_size (n, zeros (r, c)); diff --git a/scripts/statistics/distributions/exponential_rnd.m b/scripts/statistics/distributions/exponential_rnd.m --- a/scripts/statistics/distributions/exponential_rnd.m +++ b/scripts/statistics/distributions/exponential_rnd.m @@ -30,10 +30,10 @@ function rnd = exponential_rnd (l, r, c) if (nargin == 3) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("exponential_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("exponential_rnd: c must be a positive integer"); endif [retval, l] = common_size (l, zeros (r, c)); diff --git a/scripts/statistics/distributions/f_rnd.m b/scripts/statistics/distributions/f_rnd.m --- a/scripts/statistics/distributions/f_rnd.m +++ b/scripts/statistics/distributions/f_rnd.m @@ -30,10 +30,10 @@ function rnd = f_rnd (m, n, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("f_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("f_rnd: c must be a positive integer"); endif [retval, m, n] = common_size (m, n, zeros (r, c)); diff --git a/scripts/statistics/distributions/gamma_rnd.m b/scripts/statistics/distributions/gamma_rnd.m --- a/scripts/statistics/distributions/gamma_rnd.m +++ b/scripts/statistics/distributions/gamma_rnd.m @@ -30,10 +30,10 @@ function rnd = gamma_rnd (a, b, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("gamma_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("gamma_rnd: c must be a positive integer"); endif [retval, a, b] = common_size (a, b, zeros (r, c)); diff --git a/scripts/statistics/distributions/geometric_rnd.m b/scripts/statistics/distributions/geometric_rnd.m --- a/scripts/statistics/distributions/geometric_rnd.m +++ b/scripts/statistics/distributions/geometric_rnd.m @@ -30,10 +30,10 @@ function rnd = geometric_rnd (p, r, c) if (nargin == 3) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("geometric_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("geometric_rnd: c must be a positive integer"); endif [retval, p] = common_size (p, zeros (r, c)); diff --git a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m --- a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m +++ b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m @@ -49,12 +49,12 @@ if (nargin == 1) tol = eps; else - if (!is_scalar (tol) || !(tol > 0)) + if (! is_scalar (tol) || ! (tol > 0)) error ("kolmogorov_smirnov_cdf: tol has to be a positive scalar"); endif endif - [nr, nc] = size(x); + [nr, nc] = size (x); if (min (nr, nc) == 0) error ("kolmogorov_smirnov_cdf: x must not be empty"); endif @@ -65,11 +65,11 @@ ind = find (x > 0); if (length (ind) > 0) y = x(ind); - K = ceil( sqrt( - log (tol) / 2 ) / min (y) ); + K = ceil (sqrt (- log (tol) / 2) / min (y)); k = (1:K)'; - A = exp( - 2 * k.^2 * y.^2 ); + A = exp (- 2 * k.^2 * y.^2); odd = find (rem (k, 2) == 1); - A(odd, :) = -A(odd, :); + A(odd,:) = -A(odd,:); cdf(ind) = 1 + 2 * sum (A); endif diff --git a/scripts/statistics/distributions/laplace_rnd.m b/scripts/statistics/distributions/laplace_rnd.m --- a/scripts/statistics/distributions/laplace_rnd.m +++ b/scripts/statistics/distributions/laplace_rnd.m @@ -29,10 +29,10 @@ usage ("laplace_rnd (r, c)"); endif - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("laplace_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("laplace_rnd: c must be a positive integer"); endif diff --git a/scripts/statistics/distributions/logistic_rnd.m b/scripts/statistics/distributions/logistic_rnd.m --- a/scripts/statistics/distributions/logistic_rnd.m +++ b/scripts/statistics/distributions/logistic_rnd.m @@ -29,10 +29,10 @@ usage ("logistic_rnd (r, c)"); endif - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("logistic_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("logistic_rnd: c must be a positive integer"); endif diff --git a/scripts/statistics/distributions/lognormal_rnd.m b/scripts/statistics/distributions/lognormal_rnd.m --- a/scripts/statistics/distributions/lognormal_rnd.m +++ b/scripts/statistics/distributions/lognormal_rnd.m @@ -30,10 +30,10 @@ function rnd = lognormal_rnd (a, v, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("lognormal_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("lognormal_rnd: c must be a positive integer"); endif [retval, a, v] = common_size (a, v, zeros (r, c)); diff --git a/scripts/statistics/distributions/normal_rnd.m b/scripts/statistics/distributions/normal_rnd.m --- a/scripts/statistics/distributions/normal_rnd.m +++ b/scripts/statistics/distributions/normal_rnd.m @@ -30,10 +30,10 @@ function rnd = normal_rnd (m, v, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("normal_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("normal_rnd: c must be a positive integer"); endif [retval, m, v] = common_size (m, v, zeros (r, c)); diff --git a/scripts/statistics/distributions/pascal_rnd.m b/scripts/statistics/distributions/pascal_rnd.m --- a/scripts/statistics/distributions/pascal_rnd.m +++ b/scripts/statistics/distributions/pascal_rnd.m @@ -30,10 +30,10 @@ function rnd = pascal_rnd (n, p, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("pascal_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("pascal_rnd: c must be a positive integer"); endif [retval, n, p] = common_size (n, p, zeros (r, c)); diff --git a/scripts/statistics/distributions/poisson_rnd.m b/scripts/statistics/distributions/poisson_rnd.m --- a/scripts/statistics/distributions/poisson_rnd.m +++ b/scripts/statistics/distributions/poisson_rnd.m @@ -30,10 +30,10 @@ function rnd = poisson_rnd (l, r, c) if (nargin == 3) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("poisson_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("poisson_rnd: c must be a positive integer"); endif [retval, l] = common_size (l, zeros (r, c)); diff --git a/scripts/statistics/distributions/stdnormal_cdf.m b/scripts/statistics/distributions/stdnormal_cdf.m --- a/scripts/statistics/distributions/stdnormal_cdf.m +++ b/scripts/statistics/distributions/stdnormal_cdf.m @@ -34,7 +34,7 @@ error ("stdnormal_cdf: x must not be empty."); endif - cdf = ( ones (r_x, c_x) + erf (x / sqrt(2)) ) / 2; + cdf = (ones (r_x, c_x) + erf (x / sqrt (2))) / 2; endfunction diff --git a/scripts/statistics/distributions/stdnormal_pdf.m b/scripts/statistics/distributions/stdnormal_pdf.m --- a/scripts/statistics/distributions/stdnormal_pdf.m +++ b/scripts/statistics/distributions/stdnormal_pdf.m @@ -41,7 +41,7 @@ k = find (!isinf (x)); if (any (k)) - pdf (k) = (2 * pi)^(- 1/2) * exp( - x(k) .^ 2 / 2); + pdf (k) = (2 * pi)^(- 1/2) * exp (- x(k) .^ 2 / 2); endif pdf = reshape (pdf, r, c); diff --git a/scripts/statistics/distributions/stdnormal_rnd.m b/scripts/statistics/distributions/stdnormal_rnd.m --- a/scripts/statistics/distributions/stdnormal_rnd.m +++ b/scripts/statistics/distributions/stdnormal_rnd.m @@ -29,10 +29,10 @@ usage ("stdnormal_rnd (r, c)"); endif - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("stdnormal_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("stdnormal_rnd: c must be a positive integer"); endif diff --git a/scripts/statistics/distributions/t_rnd.m b/scripts/statistics/distributions/t_rnd.m --- a/scripts/statistics/distributions/t_rnd.m +++ b/scripts/statistics/distributions/t_rnd.m @@ -30,10 +30,10 @@ function rnd = t_rnd (n, r, c) if (nargin == 3) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("t_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("t_rnd: c must be a positive integer"); endif [retval, n] = common_size (n, zeros (r, c)); diff --git a/scripts/statistics/distributions/uniform_rnd.m b/scripts/statistics/distributions/uniform_rnd.m --- a/scripts/statistics/distributions/uniform_rnd.m +++ b/scripts/statistics/distributions/uniform_rnd.m @@ -30,10 +30,10 @@ function rnd = uniform_rnd (a, b, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("uniform_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("uniform_rnd: c must be a positive integer"); endif [retval, a, b] = common_size (a, b, zeros (r, c)); diff --git a/scripts/statistics/distributions/weibull_rnd.m b/scripts/statistics/distributions/weibull_rnd.m --- a/scripts/statistics/distributions/weibull_rnd.m +++ b/scripts/statistics/distributions/weibull_rnd.m @@ -30,10 +30,10 @@ function rnd = weibull_rnd (shape, scale, r, c) if (nargin == 4) - if (! (is_scalar (r) && (r > 0) && (r == round (r))) ) + if (! (is_scalar (r) && (r > 0) && (r == round (r)))) error ("weibull_rnd: r must be a positive integer"); endif - if (! (is_scalar (c) && (c > 0) && (c == round (c))) ) + if (! (is_scalar (c) && (c > 0) && (c == round (c)))) error ("weibull_rnd: c must be a positive integer"); endif [retval, shape, scale] = common_size (shape, scale, zeros (r, c)); diff --git a/scripts/statistics/tests/chisquare_test_homogeneity.m b/scripts/statistics/tests/chisquare_test_homogeneity.m --- a/scripts/statistics/tests/chisquare_test_homogeneity.m +++ b/scripts/statistics/tests/chisquare_test_homogeneity.m @@ -45,7 +45,7 @@ endif ## Now test c for strictly increasing entries df = length (c); - if (any ( (c(2 : df) - c(1 : (df - 1))) <= 0)) + if (any ((c(2 : df) - c(1 : (df - 1))) <= 0)) error ("chisquare_test_homogeneity: c must be increasing"); endif diff --git a/scripts/statistics/tests/cor_test.m b/scripts/statistics/tests/cor_test.m --- a/scripts/statistics/tests/cor_test.m +++ b/scripts/statistics/tests/cor_test.m @@ -70,13 +70,13 @@ if (nargin < 3) ALTERNATIVE = "!="; - elseif !isstr (ALTERNATIVE) + elseif (! isstr (ALTERNATIVE)) error ("cor_test: ALTERNATIVE must be a string"); endif if (nargin < 4) METHOD = "pearson"; - elseif !isstr (METHOD) + elseif (! isstr (METHOD)) error ("cor_test: METHOD must be a string"); endif diff --git a/scripts/statistics/tests/f_test_regression.m b/scripts/statistics/tests/f_test_regression.m --- a/scripts/statistics/tests/f_test_regression.m +++ b/scripts/statistics/tests/f_test_regression.m @@ -40,22 +40,20 @@ endif [T, k] = size (X); - if !( is_vector (y) && (length (y) == T) ) + if (! (is_vector (y) && (length (y) == T))) error ("f_test_regression: y must be a vector of length rows (X)"); endif y = reshape (y, T, 1); [q, c_R ] = size (R); if (c_R != k) - error (["f_test_regression: ", ... - "R must have as many columns as X."]); + error ("f_test_regression: R must have as many columns as X"); endif if (nargin == 4) s_r = size (r); if ((min (s_r) != 1) || (max (s_r) != q)) - error (["f_test_regression: ", ... - "r must be a vector of length rows (R)."]); + error ("f_test_regression: r must be a vector of length rows (R)"); endif r = reshape (r, q, 1); else @@ -67,7 +65,7 @@ [b, v] = ols (y, X); diff = R * b - r; - f = diff' * inv (R * inv (X' * X) * R') * diff / ( q * v ); + f = diff' * inv (R * inv (X' * X) * R') * diff / (q * v); pval = 1 - f_cdf (f, df_num, df_den); if (nargout == 0) diff --git a/scripts/statistics/tests/kolmogorov_smirnov_test.m b/scripts/statistics/tests/kolmogorov_smirnov_test.m --- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -34,9 +34,10 @@ ## @code{"<>"}, the null is tested against the two-sided alternative F ## != G. In this case, the test statistic @var{ks} follows a two-sided ## Kolmogorov-Smirnov distribution. If @var{alt} is @code{">"}, the -## one-sided alternative F > G is considered, similarly for @code{"<"}. -## In this case, the test statistic @var{ks} has a one-sided -## Kolmogorov-Smirnov distribution. The default is the two-sided case. +## one-sided alternative F > G is considered. Similarly for @code{"<"}, +## the one-sided alternative F > G is considered. In this case, the +## test statistic @var{ks} has a one-sided Kolmogorov-Smirnov +## distribution. The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/kolmogorov_smirnov_test_2.m b/scripts/statistics/tests/kolmogorov_smirnov_test_2.m --- a/scripts/statistics/tests/kolmogorov_smirnov_test_2.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test_2.m @@ -27,9 +27,10 @@ ## @code{"<>"}, the null is tested against the two-sided alternative F ## != G. In this case, the test statistic @var{ks} follows a two-sided ## Kolmogorov-Smirnov distribution. If @var{alt} is @code{">"}, the -## one-sided alternative F > G is considered, similarly for @code{"<"}. -## In this case, the test statistic @var{ks} has a one-sided -## Kolmogorov-Smirnov distribution. The default is the two-sided case. +## one-sided alternative F > G is considered. Similarly for @code{"<"}, +## the one-sided alternative F < G is considered. In this case, the +## test statistic @var{ks} has a one-sided Kolmogorov-Smirnov +## distribution. The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## @@ -45,7 +46,7 @@ usage ("[pval, ks] = kolmogorov_smirnov_test_2 (x, y, tol)"); endif - if !( is_vector (x) && is_vector (y)) + if (! (is_vector (x) && is_vector (y))) error ("kolmogorov_smirnov_test_2: both x and y must be vectors."); endif diff --git a/scripts/statistics/tests/prop_test_2.m b/scripts/statistics/tests/prop_test_2.m --- a/scripts/statistics/tests/prop_test_2.m +++ b/scripts/statistics/tests/prop_test_2.m @@ -26,7 +26,8 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## @var{p1} != @var{p2}. If @var{alt} is @code{">"}, the one-sided -## alternative @var{p1} > @var{p2} is used, similarly for @code{"<"}. +## alternative @var{p1} > @var{p2} is used. Similarly for @code{"<"}, +## the one-sided alternative @var{p1} < @var{p2} is used. ## The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. @@ -57,7 +58,7 @@ alt = "!="; endif - if !isstr (alt) + if (! isstr (alt)) error ("prop_test_2: alt must be a string"); endif if (strcmp (alt, "!=") || strcmp (alt, "<>")) diff --git a/scripts/statistics/tests/sign_test.m b/scripts/statistics/tests/sign_test.m --- a/scripts/statistics/tests/sign_test.m +++ b/scripts/statistics/tests/sign_test.m @@ -27,8 +27,10 @@ ## null hypothesis is tested against the two-sided alternative PROB ## (@var{x} < @var{y}) != 1/2. If @var{alt} is @code{">"}, the ## one-sided alternative PROB (@var{x} > @var{y}) > 1/2 ("x is -## stochastically greater than y") is considered, similarly for @code{"<"}. -## The default is the two-sided case. +## stochastically greater than y") is considered. Similarly for +## @code{"<"}, the one-sided alternative PROB (@var{x} > @var{y}) < 1/2 +## ("x is stochastically less than y") is considered. The default is +## the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/t_test.m b/scripts/statistics/tests/t_test.m --- a/scripts/statistics/tests/t_test.m +++ b/scripts/statistics/tests/t_test.m @@ -26,8 +26,10 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the -## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered, -## similarly for @var{"<"}. The default is the two-sided case. +## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered. +## Similarly for @var{"<"}, the one-sided alternative @code{mean +## (@var{x}) < @var{m}} is considered, The default is the two-sided +## case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/t_test_2.m b/scripts/statistics/tests/t_test_2.m --- a/scripts/statistics/tests/t_test_2.m +++ b/scripts/statistics/tests/t_test_2.m @@ -27,7 +27,9 @@ ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{mean (@var{x}) != mean (@var{y})}. If @var{alt} is @code{">"}, ## the one-sided alternative @code{mean (@var{x}) > mean (@var{y})} is -## used. Similarly for @code{"<"}. The default is the two-sided case. +## used. Similarly for @code{"<"}, the one-sided alternative @code{mean +## (@var{x}) < mean (@var{y})} is used. The default is the two-sided +## case. ## ## The p-value of the test is returned in @var{pval}. ## @@ -53,7 +55,7 @@ mu_x = sum (x) / n_x; mu_y = sum (y) / n_y; v = sumsq (x - mu_x) + sumsq (y - mu_y); - t = (mu_x - mu_y) * sqrt ( (n_x * n_y * df) / (v * (n_x + n_y)) ); + t = (mu_x - mu_y) * sqrt ((n_x * n_y * df) / (v * (n_x + n_y))); cdf = t_cdf (t, df); if (nargin == 2) diff --git a/scripts/statistics/tests/t_test_regression.m b/scripts/statistics/tests/t_test_regression.m --- a/scripts/statistics/tests/t_test_regression.m +++ b/scripts/statistics/tests/t_test_regression.m @@ -28,7 +28,8 @@ ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{@var{R} * @var{b} != @var{r}}. If @var{alt} is @code{">"}, the ## one-sided alternative @code{@var{R} * @var{b} > @var{r}} is used. -## Similarly for @var{"<"}. The default is the two-sided case. +## Similarly for @var{"<"}, the one-sided alternative @code{@var{R} * +## @var{b} < @var{r}} is used. The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## @@ -50,7 +51,7 @@ else alt = "!="; endif - elseif !(nargin == 5) + elseif (! (nargin == 5)) usage ("[pval, t, df] = t_test_regression (y, X, R, r, alt)"); endif @@ -61,11 +62,11 @@ endif [T, k] = size (X); - if !(is_vector (y) && (length (y) == T)) + if (! (is_vector (y) && (length (y) == T))) error ("t_test_regression: y must be a vector of length rows (X)"); endif s = size (R); - if !((max (s) == k) && (min (s) == 1)) + if (! ((max (s) == k) && (min (s) == 1))) error ("t_test_regression: R must be a vector of length columns (X)"); endif diff --git a/scripts/statistics/tests/u_test.m b/scripts/statistics/tests/u_test.m --- a/scripts/statistics/tests/u_test.m +++ b/scripts/statistics/tests/u_test.m @@ -26,8 +26,9 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## PROB (@var{x} > @var{y}) != 1/2. If @var{alt} is @code{">"}, the -## one-sided alternative PROB (@var{x} > @var{y}) > 1/2 is considered, -## similarly for @code{"<"}. The default is the two-sided case. +## one-sided alternative PROB (@var{x} > @var{y}) > 1/2 is considered. +## Similarly for @code{"<"}, the one-sided alternative PROB (@var{x} > +## @var{y}) < 1/2 is considered, The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/var_test.m b/scripts/statistics/tests/var_test.m --- a/scripts/statistics/tests/var_test.m +++ b/scripts/statistics/tests/var_test.m @@ -26,7 +26,9 @@ ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{var (@var{x}) != var (@var{y})}. If @var{alt} is @code{">"}, ## the one-sided alternative @code{var (@var{x}) > var (@var{y})} is -## used, similarly for "<". The default is the two-sided case. +## used. Similarly for "<", the one-sided alternative @code{var +## (@var{x}) > var (@var{y})} is used. The default is the two-sided +## case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/welch_test.m b/scripts/statistics/tests/welch_test.m --- a/scripts/statistics/tests/welch_test.m +++ b/scripts/statistics/tests/welch_test.m @@ -26,8 +26,9 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the -## one-sided alternative mean(x) > m is considered, similarly for -## @code{"<"}. The default is the two-sided case. +## one-sided alternative mean(x) > @var{m} is considered. Similarly for +## @code{"<"}, the one-sided alternative mean(x) < @var{m} is +## considered. The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## @@ -54,7 +55,7 @@ v_x = sumsq (x - mu_x) / (n_x * (n_x - 1)); v_y = sumsq (x - mu_y) / (n_y * (n_y - 1)); c = v_x / (v_x + v_y); - df = 1 / ( c^2 / (n_x - 1) + (1 - c)^2 / (n_y - 1)); + df = 1 / (c^2 / (n_x - 1) + (1 - c)^2 / (n_y - 1)); t = (mu_x - mu_y) / sqrt (v_x + v_y); cdf = t_cdf (t, df); diff --git a/scripts/statistics/tests/wilcoxon_test.m b/scripts/statistics/tests/wilcoxon_test.m --- a/scripts/statistics/tests/wilcoxon_test.m +++ b/scripts/statistics/tests/wilcoxon_test.m @@ -25,8 +25,9 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## PROB (@var{x} > @var{y}) != 1/2. If alt is @code{">"}, the one-sided -## alternative PROB (@var{x} > @var{y}) > 1/2 is considered, similarly -## for @code{"<"}. The default is the two-sided case. +## alternative PROB (@var{x} > @var{y}) > 1/2 is considered. Similarly +## for @code{"<"}, the one-sided alternative PROB (@var{x} > @var{y}) < +## 1/2 is considered. The default is the two-sided case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/z_test.m b/scripts/statistics/tests/z_test.m --- a/scripts/statistics/tests/z_test.m +++ b/scripts/statistics/tests/z_test.m @@ -25,8 +25,10 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{mean (@var{x}) != @var{m}}. If @var{alt} is @code{">"}, the -## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered, -## similarly for @code{"<"}. The default is the two-sided case. +## one-sided alternative @code{mean (@var{x}) > @var{m}} is considered. +## Similarly for @code{"<"}, the one-sided alternative @code{mean +## (@var{x}) < @var{m}} is considered. The default is the two-sided +## case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/statistics/tests/z_test_2.m b/scripts/statistics/tests/z_test_2.m --- a/scripts/statistics/tests/z_test_2.m +++ b/scripts/statistics/tests/z_test_2.m @@ -25,8 +25,10 @@ ## interest can be selected. If @var{alt} is @code{"!="} or ## @code{"<>"}, the null is tested against the two-sided alternative ## @code{mean (@var{x}) != mean (@var{y})}. If alt is @code{">"}, the -## one-sided alternative @code{mean (@var{x}) > mean (@var{y})} is used, -## similarly for @code{"<"}. The default is the two-sided case. +## one-sided alternative @code{mean (@var{x}) > mean (@var{y})} is used. +## Similarly for @code{"<"}, the one-sided alternative @code{mean +## (@var{x}) < mean (@var{y})} is used. The default is the two-sided +## case. ## ## The p-value of the test is returned in @var{pval}. ## diff --git a/scripts/strings/com2str.m b/scripts/strings/com2str.m --- a/scripts/strings/com2str.m +++ b/scripts/strings/com2str.m @@ -17,7 +17,7 @@ ## Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{retval} =} com2str(@var{zz}[,@var{flg}]) +## @deftypefn {Function File} {@var{retval} =} com2str(@var{zz}, @var{flg}) ## ## convert complex number to a string ## @strong{Inputs} @@ -33,49 +33,49 @@ function retval = com2str (zz, flg) - if (nargin < 1 | nargin > 2) - usage("com2str(zz{,flg})"); + if (nargin < 1 || nargin > 2) + usage ("com2str (zz, flg)"); endif - if(nargin == 1) + if (nargin == 1) flg = 0; endif - if( !(is_scalar(zz) & is_scalar(flg) ) ) + if (! (is_scalar (zz) && is_scalar (flg))) error("com2str: arguments must be a scalar."); endif - if(flg != 0 & flg != 1) - error(["invalid flg value: ",num2str(flg)]); + if (flg != 0 && flg != 1) + error ("invalid flg value: %d", flg); endif sgns = "+-"; - rz = real(zz); - iz = imag(zz); - az = abs(zz); - if(iz == 0) + rz = real (zz); + iz = imag (zz); + az = abs (zz); + if (iz == 0) ## strictly a real number - switch(flg) - case(0) - retval = num2str(rz); - case(1) - retval = [ sgns(1+(rz< 0))," ", num2str(abs(rz))]; + switch (flg) + case(0) + retval = num2str (rz); + case(1) + retval = [sgns(1+(rz<0)), " ", num2str(abs(rz))]; endswitch - elseif(rz == 0) + elseif (rz == 0) ## strictly an imaginary number - switch(flg) - case(0) - retval = num2str(iz); - case(1) - retval = [ sgns(1+(iz< 0))," ", num2str(abs(iz)),"i"]; + switch (flg) + case(0) + retval = num2str (iz); + case(1) + retval = [sgns(1+(iz<0)), " ", num2str(abs(iz)), "i"]; endswitch else ## complex number ## strictly an imaginary number - switch(flg) - case(0) - retval = [num2str(rz)," ",com2str(i*iz,1)]; - case(1) - retval = [ sgns(1+(rz< 0))," ", num2str(abs(rz))," ",com2str(i*iz,1)]; + switch (flg) + case(0) + retval = [num2str(rz), " ", com2str(i*iz,1)]; + case(1) + retval = [sgns(1+(rz<0)), " ", num2str(abs(rz)), " ", com2str(i*iz,1)]; endswitch endif