Mercurial > hg > octave-nkf
changeset 20038:9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Try to trim long lines to < 80 chars.
Use '##' for single line comments.
Use '(...)' around tests for if/elseif/switch/while.
Abut cell indexing operator '{' next to variable.
Abut array indexing operator '(' next to variable.
Use space between negation operator '!' and following expression.
Use two newlines between endfunction and start of %!test or %!demo code.
Remove unnecessary parens grouping between short-circuit operators.
Remove stray extra spaces (typos) between variables and assignment operators.
Remove stray extra spaces from ends of lines.
line wrap: on
line diff
--- a/scripts/audio/@audioplayer/audioplayer.m +++ b/scripts/audio/@audioplayer/audioplayer.m @@ -107,6 +107,7 @@ endfunction + %!demo %! fs = 44100; %! audio = randn (2, 2*fs) - 0.5;
--- a/scripts/audio/@audiorecorder/audiorecorder.m +++ b/scripts/audio/@audiorecorder/audiorecorder.m @@ -51,6 +51,7 @@ endfunction + %!demo %! recorder = audiorecorder (44100, 16, 2); %! record (recorder, 1);
--- a/scripts/audio/mu2lin.m +++ b/scripts/audio/mu2lin.m @@ -63,7 +63,7 @@ ## Set the shape of y to that of x overwrites the contents of y with ## ulaw of x. y = x; - y(:) = ulaw (x + 1); + y(:) = ulaw(x + 1); ## Convert to real or 8-bit. if (n == 0)
--- a/scripts/audio/record.m +++ b/scripts/audio/record.m @@ -62,7 +62,7 @@ %!assert (isempty (record (0))) -%% Test input validation +## Test input validation %!error record () %!error record (1,2,3) %!error record (-1)
--- a/scripts/audio/sound.m +++ b/scripts/audio/sound.m @@ -59,7 +59,7 @@ ## Tests of sound must not actually play anything. -%% Test input validation +## Test input validation %!error sound () %!error sound (1,2,3,4) %!error sound (1, -1)
--- a/scripts/audio/soundsc.m +++ b/scripts/audio/soundsc.m @@ -50,7 +50,7 @@ if (nargin < 2 || isempty (fs)) fs = 8000; - elseif ((nargin == 2) && (numel (fs) > 1)) + elseif (nargin == 2 && numel (fs) > 1) yrange = fs; fs = 8000; elseif (! (isscalar (fs) && (fs > 0))) @@ -59,7 +59,7 @@ if (nargin < 3 || isempty (nbits)) nbits = 8; - elseif ((nargin == 3) && (numel (nbits) > 1)) + elseif (nargin == 3 && numel (nbits) > 1) yrange = nbits; nbits = 8; elseif (! (isscalar (nbits) && (nbits == 8 || nbits == 16 || nbits == 24))) @@ -92,7 +92,7 @@ ## Tests of soundsc must not actually play anything. -%% Test input validation +## Test input validation %!error soundsc () %!error soundsc (1,2,3,4,5) %!error soundsc (1, -1)
--- a/scripts/audio/wavread.m +++ b/scripts/audio/wavread.m @@ -103,7 +103,7 @@ ## Functional tests for wavread/wavwrite pair are in wavwrite.m. -%% Test input validation +## Test input validation %!error wavread () %!error wavread (1) %!error wavread ("foo.wav", 2, 3, 4)
--- a/scripts/audio/wavwrite.m +++ b/scripts/audio/wavwrite.m @@ -168,7 +168,7 @@ %! unlink (fname); %! end_unwind_protect -%% Test input validation +## Test input validation %!error wavwrite () %!error wavwrite (1) %!error wavwrite (1,2,3,4,5)
--- a/scripts/deprecated/delaunay3.m +++ b/scripts/deprecated/delaunay3.m @@ -86,5 +86,5 @@ %! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; %! assert (sortrows (sort (delaunay3 (x, y, z), 2)), [1,2,3,4;1,2,4,5]) -%% FIXME: Need input validation tests +## FIXME: Need input validation tests
--- a/scripts/deprecated/interp1q.m +++ b/scripts/deprecated/interp1q.m @@ -55,7 +55,7 @@ dy = diff (y); dx = diff (x); idx = lookup (x, xi, "lr"); - s = (xi - x (idx)) ./ dx (idx); + s = (xi - x(idx)) ./ dx(idx); yi = bsxfun (@times, s, dy(idx,:)) + y(idx,:); range = xi < x(1) | !(xi <= x(nx)); yi(range,:) = NA;
--- a/scripts/deprecated/java_convert_matrix.m +++ b/scripts/deprecated/java_convert_matrix.m @@ -22,7 +22,7 @@ ## @deftypefnx {Built-in Function} {} java_convert_matrix (@var{new_val}, "local") ## Query or set the internal variable that controls whether Java arrays are ## automatically converted to Octave matrices. The default value is false. -## +## ## When called from inside a function with the @qcode{"local"} option, the ## variable is changed locally for the function and any subroutines it calls. ## The original variable value is restored when exiting the function.
--- a/scripts/deprecated/java_debug.m +++ b/scripts/deprecated/java_debug.m @@ -23,7 +23,7 @@ ## Query or set the internal variable that determines whether extra debugging ## information regarding the initialization of the JVM and any Java exceptions ## is printed. -## +## ## When called from inside a function with the @qcode{"local"} option, the ## variable is changed locally for the function and any subroutines it calls. ## The original variable value is restored when exiting the function.
--- a/scripts/deprecated/java_invoke.m +++ b/scripts/deprecated/java_invoke.m @@ -21,20 +21,20 @@ ## @deftypefnx {Built-in Function} {@var{ret} =} java_invoke (@var{obj}, @var{methodname}, @var{arg1}, @dots{}) ## Invoke the method @var{methodname} on the Java object @var{obj} with the ## arguments @var{arg1}, @dots{} For static methods, @var{obj} can be a -## string representing the fully qualified name of the corresponding class. +## string representing the fully qualified name of the corresponding class. ## The function returns the result of the method invocation. -## +## ## When @var{obj} is a regular Java object, structure-like indexing can be ## used as a shortcut syntax. For instance, the two following statements are ## equivalent -## +## ## @example ## @group ## ret = java_invoke (x, "method1", 1.0, "a string") ## ret = x.method1 (1.0, "a string") ## @end group ## @end example -## +## ## @seealso{javaMethod, javaObject} ## @end deftypefn @@ -46,7 +46,7 @@ warning ("Octave:deprecated-function", "java_invoke is obsolete and will be removed from a future version of Octave, please use javaMethod instead"); endif - + if (nargin < 2) print_usage (); endif
--- a/scripts/deprecated/java_new.m +++ b/scripts/deprecated/java_new.m @@ -21,14 +21,14 @@ ## @deftypefnx {Loadable Function} {@var{obj} =} java_new (@var{name}, @var{arg1}, @dots{}) ## Create a Java object of class @var{name}, by calling the class constructor ## with the arguments @var{arg1}, @dots{} -## +## ## @example ## @group ## x = java_new ("java.lang.StringBuffer") ## x = java_new ("java.lang.StringBuffer", "Initial string") ## @end group ## @end example -## +## ## @seealso{javaObject, javaMethod} ## @end deftypefn
--- a/scripts/deprecated/java_unsigned_conversion.m +++ b/scripts/deprecated/java_unsigned_conversion.m @@ -24,7 +24,7 @@ ## converted when Java matrix autoconversion is enabled. When enabled, Java ## arrays of class Byte or Integer are converted to matrices of class uint8 or ## uint32 respectively. -## +## ## When called from inside a function with the @qcode{"local"} option, the ## variable is changed locally for the function and any subroutines it calls. ## The original variable value is restored when exiting the function.
--- a/scripts/deprecated/javafields.m +++ b/scripts/deprecated/javafields.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {} javafields (@var{javaobj}) ## @deftypefnx {Function File} {} javafields ("@var{classname}") ## @deftypefnx {Function File} {@var{fld_names} =} javafields (@dots{}) -## Return the fields of a Java object or Java class in the form of a cell +## Return the fields of a Java object or Java class in the form of a cell ## array of strings. If no output is requested, print the result ## to the standard output. ## @seealso{fieldnames, methods, javaObject} @@ -34,11 +34,11 @@ warning ("Octave:deprecated-function", "javafields is obsolete and will be removed from a future version of Octave, please use fieldnames instead"); endif - + if (nargin != 1) print_usage (); endif - + c_methods = javaMethod ("getFields", "org.octave.ClassHelper", javaobj); method_list = ostrsplit (c_methods, ';');
--- a/scripts/deprecated/javamethods.m +++ b/scripts/deprecated/javamethods.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {} javamethods (@var{javaobj}) ## @deftypefnx {Function File} {} javamethods ("@var{classname}") ## @deftypefnx {Function File} {@var{mtd_names} =} javamethods (@dots{}) -## Return the methods of a Java object or Java class in the form of a cell +## Return the methods of a Java object or Java class in the form of a cell ## array of strings. If no output is requested, print the result to the ## standard output. ## @seealso{methods, fieldnames, javaMethod, javaObject} @@ -34,7 +34,7 @@ warning ("Octave:deprecated-function", "javamethods is obsolete and will be removed from a future version of Octave, please use methods instead"); endif - + if (nargin != 1) print_usage (); endif
--- a/scripts/deprecated/playaudio.m +++ b/scripts/deprecated/playaudio.m @@ -90,7 +90,7 @@ endfunction -%% Test input validation +## Test input validation %!error playaudio () %!error playaudio (1,2,3) %!error <X must be a vector> playaudio (magic (3))
--- a/scripts/deprecated/strmatch.m +++ b/scripts/deprecated/strmatch.m @@ -119,7 +119,7 @@ %!assert (strmatch ("", {"", "foo", "bar", ""}), [1, 4]) %!assert (strmatch ('', { '', '% comment', 'var a = 5', ''}, 'exact'), [1,4]) -%% Test input validation +## Test input validation %!error <Invalid call to strmatch> strmatch () %!error <Invalid call to strmatch> strmatch ("a") %!error <Invalid call to strmatch> strmatch ("a", "aaa", "exact", 1)
--- a/scripts/general/accumdim.m +++ b/scripts/general/accumdim.m @@ -149,7 +149,7 @@ endfunction -%% Test accumdim vs. accumarray +## Test accumdim vs. accumarray %!shared a %! a = rand (5, 5, 5); @@ -158,12 +158,12 @@ %!assert (accumdim ([2;3;2;1;2], a, 3, 3, @min)(1,5,:), accumarray ([2;3;2;1;2], a(1,5,:), [1,1,3], @min)) %!assert (accumdim ([1;3;2;2;1], a, 2, 3, @median)(4,:,5), accumarray ([1;3;2;2;1], a(4,:,5), [1,3], @median)) -%% Test fillval +## Test fillval %!assert (accumdim ([1;3;1;3;3], a)(2,:,:), zeros (1,5,5)) %!assert (accumdim ([1;3;1;3;3], a, 1, 4)([2 4],:,:), zeros (2,5,5)) %!assert (accumdim ([1;3;1;3;3], a, 1, 4, [], pi)([2 4],:,:), pi (2,5,5)) -%% Test input validation +## Test input validation %!error accumdim (1) %!error accumdim (1,2,3,4,5,6,7) %!error <SUBS must be a subscript vector> accumdim (ones (2,2), ones (2,2))
--- a/scripts/general/bincoeff.m +++ b/scripts/general/bincoeff.m @@ -112,7 +112,7 @@ %!assert (bincoeff ([4 NaN 4], [-1, 2, 2.5]), NaN (1, 3)) -%% Test input validation +## Test input validation %!error bincoeff () %!error bincoeff (1, 2, 3) %!error bincoeff (ones (3),ones (2))
--- a/scripts/general/blkdiag.m +++ b/scripts/general/blkdiag.m @@ -76,7 +76,7 @@ ## tests involving sparse matrices %!assert (blkdiag (sparse ([1,2;3,4]),[5,6;7,8]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6;0,0,7,8])) %!assert (blkdiag (sparse ([1,2;3,4]),[5,6]), sparse ([1,2,0,0;3,4,0,0;0,0,5,6])) -# sanity checks +## sanity checks %!test %! A = rand (round (rand (1, 2) * 10)); %! assert (blkdiag (A), A);
--- a/scripts/general/circshift.m +++ b/scripts/general/circshift.m @@ -42,7 +42,7 @@ ## 9, 7, 8 ## @end group ## @end example -## @seealso {permute, ipermute, shiftdim} +## @seealso{permute, ipermute, shiftdim} ## @end deftypefn function y = circshift (x, n) @@ -94,7 +94,7 @@ %!assert (circshift (eye (3), 1), circshift (eye (3), 1)) %!assert (circshift (eye (3), 1), [0,0,1;1,0,0;0,1,0]) -%% Test input validation +## Test input validation %!error circshift () %!error circshift (1) %!error circshift (1,2,3)
--- a/scripts/general/common_size.m +++ b/scripts/general/common_size.m @@ -67,7 +67,7 @@ else errorcode = 0; if (nargout > 1) - scal = !nscal; + scal = ! nscal; varargout = varargin; if (any (nscal)) dims = size (varargin{find (nscal, 1)});
--- a/scripts/general/cplxpair.m +++ b/scripts/general/cplxpair.m @@ -92,7 +92,7 @@ perm = [dim:nd, 1:dim-1]; z = permute (z, perm); sz = size (z); - n = sz (1); + n = sz(1); m = prod (sz) / n; z = reshape (z, n, m);
--- a/scripts/general/cumtrapz.m +++ b/scripts/general/cumtrapz.m @@ -90,7 +90,7 @@ if (! have_xy) z = 0.5 * cumsum (x(idx1{:}) + x(idx2{:}), dim); else - if (isvector (x) && !isvector (y)) + if (isvector (x) && ! isvector (y)) if (length (x) != sz(dim)) error ("cumtrapz: length of X and length of Y along DIM must match"); endif @@ -117,17 +117,20 @@ %! x1 = [0,0,0;2,2,2]; %! x2 = [0,2,4;0,2,4]; %! y = [1,2,3;4,5,6]; +%! %!assert (cumtrapz (y), [0,0,0;2.5,3.5,4.5]) %!assert (cumtrapz (x1,y), [0,0,0;5,7,9]) %!assert (cumtrapz (y,1), [0,0,0;2.5,3.5,4.5]) %!assert (cumtrapz (x1,y,1), [0,0,0;5,7,9]) %!assert (cumtrapz (y,2), [0,1.5,4;0,4.5,10]) %!assert (cumtrapz (x2,y,2), [0,3,8;0,9,20]) -%% Test ND-array implementation + +## Test ND-array implementation %!shared x1,x2,y %! x1 = 1:3; %! x2 = reshape ([0,2,4;0,2,4], [1 2 3]); %! y = reshape ([1,2,3;4,5,6], [1 2 3]); +%! %!assert (cumtrapz (y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3])) %!assert (cumtrapz (x1,y,3), reshape ([0,1.5,4;0,4.5,10],[1 2 3])) %!assert (cumtrapz (x2,y,3), reshape ([0,3,8;0,9,20],[1 2 3]))
--- a/scripts/general/curl.m +++ b/scripts/general/curl.m @@ -74,8 +74,8 @@ print_usage (); endif - if ((nargin == 4) || (nargin == 2)) - if (!size_equal (varargin{fidx}, varargin{fidx + 1})) + if (nargin == 4 || nargin == 2) + if (! size_equal (varargin{fidx}, varargin{fidx + 1})) error ("curl: size of X and Y must match"); elseif (ndims (varargin{fidx}) != 2) error ("curl: expected two-dimensional matrices X and Y"); @@ -95,8 +95,8 @@ varargout{2} = av; endif - elseif ((nargin == 6) || (nargin == 3)) - if (!size_equal (varargin{fidx}, varargin{fidx + 1}, varargin{fidx + 2})) + elseif (nargin == 6 || nargin == 3) + if (! size_equal (varargin{fidx}, varargin{fidx + 1}, varargin{fidx + 2})) error ("curl: size of X, Y, and Z must match"); elseif (ndims (varargin{fidx}) != 3) error ("curl: expected two-dimensional matrices X, Y, and Z");
--- a/scripts/general/dblquad.m +++ b/scripts/general/dblquad.m @@ -75,7 +75,7 @@ endfunction -%% Nasty integrand to show quadcc off +## Nasty integrand to show quadcc off %!assert (dblquad (@(x,y) 1 ./ (x+y), 0, 1, 0, 1), 2*log (2), 1e-6) %!assert (dblquad (@(x,y) exp (-x.^2 - y.^2) , -1, 1, -1, 1, 1e-6, @quadgk), pi * erf (1).^2, 1e-6)
--- a/scripts/general/del2.m +++ b/scripts/general/del2.m @@ -140,15 +140,15 @@ idx1{i} = 1; idx2{i} = 2; idx3{i} = 3; - DD(idx1{:}) = (dx{i}(1) + dx{i}(2)) / dx{i}(2) * DD (idx2{:}) - ... - dx{i}(1) / dx{i}(2) * DD (idx3{:}); + DD(idx1{:}) = (dx{i}(1) + dx{i}(2)) / dx{i}(2) * DD(idx2{:}) - ... + dx{i}(1) / dx{i}(2) * DD(idx3{:}); idx1{i} = sz(i); idx2{i} = sz(i) - 1; idx3{i} = sz(i) - 2; - DD(idx1{:}) = (dx{i}(sz(i) - 1) + dx{i}(sz(i) - 2)) / ... - dx{i}(sz(i) - 2) * DD (idx2{:}) - ... - dx{i}(sz(i) - 1) / dx{i}(sz(i) - 2) * DD (idx3{:}); + DD(idx1{:}) = (dx{i}(sz(i) - 1) + dx{i}(sz(i) - 2)) / ... + dx{i}(sz(i) - 2) * DD(idx2{:}) - ... + dx{i}(sz(i) - 1) / dx{i}(sz(i) - 2) * DD(idx3{:}); endif D += DD;
--- a/scripts/general/divergence.m +++ b/scripts/general/divergence.m @@ -72,20 +72,21 @@ print_usage (); endif - if ((nargin == 4) || (nargin == 2)) - if (!size_equal (varargin{fidx},varargin{fidx + 1})) + if (nargin == 4 || nargin == 2) + if (! size_equal (varargin{fidx},varargin{fidx + 1})) error ("divergence: size of X and Y must match"); elseif (ndims (varargin{fidx}) != 2) error ("divergence: expected two-dimensional matrices X and Y"); - elseif ((length (dx) != columns (varargin{fidx})) || (length (dy) != rows (varargin{fidx}))) + elseif (length (dx) != columns (varargin{fidx}) + || length (dy) != rows (varargin{fidx})) error ("divergence: size of dx and dy must match the respective dimension of X and Y"); endif retval = gradient (varargin{fidx}, dx, dy); retval += gradient (varargin{fidx + 1}.', dy, dx).'; - elseif ((nargin == 6) || (nargin == 3)) - if (!size_equal (varargin{fidx},varargin{fidx + 1},varargin{fidx + 2})) + elseif (nargin == 6 || nargin == 3) + if (! size_equal (varargin{fidx},varargin{fidx + 1},varargin{fidx + 2})) error ("divergence: size of X, Y, and Z must match"); elseif (ndims (varargin{fidx}) != 3) error ("divergence: expected two-dimensional matrices X, Y, and Z");
--- a/scripts/general/gradient.m +++ b/scripts/general/gradient.m @@ -76,7 +76,8 @@ elseif (isa (m, "function_handle")) [varargout{1:nargout_with_ans}] = handle_gradient (m, varargin{:}); elseif (ischar (m)) - [varargout{1:nargout_with_ans}] = handle_gradient (str2func (m), varargin{:}); + [varargout{1:nargout_with_ans}] = handle_gradient (str2func (m), ... + varargin{:}); else error ("gradient: first input must be an array or a function"); endif @@ -179,7 +180,7 @@ endif if (any (p0_size == 1)) - p0 = p0 (:); + p0 = p0(:); dim = 1; num_points = numel (p0); else @@ -201,7 +202,7 @@ if (isscalar (delta)) delta = repmat (delta, 1, dim); - elseif (!isvector (delta)) + elseif (! isvector (delta)) error ("gradient: spacing values must be scalars or a vector"); endif @@ -209,7 +210,7 @@ p0 = mat2cell (p0, num_points, ones (1, dim)); varargout = cell (1, dim); for d = 1:dim - s = delta (d); + s = delta(d); df_dx = (f (p0{1:d-1}, p0{d}+s, p0{d+1:end}) - f (p0{1:d-1}, p0{d}-s, p0{d+1:end})) ./ (2*s); if (dim == 1)
--- a/scripts/general/idivide.m +++ b/scripts/general/idivide.m @@ -83,7 +83,7 @@ typ = class (x); else typ = class (x); - if (!strcmp (class (x), class (y))) + if (! strcmp (class (x), class (y))) error ("idivide: incompatible types"); endif endif
--- a/scripts/general/inputParser.m +++ b/scripts/general/inputParser.m @@ -2,7 +2,7 @@ ## ## This file is part of Octave. ## -# Octave is free software; you can redistribute it and/or modify it +## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. @@ -111,7 +111,7 @@ ## ## check ("mech"); # valid, use defaults for other arguments ## check (); # error, one argument is mandatory -## check (1); # error, since !ischar +## check (1); # error, since ! ischar ## check ("mech", "~/dev"); # valid, use defaults for other arguments ## ## check ("mech", "~/dev", [0 1 0 0], "type", "linear"); # valid @@ -242,29 +242,29 @@ classdef inputParser < handle properties ## TODO set input checking for this properties - CaseSensitive = false; - FunctionName = ""; - KeepUnmatched = false; -# PartialMatching = true; # TODO unimplemented -# StructExpand = true; # TODO unimplemented + CaseSensitive = false; + FunctionName = ""; + KeepUnmatched = false; + # PartialMatching = true; # TODO unimplemented + # StructExpand = true; # TODO unimplemented endproperties properties (SetAccess = protected) - Parameters = cell (); - Results = struct (); - Unmatched = struct (); - UsingDefaults = cell (); + Parameters = cell (); + Results = struct (); + Unmatched = struct (); + UsingDefaults = cell (); endproperties properties (Access = protected) ## Since Required and Optional are ordered, they get a cell array of ## structs with the fields "name", "def" (default), and "val" (validator). - Required = cell (); - Optional = cell (); + Required = cell (); + Optional = cell (); ## ParamValue and Swicth are unordered so we have a struct whose fieldnames ## are the argname, and values are a struct with fields "def" and "val" - ParamValue = struct (); - Switch = struct (); + ParamValue = struct (); + Switch = struct (); ## List of ParamValues and Switch names to ease searches ParamValueNames = cell (); @@ -273,7 +273,7 @@ ## When checking for fieldnames in a Case Insensitive way, this variable ## holds the correct identifier for the last searched named using the ## is_argname method. - last_name = ""; + last_name = ""; endproperties properties (Access = protected, Constant = true) @@ -385,7 +385,8 @@ this.error (sprintf ("no matching value for option '%s'", toupper (name))); endif - this.validate_arg (this.last_name, this.ParamValue.(this.last_name).val, + this.validate_arg (this.last_name, + this.ParamValue.(this.last_name).val, varargin{vidx}); elseif (this.is_argname ("Switch", name)) this.Results.(this.last_name) = true;
--- a/scripts/general/interp1.m +++ b/scripts/general/interp1.m @@ -560,8 +560,8 @@ %!assert (isempty (interp1 (xp,yp,[],style))) %!assert (interp1 (xp,[yp',yp'],xi(:),style),... %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) -# %!assert (interp1 (xp,yp,xi,style),... -# %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +#%!assert (interp1 (xp,yp,xi,style),... +#%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) %!error interp1 (1,1,1, style) @@ -578,8 +578,8 @@ %!assert (isempty (interp1 (xp,yp,[],style))) %!assert (interp1 (xp,[yp',yp'],xi(:),style),... %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) -# %!assert (interp1 (xp,yp,xi,style),... -# %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +#%!assert (interp1 (xp,yp,xi,style),... +#%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) %!error interp1 (1,1,1, style) @@ -595,8 +595,8 @@ %!assert (isempty (interp1 (xp,yp,[],style))) %!assert (interp1 (xp,[yp',yp'],xi(:),style),... %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]) -# %!assert (interp1 (xp,yp,xi,style),... -# %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) +#%!assert (interp1 (xp,yp,xi,style),... +#%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) %!error interp1 (1,1,1, style) @@ -780,7 +780,7 @@ %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "right"), [-2,0.5,4,3,1.5]) %!assert (interp1 ([1,2,2,3,4],[0,1,4,2,1],[-1,1.5,2,2.5,3.5], "linear", "extrap", "left"), [-2,0.5,1,3,1.5]) -%% Test input validation +## Test input validation %!error interp1 () %!error interp1 (1,2,3,4,5,6,7) %!error <minimum of 2 points required> interp1 (1,1,1, "linear")
--- a/scripts/general/interp2.m +++ b/scripts/general/interp2.m @@ -314,11 +314,11 @@ endif - ## extrapolation 'extrap' + ## extrapolation 'extrap' if (isempty (extrap)) extrap = NA; endif - + if (X(1) < X(end)) if (Y(1) < Y(end)) ZI(XI < X(1,1) | XI > X(end) | YI < Y(1,1) | YI > Y(end)) = extrap; @@ -562,7 +562,7 @@ %!assert (interp2 (z, [2 3 1], [2 2 2], "cubic"), [5 7 3], 10 * tol) %!assert (interp2 (z, [2 3 1], [2 2 2], "spline"), [5 7 3], tol) -%% Test input validation +## Test input validation %!error interp2 (1, 1, 1, 1, 1, 2) #only 5 numeric inputs %!error interp2 (1, 1, 1, 1, 1, 2, 2) #only 5 numeric inputs %!error <Z must be a 2-D matrix> interp2 ({1})
--- a/scripts/general/interp3.m +++ b/scripts/general/interp3.m @@ -192,7 +192,7 @@ endfunction -%% FIXME: Need some demo blocks here to show off the function like interp2.m. +## FIXME: Need some demo blocks here to show off the function like interp2.m. %!test # basic test %! x = y = z = -1:1; y = y + 2; @@ -255,7 +255,7 @@ %! V(:,:,2) = V(:,:,1) + 2; %! V(:,:,3) = V(:,:,2) + 2; %! tol = 10 * eps; -%! x=[-0.1,0,0.1]; y=x; z=x; +%! x=[-0.1,0,0.1]; y=x; z=x; %! assert(interp3(X,Y,Z,V,x,y,z,"spline"), [-0.2, 1.0, 2.2]',tol); %! assert(interp3(X,Y,Z,V,x,y,z,"linear"), [NA, 1.0, 2.2]',tol); %! assert(interp3(X,Y,Z,V,x,y,z,"spline", 0), [0, 1.0, 2.2]',tol); @@ -280,7 +280,7 @@ %!assert (interp3 (z, "linear"), zout, tol) %!assert (interp3 (z, "spline"), zout, tol) -%% Test input validation +## Test input validation %!error interp3 () %!error interp3 ({1}) %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", {1})
--- a/scripts/general/interpft.m +++ b/scripts/general/interpft.m @@ -120,19 +120,19 @@ %!assert (interpft (y', n), y', 20*eps); %!assert (interpft ([y,y],n), [y,y], 20*eps); -%% Test case with complex input from bug #39566 +## Test case with complex input from bug #39566 %!test %! x = (1 + j) * [1:4]'; %! y = ifft ([15 + 15*j; -6; -1.5 - 1.5*j; 0; -1.5 - 1.5*j; -6*j]); %! assert (interpft (x, 6), y, 10*eps); -%% Test for correct spectral symmetry with even/odd lengths +## Test for correct spectral symmetry with even/odd lengths %!assert (max (abs (imag (interpft ([1:8], 20)))), 0, 20*eps); %!assert (max (abs (imag (interpft ([1:8], 21)))), 0, 21*eps); %!assert (max (abs (imag (interpft ([1:9], 20)))), 0, 20*eps); %!assert (max (abs (imag (interpft ([1:9], 21)))), 0, 21*eps); -%% Test input validation +## Test input validation %!error interpft () %!error interpft (1) %!error interpft (1,2,3)
--- a/scripts/general/interpn.m +++ b/scripts/general/interpn.m @@ -181,7 +181,8 @@ endfor idx = cell (1,nd); for i = 1 : nd - idx{i} = yidx{i} + (y{i} - x{i}(yidx{i})(:) >= x{i}(yidx{i} + 1)(:) - y{i}); + idx{i} = yidx{i} ... + + (y{i} - x{i}(yidx{i})(:) >= x{i}(yidx{i} + 1)(:) - y{i}); endfor vi = v(sub2ind (sz, idx{:})); idx = zeros (prod (yshape), 1); @@ -338,6 +339,6 @@ %! assert (interpn (z, "linear"), zout, tol); %! assert (interpn (z, "spline"), zout, tol); -%% Test input validation +## Test input validation %!warning <ignoring unsupported '\*' flag> interpn (rand (3,3), 1, "*linear");
--- a/scripts/general/logspace.m +++ b/scripts/general/logspace.m @@ -90,7 +90,7 @@ %! assert (size (x3) == [1, 10] && abs (x3(1) - 10) < eps && abs (x3(10) - 0.01) < eps); %! assert (size (x4) == [1, 10] && abs (x4(1) - 10) < eps && abs (x4(10) - pi) < sqrt (eps)); -%% Test input validation +## Test input validation %!error logspace () %!error logspace (1, 2, 3, 4) %!error logspace ([1, 2; 3, 4], 5, 6)
--- a/scripts/general/narginchk.m +++ b/scripts/general/narginchk.m @@ -37,9 +37,9 @@ if (nargin != 2) print_usage; - elseif (!isnumeric (minargs) || !isscalar (minargs)) + elseif (! isnumeric (minargs) || ! isscalar (minargs)) error ("minargs must be a numeric scalar"); - elseif (!isnumeric (maxargs) || !isscalar (maxargs)) + elseif (! isnumeric (maxargs) || ! isscalar (maxargs)) error ("maxargs must be a numeric scalar"); elseif (minargs > maxargs) error ("minargs cannot be larger than maxargs");
--- a/scripts/general/nargoutchk.m +++ b/scripts/general/nargoutchk.m @@ -50,7 +50,8 @@ ## message in a string). With 2011b, it no longer returns anything, it simply ## gives an error if the args number is incorrect. ## To try to keep compatibility with both versions, check nargout and nargin - ## to guess if the caller is expecting a value (old syntax) or none (new syntax) + ## to guess if the caller is expecting a value (old syntax) + ## or none (new syntax). if (nargout == 1 && (nargin == 3 || nargin == 4)) @@ -82,9 +83,9 @@ elseif (nargout == 0 && nargin == 2) - if (!isnumeric (minargs) || !isscalar (minargs)) + if (! isnumeric (minargs) || ! isscalar (minargs)) error ("minargs must be a numeric scalar"); - elseif (!isnumeric (maxargs) || !isscalar (maxargs)) + elseif (! isnumeric (maxargs) || ! isscalar (maxargs)) error ("maxargs must be a numeric scalar"); elseif (minargs > maxargs) error ("minargs cannot be larger than maxargs");
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -91,7 +91,7 @@ else if (isnumeric (x)) ## Setup a suitable format string, ignoring inf entries - dgt = floor (log10 (max (abs (x(!isinf (x(:))))))); + dgt = floor (log10 (max (abs (x(! isinf (x(:))))))); if (isempty (dgt)) ## If the whole input array is inf... dgt = 1; @@ -129,8 +129,8 @@ endif else ## Setup a suitable format string - dgt = floor (log10 (max (max (abs (real (x(!isinf (real (x(:))))))), - max (abs (imag (x(!isinf (imag (x(:)))))))))); + dgt = floor (log10 (max (max (abs (real (x(! isinf (real (x(:))))))), + max (abs (imag (x(! isinf (imag (x(:)))))))))); if (isempty (dgt)) ## If the whole input array is inf... dgt = 1;
--- a/scripts/general/postpad.m +++ b/scripts/general/postpad.m @@ -72,14 +72,14 @@ sz(nd+1:dim) = 1; endif - d = sz (dim); + d = sz(dim); if (d >= l) idx = repmat ({':'}, nd, 1); idx{dim} = 1:l; y = x(idx{:}); else - sz (dim) = l - d; + sz(dim) = l - d; y = cat (dim, x, c(ones (sz))); endif
--- a/scripts/general/prepad.m +++ b/scripts/general/prepad.m @@ -72,14 +72,14 @@ sz(nd+1:dim) = 1; endif - d = sz (dim); + d = sz(dim); if (d >= l) idx = repmat ({':'}, nd, 1); idx{dim} = d-l+1:d; y = x(idx{:}); else - sz (dim) = l - d; + sz(dim) = l - d; y = cat (dim, c(ones (sz)), x); endif
--- a/scripts/general/private/__splinen__.m +++ b/scripts/general/private/__splinen__.m @@ -28,8 +28,9 @@ function yi = __splinen__ (x, y, xi, extrapval, f) ## ND isvector function. isvec = @(x) numel (x) == length (x); - if (!iscell (x) || length (x) < ndims (y) || any (! cellfun (isvec, x)) - || !iscell (xi) || length (xi) < ndims (y) || any (! cellfun (isvec, xi))) + if (! iscell (x) || length (x) < ndims (y) || any (! cellfun (isvec, x)) + || ! iscell (xi) || length (xi) < ndims (y) + || any (! cellfun (isvec, xi))) error ("__splinen__: %s: non-gridded data or dimensions inconsistent", f); endif yi = y; @@ -38,7 +39,7 @@ endfor [xi{:}] = ndgrid (cellfun (@(x) x(:), xi, "uniformoutput", false){:}); - if (!isempty (extrapval)) + if (! isempty (extrapval)) idx = zeros (size (xi{1})); for i = 1 : length (x) idx |= xi{i} < min (x{i}(:)) | xi{i} > max (x{i}(:));
--- a/scripts/general/profile.m +++ b/scripts/general/profile.m @@ -147,7 +147,7 @@ %! assert (size (hier), [0, 1]); %! assert (fieldnames (hier), {"Index"; "SelfTime"; "NumCalls"; "Children"}); -%% Test input validation +## Test input validation %!error profile () %!error profile ("on", 2) %!error profile ("INVALID_OPTION")
--- a/scripts/general/quadgk.m +++ b/scripts/general/quadgk.m @@ -163,7 +163,7 @@ elseif (strcmpi (str, "waypoints")) waypoints = varargin{idx++} (:); if (isreal (waypoints)) - waypoints (waypoints < a | waypoints > b) = []; + waypoints(waypoints < a | waypoints > b) = []; endif elseif (strcmpi (str, "maxintervalcount")) maxint = varargin{idx++};
--- a/scripts/general/quadv.m +++ b/scripts/general/quadv.m @@ -152,12 +152,12 @@ %!assert (quadv (@sin, 0, 2 * pi), 0, 1e-5) %!assert (quadv (@sin, 0, pi), 2, 1e-5) -%% Handles weak singularities at the edge +## Handles weak singularities at the edge %!assert (quadv (@(x) 1 ./ sqrt (x), 0, 1), 2, 1e-5) -%% Handles vector-valued functions +## Handles vector-valued functions %!assert (quadv (@(x) [(sin (x)), (sin (2 * x))], 0, pi), [2, 0], 1e-5) -%% Handles matrix-valued functions +## Handles matrix-valued functions %!assert (quadv (@(x) [ x, x, x; x, 1./sqrt(x), x; x, x, x ], 0, 1 ), [0.5, 0.5, 0.5; 0.5, 2, 0.5; 0.5, 0.5, 0.5], 1e-5)
--- a/scripts/general/randi.m +++ b/scripts/general/randi.m @@ -129,7 +129,7 @@ %! %!assert (size (randi (10, 3,1,2)), [3, 1, 2]) -%% Test input validation +## Test input validation %!error (randi ()) %!error (randi ("test")) %!error (randi (10+2i))
--- a/scripts/general/repmat.m +++ b/scripts/general/repmat.m @@ -68,7 +68,7 @@ endif else if (nargin > 3) - # input check for m and varargin + ## input check for m and varargin if (isscalar (m) && all (cellfun ("numel", varargin) == 1)) m = [m varargin{:}]; n = []; @@ -137,7 +137,7 @@ endfunction -# Tests for ML compatibility +## Tests for ML compatibility %!shared x %! x = [1 2 3]; %!assert (repmat (x, [3, 1]), repmat (x, 3, [])) @@ -152,7 +152,7 @@ %!assert (repmat (x, [1 1], 4), repmat (x, [1 1 4])); %!assert (repmat (x, [1 1], 4), repmat (x, 1, [1 4])); -# Test various methods of providing size parameters +## Test various methods of providing size parameters %!shared x %! x = [1 2;3 4]; %!assert (repmat (x, [1 1]), repmat (x, 1)) @@ -163,7 +163,7 @@ %!assert (repmat (x, [3 3]), repmat (x, 3, 3)) %!assert (repmat (pi, [1,2,3,4]), repmat (pi, 1,2,3,4)) -# Tests for numel==1 case: +## Tests for numel==1 case: %!shared x, r %! x = [ 65 ]; %! r = kron (ones (2,2), x); @@ -171,7 +171,7 @@ %!assert (char (r), repmat (char (x), [2 2])) %!assert (int8 (r), repmat (int8 (x), [2 2])) -# Tests for ndims==2 case: +## Tests for ndims==2 case: %!shared x, r %! x = [ 65 66 67 ]; %! r = kron (ones (2,2), x); @@ -179,7 +179,7 @@ %!assert (char (r), repmat (char (x), [2 2])) %!assert (int8 (r), repmat (int8 (x), [2 2])) -# Tests for dim>2 case: +## Tests for dim>2 case: %!shared x, r %! x = [ 65 66 67 ]; %! r = kron (ones (2,2), x); @@ -188,7 +188,7 @@ %!assert (char (r), repmat (char (x), [2 2 2])) %!assert (int8 (r), repmat (int8 (x), [2 2 2])) -# Test that sparsity is kept +## Test that sparsity is kept %!assert (sparse (4,4), repmat (sparse (2,2),[2 2])) %!assert (size (repmat (".", -1, 1)), [0, 1])
--- a/scripts/general/rot90.m +++ b/scripts/general/rot90.m @@ -132,7 +132,7 @@ %! assert (rot90 (a, 2), rot90 (b, 1)) %! assert (rot90 (a, 3), rot90 (b, 2)) -%% Test input validation +## Test input validation %!error rot90 () %!error rot90 (1, 2, 3) %!error rot90 (1, ones (2))
--- a/scripts/general/rotdim.m +++ b/scripts/general/rotdim.m @@ -61,7 +61,7 @@ endif if (nargin > 1 && ! isempty (n)) - if (!isscalar (n) || !isreal (n) || fix (n) != n) + if (! isscalar (n) || ! isreal (n) || fix (n) != n) error ("rotdim: N must be a scalar integer"); endif else
--- a/scripts/general/shift.m +++ b/scripts/general/shift.m @@ -87,7 +87,7 @@ %! assert (shift (m, 1), [c; a; b]); %! assert (shift (m, -2), [c; a; b]); -%% Test input validation +## Test input validation %!error shift () %!error shift (1, 2, 3, 4) %!error shift ([], 1)
--- a/scripts/general/shiftdim.m +++ b/scripts/general/shiftdim.m @@ -44,7 +44,7 @@ ## @result{} ns = 1 ## @end group ## @end example -## @seealso {reshape, permute, ipermute, circshift, squeeze} +## @seealso{reshape, permute, ipermute, circshift, squeeze} ## @end deftypefn function [y, ns] = shiftdim (x, n) @@ -93,7 +93,7 @@ %!assert (size (shiftdim (rand (0, 1, 2))), [0 1 2]) -%% Test input validation +## Test input validation %!error (shiftdim ()) %!error (shiftdim (1,2,3)) %!error (shiftdim (1, ones (2)))
--- a/scripts/general/sortrows.m +++ b/scripts/general/sortrows.m @@ -127,7 +127,7 @@ %! assert (x, full (sx)); %! assert (idx, sidx); -%% Test input validation +## Test input validation %!error sortrows () %!error sortrows (1, 2, 3) %!error sortrows (1, "ascend")
--- a/scripts/general/structfun.m +++ b/scripts/general/structfun.m @@ -106,7 +106,8 @@ [varargout{:}] = cellfun (func, struct2cell (S), varargin{:}); if (! uniform_output) - varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, uo_str, false); + varargout = cellfun ("cell2struct", varargout, {fieldnames(S)}, {1}, ... + uo_str, false); endif endfunction
--- a/scripts/general/trapz.m +++ b/scripts/general/trapz.m @@ -104,7 +104,7 @@ if (! have_xy) z = 0.5 * sum (x(idx1{:}) + x(idx2{:}), dim); else - if (isvector (x) && !isvector (y)) + if (isvector (x) && ! isvector (y)) if (length (x) != sz(dim)) error ("trapz: length of X and length of Y along DIM must match"); endif
--- a/scripts/general/triplequad.m +++ b/scripts/general/triplequad.m @@ -65,7 +65,8 @@ varargin = {}; endif - q = dblquad (@(y, z) inner (y, z, f, xa, xb, tol, quadf, varargin{:}), ya, yb, za, zb, tol); + q = dblquad (@(y, z) inner (y, z, f, xa, xb, tol, quadf, varargin{:}), ... + ya, yb, za, zb, tol); endfunction @@ -79,7 +80,7 @@ %!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadcc), pi^(3/2) * erf (1).^3, 1e-6) -%% These tests are too expensive to run normally (~30 sec each). Disable them +## These tests are too expensive to run normally (~30 sec each). Disable them #%!assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadgk), pi^(3/2) * erf (1).^3, 1e-6) #%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadl), pi^(3/2) * erf (1).^3, 1e-6) #%!#assert (triplequad (@(x,y,z) exp (-x.^2 - y.^2 - z.^2) , -1, 1, -1, 1, -1, 1, [], @quadv), pi^(3/2) * erf (1).^3, 1e-6)
--- a/scripts/general/validateattributes.m +++ b/scripts/general/validateattributes.m @@ -338,6 +338,7 @@ endif endfunction + %!error <double> validateattributes (rand (5), {"uint8"}, {}) %!error <single> validateattributes (uint8 (rand (5)), {"float"}, {}) %!error <2d> validateattributes (rand (5, 5, 5), {}, {"2d"})
--- a/scripts/geometry/convhull.m +++ b/scripts/geometry/convhull.m @@ -100,5 +100,5 @@ %! y = abs (sin (x)); %! assert (convhull (x, y), [1;7;13;12;11;10;4;3;2;1]); -%% FIXME: Need input validation tests +## FIXME: Need input validation tests
--- a/scripts/geometry/delaunay.m +++ b/scripts/geometry/delaunay.m @@ -197,7 +197,7 @@ %! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; %! assert (sortrows (sort (delaunay (x, y, z), 2)), [1,2,3,4;1,2,4,5]) -%% Input validation tests +## Input validation tests %!error delaunay () %!error delaunay (1,2,3,4,5) %!error <X must be a matrix with 2 or 3 columns> delaunay (ones (2,4))
--- a/scripts/geometry/delaunayn.m +++ b/scripts/geometry/delaunayn.m @@ -96,8 +96,8 @@ %! x = [-1, -1, 1, 0, -1]; y = [-1, 1, 1, 0, -1]; z = [0, 0, 0, 1, 1]; %! assert (sortrows (sort (delaunayn ([x(:) y(:) z(:)]), 2)), [1,2,3,4;1,2,4,5]) -%% FIXME: Need tests for delaunayn +## FIXME: Need tests for delaunayn -%% Input validation tests +## Input validation tests %!error delaunayn ()
--- a/scripts/geometry/griddata.m +++ b/scripts/geometry/griddata.m @@ -89,7 +89,7 @@ elseif (strcmp (method, "nearest")) ## Search index of nearest point. idx = dsearch (x, y, tri, xi, yi); - valid = !isnan (idx); + valid = ! isnan (idx); zi(valid) = z(idx(valid)); elseif (strcmp (method, "linear")) @@ -97,7 +97,7 @@ tri_list = tsearch (x, y, tri, xi(:), yi(:)); ## Only keep the points within triangles. - valid = !isnan (tri_list); + valid = ! isnan (tri_list); tri_list = tri_list(valid); nr_t = rows (tri_list); @@ -187,7 +187,7 @@ %! zz2(isnan (zz)) = NaN; %! assert (zz, zz2, 100*eps); -%% Test input validation +## Test input validation %!error griddata () %!error griddata (1) %!error griddata (1,2)
--- a/scripts/geometry/griddatan.m +++ b/scripts/geometry/griddatan.m @@ -62,7 +62,7 @@ if (strcmp (method, "nearest")) ## search index of nearest point idx = dsearchn (x, tri, xi); - valid = !isnan (idx); + valid = ! isnan (idx); yi(valid) = y(idx(valid)); elseif (strcmp (method, "linear")) @@ -70,13 +70,13 @@ [tri_list, bary_list] = tsearchn (x, tri, xi); ## only keep the points within triangles. - valid = !isnan (tri_list); - tri_list = tri_list(!isnan (tri_list)); - bary_list = bary_list(!isnan (tri_list), :); + valid = ! isnan (tri_list); + tri_list = tri_list(! isnan (tri_list)); + bary_list = bary_list(! isnan (tri_list), :); nr_t = rows (tri_list); ## assign x,y for each point of simplex - xt = reshape (x(tri(tri_list,:),:), [nr_t, n+1, n]); + xt = reshape (x(tri(tri_list,:),:), [nr_t, n+1, n]); yt = y(tri(tri_list,:)); ## Use barycentric coordinate of point to calculate yi
--- a/scripts/geometry/inpolygon.m +++ b/scripts/geometry/inpolygon.m @@ -70,14 +70,14 @@ ## AND (x,y) on the left of the edge ? idx1 = (((yv(i) <= y & y < yv(j)) | (yv(j) <= y & y < yv(i))) & 0 < distance.*delta_yv); - in (idx1) = !in (idx1); + in(idx1) = ! in(idx1); ## Check if (x,y) are actually on the boundary of the polygon. if (do_boundary) idx2 = (((yv(i) <= y & y <= yv(j)) | (yv(j) <= y & y <= yv(i))) & ((xv(i) <= x & x <= xv(j)) | (xv(j) <= x & x <= xv(i))) & (0 == distance | !delta_xv)); - on (idx2) = true; + on(idx2) = true; endif j = i; endfor @@ -138,7 +138,7 @@ %! assert (in, [false, true]); %! assert (on, [true, false]); -%% Test input validation +## Test input validation %!error inpolygon () %!error inpolygon (1, 2) %!error inpolygon (1, 2, 3)
--- a/scripts/geometry/voronoi.m +++ b/scripts/geometry/voronoi.m @@ -203,7 +203,7 @@ %! assert (vx, [-0.7; 1.7], eps); %! assert (vy, [-0.7; 1.7], eps); -%% Input validation tests +## Input validation tests %!error voronoi () %!error voronoi (ones (3,1)) %!error voronoi (ones (3,1), ones (3,1), "bogus1", "bogus2", "bogus3")
--- a/scripts/geometry/voronoin.m +++ b/scripts/geometry/voronoin.m @@ -75,7 +75,7 @@ endfunction -%% FIXME: Need functional tests +## FIXME: Need functional tests %!error voronoin () %!error voronoin (1,2,3)
--- a/scripts/gui/guidata.m +++ b/scripts/gui/guidata.m @@ -59,7 +59,7 @@ endfunction -%% Test input validation +## Test input validation %!error guidata () %!error guidata (1,2,3) %!error <H must be a valid object handle> guidata ({1})
--- a/scripts/gui/private/__get_funcname__.m +++ b/scripts/gui/private/__get_funcname__.m @@ -31,8 +31,10 @@ if (! __octave_link_enabled__ ()) tk = graphics_toolkit (); funcname = strcat ("__", basename, "_", tk, "__"); - if ((numel (tk) > 0) && (! strcmp(tk, "fltk")) && (! __is_function__ (funcname))) - warning ("%s: no implementation for toolkit '%s', using 'fltk' instead",basename, tk); + if (numel (tk) > 0 && ! strcmp (tk, "fltk") + && ! __is_function__ (funcname))) + warning ("%s: no implementation for toolkit '%s', using 'fltk' instead", + basename, tk); endif funcname = strcat ("__", basename, "_fltk__"); else
--- a/scripts/gui/private/__uigetdir_fltk__.m +++ b/scripts/gui/private/__uigetdir_fltk__.m @@ -29,7 +29,8 @@ error ("uigetdir: fltk graphics toolkit required"); endif - dirname = __fltk_uigetfile__ ("", dialog_title, start_path, [240, 120], "dir"); + dirname = __fltk_uigetfile__ ("", dialog_title, + start_path, [240, 120], "dir"); endfunction
--- a/scripts/gui/private/__uigetfile_fltk__.m +++ b/scripts/gui/private/__uigetfile_fltk__.m @@ -33,7 +33,8 @@ if (length (defdir) > 0) defval = fullfile (defdir, defval); endif - [retval, retpath, retindex] = __fltk_uigetfile__ (filters, title, defval, position, multiselect); + [retval, retpath, retindex] = ... + __fltk_uigetfile__ (filters, title, defval, position, multiselect); endfunction
--- a/scripts/gui/private/__uiobject_split_args__.m +++ b/scripts/gui/private/__uiobject_split_args__.m @@ -55,7 +55,8 @@ endif if (! isempty (parent)) - if (! isempty (parent_type) && isempty (find (strcmpi (get (parent, "type"), parent_type)))) + if (! isempty (parent_type) + && isempty (find (strcmpi (get (parent, "type"), parent_type)))) error ("%s: invalid parent, the parent type must be: %s", ... who, sprintf ("%s, ", parent_type{:})(1:end-2)); endif
--- a/scripts/gui/private/__uiputfile_fltk__.m +++ b/scripts/gui/private/__uiputfile_fltk__.m @@ -33,7 +33,8 @@ if (length (defdir) > 0) defval = fullfile (defdir, defval); endif - [retval, retpath, retindex] = __fltk_uigetfile__ (filters, title, defval, position, tag); + [retval, retpath, retindex] = ... + __fltk_uigetfile__ (filters, title, defval, position, tag); endfunction
--- a/scripts/gui/uicontextmenu.m +++ b/scripts/gui/uicontextmenu.m @@ -17,15 +17,15 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uicontextmenu ("Name", value, @dots{}) +## @deftypefn {Function File} {@var{hui} =} uicontextmenu ("Name", value, @dots{}) ## @end deftypefn ## Author: goffioul -function handle = uicontextmenu (varargin) +function hui = uicontextmenu (varargin) [h, args] = __uiobject_split_args__ ("uicontextmenu", varargin, {"figure"}); - handle = __go_uicontextmenu__ (h, args{:}); + hui = __go_uicontextmenu__ (h, args{:}); endfunction
--- a/scripts/gui/uicontrol.m +++ b/scripts/gui/uicontrol.m @@ -17,21 +17,23 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uicontrol ("Name", value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uicontrol (@var{parent}, "Name", value, @dots{}) -## @deftypefnx {Function File} {} uicontrol (@var{handle}) +## @deftypefn {Function File} {@var{hui} =} uicontrol ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uicontrol (@var{parent}, "Name", value, @dots{}) +## @deftypefnx {Function File} {} uicontrol (@var{h}) ## @end deftypefn ## Author: goffioul -function handle = uicontrol (varargin) +function hui = uicontrol (varargin) - if (nargin == 1 && ishandle (varargin{1}) && strcmpi (get (varargin{1}, "type"), "uicontrol")) + if (nargin == 1 && ishandle (varargin{1}) + && strcmpi (get (varargin{1}, "type"), "uicontrol")) error ("uicontrol focusing not implemented yet."); - else - [h, args] = __uiobject_split_args__ ("uicontrol", varargin, {"figure", "uipanel", "uibuttongroup"}); - handle = __go_uicontrol__ (h, args{:}); endif + [h, args] = __uiobject_split_args__ ("uicontrol", varargin, + {"figure", "uipanel", "uibuttongroup"}); + hui = __go_uicontrol__ (h, args{:}); + endfunction
--- a/scripts/gui/uigetdir.m +++ b/scripts/gui/uigetdir.m @@ -20,9 +20,10 @@ ## @deftypefn {Function File} {@var{dirname} =} uigetdir () ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}) ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}, @var{dialog_name}) -## Open a GUI dialog for selecting a directory. If @var{init_path} is not -## given the current working directory is used. @var{dialog_name} may be -## used to customize the dialog title. +## Open a GUI dialog for selecting a directory. +## +## If @var{init_path} is not given the current working directory is used. +## @var{dialog_name} may be used to customize the dialog title. ## @seealso{uigetfile, uiputfile} ## @end deftypefn @@ -30,17 +31,15 @@ function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open") - funcname = __get_funcname__ (mfilename ()); - if (nargin > 2) print_usage (); endif - if (!ischar (init_path) || !ischar (dialog_name)) + if (! ischar (init_path) || ! ischar (dialog_name)) error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments"); endif - if (!isdir (init_path)) + if (! isdir (init_path)) init_path = fileparts (init_path); endif @@ -55,8 +54,10 @@ default_file_name, dialog_position, dialog_mode, init_path); else + funcname = __get_funcname__ (mfilename ()); dirname = feval (funcname, init_path, dialog_name); endif + endfunction
--- a/scripts/gui/uigetfile.m +++ b/scripts/gui/uigetfile.m @@ -26,6 +26,7 @@ ## ## Open a GUI dialog for selecting a file and return the filename @var{fname}, ## the path to this file @var{fpath}, and the filter index @var{fltidx}. +## ## @var{flt} contains a (list of) file filter string(s) in one of the following ## formats: ## @@ -66,23 +67,17 @@ function [retfile, retpath, retindex] = uigetfile (varargin) - funcname = __get_funcname__ (mfilename ()); - if (nargin > 7) error ("uigetfile: number of input arguments must be less than eight"); endif - defaultvals = {cell(0, 2), # File Filter - "Open File", # Dialog Title - "", # Default file name - [240, 120], # Dialog Position (pixel x/y) - "off", # MultiSelect on/off - pwd}; # Default directory - - outargs = cell (6, 1); - for i = 1 : 6 - outargs{i} = defaultvals{i}; - endfor + ## Preset default values + outargs = {cell(0, 2), # File Filter + "Open File", # Dialog Title + "", # Default file name + [240, 120], # Dialog Position (pixel x/y) + "off", # MultiSelect on/off + pwd}; # Default directory idx1 = idx2 = []; if (length (varargin) > 0) @@ -150,7 +145,7 @@ endif if (stridx) - ## we have string arguments ("position" or "multiselect") + ## string arguments ("position" or "multiselect") ## check for even number of remaining arguments, prop/value pair(s) if (rem (nargin - stridx + 1, 2)) @@ -181,6 +176,7 @@ if (isguirunning ()) [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:}); else + funcname = __get_funcname__ (mfilename ()); [retfile, retpath, retindex] = feval (funcname, outargs{:}); endif
--- a/scripts/gui/uimenu.m +++ b/scripts/gui/uimenu.m @@ -17,11 +17,12 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} uimenu (@var{property}, @var{value}, @dots{}) -## @deftypefnx {Function File} {} uimenu (@var{h}, @var{property}, @var{value}, @dots{}) -## Create a uimenu object and return a handle to it. If @var{h} is omitted -## then a top-level menu for the current figure is created. If @var{h} -## is given then a submenu relative to @var{h} is created. +## @deftypefn {Function File} {@var{hui} =} uimenu (@var{property}, @var{value}, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uimenu (@var{h}, @var{property}, @var{value}, @dots{}) +## Create a uimenu object and return a handle to it. +## +## If @var{h} is omitted then a top-level menu for the current figure is +## created. If @var{h} is given then a submenu relative to @var{h} is created. ## ## uimenu objects have the following specific properties: ## @@ -80,7 +81,8 @@ function hui = uimenu (varargin) - [h, args] = __uiobject_split_args__ ("uimenu", varargin, {"figure", "uicontextmenu", "uimenu"}); + [h, args] = __uiobject_split_args__ ("uimenu", varargin, + {"figure", "uicontextmenu", "uimenu"}); tmp = __go_uimenu__ (h, args{:}); @@ -117,7 +119,7 @@ %! graphics_toolkit (toolkit); %! end_unwind_protect -%% check for top level menus file, edit, and help +## check for top level menus file, edit, and help %!testif HAVE_FLTK %! toolkit = graphics_toolkit ("fltk"); %! hf = figure ("visible", "off");
--- a/scripts/gui/uipanel.m +++ b/scripts/gui/uipanel.m @@ -17,16 +17,17 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uipanel ("Name", value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uipanel (@var{parent}, "Name", value, @dots{}) +## @deftypefn {Function File} {@var{hui} =} uipanel ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uipanel (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul -function handle = uipanel (varargin) +function hui = uipanel (varargin) - [h, args] = __uiobject_split_args__ ("uipanel", varargin, {"figure", "uipanel", "uibuttongroup"}); - handle = __go_uipanel__ (h, args{:}); + [h, args] = __uiobject_split_args__ ("uipanel", varargin, + {"figure", "uipanel", "uibuttongroup"}); + hui = __go_uipanel__ (h, args{:}); endfunction
--- a/scripts/gui/uipushtool.m +++ b/scripts/gui/uipushtool.m @@ -17,15 +17,16 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uipushtool ("Name", value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uipushtool (@var{parent}, "Name", value, @dots{}) +## @deftypefn {Function File} {@var{hui} =} uipushtool ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uipushtool (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul -function handle = uipushtool (varargin) +function hui = uipushtool (varargin) - [h, args] = __uiobject_split_args__ ("uipushtool", varargin, {"uitoolbar"}, 0); + [h, args] = __uiobject_split_args__ ("uipushtool", varargin, + {"uitoolbar"}, 0); if (isempty (h)) h = findobj (gcf, "-depth", 1, "type", "uitoolbar"); if (isempty (h)) @@ -34,7 +35,7 @@ h = h(1); endif endif - handle = __go_uipushtool__ (h, args{:}); + hui = __go_uipushtool__ (h, args{:}); endfunction
--- a/scripts/gui/uiputfile.m +++ b/scripts/gui/uiputfile.m @@ -21,8 +21,10 @@ ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}) ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name}) ## @deftypefnx {Function File} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uiputfile (@var{flt}, @var{dialog_name}, @var{default_file}) -## Open a GUI dialog for selecting a file. @var{flt} contains a (list of) file -## filter string(s) in one of the following formats: +## Open a GUI dialog for selecting a file. +## +## @var{flt} contains a (list of) file filter string(s) in one of the following +## formats: ## ## @table @asis ## @item @qcode{"/path/to/filename.ext"} @@ -56,23 +58,17 @@ function [retfile, retpath, retindex] = uiputfile (varargin) - funcname = __get_funcname__ (mfilename ()); - if (nargin > 3) print_usage (); endif - defaultvals = {cell(0, 2), # File Filter - "Save File", # Dialog Title - "", # Default file name - [240, 120], # Dialog Position (pixel x/y) - "create", - pwd}; # Default directory - - outargs = cell (6, 1); - for i = 1 : 6 - outargs{i} = defaultvals{i}; - endfor + ## Preset default values + outargs = {cell(0, 2), # File Filter + "Save File", # Dialog Title + "", # Default file name + [240, 120], # Dialog Position (pixel x/y) + "create", + pwd}; # Default directory if (nargin > 0) file_filter = varargin{1}; @@ -114,17 +110,17 @@ if (isguirunning ()) [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:}); else + funcname = __get_funcname__ (mfilename ()); [retfile, retpath, retindex] = feval (funcname, outargs{:}); endif - # add extension to the name it isnt already added - - if ischar (retfile) + ## Append extension to the name if it isn't already added. + if (ischar (retfile)) ext = outargs{1}{retindex}; - ext = strrep (ext, '*', ''); + ext = strrep (ext, "*", ""); - if length (retfile) >= length (ext) - if ! strcmp (retfile(end-length (ext)+1:end), ext) + if (length (retfile) >= length (ext)) + if (! strcmp (retfile(end-length (ext)+1:end), ext)) retfile = [retfile ext]; endif endif
--- a/scripts/gui/uiresume.m +++ b/scripts/gui/uiresume.m @@ -18,10 +18,11 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {} uiresume (@var{h}) -## Resume program execution suspended with @code{uiwait}. The handle @var{h} -## must be the same as the on specified in @code{uiwait}. If the handle -## is invalid or there is no @code{uiwait} call pending for the figure -## with handle @var{h}, this function does nothing. +## Resume program execution suspended with @code{uiwait}. +## +## The handle @var{h} must be the same as the on specified in @code{uiwait}. +## If the handle is invalid or there is no @code{uiwait} call pending for the +## figure with handle @var{h}, this function does nothing. ## @seealso{uiwait} ## @end deftypefn
--- a/scripts/gui/uitoggletool.m +++ b/scripts/gui/uitoggletool.m @@ -17,15 +17,16 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uitoggletool ("Name", value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uitoggletool (@var{parent}, "Name", value, @dots{}) +## @deftypefn {Function File} {@var{hui} =} uitoggletool ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uitoggletool (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul -function handle = uitoggletool (varargin) +function hui = uitoggletool (varargin) - [h, args] = __uiobject_split_args__ ("uitoggletool", varargin, {"uitoolbar"}, 0); + [h, args] = __uiobject_split_args__ ("uitoggletool", varargin, + {"uitoolbar"}, 0); if (isempty (h)) h = findobj (gcf, "-depth", 1, "type", "uitoolbar"); if (isempty (h)) @@ -34,7 +35,7 @@ h = h(1); endif endif - handle = __go_uitoggletool__ (h, args{:}); + hui = __go_uitoggletool__ (h, args{:}); endfunction
--- a/scripts/gui/uitoolbar.m +++ b/scripts/gui/uitoolbar.m @@ -17,16 +17,16 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {@var{handle} =} uitoolbar ("Name", value, @dots{}) -## @deftypefnx {Function File} {@var{handle} =} uitoolbar (@var{parent}, "Name", value, @dots{}) +## @deftypefn {Function File} {@var{hui} =} uitoolbar ("Name", value, @dots{}) +## @deftypefnx {Function File} {@var{hui} =} uitoolbar (@var{parent}, "Name", value, @dots{}) ## @end deftypefn ## Author: goffioul -function handle = uitoolbar (varargin) +function hui = uitoolbar (varargin) [h, args] = __uiobject_split_args__ ("uitoolbar", varargin, {"figure"}); - handle = __go_uitoolbar__ (h, args{:}); + hui = __go_uitoolbar__ (h, args{:}); endfunction
--- a/scripts/gui/uiwait.m +++ b/scripts/gui/uiwait.m @@ -21,9 +21,9 @@ ## @deftypefnx {Function File} {} uiwait (@var{h}) ## @deftypefnx {Function File} {} uiwait (@var{h}, @var{timeout}) ## Suspend program execution until the figure with handle @var{h} is -## deleted or @code{uiresume} is called. When no figure handle is specified, -## this function uses the current figure. +## deleted or @code{uiresume} is called. ## +## When no figure handle is specified this function uses the current figure. ## If the figure handle is invalid or there is no current figure, this ## functions returns immediately. ##
--- a/scripts/gui/waitbar.m +++ b/scripts/gui/waitbar.m @@ -190,7 +190,7 @@ %! close (h1); %! close (h2); -%% Test input validation +## Test input validation %!error <FRAC must be between 0 and 1> waitbar (-0.5) %!error <FRAC must be between 0 and 1> waitbar (1.5) %!error <MSG must be a character string> waitbar (0.5, struct ())
--- a/scripts/gui/waitforbuttonpress.m +++ b/scripts/gui/waitforbuttonpress.m @@ -49,7 +49,7 @@ endfunction -%% Test input validation +## Test input validation %!error waitforbuttonpress (1) %!error [a,b,c] = waitforbuttonpress ()
--- a/scripts/help/doc.m +++ b/scripts/help/doc.m @@ -54,7 +54,7 @@ endif ## if GUI is running, let it display the function - if isguirunning () + if (isguirunning ()) __octave_link_show_doc__ (fname); else
--- a/scripts/help/doc_cache_create.m +++ b/scripts/help/doc_cache_create.m @@ -124,7 +124,7 @@ if (! iscell (directory)) directory = {directory}; endif - dirs_notpath = {directory{!dir_in_path}}; + dirs_notpath = {directory{! dir_in_path}}; ## add them if (! isempty (dirs_notpath)) @@ -155,7 +155,7 @@ endfunction -%% No true tests desirable for this function. -%% Test input validation +## No true tests desirable for this function. +## Test input validation %!error doc_cache_create (1)
--- a/scripts/help/get_first_help_sentence.m +++ b/scripts/help/get_first_help_sentence.m @@ -46,7 +46,7 @@ print_usage (); endif - if (!ischar (name)) + if (! ischar (name)) error ("get_first_help_sentence: NAME must be a string"); endif @@ -92,7 +92,8 @@ ## This function extracts the first sentence from a Texinfo help text. ## The function works by removing @def* from the texinfo text. After this, we -## render the text to plain text using makeinfo, and then extract the first line. +## render the text to plain text using makeinfo, and then extract the first +## line. function [text, status] = first_sentence_texinfo (help_text, max_len) ## Lines ending with "@\n" are continuation lines, so they should be ## concatenated with the following line. @@ -154,7 +155,7 @@ %!assert (get_first_help_sentence ('get_first_help_sentence'), ... %! "Return the first sentence of a function's help text.") -%% Test input validation +## Test input validation %!error get_first_help_sentence () %!error get_first_help_sentence (1, 2, 3) %!error <NAME must be a string> get_first_help_sentence (1)
--- a/scripts/help/print_usage.m +++ b/scripts/help/print_usage.m @@ -113,7 +113,7 @@ endl_idx = find (help_text == "\n"); buffer = ""; for k = 1:length (def_idx) - endl = endl_idx (find (endl_idx > def_idx(k), 1)); + endl = endl_idx(find (endl_idx > def_idx(k), 1)); if (isempty (endl)) buffer = strcat (buffer, help_text (def_idx(k):end), "\n"); else
--- a/scripts/help/private/__strip_html_tags__.m +++ b/scripts/help/private/__strip_html_tags__.m @@ -50,9 +50,9 @@ groups = [els(1), 1]; # list containing [start, length] of each group for k = 1:length (dels) if (dels (k) == 1) - groups (end, 2) ++; + groups(end, 2) ++; else - groups (end+1, 1:2) = [els(k+1), 1]; + groups(end+1, 1:2) = [els(k+1), 1]; endif endfor @@ -60,20 +60,20 @@ ## Remove end-lines in the beginning if (groups (1, 1) == 1) - keep (1:groups (1, 2)) = false; + keep(1:groups (1, 2)) = false; endif ## Remove end-lines from the end - if (sum (groups (end, :)) - 1 == length (text)) - keep (groups (end, 1):end) = false; + if (sum (groups(end, :)) - 1 == length (text)) + keep(groups(end, 1):end) = false; endif ## Remove groups of end-lines with more than 3 end-lines next to each other idx = find (groups (:, 2) >= 3); for k = 1:length (idx) - start = groups (idx (k), 1); - stop = start + groups (idx (k), 2) - 1; - keep (start+2:stop) = false; + start = groups(idx(k), 1); + stop = start + groups(idx(k), 2) - 1; + keep(start+2:stop) = false; endfor ## Actually remove the elements
--- a/scripts/image/autumn.m +++ b/scripts/image/autumn.m @@ -53,6 +53,7 @@ endfunction + %!demo %! ## Show the 'autumn' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/bone.m +++ b/scripts/image/bone.m @@ -80,6 +80,7 @@ endfunction + %!demo %! ## Show the 'bone' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/cool.m +++ b/scripts/image/cool.m @@ -52,6 +52,7 @@ endfunction + %!demo %! ## Show the 'cool' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/copper.m +++ b/scripts/image/copper.m @@ -55,6 +55,7 @@ endfunction + %!demo %! ## Show the 'copper' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/cubehelix.m +++ b/scripts/image/cubehelix.m @@ -79,6 +79,7 @@ endfunction + %!demo %! subplot (1, 2, 1) %! rgbplot (cubehelix (256), "composite")
--- a/scripts/image/flag.m +++ b/scripts/image/flag.m @@ -50,6 +50,7 @@ endfunction + %!demo %! ## Show the 'flag' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/gmap40.m +++ b/scripts/image/gmap40.m @@ -48,6 +48,7 @@ endfunction + %!demo %! ## Show the 'gmap40' colormap as an image %! image (1:6, linspace (0, 1, 6), repmat ((1:6)', 1, 6));
--- a/scripts/image/gray.m +++ b/scripts/image/gray.m @@ -53,6 +53,7 @@ endfunction + %!demo %! ## Show the 'gray' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/gray2ind.m +++ b/scripts/image/gray2ind.m @@ -55,7 +55,8 @@ endif cls = class (I); - if (! any (strcmp (cls, {"logical", "uint8", "uint16", "int16", "single", "double"}))) + if (! any (strcmp (cls, {"logical", "uint8", "uint16", "int16", ... + "single", "double"}))) error ("gray2ind: invalid data type '%s'", cls); elseif (isfloat (I) && (min (I(:) < 0) || max (I(:) > 1))) error ("gray2ind: floating point images may only contain values between 0 and 1"); @@ -103,7 +104,7 @@ %! assert (class (gray2ind ([0.0 0.5 1.0], 256)), "uint8") %! assert (class (gray2ind ([0.0 0.5 1.0], 257)), "uint16") -%% Test input validation +## Test input validation %!error gray2ind () %!error gray2ind (1,2,3) %!error <I must be a grayscale or binary image> gray2ind ({1})
--- a/scripts/image/hot.m +++ b/scripts/image/hot.m @@ -68,6 +68,7 @@ endfunction + %!demo %! ## Show the 'hot' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/hsv.m +++ b/scripts/image/hsv.m @@ -55,6 +55,7 @@ endfunction + %!demo %! ## Show the 'hsv' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/hsv2rgb.m +++ b/scripts/image/hsv2rgb.m @@ -106,7 +106,7 @@ endfunction -%% Test pure colors +## Test pure colors %!assert (hsv2rgb ([0 1 1]), [1 0 0]) %!assert (hsv2rgb ([1 1 1]), [1 0 0]) %!assert (hsv2rgb ([1/3 1 1]), [0 1 0]) @@ -120,7 +120,7 @@ %! hsv_img = rand (64, 64, 3); %! assert (rgb2hsv (hsv2rgb (hsv_img)), hsv_img, 1e-6); -%% Test input validation +## Test input validation %!error hsv2rgb () %!error hsv2rgb (1,2) %!error <invalid data type> hsv2rgb ({1})
--- a/scripts/image/imread.m +++ b/scripts/image/imread.m @@ -105,7 +105,9 @@ error ("imread: FILENAME must be a string"); endif - [img, varargout{1:nargout-1}] = imageIO ("imread", @__imread__, "read", filename, varargin{:}); + [img, varargout{1:nargout-1}] = ... + imageIO ("imread", @__imread__, "read", filename, varargin{:}); + endfunction
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -208,7 +208,8 @@ htmp = imagesc (xdata, ydata, im, display_range); set (gca (), "clim", display_range); endif - set (gca (), "visible", "off", "view", [0, 90], "ydir", "reverse", "layer", "top"); + set (gca (), "visible", "off", "view", [0, 90], + "ydir", "reverse", "layer", "top"); axis ("image"); if (nargout > 0) @@ -255,7 +256,7 @@ %! imshow (rand (100, 100)); %! colormap (jet (64)); -%% Test input validation +## Test input validation %!error imshow () %!error <IM must be an image> imshow ({"cell"}) %!error <TrueColor image must be uint8> imshow (ones (3,3,3, "uint32"))
--- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -114,7 +114,7 @@ endfunction -%% Test input validation +## Test input validation %!error imwrite () # Wrong # of args %!error imwrite (1) # Wrong # of args %!error imwrite ({"cell"}, "filename.jpg") # Wrong class for img @@ -192,12 +192,12 @@ %! assert (a, alpha) %!testif HAVE_MAGICK -%! gray = repmat (uint8 (0:255), 100, 1); +%! gray = repmat (uint8 (0:255), 100, 1); %! [g] = write_and_read (".jpeg", gray); %! assert (g, gray, 2) %!testif HAVE_MAGICK -%! gray = repmat (uint8 (0:255), 100, 1); +%! gray = repmat (uint8 (0:255), 100, 1); %! [g] = write_and_read (".jpeg", gray, "quality", 100); %! assert (g, gray)
--- a/scripts/image/ind2gray.m +++ b/scripts/image/ind2gray.m @@ -73,7 +73,7 @@ %!assert (i2g, 0:1/99:1, eps) %!assert (gray2ind (i2g, 100), uint8 (0:99)) -%% Test input validation +## Test input validation %!error ind2gray () %!error ind2gray (1) %!error ind2gray (1,2,3)
--- a/scripts/image/ind2rgb.m +++ b/scripts/image/ind2rgb.m @@ -59,7 +59,8 @@ if (ndims (x) == 2) R = reshape ([R(:); G(:); B(:)], [sz, 3]); elseif (ndims (x) == 4) - R = permute (reshape ([R(:); G(:); B(:)], [sz(1) sz(2) sz(4) 3]), [1 2 4 3]); + R = permute (reshape ([R(:); G(:); B(:)], [sz(1) sz(2) sz(4) 3]), ... + [1 2 4 3]); else ## we should never reach here since ind2x() should filter them out error ("ind2rgb: an indexed image must have 2 or 4 dimensions."); @@ -97,7 +98,7 @@ %! assert (rgb(:,1:2,:), zeros (1,2,3)); %! assert (rgb(:,3,:), 1/63 * ones (1,1,3)); -%% Test input validation +## Test input validation %!error ind2rgb () %!error ind2rgb (1,2,3) %!error <X must be an indexed image> ind2rgb (ones (3,3,3), jet (64))
--- a/scripts/image/jet.m +++ b/scripts/image/jet.m @@ -87,6 +87,7 @@ endfunction + %!demo %! ## Show the 'jet' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/lines.m +++ b/scripts/image/lines.m @@ -50,6 +50,7 @@ endfunction + %!demo %! ## Show the 'lines' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/ntsc2rgb.m +++ b/scripts/image/ntsc2rgb.m @@ -81,7 +81,7 @@ endfunction -%% Test pure R, G, B colors +## Test pure R, G, B colors %!assert (ntsc2rgb ([.299 .596 .211]), [1 0 0], 1e-5) %!assert (ntsc2rgb ([.587 -.274 -.523]), [0 1 0], 1e-5) %!assert (ntsc2rgb ([.114 -.322 .312]), [0 0 1], 1e-5) @@ -94,7 +94,7 @@ %! rgb_img = rand (64, 64, 3); %! assert (ntsc2rgb (rgb2ntsc (rgb_img)), rgb_img, 1e-3); -%% Test input validation +## Test input validation %!error ntsc2rgb () %!error ntsc2rgb (1,2) %!error <YIQ must be of type double> ntsc2rgb (uint8 (1))
--- a/scripts/image/ocean.m +++ b/scripts/image/ocean.m @@ -62,6 +62,7 @@ endfunction + %!demo %! ## Show the 'ocean' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/pink.m +++ b/scripts/image/pink.m @@ -68,6 +68,7 @@ endfunction + %!demo %! ## Show the 'pink' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/prism.m +++ b/scripts/image/prism.m @@ -50,6 +50,7 @@ endfunction + %!demo %! ## Show the 'prism' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/private/__imread__.m +++ b/scripts/image/private/__imread__.m @@ -68,11 +68,12 @@ ## Check key/value options. indexes = cellfun ("isclass", varargin, "char"); - indexes(indexes) &= ismember (tolower (varargin(indexes)), {"frames", "index"}); + indexes(indexes) &= ismember (tolower (varargin(indexes)), + {"frames", "index"}); indexes = find (indexes); if (indexes) options.index = varargin{indexes+1}; - if (! (is_valid_index_option (options.index)) && + if (! is_valid_index_option (options.index) && ! (ischar (options.index) && strcmpi (options.index, "all"))) error ("imread: value for %s must be a vector or the string `all'"); endif
--- a/scripts/image/private/__imwrite__.m +++ b/scripts/image/private/__imwrite__.m @@ -80,7 +80,8 @@ error ("imwrite: value for %s must either be a scalar or the number of frames", param_list{idx}); endif - if (any (options.delaytime(:) < 0) || any (options.delaytime(:) > 65535)) + if (any (options.delaytime(:) < 0) + || any (options.delaytime(:) > 65535)) error ("imwrite: value for %s must be between 0 and 655.35 seconds", param_list{idx}); endif @@ -96,14 +97,16 @@ endif options.disposalmethod = tolower (options.disposalmethod); matches = ismember (options.disposalmethod, - {"donotspecify", "leaveinplace", "restorebg", "restoreprevious"}); + {"donotspecify", "leaveinplace", ... + "restorebg", "restoreprevious"}); if (any (! matches)) error ("imwrite: unknow method %s for option %s", options.disposalmethod{find (! matches, 1)}, param_list{idx}); endif if (isscalar (options.disposalmethod)) - options.disposalmethod = repmat (options.disposalmethod, 1, size (img, 4)); + options.disposalmethod = repmat (options.disposalmethod, ... + 1, size (img, 4)); elseif (numel (options.disposalmethod) != size (img, 4)) error ("imwrite: if value %s is a cell array must have same length as number of frames", param_list{idx});
--- a/scripts/image/private/imwrite_filename.m +++ b/scripts/image/private/imwrite_filename.m @@ -34,7 +34,8 @@ cmap = []; if (ischar (varargin{1})) filename_idx = 1; - elseif (numel (varargin) >= 2 && iscolormap (varargin{1}) && ischar (varargin{2})) + elseif (numel (varargin) >= 2 + && iscolormap (varargin{1}) && ischar (varargin{2})) filename_idx = 2; cmap = varargin{1}; else
--- a/scripts/image/rainbow.m +++ b/scripts/image/rainbow.m @@ -66,6 +66,7 @@ endfunction + %!demo %! ## Show the 'rainbow' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/rgb2hsv.m +++ b/scripts/image/rgb2hsv.m @@ -109,7 +109,7 @@ endfunction -%% Test pure colors and gray +## Test pure colors and gray %!assert (rgb2hsv ([1 0 0]), [0 1 1]) %!assert (rgb2hsv ([0 1 0]), [1/3 1 1]) %!assert (rgb2hsv ([0 0 1]), [2/3 1 1]) @@ -123,7 +123,7 @@ %! rgb_img = rand (64, 64, 3); %! assert (hsv2rgb (rgb2hsv (rgb_img)), rgb_img, 1e-6); -%% Test input validation +## Test input validation %!error rgb2hsv () %!error rgb2hsv (1,2) %!error <invalid data type 'cell'> rgb2hsv ({1})
--- a/scripts/image/rgb2ind.m +++ b/scripts/image/rgb2ind.m @@ -99,7 +99,7 @@ endfunction -%% Test input validation +## Test input validation %!error rgb2ind () %!error rgb2ind (1,2,3,4,5,6,7) %!error <RGB> rgb2ind (rand (10, 10, 4))
--- a/scripts/image/rgb2ntsc.m +++ b/scripts/image/rgb2ntsc.m @@ -97,7 +97,7 @@ endfunction -%% Test pure RED, GREEN, BLUE colors +## Test pure RED, GREEN, BLUE colors %!assert (rgb2ntsc ([1 0 0]), [.299 .596 .211]) %!assert (rgb2ntsc ([0 1 0]), [.587 -.274 -.523]) %!assert (rgb2ntsc ([0 0 1]), [.114 -.322 .312]) @@ -110,7 +110,7 @@ %! rgb_img = rand (64, 64, 3); %! assert (ntsc2rgb (rgb2ntsc (rgb_img)), rgb_img, 1e-3); -%% Test input validation +## Test input validation %!error rgb2ntsc () %!error rgb2ntsc (1,2) %!error <invalid data type 'cell'> rgb2ntsc ({1})
--- a/scripts/image/rgbplot.m +++ b/scripts/image/rgbplot.m @@ -83,7 +83,7 @@ %! subplot (1, 2, 2); %! rgbplot (ocean, "composite"); -%% Test input validation +## Test input validation %!error rgbplot () %!error rgbplot (1,2) %!error <CMAP must be a valid colormap> rgbplot ({0 1 0})
--- a/scripts/image/spring.m +++ b/scripts/image/spring.m @@ -52,6 +52,7 @@ endfunction + %!demo %! ## Show the 'spring' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/summer.m +++ b/scripts/image/summer.m @@ -53,6 +53,7 @@ endfunction + %!demo %! ## Show the 'summer' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/white.m +++ b/scripts/image/white.m @@ -42,6 +42,7 @@ endfunction + %!demo %! ## Show the 'white' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/image/winter.m +++ b/scripts/image/winter.m @@ -52,6 +52,7 @@ endfunction + %!demo %! ## Show the 'winter' colormap as an image %! image (1:64, linspace (0, 1, 64), repmat ((1:64)', 1, 64));
--- a/scripts/io/csvread.m +++ b/scripts/io/csvread.m @@ -35,7 +35,7 @@ endfunction -%% Tests for csvread() are in csvwrite() -%% Mark file as being tested +## Tests for csvread() are in csvwrite() +## Mark file as being tested %!assert (1)
--- a/scripts/io/fileread.m +++ b/scripts/io/fileread.m @@ -56,7 +56,7 @@ %! unlink (fname); %! assert (str, [cstr{1} "\n" cstr{2} "\n" cstr{3} "\n"]); -%% Test input validation +## Test input validation %!error fileread () %!error fileread (1, 2) %!error <FILENAME argument must be a string> fileread (1)
--- a/scripts/io/importdata.m +++ b/scripts/io/importdata.m @@ -129,8 +129,8 @@ [output.data, output.fs] = wavread (fname); otherwise ## Assume the file is in ASCII format. - [output, delimiter, header_rows] = ... - importdata_ascii (fname, delimiter, header_rows); + [output, delimiter, header_rows] = ... + importdata_ascii (fname, delimiter, header_rows); endswitch ## If there are any empty fields in the output structure, then remove them
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -493,9 +493,10 @@ ## 1. Assess "period" in the split-up words array ( < num_words_per_line). ## Could be done using EndOfLine but that prohibits EndOfLine = "" option. - ## Alternative below goes by simply parsing a first grab of words - ## and matching fmt_words to words until the fmt_words array is exhausted. - ## iwrd: ptr to current analyzed word; iwrdp: ptr to pos before analyzed char + ## Alternative below goes by simply parsing a first grab of words and + ## matching fmt_words to words until the fmt_words array is exhausted. + ## iwrd: ptr to current analyzed word. + ## iwrdp: ptr to pos before analyzed char. iwrd = 1; iwrdp = 0; iwrdl = length (words{1}); fwptr = zeros (1, numel (fmt_words)); ii = 1; @@ -601,29 +602,31 @@ e = s(1) + length (fmt_words{ii}) - 1; endif if (! strcmp (fmt_words{ii}, words{icol, 1})) - ## Column doesn't exactly match literal => split needed. Insert a column + ## Column doesn't exactly match literal => split needed. + ## Insert a column words(icol+1:end+1, :) = words(icol:end, :); ## Watch out for empty cells jptr = find (! cellfun ("isempty", words(icol, :))); ## Distinguish leading or trailing literals if (! idg(ii) && ! isempty (s) && s(1) == 1) - ## Leading literal. Assign literal to icol, paste rest in icol + 1 + ## Leading literal. + ## Assign literal to icol, paste rest in icol + 1 ## Apply only to those cells that do have something beyond literal jptr = find (cellfun ("length", words(icol+1, jptr), ... "UniformOutput", false) > e(1)); words(icol+1, :) = {""}; - words(icol+1, jptr) = cellfun ... - (@(x) substr (x, e(1)+1, length (x) - e(1)), words(icol, jptr), ... + words(icol+1, jptr) = cellfun ( + @(x) substr (x, e(1)+1, length (x) - e(1)), words(icol, jptr), "UniformOutput", false); words(icol, jptr) = fmt_words{ii}; fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))]; else if (! idg(ii) && ! isempty (strfind (fmt_words{ii-1}, "%s"))) - ## Trailing literal. If preceding format == '%s' this is an error - warning ... - ("strread: ambiguous '%s' specifier next to literal in column %d", icol); + ## Trailing literal. + ## If preceding format == '%s' this is an error. + warning ("strread: ambiguous '%s' specifier next to literal in column %d", icol); elseif (idg(ii)) ## Current field = fixed width. Strip into icol, rest in icol+1 sw = regexp (fmt_words{ii}, '\d', "once"); @@ -661,7 +664,8 @@ endif else - ## Conv. specifier. Peek if next fmt_word needs split from current column + ## Conversion specifier. + ## Peek if next fmt_word needs split from current column. if (ii < num_words_per_line) if (fwptr(ii) == fwptr(ii+1)) --icol; @@ -672,7 +676,8 @@ ++ii; ++icol; endwhile - ## Done. Reshape words back into 1 long vector and strip padded empty words + ## Done. + ## Reshape words back into one long vector and strip padded empty words words = reshape (words, 1, numel (words))(1 : end-num_words_padded); catch @@ -800,7 +805,7 @@ out = ostrsplit (text, sep, mult_dlms_s1); if (index (sep, eol_char)); out = strrep (out, char (255), ''); endif ## In case of trailing delimiter, strip stray last empty word - if (!isempty (out) && any (sep == text(end))) + if (! isempty (out) && any (sep == text(end))) out(end) = []; endif @@ -850,7 +855,7 @@ %!test %! assert (strread ("Hello World! // this is comment", "%s",... %! "commentstyle", "c++"), ... -%! {"Hello"; "World!"}); +%! {"Hello"; "World!"}); %! assert (strread ("Hello World! % this is comment", "%s",... %! "commentstyle", "matlab"), ... %! {"Hello"; "World!"}); @@ -923,7 +928,7 @@ %! assert (b(1:2), {"2"; "4"}); %! assert (isempty (b{3}), true); -%% MultipleDelimsAsOne +## MultipleDelimsAsOne %!test %! str = "11, 12, 13,, 15\n21,, 23, 24, 25\n,, 33, 34, 35"; %! [a b c d] = strread (str, "%f %f %f %f", "delimiter", ",", "multipledelimsasone", 1, "endofline", "\n"); @@ -932,12 +937,12 @@ %! assert (c', [13, 24, 34]); %! assert (d', [15, 25, 35]); -%% delimiter as sq_string and dq_string +## delimiter as sq_string and dq_string %!test %! assert (strread ("1\n2\n3", "%d", "delimiter", "\n"), %! strread ("1\n2\n3", "%d", "delimiter", '\n')) -%% whitespace as sq_string and dq_string +## whitespace as sq_string and dq_string %!test %! assert (strread ("1\b2\r3\b4\t5", "%d", "whitespace", "\b\r\n\t"), %! strread ("1\b2\r3\b4\t5", "%d", "whitespace", '\b\r\n\t')) @@ -946,7 +951,7 @@ %! str = "0.31 0.86 0.94\n 0.60 0.72 0.87"; %! fmt = "%f %f %f"; %! args = {"delimiter", " ", "endofline", "\n", "whitespace", " "}; -%! [a, b, c] = strread (str, fmt, args {:}); +%! [a, b, c] = strread (str, fmt, args{:}); %! assert (a, [0.31; 0.60], 0.01) %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) @@ -955,7 +960,7 @@ %! str = "0.31,0.86,0.94\n0.60,0.72,0.87"; %! fmt = "%f %f %f"; %! args = {"delimiter", ",", "endofline", "\n", "whitespace", " "}; -%! [a, b, c] = strread (str, fmt, args {:}); +%! [a, b, c] = strread (str, fmt, args{:}); %! assert (a, [0.31; 0.60], 0.01) %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) @@ -964,7 +969,7 @@ %! str = "0.31 0.86 0.94\n 0.60 0.72 0.87"; %! fmt = "%f %f %f"; %! args = {"delimiter", ",", "endofline", "\n", "whitespace", " "}; -%! [a, b, c] = strread (str, fmt, args {:}); +%! [a, b, c] = strread (str, fmt, args{:}); %! assert (a, [0.31; 0.60], 0.01) %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) @@ -973,7 +978,7 @@ %! str = "0.31, 0.86, 0.94\n 0.60, 0.72, 0.87"; %! fmt = "%f %f %f"; %! args = {"delimiter", ",", "endofline", "\n", "whitespace", " "}; -%! [a, b, c] = strread (str, fmt, args {:}); +%! [a, b, c] = strread (str, fmt, args{:}); %! assert (a, [0.31; 0.60], 0.01) %! assert (b, [0.86; 0.72], 0.01) %! assert (c, [0.94; 0.87], 0.01) @@ -1001,39 +1006,39 @@ %! assert (a, [1; 2], 1e-15); %! assert (b, [1; 3], 1e-15); -%% Test for no output arg (interactive use) +## Test for no output arg (interactive use) %!test %! assert (strread (",2,,4\n5,,7,", "", "delimiter", ","), [NaN; 2; NaN; 4; 5; NaN; 7]); -%% Test #1 bug #42609 +## Test #1 bug #42609 %!test %! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", "%f %f %f\n"); %! assert (a, [1; 4; 7]); %! assert (b, [2; 5; 8]); %! assert (c, [3; 6; 9]); -%% Test #2 bug #42609 +## Test #2 bug #42609 %!test %! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", "%f %f\n%f"); %! assert (a, [1;4;7]); %! assert (b, [2; 5; 8]); %! assert (c, [3; 6; 9]); -%% Test #3 bug #42609 +## Test #3 bug #42609 %!test %! [a, b, c] = strread ("1 2 3\n4 5 6\n7 8 9\n", '%f %f %f\n'); %! assert (a, [1; 4; 7]); %! assert (b, [2; 5; 8]); %! assert (c, [3; 6; 9]); -%% Test #3 bug #42609 +## Test #3 bug #42609 %!test %! [a, b, c] = strread ("1 2\n3\n4 5\n6\n7 8\n9\n", '%f %f\n%f'); %! assert (a, [1;4;7]); %! assert (b, [2; 5; 8]); %! assert (c, [3; 6; 9]); -%% Unsupported format specifiers +## Unsupported format specifiers %!test %!error <format specifiers are not supported> strread ("a", "%c") %!error <format specifiers are not supported> strread ("a", "%*c %d") @@ -1050,10 +1055,10 @@ %!error <format specifiers are not supported> strread ("a", "%u32") %!error <format specifiers are not supported> strread ("a", "%*u32 %d") -%% Illegal format specifiers +## Illegal format specifiers %!test %!error <no valid format conversion specifiers> strread ("1.0", "%z"); -%% Test for false positives in check for non-supported format specifiers +## Test for false positives in check for non-supported format specifiers %!test %! assert (strread ("Total: 32.5 % (of cm values)","Total: %f % (of cm values)"), 32.5, 1e-5);
--- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -118,7 +118,8 @@ error ("character value required for EndOfLine"); endif else - ## Determine EOL from file. Search for EOL candidates in first BUFLENGTH chars + ## Determine EOL from file. + ## Search for EOL candidates in the first BUFLENGTH chars eol_srch_len = min (length (str), BUFLENGTH); ## First try DOS (CRLF) if (! isempty (strfind (str(1 : eol_srch_len), "\r\n"))) @@ -158,7 +159,7 @@ endwhile ## Found EOL delimiting last requested line. Compute ptr (incl. EOL) if (isempty (eoi)) - printf ("textread: format repeat count specified but no endofline found\n"); + disp ("textread: format repeat count specified but no endofline found"); eoi_pos = nblks * BUFLENGTH + count; else eoi_pos = (nblks * BUFLENGTH) + eoi(end + min (nlines, n_eoi) - n_eoi); @@ -177,7 +178,7 @@ endif ## Call strread to make it do the real work - [varargout{1:max (nargout, 1)}] = strread (str, format, varargin {:}); + [varargout{1:max (nargout, 1)}] = strread (str, format, varargin{:}); ## Hack to concatenate/reshape numeric output into 2D array (undocumented ML) ## In ML this only works in case of an empty format string @@ -202,7 +203,7 @@ ncols = numel (strfind (str, " ")) + 1; else ## 3B. Just count delimiters. FIXME: delimiters could occur in literals - delimiter = varargin {idelimiter+1}; + delimiter = varargin{idelimiter+1}; ncols = numel (regexp (str, sprintf ("[%s]", delimiter))) + 1; endif ## 6. Reshape; watch out, we need a transpose @@ -238,7 +239,7 @@ %! unlink (f); %! assert (a, d(2:7, 1), 1e-2); -%% Test reading 2D matrix with empty format +## Test reading 2D matrix with empty format %!test %! f = tempname (); %! d = rand (5, 2); @@ -247,7 +248,7 @@ %! unlink (f); %! assert (A, d(4:5, :), 1e-2); -%% Read multiple lines using empty format string +## Read multiple lines using empty format string %!test %! f = tempname (); %! unlink (f); @@ -259,7 +260,7 @@ %! unlink (f); %! assert (A, d, 1e-6); -%% Empty format, corner case = one line w/o EOL +## Empty format, corner case = one line w/o EOL %!test %! f = tempname (); %! unlink (f); @@ -271,7 +272,7 @@ %! unlink (f); %! assert (A, d, 1e-6); -%% Read multiple lines using empty format string, missing data (should be 0) +## Read multiple lines using empty format string, missing data (should be 0) %!test %! f = tempname (); %! unlink (f); @@ -283,7 +284,7 @@ %! unlink (f); %! assert (A, [ d(1:2) 0 d(3:4)], 1e-6); -%% Test with empty positions - ML returns 0 for empty fields +## Test with empty positions - ML returns 0 for empty fields %!test %! f = tempname (); %! unlink (f); @@ -295,8 +296,8 @@ %! unlink (f); %! assert (A, [0 2 0 4; 5 0 7 0], 1e-6); -%% Another test with empty format + positions, now with more incomplete lower -%% row (must be appended with zeros to get rectangular matrix) +## Another test with empty format + positions, now with more incomplete lower +## row (must be appended with zeros to get rectangular matrix) %!test %! f = tempname (); %! unlink (f); @@ -308,7 +309,7 @@ %! unlink (f); %! assert (A, [0 2 0 4; 5 0 0 0], 1e-6); -%% Test input validation +## Test input validation %!error textread () %!error textread (1) %!error <arguments must be strings> textread (1, "%f")
--- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -232,7 +232,8 @@ endif else if (! ischar (fid)) - ## Determine EOL from file. Search for EOL candidates in first BUFLENGTH chars + ## Determine EOL from file. + ## Search for EOL candidates in the first BUFLENGTH chars eol_srch_len = min (length (str), BUFLENGTH); ## First try DOS (CRLF) if (! isempty (strfind (str(1 : eol_srch_len), "\r\n"))) @@ -251,7 +252,7 @@ args(end+1:end+2) = {"endofline", eol_char}; endif - if (!ischar (fid)) + if (! ischar (fid)) ## Now that we know what EOL looks like, we can process format_repeat_count. ## FIXME The below isn't ML-compatible: counts lines, not format string uses if (isfinite (nlines) && (nlines >= 0)) @@ -276,11 +277,12 @@ endwhile ## OK, found EOL delimiting last requested line. Compute ptr (incl. EOL) if (isempty (eoi)) - printf ("textscan: format repeat count specified but no endofline found\n"); + disp ("textscan: format repeat count specified but no endofline found"); data_size = nblks * BUFLENGTH + count; else ## Compute data size to read incl complete EOL - data_size = (nblks * BUFLENGTH) + eoi(end + min (nlines, n_eoi) - n_eoi) ... + data_size = (nblks * BUFLENGTH) ... + + eoi(end + min (nlines, n_eoi) - n_eoi) ... + l_eol_char - 1; endif fseek (fid, st_pos, "bof"); @@ -434,12 +436,12 @@ %! assert (a{2}', {'B' 'J' 'R' 'Z'}); %! assert (a{3}', int32 ([16 241 3 0])); -%% Test with default endofline parameter +## Test with default endofline parameter %!test %! c = textscan ("L1\nL2", "%s"); %! assert (c{:}, {"L1"; "L2"}); -%% Test with endofline parameter set to "" (empty) - newline should be in word +## Test with endofline parameter set to "" (empty) - newline should be in word %!test %! c = textscan ("L1\nL2", "%s", "endofline", ""); %! assert (int8 (c{:}{:}), int8 ([ 76, 49, 10, 76, 50 ])); @@ -450,8 +452,8 @@ %! c = textscan (str, "Text%*dText%dText"); %! assert (c{1}, int32 ([2; 4; 0])); +## CollectOutput test %!test -%% CollectOutput test %! b = [10:10:100]; %! b = [b; 8*b/5; 8*b*1000/5]; %! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b); @@ -460,8 +462,8 @@ %! assert (size (c{3}), [10, 2]); %! assert (size (c{2}), [10, 2]); +## CollectOutput test with uneven column length files %!test -%% CollectOutput test with uneven column length files %! b = [10:10:100]; %! b = [b; 8*b/5; 8*b*1000/5]; %! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b); @@ -475,7 +477,7 @@ %! assert (c{2}{11, 1}, "/hr"); %! assert (isempty (c{2}{11, 2}), true); -%% Test input validation +## Test input validation %!error textscan () %!error textscan (single (4)) %!error textscan ({4}) @@ -488,13 +490,13 @@ %! assert (R{1}, int32 (1)); %! assert (isempty (R{2}), true); -%% bug #37023 (actually a strread test) +## bug #37023 (actually a strread test) %!test %! data = textscan(" 1. 1 \n 2 3\n", '%f %f'); %! assert (data{1}, [1; 2], 1e-15); %! assert (data{2}, [1; 3], 1e-15); -%% Whitespace test (bug #37333) using delimiter ";" +## Whitespace test (bug #37333) using delimiter ";" %!test %! tc = []; %! tc{1, 1} = "C:/code;"; @@ -511,7 +513,7 @@ %! assert (strcmp (lh, rh)); %! end -%% Whitespace test (bug #37333), adding multipleDelimsAsOne true arg +## Whitespace test (bug #37333), adding multipleDelimsAsOne true arg %!test %! tc = []; %! tc{1, 1} = "C:/code;"; @@ -528,7 +530,7 @@ %! assert (strcmp (lh, rh)); %! end -%% Whitespace test (bug #37333), adding multipleDelimsAsOne false arg +## Whitespace test (bug #37333), adding multipleDelimsAsOne false arg %!test %! tc = []; %! tc{1, 1} = "C:/code;"; @@ -546,7 +548,7 @@ %! assert (strcmp (lh, rh)); %! end -%% Whitespace test (bug #37333) whitespace "" arg +## Whitespace test (bug #37333) whitespace "" arg %!test %! tc = []; %! tc{1, 1} = "C:/code;"; @@ -562,7 +564,7 @@ %! assert (strcmp (lh, rh)); %! end -%% Whitespace test (bug #37333), whitespace " " arg +## Whitespace test (bug #37333), whitespace " " arg %!test %! tc = []; %! tc{1, 1} = "C:/code;"; @@ -579,7 +581,7 @@ %! assert (strcmp (lh, rh)); %! end -%% Test reading from a real file +## Test reading from a real file %!test %! f = tempname (); %! fid = fopen (f, "w+"); @@ -592,7 +594,7 @@ %! assert (A{1}, [d(1); d(3)], 1e-6); %! assert (A{2}, [d(2); d(4)], 1e-6); -%% Tests reading with empty format, should return proper nr of columns +## Tests reading with empty format, should return proper nr of columns %!test %! f = tempname (); %! fid = fopen (f, "w+"); @@ -606,7 +608,7 @@ %! assert (A{3}, [3 ; 7], 1e-6); %! assert (A{4}, [4 ; 8], 1e-6); -%% Tests reading with empty format; empty fields & incomplete lower row +## Tests reading with empty format; empty fields & incomplete lower row %!test %! f = tempname (); %! fid = fopen (f, "w+"); @@ -617,7 +619,7 @@ %! unlink (f); %! assert (A{1}, [999, 2, 999, 4; 5, 6, 999, 999], 1e-6); -%% Error message tests +## Error message tests %!test %! f = tempname (); @@ -667,24 +669,24 @@ %! unlink (f); %! assert (msg1, lasterr); -%% Bug #41824 +## Bug #41824 %!test %! assert (textscan ("123", "", "whitespace", " "){:}, 123); -%% Bug #42343-1, just test supplied emptyvalue (actually done by strread.m) +## Bug #42343-1, just test supplied emptyvalue (actually done by strread.m) %!test %! assert (textscan (",NaN", "", "delimiter", "," ,"emptyValue" ,Inf), {Inf, NaN}); -%% Bug #42343-2, test padding with supplied emptyvalue (done by textscan.m) +## Bug #42343-2, test padding with supplied emptyvalue (done by textscan.m) %!test %! a = textscan (",1,,4\nInf, ,NaN", "", "delimiter", ",", "emptyvalue", -10); %! assert (cell2mat (a), [-10, 1, -10, 4; Inf, -10, NaN, -10]); -%% Bug #42528 +## Bug #42528 %!test %! assert (textscan ("1i", ""){1}, 0+1i); %! assert (cell2mat (textscan ("3, 2-4i, NaN\n -i, 1, 23.4+2.2i", "")), [3+0i, 2-4i, NaN+0i; 0-i, 1+0i, 23.4+2.2i]); -%% Illegal format specifiers +## Illegal format specifiers %!test %!error <no valid format conversion specifiers> textscan ("1.0", "%z");
--- a/scripts/java/javachk.m +++ b/scripts/java/javachk.m @@ -146,6 +146,6 @@ %!testif HAVE_JAVA %! assert (javachk ("jvm"), ""); -%% Test input validation +## Test input validation %!error <javachk: unrecognized feature 'foobar'> javachk ("foobar")
--- a/scripts/java/javaclasspath.m +++ b/scripts/java/javaclasspath.m @@ -28,8 +28,8 @@ ## If called with no inputs: ## ## @itemize -## @item If no output is requested, the dynamic and static classpaths are printed -## to the standard output. +## @item If no output is requested, the dynamic and static classpaths are +## printed to the standard output. ## ## @item If one output value @var{dpath} is requested, the result is ## the dynamic classpath. @@ -65,7 +65,8 @@ dynamic_path_list = ostrsplit (dynamic_path, pathsep ()); ## static classpath - static_path = javaMethod ("getProperty", "java.lang.System", "java.class.path"); + static_path = javaMethod ("getProperty", + "java.lang.System", "java.class.path"); static_path_list = ostrsplit (static_path, pathsep ()); if (numel (static_path_list) > 1) ## remove first element (which is .../octave.jar) @@ -98,7 +99,7 @@ path2 = cellstr (static_path_list); else switch (tolower (which)) - case "-all", path1 = cellstr ([static_path_list, dynamic_path_list]); + case "-all", path1 = cellstr ([static_path_list,dynamic_path_list]); case "-dynamic", path1 = cellstr (dynamic_path_list); case "-static", path1 = cellstr (static_path_list); otherwise
--- a/scripts/java/usejava.m +++ b/scripts/java/usejava.m @@ -57,7 +57,7 @@ retval = false; - switch feature + switch (feature) ## For each feature, try methods() on a Java class of a feature case "awt" try @@ -88,7 +88,7 @@ %!testif HAVE_JAVA %! assert (usejava ("jvm"), true); -%% Test input validation +## Test input validation %!error usejava () %!error usejava (1, 2) %!error usejava (1)
--- a/scripts/linear-algebra/bandwidth.m +++ b/scripts/linear-algebra/bandwidth.m @@ -98,7 +98,7 @@ %! [a,b] = bandwidth (ones (5,5)); %! assert ([a,b] == [4,4]); -%% Test input validation +## Test input validation %!error bandwidth () %!error bandwidth (1,2,3) %!error [a,b,c] = bandwidth (ones (2))
--- a/scripts/linear-algebra/commutation_matrix.m +++ b/scripts/linear-algebra/commutation_matrix.m @@ -90,7 +90,7 @@ k = zeros (m * n, m * n); for i = 1 : m for j = 1 : n - k ((i - 1) * n + j, (j - 1) * m + i) = 1; + k((i - 1) * n + j, (j - 1) * m + i) = 1; endfor endfor
--- a/scripts/linear-algebra/duplication_matrix.m +++ b/scripts/linear-algebra/duplication_matrix.m @@ -77,10 +77,10 @@ ## It is clearly possible to make this a LOT faster! count = 0; for j = 1 : n - d ((j - 1) * n + j, count + j) = 1; + d((j - 1) * n + j, count + j) = 1; for i = (j + 1) : n - d ((j - 1) * n + i, count + i) = 1; - d ((i - 1) * n + j, count + i) = 1; + d((j - 1) * n + i, count + i) = 1; + d((i - 1) * n + j, count + i) = 1; endfor count = count + n - j; endfor
--- a/scripts/linear-algebra/expm.m +++ b/scripts/linear-algebra/expm.m @@ -149,7 +149,7 @@ %!assert (full (expm (eye (3))), expm (full (eye (3)))) %!assert (full (expm (10*eye (3))), expm (full (10*eye (3))), 8*eps) -%% Test input validation +## Test input validation %!error expm () %!error expm (1, 2) %!error <expm: A must be a square matrix> expm ([1 0;0 1; 2 2])
--- a/scripts/linear-algebra/isbanded.m +++ b/scripts/linear-algebra/isbanded.m @@ -74,7 +74,7 @@ %! assert (! isbanded (A,0,1)) %! assert (! isbanded (A,1,0)) -%% Test input validation +## Test input validation %!error isbanded () %!error isbanded (1) %!error isbanded (1,2)
--- a/scripts/linear-algebra/isdiag.m +++ b/scripts/linear-algebra/isdiag.m @@ -50,7 +50,7 @@ %!assert (isdiag (speye (1000000))) %!assert (isdiag (logical (eye (10)))) -%% Test input validation +## Test input validation %!error isdiag () %!error isdiag (1,2)
--- a/scripts/linear-algebra/istril.m +++ b/scripts/linear-algebra/istril.m @@ -55,7 +55,7 @@ %!assert (istril (tril (randn (10)))) %!assert (! istril (randn (10))) -%% Test input validation +## Test input validation %!error istril () %!error istril (1,2)
--- a/scripts/linear-algebra/istriu.m +++ b/scripts/linear-algebra/istriu.m @@ -55,7 +55,7 @@ %!assert (istriu (triu (randn (10)))) %!assert (! istriu (randn (10))) -%% Test input validation +## Test input validation %!error istriu () %!error istriu (1,2)
--- a/scripts/linear-algebra/logm.m +++ b/scripts/linear-algebra/logm.m @@ -170,7 +170,7 @@ %!assert (full (logm (10*eye (3))), logm (full (10*eye (3))), 8*eps) %!assert (logm (expm ([0 1i; -1i 0])), [0 1i; -1i 0], 10 * eps) -%% Test input validation +## Test input validation %!error logm () %!error logm (1, 2, 3) %!error <logm: A must be a square matrix> logm ([1 0;0 1; 2 2])
--- a/scripts/linear-algebra/normest.m +++ b/scripts/linear-algebra/normest.m @@ -84,7 +84,7 @@ %! A = rand (10); %! assert (normest (A), norm (A), 1e-6); -%% Test input validation +## Test input validation %!error normest () %!error normest (1, 2, 3) %!error normest ([true true])
--- a/scripts/linear-algebra/null.m +++ b/scripts/linear-algebra/null.m @@ -65,7 +65,7 @@ rank = sum (s > tol); if (rank < cols) - retval = V (:, rank+1:cols); + retval = V(:, rank+1:cols); if (isa (A, "single")) retval (abs (retval) < eps ("single")) = 0; else @@ -79,7 +79,7 @@ endfunction -%% FIXME: Need some tests for 'single' variables as well +## FIXME: Need some tests for 'single' variables as well %!test %! A = 0;
--- a/scripts/linear-algebra/orth.m +++ b/scripts/linear-algebra/orth.m @@ -67,7 +67,7 @@ rank = sum (s > tol); if (rank > 0) - retval = -U (:, 1:rank); + retval = -U(:, 1:rank); else retval = zeros (rows, 0); endif
--- a/scripts/linear-algebra/qzhess.m +++ b/scripts/linear-algebra/qzhess.m @@ -71,21 +71,21 @@ ## disp (["zero out aa(", num2str(i), ",", num2str(j), ")"]) rot = givens (aa (i-1, j), aa (i, j)); - aa ((i-1):i, :) = rot *aa ((i-1):i, :); - bb ((i-1):i, :) = rot *bb ((i-1):i, :); - q ((i-1):i, :) = rot *q ((i-1):i, :); + aa((i-1):i, :) = rot *aa((i-1):i, :); + bb((i-1):i, :) = rot *bb((i-1):i, :); + q((i-1):i, :) = rot * q((i-1):i, :); ## disp (["now zero out bb(", num2str(i), ",", num2str(i-1), ")"]) rot = givens (bb (i, i), bb (i, i-1))'; - bb (:, (i-1):i) = bb (:, (i-1):i) * rot'; - aa (:, (i-1):i) = aa (:, (i-1):i) * rot'; - z (:, (i-1):i) = z (:, (i-1):i) * rot'; + bb(:, (i-1):i) = bb(:, (i-1):i) * rot'; + aa(:, (i-1):i) = aa(:, (i-1):i) * rot'; + z(:, (i-1):i) = z(:, (i-1):i) * rot'; endfor endfor - bb (2, 1) = 0.0; + bb(2, 1) = 0.0; for i = 3:na bb (i, 1:(i-1)) = zeros (1, i-1); aa (i, 1:(i-2)) = zeros (1, i-2);
--- a/scripts/linear-algebra/rref.m +++ b/scripts/linear-algebra/rref.m @@ -65,7 +65,7 @@ A(r:rows, c) = zeros (rows-r+1, 1); else ## keep track of bound variables - used (1, c) = 1; + used(1, c) = 1; ## Swap current row and pivot row A([pivot, r], c:cols) = A([r, pivot], c:cols);
--- a/scripts/miscellaneous/citation.m +++ b/scripts/miscellaneous/citation.m @@ -47,7 +47,7 @@ endfunction -%% Test input validation +## Test input validation %!error citation (1, 2) %!error <citation: PACKAGE must be a string> citation (1) %!error <citation: package .* is not installed> citation ("__NOT_A_VALID_PKG_NAME__")
--- a/scripts/miscellaneous/compare_versions.m +++ b/scripts/miscellaneous/compare_versions.m @@ -122,7 +122,7 @@ if (isempty (v1n) && isempty (v1c)) error ("compare_versions: version string V1 is not valid: %s", v1); - elseif (isempty (v2n) && isempty (v2c)) + elseif (isempty (v2n) && isempty (v2c)) error ("compare_versions: version string V2 is not valid: %s", v2); endif @@ -222,7 +222,7 @@ %!assert (compare_versions ("0.1", "0.1", "!="), false) %!assert (compare_versions ("0.1", "0.1", "~="), false) -%% Test input validation +## Test input validation %!error compare_versions () %!error compare_versions (1) %!error compare_versions (1,2)
--- a/scripts/miscellaneous/delete.m +++ b/scripts/miscellaneous/delete.m @@ -89,7 +89,7 @@ %! close (hf); %! end_unwind_protect -%% Test input validation +## Test input validation %!error delete () %!error <first argument must be a filename> delete (struct ())
--- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -582,7 +582,7 @@ %! edit author none %! edit email none %! edit license none -%! edit ("editinplace", !s.editinplace) +%! edit ("editinplace", ! s.editinplace) %! if (s.mode(1) == "a") %! edit mode sync %! else
--- a/scripts/miscellaneous/fileparts.m +++ b/scripts/miscellaneous/fileparts.m @@ -103,7 +103,7 @@ %! [d, n, e] = fileparts (".ext"); %! assert (strcmp (d, "") && strcmp (n, "") && strcmp (e, ".ext")); -%% Test input validation +## Test input validation %!error fileparts () %!error fileparts (1,2) %!error <FILENAME must be a single string> fileparts (1)
--- a/scripts/miscellaneous/fullfile.m +++ b/scripts/miscellaneous/fullfile.m @@ -102,18 +102,18 @@ %!assert (fullfile ("x", "y", {"c", "d"}), {[xfsyfs "c"], [xfsyfs "d"]}) -%% Windows specific - drive letters and file sep type +## Windows specific - drive letters and file sep type %!test %! if (ispc) %! assert (fullfile ('\/\/\//A:/\/\', "x/", "/", "/", "y", "/", "/"), ... %! ['A:\' xfsyfs]); %! endif -%% Windows specific - drive letters and file sep type, cell array +## Windows specific - drive letters and file sep type, cell array %!test %! if (ispc) %! tmp = fullfile ({"\\\/B:\//", "A://c", "\\\C:/g/h/i/j\/"}); %! assert (tmp{1}, 'B:\'); %! assert (tmp{2}, 'A:\c'); %! assert (tmp{3}, 'C:\g\h\i\j\'); -%! endif \ No newline at end of file +%! endif
--- a/scripts/miscellaneous/genvarname.m +++ b/scripts/miscellaneous/genvarname.m @@ -210,7 +210,7 @@ ## Exclusions in odd format %!assert (genvarname ("x", {"a", "b"; "x", "d"}), "x1") -%% Test input validation +## Test input validation %!error genvarname () %!error genvarname (1,2,3) %!error <more than one STR is given, it must be a cellstr> genvarname (char ("a", "b", "c"))
--- a/scripts/miscellaneous/getfield.m +++ b/scripts/miscellaneous/getfield.m @@ -60,7 +60,7 @@ %! ss(1,2).fd(3).b(1,4) = 5; %! assert (getfield (ss,{1,2},"fd",{3},"b", {1,4}), 5); -%% Test input validation +## Test input validation %!error getfield () %!error getfield (1) %!error <invalid index> getfield (1,2)
--- a/scripts/miscellaneous/license.m +++ b/scripts/miscellaneous/license.m @@ -102,7 +102,7 @@ ## We ignore the toogle argument because... what's the point? We ## don't need a license management system on Octave. This function ## will return true, even if anyone tries to disabled a license. - switch tolower (toogle) + switch (tolower (toogle)) case "enable" # do nothing case "disable" # do nothing otherwise error ("license: TOOGLE must be enable or disable"); @@ -181,7 +181,7 @@ %! [s, e] = license ("checkout", "NOT_A_PACKAGE"); %! assert (e, 'No package named "NOT_A_PACKAGE" installed'); -%% Test input validation +## Test input validation %!error license ("not_inuse") %!error license ("not_test", "octave", "enable") %!error <TOOGLE must be enable or disable> license ("test", "octave", "invalid_toogle")
--- a/scripts/miscellaneous/mkoctfile.m +++ b/scripts/miscellaneous/mkoctfile.m @@ -148,7 +148,8 @@ bindir = octave_config_info ("bindir"); ext = octave_config_info ("EXEEXT"); - shell_script = fullfile (bindir, sprintf ("mkoctfile-%s%s", OCTAVE_VERSION, ext)); + shell_script = fullfile (bindir, + sprintf ("mkoctfile-%s%s", OCTAVE_VERSION, ext)); if (! exist (shell_script, "file")) __gripe_missing_component__ ("mkoctfile", "mkoctfile");
--- a/scripts/miscellaneous/open.m +++ b/scripts/miscellaneous/open.m @@ -72,7 +72,7 @@ endfunction -%% Test input validation +## Test input validation %!error open %!error open (1) %!error output = open (1)
--- a/scripts/miscellaneous/run.m +++ b/scripts/miscellaneous/run.m @@ -87,7 +87,7 @@ endfunction -%% Test input validation +## Test input validation %!error run () %!error run ("a", "b") %!error <SCRIPT must exist> run ("__A_very_#unlikely#_file_name__")
--- a/scripts/miscellaneous/setfield.m +++ b/scripts/miscellaneous/setfield.m @@ -141,7 +141,7 @@ %! oo = setfield (oo,{1,2},"fd",{3},"b", {1,4}, 6); %! assert (oo(1,2).fd(3).b(1,4), 6); -%% Test input validation +## Test input validation %!error setfield () %!error setfield (1) %!error setfield (1,2)
--- a/scripts/miscellaneous/xor.m +++ b/scripts/miscellaneous/xor.m @@ -94,7 +94,7 @@ ## Test XOR reduction %!assert (xor ([1 0], [1 1], [0 0]), logical ([0 1])) -%% Test input validation +## Test input validation %!error xor () %!error xor (1) %!error <X and Y must be of compatible size> xor (ones (3,2), ones (2,3))
--- a/scripts/optimization/fminbnd.m +++ b/scripts/optimization/fminbnd.m @@ -53,7 +53,8 @@ ## @end deftypefn ## This is patterned after opt/fmin.f from Netlib, which in turn is taken from -## Richard Brent: Algorithms For Minimization Without Derivatives, Prentice-Hall (1973) +## Richard Brent: Algorithms For Minimization Without Derivatives, +## Prentice-Hall (1973) ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup. ## PKG_ADD: [~] = __all_opts__ ("fminbnd");
--- a/scripts/optimization/fminunc.m +++ b/scripts/optimization/fminunc.m @@ -251,7 +251,7 @@ if (fval1 < fval) ## Scaled actual reduction. - actred = (fval - fval1) / (abs (fval1) + abs (fval)); + actred = (fval - fval1) / (abs (fval1) + abs (fval)); else actred = -1; endif @@ -371,6 +371,7 @@ %! n = length (x); %! f = sumsq (1 - x(1:n-1)) + 100 * sumsq (x(2:n) - x(1:n-1).^2); %!endfunction +%! %!test %! [x, fval, info, out] = fminunc (@__rosenb, [5, -5]); %! tol = 2e-5; @@ -383,7 +384,8 @@ %! assert (info > 0); %! assert (x, ones (1, 4), tol); %! assert (fval, 0, tol); -%% Test FunValCheck works correctly + +## Test FunValCheck works correctly %!assert (fminunc (@(x) x^2, 1, optimset ("FunValCheck", "on")), 0, eps) %!error <non-real value> fminunc (@(x) x + i, 1, optimset ("FunValCheck", "on")) %!error <NaN value> fminunc (@(x) x + NaN, 1, optimset ("FunValCheck", "on"))
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -262,9 +262,9 @@ ## FIXME: the original minpack used the following rescaling strategy: ## dg = max (dg, jcn); ## but it seems not good if we start with a bad guess yielding Jacobian - ## columns with large norms that later decrease, because the corresponding - ## variable will still be overscaled. So instead, we only give the old - ## scaling a small momentum, but do not honor it. + ## columns with large norms that later decrease, because the + ## corresponding variable will still be overscaled. So instead, we only + ## give the old scaling a small momentum, but do not honor it. dg = max (0.1*dg, jcn); endif
--- a/scripts/optimization/fzero.m +++ b/scripts/optimization/fzero.m @@ -333,7 +333,8 @@ ## Check solution for a singularity by examining slope if (info == 1) - if ((b - a) != 0 && abs ((fb - fa)/(b - a) / slope0) > max (1e6, 0.5/(eps+tolx))) + if ((b - a) != 0 + && abs ((fb - fa)/(b - a) / slope0) > max (1e6, 0.5/(eps+tolx))) info = -5; endif endif
--- a/scripts/optimization/lsqnonneg.m +++ b/scripts/optimization/lsqnonneg.m @@ -82,7 +82,8 @@ return; endif - if (! (nargin >= 2 && nargin <= 4 && ismatrix (c) && ismatrix (d) && isstruct (options))) + if (nargin < 2 || nargin > 4 + || ! (ismatrix (c) && ismatrix (d) && isstruct (options))) print_usage (); endif
--- a/scripts/optimization/optimget.m +++ b/scripts/optimization/optimget.m @@ -68,7 +68,7 @@ %!assert (optimget (opts, "TolFun"), []) %!assert (optimget (opts, "TolFun", 1e-3), 1e-3) -%% Test input validation +## Test input validation %!error optimget () %!error optimget (1) %!error optimget (1,2,3,4,5)
--- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -184,7 +184,7 @@ %!assert (isfield (optimset ("tolFun", 1e-3), "TolFun")) %!assert (optimget (optimset ("tolx", 1e-2), "tOLx"), 1e-2) -%% Test input validation +## Test input validation %!error optimset ("1_Parameter") %!error <no defaults for function> optimset ("%NOT_A_REAL_FUNCTION_NAME%") %!warning <unrecognized option: foobar> optimset ("foobar", 13);
--- a/scripts/optimization/pqpnonneg.m +++ b/scripts/optimization/pqpnonneg.m @@ -75,7 +75,8 @@ return; endif - if (! (nargin >= 2 && nargin <= 4 && ismatrix (c) && ismatrix (d) && isstruct (options))) + if (nargin < 2 || nargin > 4 + || ! (ismatrix (c) && ismatrix (d) && isstruct (options))) print_usage (); endif @@ -134,7 +135,7 @@ x += alpha*(xx - x); ## LH11: move from P to Z all X == 0. ## This corresponds to those indices where minimum of sf is attained. - idx = idx (sf == alpha); + idx = idx(sf == alpha); p(idx) = []; if (usechol) ## update the Cholesky factorization.
--- a/scripts/optimization/qp.m +++ b/scripts/optimization/qp.m @@ -273,7 +273,8 @@ if (! isempty (A_lb) && ! isempty (A_ub)) rtol = sqrt (eps); for i = 1:dimA_in - if (abs (A_lb(i) - A_ub(i)) < rtol*(1 + max (abs (A_lb(i) + A_ub(i))))) + if (abs (A_lb(i) - A_ub(i)) + < rtol*(1 + max (abs (A_lb(i) + A_ub(i))))) ## These are actually an equality constraint tmprow = A_in(i,:); A = [A;tmprow]; @@ -306,8 +307,8 @@ n_in = numel (bin); ## Check if the initial guess is feasible. - if (isa (x0, "single") || isa (H, "single") || isa (q, "single") || isa (A, "single") - || isa (b, "single")) + if (isa (x0, "single") || isa (H, "single") || isa (q, "single") + || isa (A, "single") || isa (b, "single")) rtol = sqrt (eps ("single")); else rtol = sqrt (eps); @@ -408,7 +409,7 @@ endfunction -%% Test infeasible initial guess (bug #40536) +## Test infeasible initial guess (bug #40536) %!testif HAVE_GLPK %! %! H = 1; q = 0; # objective: x -> 0.5 x^2
--- a/scripts/optimization/sqp.m +++ b/scripts/optimization/sqp.m @@ -196,7 +196,7 @@ print_usage (); endif - if (!isvector (x0)) + if (! isvector (x0)) error ("sqp: X0 must be a vector"); endif if (rows (x0) == 1) @@ -208,7 +208,7 @@ switch (numel (objf)) case 1 obj_fun = objf{1}; - obj_grd = @ (x) fd_obj_grd (x, obj_fun); + obj_grd = @(x) fd_obj_grd (x, obj_fun); case 2 obj_fun = objf{1}; obj_grd = objf{2}; @@ -222,7 +222,7 @@ endswitch else obj_fun = objf; # No cell array, only obj_fun set - obj_grd = @ (x) fd_obj_grd (x, obj_fun); + obj_grd = @(x) fd_obj_grd (x, obj_fun); endif ce_fun = @empty_cf; @@ -232,7 +232,7 @@ switch (numel (cef)) case 1 ce_fun = cef{1}; - ce_grd = @ (x) fd_ce_jac (x, ce_fun); + ce_grd = @(x) fd_ce_jac (x, ce_fun); case 2 ce_fun = cef{1}; ce_grd = cef{2}; @@ -241,7 +241,7 @@ endswitch elseif (! isempty (cef)) ce_fun = cef; # No cell array, only constraint equality function set - ce_grd = @ (x) fd_ce_jac (x, ce_fun); + ce_grd = @(x) fd_ce_jac (x, ce_fun); endif endif @@ -262,7 +262,7 @@ if (nargin < 5 || (nargin > 5 && isempty (lb) && isempty (ub))) ## constraint inequality function only without any bounds - ci_grd = @ (x) fd_ci_jac (x, globals.cifcn); + ci_grd = @(x) fd_ci_jac (x, globals.cifcn); if (iscell (cif)) switch (length (cif)) case 1 @@ -314,8 +314,8 @@ error ("sqp: upper bound smaller than lower bound"); endif bounds_grad = [lb_grad; ub_grad]; - ci_fun = @ (x) cf_ub_lb (x, lb_idx, ub_idx, globals); - ci_grd = @ (x) cigrad_ub_lb (x, bounds_grad, globals); + ci_fun = @(x) cf_ub_lb (x, lb_idx, ub_idx, globals); + ci_grd = @(x) cigrad_ub_lb (x, bounds_grad, globals); endif endif # if (nargin > 3) @@ -704,7 +704,7 @@ function res = cigrad_ub_lb (x, bgrad, globals) - cigradfcn = @ (x) fd_ci_jac (x, globals.cifcn); + cigradfcn = @(x) fd_ci_jac (x, globals.cifcn); if (iscell (globals.cif) && length (globals.cif) > 1) cigradfcn = globals.cif{2}; @@ -718,7 +718,7 @@ endfunction -# Utility function used to debug sqp +## Utility function used to debug sqp function report (iter, qp_iter, alpha, nfun, obj) if (nargin == 0) @@ -730,8 +730,8 @@ endfunction -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Test Code +################################################################################ +## Test Code %!function r = __g (x) %! r = [sumsq(x)-10; @@ -760,7 +760,7 @@ %! assert (x, x_opt, 8*sqrt (eps)); %! assert (obj, obj_opt, sqrt (eps)); -%% Test input validation +## Test input validation %!error sqp () %!error sqp (1) %!error sqp (1,2,3,4,5,6,7,8,9)
--- a/scripts/path/pathdef.m +++ b/scripts/path/pathdef.m @@ -76,7 +76,7 @@ endfunction -## Extact the path information from the script/function @var{file}, created by +## Extract the path information from the script/function @var{file}, created by ## @file{savepath.m}. If successful, @code{__extractpath__} returns the path ## specified in @var{file}.
--- a/scripts/path/savepath.m +++ b/scripts/path/savepath.m @@ -186,6 +186,7 @@ path_elements = strcat (ostrsplit (p, pathsep), pathsep); endfunction + %!test %! fname = tempname (); %! status = savepath (fname);
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -390,12 +390,15 @@ unwind_protect if (octave_forge) - [urls, local_files] = cellfun ("get_forge_download", files, "uniformoutput", false); - [files, succ] = cellfun ("urlwrite", urls, local_files, "uniformoutput", false); + [urls, local_files] = cellfun ("get_forge_download", files, + "uniformoutput", false); + [files, succ] = cellfun ("urlwrite", urls, local_files, + "uniformoutput", false); succ = [succ{:}]; if (! all (succ)) i = find (! succ, 1); - error ("could not download file %s from url %s", local_files{i}, urls{i}); + error ("could not download file %s from url %s", + local_files{i}, urls{i}); endif endif
--- a/scripts/pkg/private/configure_make.m +++ b/scripts/pkg/private/configure_make.m @@ -29,8 +29,10 @@ octave_bindir = octave_config_info ("bindir"); ver = version (); ext = octave_config_info ("EXEEXT"); - mkoctfile_program = fullfile (octave_bindir, sprintf ("mkoctfile-%s%s", ver, ext)); - octave_config_program = fullfile (octave_bindir, sprintf ("octave-config-%s%s", ver, ext)); + mkoctfile_program = fullfile (octave_bindir, ... + sprintf ("mkoctfile-%s%s", ver, ext)); + octave_config_program = fullfile (octave_bindir, ... + sprintf ("octave-config-%s%s", ver, ext)); octave_binary = fullfile (octave_bindir, sprintf ("octave-%s%s", ver, ext)); if (! exist (mkoctfile_program, "file")) @@ -82,7 +84,7 @@ if (ispc ()) jobs = 1; else - jobs = nproc ("overridable"); + jobs = nproc ("overridable"); endif if (exist (fullfile (src, "Makefile"), "file")) @@ -113,7 +115,7 @@ filenames(end) = []; endif filenames = strtrim (ostrsplit (filenames, "\n")); - delete_idx = []; + delete_idx = []; for i = 1:length (filenames) if (! all (isspace (filenames{i}))) filenames{i} = fullfile (src, filenames{i}); @@ -138,8 +140,8 @@ else idx = cellfun ("is_architecture_dependent", filenames); endif - archdependent = filenames (idx); - archindependent = filenames (!idx); + archdependent = filenames(idx); + archindependent = filenames(!idx); ## Copy the files. if (! all (isspace ([filenames{:}])))
--- a/scripts/pkg/private/copy_files.m +++ b/scripts/pkg/private/copy_files.m @@ -104,7 +104,6 @@ packinfo_copy_file ("DESCRIPTION", "required", packdir, packinfo, desc, octfiledir); packinfo_copy_file ("COPYING", "required", packdir, packinfo, desc, octfiledir); - packinfo_copy_file ("CITATION", "optional", packdir, packinfo, desc, octfiledir); packinfo_copy_file ("NEWS", "optional", packdir, packinfo, desc, octfiledir); packinfo_copy_file ("ONEWS", "optional", packdir, packinfo, desc, octfiledir);
--- a/scripts/pkg/private/get_forge_pkg.m +++ b/scripts/pkg/private/get_forge_pkg.m @@ -37,7 +37,8 @@ name = tolower (name); ## Try to download package's index page. - [html, succ] = urlread (sprintf ("http://packages.octave.org/%s/index.html", name)); + [html, succ] = urlread (sprintf ("http://packages.octave.org/%s/index.html", + name)); if (succ) ## Remove blanks for simpler matching. html(isspace(html)) = [];
--- a/scripts/pkg/private/install.m +++ b/scripts/pkg/private/install.m @@ -322,7 +322,7 @@ nm = descriptions{i}.name; for j = 1:length (installed_pkgs_lst) if (strcmp (nm, installed_pkgs_lst{j}.name)) - idx (end + 1) = j; + idx(end + 1) = j; break; endif endfor @@ -332,10 +332,11 @@ global_install); endif - ## If there's a NEWS file, mention it - ## we are checking if desc exists too because it's possible to ge to this point + ## If there is a NEWS file, mention it. + ## Check if desc exists too because it's possible to get to this point ## without creating it such as giving an invalid filename for the package - if (exist ("desc", "var") && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file")) + if (exist ("desc", "var") + && exist (fullfile (desc.dir, "packinfo", "NEWS"), "file")) printf ("For information about changes from previous versions of the %s package, run 'news %s'.\n", desc.name, desc.name); endif
--- a/scripts/pkg/private/load_package_dirs.m +++ b/scripts/pkg/private/load_package_dirs.m @@ -42,7 +42,7 @@ for j = 1 : length (installed_pkgs_lst) if (strcmp (installed_pkgs_lst{j}.name, deps{k}.package)) if (! any (idx == j)) - tmplidx (end + 1) = j; + tmplidx(end + 1) = j; break; endif endif
--- a/scripts/pkg/private/load_packages.m +++ b/scripts/pkg/private/load_packages.m @@ -41,7 +41,7 @@ idx = []; for i = 1:length (installed_pkgs_lst) if (exist (fullfile (pdirs{i}, "packinfo", ".autoload"), "file")) - idx (end + 1) = i; + idx(end + 1) = i; endif endfor ## Load package_name1 ... @@ -52,7 +52,7 @@ if (! any (idx2)) error ("package %s is not installed", files{i}); endif - idx (end + 1) = idx2; + idx(end + 1) = idx2; endfor endif
--- a/scripts/pkg/private/packinfo_copy_file.m +++ b/scripts/pkg/private/packinfo_copy_file.m @@ -24,7 +24,7 @@ function packinfo_copy_file (filename, requirement, packdir, packinfo, desc, octfiledir) filepath = fullfile (packdir, filename); - if (!exist (filepath, "file") && strcmpi (requirement, "optional")) + if (! exist (filepath, "file") && strcmpi (requirement, "optional")) ## do nothing, it's still OK else [status, output] = copyfile (filepath, packinfo);
--- a/scripts/pkg/private/rebuild.m +++ b/scripts/pkg/private/rebuild.m @@ -93,7 +93,7 @@ endfor endfor if (! isempty (dup)) - descriptions (dup) = []; + descriptions(dup) = []; endif endif endfunction
--- a/scripts/pkg/private/save_order.m +++ b/scripts/pkg/private/save_order.m @@ -28,7 +28,7 @@ deps = desc{i}.depends; if (isempty (deps) || (length (deps) == 1 && strcmp (deps{1}.package, "octave"))) - newdesc {end + 1} = desc{i}; + newdesc{end + 1} = desc{i}; else tmpdesc = {}; for k = 1 : length (deps) @@ -51,7 +51,7 @@ for i = 1 : length (newdesc) for j = (i + 1) : length (newdesc) if (strcmp (newdesc{i}.name, newdesc{j}.name)) - idx (end + 1) = j; + idx(end + 1) = j; endif endfor endfor
--- a/scripts/pkg/private/write_index.m +++ b/scripts/pkg/private/write_index.m @@ -37,7 +37,7 @@ ## Get classes in dir class_idx = find (strncmp (files, '@', 1)); for k = 1:length (class_idx) - class_name = files {class_idx (k)}; + class_name = files {class_idx(k)}; class_dir = fullfile (dir, class_name); if (exist (class_dir, "dir")) [files2, err, msg] = readdir (class_dir);
--- a/scripts/plot/appearance/annotation.m +++ b/scripts/plot/appearance/annotation.m @@ -1,15 +1,15 @@ ## Copyright (C) 2015 Pantxo Diribarne -## +## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. -## +## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. -## +## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## <http://www.gnu.org/licenses/>. @@ -36,19 +36,19 @@ ## property of the annotation objects: the default is ## @qcode{"normalized"}, which means the lower left hand corner of the ## figure has coordinates @samp{[0 0]} and the upper right hand corner -## @samp{[1 1]}. +## @samp{[1 1]}. ## -## The figure on which the annotations should be drawn may be +## The figure on which the annotations should be drawn may be ## specified by providing its graphics handle @var{hf} before any ## other argument. Otherwise annotations are drawn on the current -## figure. -## +## figure. +## ## Further arguments can be provided in the form of ## @var{prop}/@var{val} pairs to customize the annotation appearance ## and the units in which coordinates are interpreted. The annotation -## can also be customized afterward using its graphics handle +## can also be customized afterward using its graphics handle ## @var{h} and @code{set} function. -## +## ## All annotation objects share two properties: ## ## @itemize @@ -67,7 +67,7 @@ ## @end itemize ## ## Valid annotation types and their specific properties are described -## below: +## below: ## ## @table @asis ## @item @qcode{"line"} @@ -87,9 +87,9 @@ ## @qcode{"headlength"}, @qcode{"headwidth"} and @qcode{"headstyle"} ## properties. Supported values for @qcode{"headstyle"} property are: ## [@qcode{"diamond"} | @qcode{"ellipse"} | @qcode{"plain"} | -## @qcode{"rectangle"} | @qcode{"vback1"} | @qcode{"@{vback2@}"} | -## @qcode{"vback3"}] -## +## @qcode{"rectangle"} | @qcode{"vback1"} | @qcode{"@{vback2@}"} | +## @qcode{"vback3"}] +## ## @item @qcode{"doublearrow"} ## Construct a double arrow. Vectors @var{x} and @var{y} specify the ## arrowheads coordinates. @@ -99,7 +99,7 @@ ## @qcode{"head1length"}/@qcode{"head2length"}, ## @qcode{"head1width"}/@qcode{"head2width"}, etc. The index 1 marks ## the properties of the arrowhead at the first point in @var{x} and -## @var{y} coordinates. +## @var{y} coordinates. ## ## @item @qcode{"textarrow"} ## Construct an arrow with a text label at the opposite of the @@ -132,7 +132,7 @@ ## ## @item @qcode{"rectangle"} ## Construct a rectangle. @var{pos} specifies the -## @qcode{"position"} property of the annotation. +## @qcode{"position"} property of the annotation. ## ## You may use @qcode{"facecolor"}, @qcode{"color"}, ## @qcode{"linestyle"} and @qcode{"linewidth"} properties to customize @@ -140,11 +140,11 @@ ## ## @item @qcode{"ellipse"} ## Construct an ellipse. @var{pos} specifies the -## @qcode{"position"} property of the annotation. +## @qcode{"position"} property of the annotation. ## -## See @qcode{"rectangle"} annotations for customization. +## See @qcode{"rectangle"} annotations for customization. ## @end table -## +## ## @seealso{xlabel, title} ## @end deftypefn @@ -155,20 +155,20 @@ lims = []; x = y = []; opts = {}; - + nargin = numel (varargin); if (nargin == 0) print_usage (); endif - - + + ## Parent figure if (isfigure (varargin{1})) hf = varargin{1}; varargin = varargin(2:end); nargin --; endif - + ## Annotation type types = {"line", "arrow", "doublearrow", "textarrow", ... "textbox", "ellipse", "rectangle"}; @@ -179,21 +179,21 @@ else print_usage (); endif - - switch objtype + + switch (objtype) case types(1:4) - + if (nargin == 0) - lims = []; + lims = []; elseif (nargin >= 2) x = varargin{1}; y = varargin{2}; varargin(1:2) = []; - - if (isnumeric (x) && isnumeric (y) && + + if (isnumeric (x) && isnumeric (y) && length (x) == 2 && length (y) == 2) lims = [x(1) y(1) diff(x) diff(y)]; - else + else error ("annotation: expect 2 elements vectors for X and Y"); endif else @@ -201,11 +201,11 @@ endif case types(5:end) if (nargin == 0) - lims = []; + lims = []; else lims = varargin{1}; varargin(1) = []; - + if (! isvector (lims) || length (lims) != 4) error ("annotation: expect 4 elements vector for POS") endif @@ -218,13 +218,13 @@ opts = varargin; nopts = numel (opts); if (! isempty (opts)) - if (fix (nopts/2) != nopts/2 || - !all (cellfun (@ischar, opts(1:2:end)))) + if (fix (nopts/2) != nopts/2 + || ! all (cellfun (@ischar, opts(1:2:end)))) warning ("annotation: couldn't parse PROP/VAL pairs, skipping"); opts = {}; endif endif - + ## create annotation showhidden = get (0, "showhiddenhandles"); set (0, "showhiddenhandles", "on"); @@ -233,7 +233,7 @@ if (isempty (hf)) hf = gcf (); endif - + ## Axes hca = get (hf, "currentaxes"); @@ -249,15 +249,15 @@ htmp = buildannot (hax, objtype, lims); ## Set user defined properties - if (!isempty (opts)) + if (! isempty (opts)) set (htmp, opts{:}); endif - + unwind_protect_cleanup set (0, "showhiddenhandles", showhidden); set (hf, "currentaxes", hca); end_unwind_protect - + if (nargout != 0) varargout{1} = htmp; endif @@ -270,19 +270,19 @@ "visible", "off","tag", "scribeoverlay", ... "xlim", [0 1], "ylim", [0 1], ... "handlevisibility", "off"); - + ## hidden property to store figure size in absolute (points) - ## coordinates + ## coordinates addproperty ("figsize_points", hax, "axesxmtick", []); update_figsize_points (hf, {}, hax); - + listener = {@update_figsize_points, hax}; addlistener (hf, "position", listener); - + delfcn = @() dellistener (hf, "position", listener); set (hax, "deletefcn", delfcn); - + endfunction function update_figsize_points (hf, dummy, hax) @@ -294,23 +294,23 @@ set (hf, "units", "points"); pos = get (hf, "position"); set (hf, "units", units); - + set (hax, "figsize_points", pos(3:4)); recursive = false; endif - + endfunction - + function h = buildannot (hax, objtype, pos) ## Base hggroup h = hggroup ("parent", hax); - + ## Add common properties if (strcmp (graphics_toolkit (), "gnuplot")) ## FIXME: this is a workaround for bug #39394 (gnuplot toolkit) defprops = {"position", "axesposition", [0.3 0.3 0.1 0.1], ... - "units", "textunits", "data"}; + "units", "textunits", "data"}; else defprops = {"position", "axesposition", [0.3 0.3 0.1 0.1], ... "units", "axesunits", "normalized"}; @@ -320,22 +320,22 @@ ## Common updaters listener = {@update_position, h, true}; - + addlistener (hax, "figsize_points", listener); - + delfcn = @() dellistener (hax, "figsize_points", listener); set (h, "deletefcn", delfcn); - + addlistener (h, "units", {@update_position, h}); - + ## Now work with normalized coordinates if (! isempty (pos)) set (h, "position", pos); endif pos = getnormpos (h); - + ## Build annotation object and its specific properties/updaters - switch objtype + switch (objtype) case {"line", "arrow", "doublearrow", "textarrow"} ## Add properties proptable = lineprops (); @@ -349,14 +349,14 @@ endif addbaseprops (h, proptable); - + ## create line hli = line ([pos(1); (pos(1) + pos(3))], [pos(2); (pos(2) + pos(4))], "parent", h, "color", get (h, "color"), "linestyle", get (h, "linestyle"), "linewidth", get (h, "linewidth")); - + ## create patch(s) and text if (strcmp (objtype, "arrow")) [x, y] = arrowcoordinates (h); @@ -367,18 +367,18 @@ [x, y] = arrowcoordinates (h, 1); hpa = patch (x, y, get (h, "color"), "parent", h, "edgecolor", get (h, "color")); - + [x, y] = arrowcoordinates (h, 2); hpa(2) = patch (x, y, get (h, "color"), "parent", h, "edgecolor", get (h, "color")); - + update_arrow (h, {}, "position", hpa); elseif (strcmp (objtype, "textarrow")) [x, y] = arrowcoordinates (h); hpa = patch (x, y, get (h, "color"), "parent", h, "edgecolor", get (h, "color")); update_arrow (h, {}, "position", hpa); - + hte = text (get (h, "position")(1), ... get (h, "position")(2), ... get (h, "string"), "parent", h, ... @@ -389,7 +389,7 @@ endfor update_text (h, {}, "position", hte); endif - + ## updaters addlistener (h, "color", {@update_line, "color", hli}); addlistener (h, "linestyle", {@update_line, "linestyle", hli}); @@ -406,7 +406,7 @@ addlistener (h, "color", {@update_arrow, "color", hpa}); elseif (strcmp (objtype, "doublearrow")) addlistener (h, "position", {@update_arrow, "position", hpa}); - addlistener (h, "head1width", + addlistener (h, "head1width", {@update_arrow, "position", [hpa(1) 0]}); addlistener (h, "head2width", {@update_arrow, "position", [0 hpa(2)]}); @@ -443,21 +443,21 @@ addlistener (h, "position", {@update_text, "position", hte}); addlistener (h, "color", {@update_text, "color", hte}); endif - + case {"rectangle", "ellipse"} - + ## Add properties addbaseprops (h, rectprops ()); - + ## Create rectangle/ellipse if (strcmp (objtype, "rectangle")) [x, y] = pos2rect (pos); else [x, y] = pos2ell (pos); endif - - hr = patch (x, y, "parent", h); - + + hr = patch (x, y, "parent", h); + propnames = rectprops ("names"); for ii = 1:numel (propnames) update_rect (h, {}, propnames{ii}, hr, objtype); @@ -471,7 +471,7 @@ endfor case "textbox" - + ## Add properties addbaseprops (h, textboxprops()); @@ -480,7 +480,7 @@ hte = text (pos(1), pos(2), get (h, "string"), "parent", h, ... "color", get (h, "color")); update_textbox (h, {}, "position", [hte hpa]); - + propnames = textboxprops ("names"); for ii = 1:numel (propnames) update_textbox (h, {}, propnames{ii}, [hte hpa]); @@ -496,9 +496,9 @@ {@update_textbox, "position", [hte hpa]}); addlistener (h, "verticalalignment", {@update_textbox, "position", [hte hpa]}); - + endswitch - + endfunction function props = lineprops (varargin) @@ -515,7 +515,7 @@ function props = arrowprops (varargin) props = {"headlength", "data", 10, ... "headstyle", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... - "headwidth", "data", 10}; + "headwidth", "data", 10}; if (strcmp (varargin, "names")) props = props(1:3:end); endif @@ -524,7 +524,7 @@ function props = dblarrowprops (varargin) props = {"head1length", "data", 10, ... "head1style", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... - "head1width", "data", 10, ... + "head1width", "data", 10, ... "head2length", "data", 10, ... "head2style", "radio", "diamond|ellipse|none|plain|rectangle|vback1|{vback2}|vback3", ... "head2width", "data", 10}; @@ -603,14 +603,14 @@ ## FIXME: Inefficient trick to force all objects to be redrawn set (h, "position", [0 0 .5 .5], "position", get (h, "position")); - endif + endif endfunction function update_line (h, dummy, prop, hli) persistent recursive = false; if (! recursive) - switch prop + switch (prop) case "color" set (hli, "color", get (h, "color")); case "linestyle" @@ -631,7 +631,7 @@ pos = getnormpos (h); x = [pos(1) (pos(1) + pos(3))]; set (hli, "xdata", x); - + case "y" ## Update position y = get (h, "y"); @@ -651,19 +651,19 @@ pos = get (h, "position"); x = [pos(1) (pos(1) + pos(3))]; y = [pos(2) (pos(2) + pos(4))]; - + recursive = true; set (h, "x", x); set (h, "y", y); recursive = false; - + ## Draw in normalized coordinates pos = getnormpos (h); x = [pos(1) (pos(1) + pos(3))]; y = [pos(2) (pos(2) + pos(4))]; set (hli, "xdata", x); set (hli, "ydata", y); - + endswitch endif endfunction @@ -694,7 +694,7 @@ error ("annotation: %d, no such arrow number") endif - switch headstyle + switch (headstyle) case "diamond" x = [0 -ln/2 -ln -ln/2 0]; y = [0 -wd/2 0 wd/2 0]; @@ -729,21 +729,21 @@ XY = R * [x; y]; XY = pts2norm (h, XY); XY = pos(1:2).' .+ XY; - + x = XY(1,:).'; y = XY(2,:).'; endfunction function update_arrow (h, dummy, prop, hpa = []) persistent recursive = false; - + nar = []; for ii = 1:numel (hpa) if (numel (hpa) == 2) nar = ii; endif if (hpa(ii)) - switch prop + switch (prop) case "position" [x, y] = arrowcoordinates (h, nar); set (hpa(ii), "xdata", x, "ydata", y); @@ -759,16 +759,16 @@ persistent recursive = false; if (! recursive) - switch prop + switch (prop) case "position" if (isempty (get (h, "string"))) return endif - + pos = getnormpos (h); - + set (hte, "position", [textcoordinates(hte, pos) 0]); - + otherwise if (strncmp (prop, "text", 4)) set (hte, prop(5:end), get (h, prop)); @@ -784,9 +784,9 @@ hte = htb(1); hpa = htb(2); - + if (! recursive) - switch prop + switch (prop) case {"edgecolor", "facealpha", "linestyle", "linewidth"} set (hpa, prop, get (h, prop)); @@ -796,16 +796,16 @@ if (! any (strcmp (prop, {"fitboxtotext", "position"}))) set (hte, prop, get (h, prop)); endif - + pos = getnormpos (h); - + if (strcmp (get (h, "fitboxtotext"), "on")) pos(3:4) = get (hte, "extent")(3:4); endif - + [x, y] = pos2rect (pos); set (hpa, "xdata", x', "ydata", y'); - + switch (get (h, "horizontalalignment")) case "left" x = x(1); @@ -826,7 +826,7 @@ set (hte, "position", [x y 0]); endswitch endif - + endfunction function XY = textcoordinates (hte, pos) @@ -840,78 +840,78 @@ set (hte, "rotation", 0, "units", "points", "position", [0 0 0]); ext = get (hte, "extent"); set (hte, "rotation", rot, "units", units, "position", textpos); - + ## Find which one of the 8 following points we should align the ## arrow with ## 8-----7-----6 ## 1 text box 5 ## 2-----3-----4 - + ## FIXME: Matlab's horizontal/verticalalignment properties are - ## interpreted differently: horizontalalignment is passed to the + ## interpreted differently: horizontalalignment is passed to the ## underlying text object whereas the verticalalignement controls ## the vertical alignment of the arrow. - + ang = angle (complex (pos(3), pos(4))); rot = rot / 180 * pi; - [~, pt] = min (abs ((-pi:pi/4:pi) - ang)); + [~, pt] = min (abs ((-pi:pi/4:pi) - ang)); pt -= floor (rot / (pi/4)); if (pt <= 0) pt = rem (pt, 8) + 8; elseif (pt > 8) pt = rem (pt, 8); endif - + ## Compute the text actual "position" property dx = ext(3)/2; dy = ext(4)/2; XY = [-dx -dx 0 dx dx dx 0 -dx; 0 -dy -dy -dy 0 dy dy dy]; - - switch get (hte, "horizontalalignment") + + switch (get (hte, "horizontalalignment")) case "left" XY(1,:) += dx; case "right" XY(1,:) -= dx; endswitch - - switch get (hte, "verticalalignment") + + switch (get (hte, "verticalalignment")) case {"baseline", "bottom"} XY(2,:) += dy; case {"cap", "top"} XY(2,:) -= dy; endswitch - + R = [cos(rot) -sin(rot); sin(rot) cos(rot)]; XY = R * XY; XY = pts2norm (get (hte, "parent"), XY); XY = pos(1:2) .- XY(:,pt).'; - + endfunction function nXY = pts2norm (h, pXY) sz = get (get (h,"parent"), "figsize_points"); - + nXY(1,:) = pXY(1,:) ./ sz(1); nXY(2,:) = pXY(2,:) ./ sz(2); endfunction function pXY = norm2pts (h, nXY) sz = get (get (h,"parent"), "figsize_points"); - + pXY(1,:) = nXY(1,:) .* sz(1); pXY(2,:) = nXY(2,:) .* sz(2); endfunction function pos = convertposition (h, from, to) - ## FIXME: handle "characters" units + ## FIXME: handle "characters" units pos = get (h, "position"); - + ## First convert to normalized coordinates sz = get (get (h,"parent"), "figsize_points"); - switch from + switch (from) case "centimeters" pos /= 2.54; pos *= 72; @@ -929,7 +929,7 @@ endswitch ## Then convert to requested coordinates - switch to + switch (to) case "centimeters" sz /= 72; sz *= 2.54; @@ -941,7 +941,7 @@ pos(2:2:end) *= sz(2); case "pixels" sz /= 72; - sz *= get (0, "screenpixelsperinch"); + sz *= get (0, "screenpixelsperinch"); pos(1:2:end) *= sz(1); pos(2:2:end) *= sz(2); endswitch @@ -962,10 +962,10 @@ a = pos(3)/2; b = pos(4)/2; - ## Arbitrarily use 100 points + ## Arbitrarily use 100 points ## when it is spread over ang = linspace (0, 2*pi, 100); - + x = a * cos (ang); y = b * sin (ang); @@ -975,9 +975,9 @@ function update_rect (h, dummy, prop, hre, typ) persistent recursive = false; - + if (! recursive) - switch prop + switch (prop) case "position" pos = getnormpos (h); if (strcmp (typ, "rectangle")) @@ -985,7 +985,7 @@ else [x, y] = pos2ell (pos); endif - + set (hre, "xdata", x, "ydata", y); otherwise set (hre, prop, get (h, prop)); @@ -1010,7 +1010,7 @@ %! annotation ('textarrow', [x x0], [y y0], ... %! 'string', lab{ii}, 'fontsize', 20); %! end -%! +%! %! h = annotation ('doublearrow', [x0 x0], [y0-r y0+r], ... %! 'head1style', 'diamond', 'head1length', 60, ... %! 'head2style', 'diamond', 'head2length', 60); @@ -1021,24 +1021,24 @@ %! xlabel ('X-LABEL') %! ylabel ('LARGE Y-LABEL', 'fontsize', 20) %! title ('FIGURE LAYOUT', 'fontsize', 24) -%! +%! %! ti = get (gca, 'tightinset'); %! pos = get (gca, 'position'); %! pos(1:2) = pos(1:2) - ti(1:2); %! pos(3) = pos(3) + ti (1) + ti (3); %! pos(4) = pos(4) + ti (2) + ti (4); -%! +%! %! ht = annotation ('textbox', pos, 'string', ' Position + tighinset', ... %! 'fitboxtotext', 'off', 'linestyle', '--', ... %! 'edgecolor', 'g', 'linewidth', 3, 'color', 'g', ... %! 'verticalalignment', 'bottom', 'fontsize', 15); -%! +%! %! ho = annotation ('textbox', get (gca, 'outerposition'), ... %! 'string', ' Outerposition','fitboxtotext', 'off', ... %! 'linestyle', '--', 'edgecolor', 'r', ... %! 'linewidth', 3, 'color', 'r', ... %! 'verticalalignment', 'bottom', 'fontsize', 15); -%! +%! %! hi = annotation ('textbox', get (gca, 'position'), ... %! 'string', ' Position','fitboxtotext', 'off', ... %! 'linestyle', '--', 'edgecolor', 'b', ... @@ -1048,24 +1048,24 @@ %!demo %! clf; axes ('visible', 'off'); %! h = annotation ('arrow'); -%! +%! %! %% Get allowed headstyles %! styles = set (h, 'headstyle'); %! delete (h) -%! +%! %! %% Textbox for the title %! annotation ('textbox', [0.1 0 0.8 1], 'string', ... %! '"headstyle" property:', ... %! 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... %! 'fitboxtotext', 'off', 'verticalalignment', 'top', ... %! 'horizontalalignment', 'center'); -%! -%! %% Textarrows +%! +%! %% Textarrows %! ns = numel (styles); %! nrows = ceil (ns/2); %! dy = 1/nrows; %! y = 1 - dy/2; -%! +%! %! jj = 1; %! for ii = 1:nrows %! annotation ('textarrow', [0.3 0.5], [y y], ... @@ -1084,15 +1084,15 @@ %!demo %! clf; axes ('visible', 'off'); -%! +%! %! %% Textbox for the title %! annotation ('textbox', [0.1 0 0.8 1], 'string', ... %! 'Text arrows: text rotation', ... %! 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... %! 'fitboxtotext', 'off', 'verticalalignment', 'top', ... %! 'horizontalalignment', 'center'); -%! -%! %% Textarrows +%! +%! %% Textarrows %! for ii = 1:10 %! rot = floor (rand (1) * 360 / 90) * 90; %! annotation ('textarrow', 0.5 + [(0.6 * (rand(1) - .5)) 0], ... @@ -1103,14 +1103,14 @@ %!demo %! clf; axes ('visible', 'off'); -%! +%! %! %% Textbox for the title %! annotation ('textbox', [0.1 0 0.8 1], 'string', ... %! 'Text arrows: text alignment', ... %! 'backgroundcolor', [0.7 0.7 0.7], 'fontsize', 20, ... %! 'fitboxtotext', 'off', 'verticalalignment', 'top', ... %! 'horizontalalignment', 'center'); -%! +%! %! %% Textarrows %! halig = {'right', 'center', 'left'}; %! ii = 1; @@ -1123,27 +1123,27 @@ %!demo %! clf; axes ('visible', 'off'); -%! +%! %! x = 0:0.01:2*pi; %! y = sin (x); %! plot (x, y) -%! +%! %! %% Extrema %! x0 = [pi/2 3*pi/2]; %! y0 = [1 -1]; -%! +%! %! %% Convert axes coordinates into normalized coordinates %! xl = xlim (); %! yl = [-1.2 1.5]; %! ylim (yl); %! x0 = (x0 - xl(1)) / diff(xl); %! y0 = (y0 - yl(1)) / diff(yl); -%! +%! %! pos = get (gca (), 'position'); %! x0 = x0*pos(3) + pos(1); %! y0 = y0*pos(4) + pos(2); -%! -%! +%! +%! %! %% Textarrows %! for ii = 1:2 %! annotation ('doublearrow', [(x0(ii) - .05) (x0(ii) + .05)], ... @@ -1153,7 +1153,7 @@ %! h = annotation ('textarrow', [0.5 x0(ii)], [.85 y0(ii)], ... %! 'linestyle', '--', 'headstyle', 'none'); %! end -%! set (h, 'string', 'Extrema', 'fontsize', 15) +%! set (h, 'string', 'Extrema', 'fontsize', 15) ## test line properties %!test @@ -1176,7 +1176,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! h = annotation ("textarrow", [0.2 0.7], [0.2 0.7], -%! "string", "Hello!", "fontsize", 20, +%! "string", "Hello!", "fontsize", 20, %! "textrotation", 90, "textcolor", "r"); %! hte = findobj (h, "-depth", 1, "type", "text"); %! assert (get (hte, "string"), "Hello!"); @@ -1192,7 +1192,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! h = annotation ("textbox", [0.2 0.2 0.7 0.3], "string", "Hello!", -%! "horizontalalignment", "left", +%! "horizontalalignment", "left", %! "verticalalignment", "bottom", %! "backgroundcolor", "r"); %! hte = findobj (h, "-depth", 1, "type", "text"); @@ -1234,7 +1234,7 @@ %! close (hf1) %! close (hf2) %! end_unwind_protect - + ## Test input validation %!error <unknown annotation type foo> annotation ("foo") %!error annotation ([], "foo")
--- a/scripts/plot/appearance/clabel.m +++ b/scripts/plot/appearance/clabel.m @@ -127,7 +127,7 @@ set (htmp, varargin{:}); endif else - htmp = __clabel__ (c, v, hparent, label_spacing, [], varargin{:}); + htmp = __clabel__ (c, v, hparent, label_spacing, [], varargin{:}); endif if (nargout > 0)
--- a/scripts/plot/appearance/legend.m +++ b/scripts/plot/appearance/legend.m @@ -307,7 +307,7 @@ have_labels = (nargs > 0); hobjects = []; - hplots = []; + hplots = []; text_strings = {}; if (delete_leg) @@ -336,7 +336,8 @@ set (hlegend, "box", "off", "visible", "off"); endif elseif (! have_labels && ! isempty (hlegend) - && ! (strcmp (location, "default") && strcmp (orientation, "default"))) + && ! (strcmp (location, "default") + && strcmp (orientation, "default"))) ## Changing location or orientation of existing legend if (strcmp (location, "default")) set (hlegend, "orientation", orientation); @@ -358,7 +359,7 @@ else ## Create new legend hobjects = []; - hplots = []; + hplots = []; text_strings = {}; if (have_labels) @@ -499,7 +500,7 @@ delete (fkids(fkids == hlegend)); hlegend = []; hobjects = []; - hplots = []; + hplots = []; text_strings = {}; endif else
--- a/scripts/plot/appearance/orient.m +++ b/scripts/plot/appearance/orient.m @@ -156,7 +156,7 @@ %! assert (get (hfig, "papersize"), papersize); %! assert (get (hfig, "paperposition"), paperposition); -%% Test input validation +## Test input validation %!error orient (1.73, 2.5) %!error <unknown ORIENTATION> orient ("nobody")
--- a/scripts/plot/appearance/private/__axis_limits__.m +++ b/scripts/plot/appearance/private/__axis_limits__.m @@ -42,7 +42,7 @@ set (hax, fcnmode, arg); endif else - if (!isnumeric (arg) && any (size (arg(:)) != [2, 1])) + if (! isnumeric (arg) && any (size (arg(:)) != [2, 1])) error ("%s: LIMITS must be a 2-element vector", fcn); else if (arg(1) >= arg(2))
--- a/scripts/plot/appearance/whitebg.m +++ b/scripts/plot/appearance/whitebg.m @@ -75,15 +75,15 @@ if (isroot) fac = get (0, "factory"); fields = fieldnames (fac); - fieldindex = intersect (find (!cellfun ("isempty", regexp (fields, 'color'))), union (find (!cellfun ("isempty", regexp (fields, 'factoryaxes.*'))), find (!cellfun ("isempty", regexp (fields, 'factoryfigure.*'))))); + fieldindex = intersect (find (! cellfun ("isempty", regexp (fields, 'color'))), union (find (! cellfun ("isempty", regexp (fields, 'factoryaxes.*'))), find (!cellfun ("isempty", regexp (fields, 'factoryfigure.*'))))); ## Check whether the factory value has been replaced for nf = 1 : numel (fieldindex); - defaultfield = strrep (fields {fieldindex (nf)}, "factory", "default"); + defaultfield = strrep (fields{fieldindex(nf)}, "factory", "default"); try - defaultvalue = 1 - get (0, defaultfield {n}); + defaultvalue = 1 - get (0, defaultfield{n}); catch - field = fields {fieldindex (nf)}; + field = fields{fieldindex(nf)}; defaultvalue = 1 - subsref (fac, struct ("type", ".", "subs", field)); end_try_catch set (0, defaultfield, defaultvalue); @@ -108,7 +108,7 @@ fieldindex = find (!cellfun ("isempty", regexp (fields, 'color'))); if (numel (fieldindex)) for nf = 1 : numel (fieldindex); - field = fields {fieldindex (nf)}; + field = fields{fieldindex(nf)}; c = subsref (p, struct ("type", ".", "subs", field)); if (! ischar (c) && columns (c) == 3) set (h (nh), field, 1 - c); @@ -122,10 +122,11 @@ def = get (h (nh), "default"); fields = fieldnames (def); if (! isempty (fields)) - fieldindex = find (!cellfun ("isempty", regexp (fields, 'color'))); + fieldindex = find (! cellfun ("isempty", regexp (fields, 'color'))); for nf = 1 : numel (fieldindex) - defaultfield = fields {fieldindex (nf)}; - defaultvalue = 1 - subsref (def, struct ("type", ".", "subs", defaultfield)); + defaultfield = fields{fieldindex(nf)}; + defaultvalue = ... + 1 - subsref (def, struct ("type", ".", "subs", defaultfield)); set (h (nh), defaultfield, defaultvalue); endfor endif
--- a/scripts/plot/draw/area.m +++ b/scripts/plot/draw/area.m @@ -271,7 +271,7 @@ %! set (h, 'ydata', sort (get (h, 'ydata'))) %! title ('area() plot of sorted data'); -%% Test input validation +## Test input validation %!error area () %!error area (1,2,3,4) %!error <X and Y must be real vectors or matrices> area ({1})
--- a/scripts/plot/draw/colorbar.m +++ b/scripts/plot/draw/colorbar.m @@ -143,12 +143,12 @@ ## FIXME: No listener on location property so have to re-create ## colorbar whenever an option changes. ## re-instate this code if listener is developed. - # if (! isempty (loc)) - # set (hcb, "location", loc); - # endif - # if (! isempty (args)) - # set (hcb, args{:}); - # endif + ## if (! isempty (loc)) + ## set (hcb, "location", loc); + ## endif + ## if (! isempty (args)) + ## set (hcb, args{:}); + ## endif ax = get (get (hcb, "parent"), "currrentaxes"); endif endif @@ -163,7 +163,8 @@ showhiddenhandles = get (0, "showhiddenhandles"); unwind_protect set (0, "showhiddenhandles", "on"); - cax = findobj (get (ax, "parent"), "tag", "colorbar", "type", "axes", "axes", ax); + cax = findobj (get (ax, "parent"), + "tag", "colorbar", "type", "axes", "axes", ax); if (! isempty (cax)) delete (cax); endif @@ -187,8 +188,8 @@ cmin = cext(1) + cdiff; cmax = cext(2) - cdiff; - [pos, cpos, vertical, mirror] = ... - __position_colorbox__ (loc, obj, ancestor (ax, "figure")); + [pos, cpos, vertical, mirror] = ... + __position_colorbox__ (loc, obj, ancestor (ax, "figure")); set (ax, "position", pos); cax = __go_axes__ (hpar, "tag", "colorbar", @@ -260,7 +261,7 @@ if (strcmp (get (hc, "beingdeleted"), "off")) delete (hc); endif - if (!isempty (ancestor (h, "axes")) + if (! isempty (ancestor (h, "axes")) && strcmp (get (ancestor (h, "axes"), "beingdeleted"), "off")) ax = ancestor (h, "axes"); units = get (ax, "units"); @@ -340,8 +341,8 @@ obj.__cbar_hax__ = h; obj.position = orig_props.position; obj.outerposition = orig_props.outerposition; - [pos, cpos, vertical, mirror] = ... - __position_colorbox__ (loc, obj, ancestor (h, "figure")); + [pos, cpos, vertical, mirror] = ... + __position_colorbox__ (loc, obj, ancestor (h, "figure")); if (vertical) if (mirror)
--- a/scripts/plot/draw/compass.m +++ b/scripts/plot/draw/compass.m @@ -128,7 +128,7 @@ %! a = toeplitz ([1;randn_9x1_data], [1,randn_1x9_data]); %! compass (eig (a)); -%% Test input validation +## Test input validation %!error compass () %!error compass (1,2,3,4) %!error compass (1, "-r", 2)
--- a/scripts/plot/draw/feather.m +++ b/scripts/plot/draw/feather.m @@ -127,7 +127,7 @@ %! axis tight; %! title ('feather plot'); -%% Test input validation +## Test input validation %!error feather () %!error feather (1,2,3,4) %!error feather (1, "-r", 2)
--- a/scripts/plot/draw/fplot.m +++ b/scripts/plot/draw/fplot.m @@ -208,7 +208,7 @@ %! assert (rows (x) == rows (y)); %! assert (y, [cos(x), sin(x)], -2e-3); -%% Test input validation +## Test input validation %!error fplot (1) %!error fplot (1,2,3,4,5,6) %!error <FN must be a function handle> fplot (1, [0 1])
--- a/scripts/plot/draw/isocolors.m +++ b/scripts/plot/draw/isocolors.m @@ -54,7 +54,7 @@ ## "PlotBoxAspectRatio", [1 1 1]); ## set (p, "FaceColor", "interp"); ## ## set (p, "FaceLighting", "flat"); -## ## light ("Position", [1 1 5]); ## Available with JHandles +## ## light ("Position", [1 1 5]); # Available with JHandles ## endfunction ## ## N = 15; # Increase number of vertices in each direction @@ -152,7 +152,7 @@ endif switch (nargout) case 0 - if (!isempty (pa)) + if (! isempty (pa)) set (pa, "FaceVertexCData", new_col); endif case 1
--- a/scripts/plot/draw/isonormals.m +++ b/scripts/plot/draw/isonormals.m @@ -68,7 +68,7 @@ ## [f, v, cdat] = isosurface (x, y, z, c, iso, y); ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... ## "FaceColor", "interp", "EdgeColor", "none"); -## isofinish (p); ## Call user function isofinish +## isofinish (p); # Call user function isofinish ## ## subplot (2,2,2); view (-38, 20); ## p = patch ("Faces", f, "Vertices", v, "FaceVertexCData", cdat, ... @@ -138,7 +138,7 @@ endif switch (nargout) case 0 - if (!isempty (pa)) + if (! isempty (pa)) set (pa, "VertexNormals", normals); endif case 1
--- a/scripts/plot/draw/isosurface.m +++ b/scripts/plot/draw/isosurface.m @@ -152,7 +152,8 @@ if (nargout == 2) warning ("isosurface: colors will be calculated, but no output argument to receive it."); endif - [fvc.faces, fvc.vertices, fvc.facevertexcdata] = __marching_cube__ (x, y, z, val, iso, colors); + [fvc.faces, fvc.vertices, fvc.facevertexcdata] = ... + __marching_cube__ (x, y, z, val, iso, colors); else [fvc.faces, fvc.vertices] = __marching_cube__ (x, y, z, val, iso); endif
--- a/scripts/plot/draw/private/__contour__.m +++ b/scripts/plot/draw/private/__contour__.m @@ -89,7 +89,7 @@ if (isscalar (vn)) ## FIXME: The levels should be determined similarly to {x,y,z}ticks ## so that they aren't set at extremely odd values. - lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))), vn + 2); + lvl = linspace (min (z1(! isinf (z1))), max (z1(! isinf (z1))), vn + 2); ## Strip off max outlier, min must stay for contourf hole algorithm. lvl = lvl(1:end-1); else @@ -446,7 +446,7 @@ z = get (h, "zdata"); ## FIXME: The levels should be determined similarly to {x,y,z}ticks ## so that they aren't set at extremely odd values. - lvl = linspace (min (z(!isinf (z))), max (z(!isinf (z))), 10 + 2); + lvl = linspace (min (z(! isinf (z))), max (z(! isinf (z))), 10 + 2); ## Strip off max outlier, min must stay for contourf hole algorithm. lvl = lvl(1:end-1); endif
--- a/scripts/plot/draw/private/__errplot__.m +++ b/scripts/plot/draw/private/__errplot__.m @@ -207,7 +207,7 @@ && strcmp (get (fkids(i), "tag"), "legend")) udata = get (fkids(i), "userdata"); if (! isempty (intersect (udata.handle, gca ()))) - hlegend = fkids (i); + hlegend = fkids(i); break; endif endif
--- a/scripts/plot/draw/private/__interp_cube__.m +++ b/scripts/plot/draw/private/__interp_cube__.m @@ -42,7 +42,7 @@ if (columns (v) != 3) error ( "V has to be Nx3 matrix"); endif - ##if (!ischar (req)) + ##if (! ischar (req)) ## error ('__interp_cube__: Invalid request parameter use "values", "normals" or "normals8"'); ##endif if (isempty (v))
--- a/scripts/plot/draw/private/__line__.m +++ b/scripts/plot/draw/private/__line__.m @@ -47,7 +47,8 @@ [~, m] = max (m); b = ones (size (varargin{m(1)})); try - varargin(n) = cellfun (@(x) bsxfun (@times, b, x), varargin(n), "uniformoutput", false); + varargin(n) = cellfun (@(x) bsxfun (@times, b, x), varargin(n), + "uniformoutput", false); catch error ("line: number of X, Y, and Z points must be equal"); end_try_catch
--- a/scripts/plot/draw/private/__marching_cube__.m +++ b/scripts/plot/draw/private/__marching_cube__.m @@ -98,12 +98,13 @@ print_usage (); endif - if (!isnumeric (xx) || !isnumeric (yy) || !isnumeric (zz) || !isnumeric (c) || ... - ndims (xx) != 3 || ndims (yy) != 3 || ndims (zz) != 3 || ndims (c) != 3) + 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 - if (!size_equal (xx, yy, zz, c)) + if (! size_equal (xx, yy, zz, c)) error ("__marching_cube__: XX, YY, ZZ, C must be of equal size"); endif @@ -111,12 +112,12 @@ error ("__marching_cube__: grid size must be at least 2x2x2"); endif - if (!isscalar (iso)) + if (! isscalar (iso)) error ("__marching_cube__: ISO must be scalar value"); endif if (nargin == 6) - if ( !isnumeric (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; @@ -146,7 +147,7 @@ endfor cedge = edge_table(cc+1); # assign the info about intersected edges - id = find (cedge); # select only voxels which are intersected + id = find (cedge); # select only voxels which are intersected if (isempty (id)) T = p = col = []; return; @@ -184,7 +185,7 @@ for jj=1:3:15 id_ = find (tri(:, jj)>0); p = [id_, lindex*ones(rows (id_), 1),tri(id_, jj:jj+2)]; - if (!isempty (p)) + if (! isempty (p)) p1 = sub2ind (size (pp), p(:,1), p(:,2), p(:,3)); p2 = sub2ind (size (pp), p(:,1), p(:,2), p(:,4)); p3 = sub2ind (size (pp), p(:,1), p(:,2), p(:,5));
--- a/scripts/plot/draw/private/__patch__.m +++ b/scripts/plot/draw/private/__patch__.m @@ -168,7 +168,7 @@ elseif (ischar (c) && rem (nargin - iarg, 2) == 0) ## Assume any additional argument over an even number is a color string. args{7} = "facecolor"; - args{8} = tolower (c); + args{8} = tolower (c); args{9} = "cdata"; args{10} = []; else @@ -184,7 +184,7 @@ args = varargin; endif - if (!failed) + if (! failed) h = __go_patch__ (p, args{:}); endif endfunction
--- a/scripts/plot/draw/private/__plt__.m +++ b/scripts/plot/draw/private/__plt__.m @@ -111,12 +111,14 @@ endif if (y_set) tmp = __plt2__ (h, x, y, options, properties); - [hlgnd, tlgnd, setlgnd] = __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); + [hlgnd, tlgnd, setlgnd] = ... + __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); properties = {}; retval = [retval; tmp]; else tmp = __plt1__ (h, x, options, properties); - [hlgnd, tlgnd, setlgnd] = __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); + [hlgnd, tlgnd, setlgnd] = ... + __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); properties = {}; retval = [retval; tmp]; endif @@ -129,7 +131,8 @@ if (y_set) options = __pltopt__ (caller, {""}); tmp = __plt2__ (h, x, y, options, properties); - [hlgnd, tlgnd, setlgnd] = __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); + [hlgnd, tlgnd, setlgnd] = ... + __plt_key__ (tmp, options, hlgnd, tlgnd, setlgnd); retval = [retval; tmp]; x = next_arg; y_set = false;
--- a/scripts/plot/draw/private/__stem__.m +++ b/scripts/plot/draw/private/__stem__.m @@ -424,7 +424,7 @@ y = get (h, "ydata"); z = get (h, "zdata"); - if (!isempty (z) && size_equal (x, y, z)) + if (! isempty (z) && size_equal (x, y, z)) sz = min ([size(x); size(y); size(z)]); x = x(1:sz(1),1:sz(2)); y = y(1:sz(1),1:sz(2));
--- a/scripts/plot/draw/rectangle.m +++ b/scripts/plot/draw/rectangle.m @@ -103,7 +103,7 @@ elseif (strcmpi (arg, "curvature")) curv2 = varargin{iarg+1}; varargin(iarg:iarg+1) = []; - if (!isnumeric (curv2) || (numel (curv2) != 1 && numel (curv2) != 2)) + if (! isnumeric (curv2) || (numel (curv2) != 1 && numel (curv2) != 2)) error ("rectangle: curvature must be a 2-element vector or a scalar"); endif if (any (curv2 < 0) || any (curv2 > 1))
--- a/scripts/plot/draw/shrinkfaces.m +++ b/scripts/plot/draw/shrinkfaces.m @@ -217,7 +217,7 @@ %!assert (size (nfv.vertices), [3 3]) %!assert (norm (nfv2.vertices - vertices), 0, 2*eps) -%% Test input validation +## Test input validation %!error shrinkfaces () %!error shrinkfaces (1,2,3,4) %!error [a,b,c] = shrinkfaces (1)
--- a/scripts/plot/draw/slice.m +++ b/scripts/plot/draw/slice.m @@ -160,7 +160,9 @@ if (length (sy) > 0) for i = length (sy):-1:1 - [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), sy(i), squeeze (z(1,1,:))); + [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), + sy(i), + squeeze (z(1,1,:))); vy = squeeze (interp3 (x, y, z, v, xi, yi, zi, method)); htmp(sidx++) = surface (squeeze (xi), squeeze (sy(i) * ones (size (zi))),
--- a/scripts/plot/draw/surface.m +++ b/scripts/plot/draw/surface.m @@ -143,7 +143,7 @@ error ("mesh: X, C arguments must be real"); endif - if (ismatrix (z) && !isvector (z) && !isscalar (z)) + if (ismatrix (z) && ! isvector (z) && ! isscalar (z)) [nr, nc] = size (z); x = 1:nc; y = (1:nr)'; @@ -159,7 +159,7 @@ error ("mesh: Z argument must be real"); endif - if (ismatrix (z) && !isvector (z) && !isscalar (z)) + if (ismatrix (z) && ! isvector (z) && ! isscalar (z)) [nr, nc] = size (z); x = 1:nc; y = (1:nr)';
--- a/scripts/plot/draw/surfnorm.m +++ b/scripts/plot/draw/surfnorm.m @@ -188,7 +188,7 @@ %! [x, y, z] = sombrero (10); %! surfnorm (x, y, z); -%% Test input validation +## Test input validation %!error surfnorm () %!error surfnorm (1,2) %!error <X, Y, and Z must be 2-D real matrices> surfnorm (i)
--- a/scripts/plot/draw/trimesh.m +++ b/scripts/plot/draw/trimesh.m @@ -109,7 +109,7 @@ %! tri = delaunay (x(:), y(:)); %! trimesh (tri, x(:), y(:), z(:)); -%% Test input validation +## Test input validation %!error trimesh () %!error trimesh (1) %!error trimesh (1,2)
--- a/scripts/plot/draw/trisurf.m +++ b/scripts/plot/draw/trisurf.m @@ -162,7 +162,7 @@ %! tri = delaunay (x, y); %! trisurf (tri, x, y, z, 'facecolor', 'interp', 'edgecolor', 'k'); -%% Test input validation +## Test input validation %!error trisurf () %!error trisurf (1) %!error trisurf (1,2)
--- a/scripts/plot/util/__actual_axis_position__.m +++ b/scripts/plot/util/__actual_axis_position__.m @@ -66,7 +66,7 @@ axis_obj.plotboxaspectratio(3)/sqrt(2)]; endif orig_aspect_ratio_2d = pos_in_pixels(3:4); - rel_aspect_ratio_2d = aspect_ratio_2d ./ orig_aspect_ratio_2d; + rel_aspect_ratio_2d = aspect_ratio_2d ./ orig_aspect_ratio_2d; rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d); if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2)); dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3);
--- a/scripts/plot/util/__gnuplot_drawnow__.m +++ b/scripts/plot/util/__gnuplot_drawnow__.m @@ -209,9 +209,11 @@ size_str = sprintf ("size %gin,%gin", gnuplot_size); case "dumb" new_stream = 1; - if (!isempty (getenv ("COLUMNS")) && !isempty (getenv ("LINES"))) + if (! isempty (getenv ("COLUMNS")) + && ! isempty (getenv ("LINES"))) ## Let dumb use full text screen size (minus prompt lines). - n = sprintf ("%i", -2 - length (find (sprintf ("%s", PS1) == "\n"))); + n = sprintf ("%i", + -2 - length (find (sprintf ("%s", PS1) == "\n"))); ## n = the number of times \n appears in PS1 size_str = ["size " getenv("COLUMNS") "," getenv("LINES") n]; else @@ -297,8 +299,8 @@ ## If "set termoption dashed" isn't available add "dashed" option ## to the "set terminal ..." command, if it is supported. if (any (strcmp (term, {"aqua", "cgm", "eepic", "emf", "epslatex", ... - "fig", "pcl5", "mp", "next", "openstep", "pdf", ... - "pdfcairo", "pngcairo", "postscript", ... + "fig", "pcl5", "mp", "next", "openstep", ... + "pdf", "pdfcairo", "pngcairo", "postscript", ... "pslatex", "pstext", "svg", "tgif", "x11"}))) term_str = [term_str " dashed"]; endif
--- a/scripts/plot/util/axes.m +++ b/scripts/plot/util/axes.m @@ -34,7 +34,7 @@ ## of children. This causes @var{hax} to be displayed on top of any other ## axes objects (Z-order stacking). ## -## @seealso {gca, set, get} +## @seealso{gca, set, get} ## @end deftypefn ## Author: jwe @@ -61,7 +61,7 @@ hover = hax(idx); do_restack = true; endif - + ## Create an axes object. htmp = __go_axes__ (cf, varargin{:}); if (__is_handle_visible__ (htmp))
--- a/scripts/plot/util/clf.m +++ b/scripts/plot/util/clf.m @@ -76,7 +76,7 @@ else ## Select only the chilren with visible handles. delete (get (hfig, "children")); - + ## Also delete the annotation axes hover = findall (hfig, "-depth", 1, "tag", "scribeoverlay"); delete (hover);
--- a/scripts/plot/util/colstyle.m +++ b/scripts/plot/util/colstyle.m @@ -84,7 +84,7 @@ %! [l, c, m, msg] = colstyle ("~"); %! assert (msg, "colstyle: unrecognized format character: '~'"); -%% Test input validation +## Test input validation %!error colstyle () %!error colstyle (1, 2) %!error <STYLE must be a string> colstyle (1.5)
--- a/scripts/plot/util/figure.m +++ b/scripts/plot/util/figure.m @@ -121,6 +121,7 @@ endfunction + %!test %! hf = figure ("visible", "off"); %! unwind_protect
--- a/scripts/plot/util/frame2im.m +++ b/scripts/plot/util/frame2im.m @@ -57,6 +57,7 @@ endfunction + %!function f = make_rgb_f () %! f = randi ([0 255], 10, 20, 3); %!endfunction
--- a/scripts/plot/util/hdl2struct.m +++ b/scripts/plot/util/hdl2struct.m @@ -31,7 +31,7 @@ function s = hdl2struct (h) - if (nargin != 1 || !ishandle (h)) + if (nargin != 1 || ! ishandle (h)) print_usage (); endif @@ -43,8 +43,8 @@ ## main object main = get (h); s.handle = h; - s.type = main.type; - s.properties = getprops (h); + s.type = main.type; + s.properties = getprops (h); s.children = []; s.special = [];
--- a/scripts/plot/util/hgload.m +++ b/scripts/plot/util/hgload.m @@ -62,7 +62,7 @@ ## Functional test for hgload/hgsave pair is in hgsave.m -%% Test input validation +## Test input validation %!error hgload () %!error hgload (1, 2) %!error <unable to locate file> hgload ("%%_A_REALLY_UNLIKELY_FILENAME_%%")
--- a/scripts/plot/util/hgsave.m +++ b/scripts/plot/util/hgsave.m @@ -121,7 +121,7 @@ %! graphics_toolkit (toolkit); %! end_unwind_protect -%% Test input validation +## Test input validation %!error hgsave () %!error hgsave (1, 2, 3, 4) %!error hgsave ("abc", "def")
--- a/scripts/plot/util/im2frame.m +++ b/scripts/plot/util/im2frame.m @@ -65,6 +65,7 @@ frame = struct ("cdata", x, "colormap", map); endfunction + %!function f = make_rgb_f () %! f = randi ([0 255], 10, 20, 3); %!endfunction
--- a/scripts/plot/util/linkaxes.m +++ b/scripts/plot/util/linkaxes.m @@ -55,7 +55,7 @@ function linkaxes (hax, optstr = "xy") - if (nargin < 1 || nargin > 2) + if (nargin < 1 || nargin > 2) print_usage (); endif @@ -78,7 +78,7 @@ endif endfor - switch (optstr) + switch (optstr) case "x" hlink = linkprop (hax, "xlim"); case "y" @@ -160,7 +160,7 @@ %! close ([hf1 hf2 hf3]); %! end_unwind_protect -%% Test input validation +## Test input validation %!error linkaxes () %!error linkaxes (1,2,3) %!error <HAX must be a vector of axes handles> linkaxes ([pi, e])
--- a/scripts/plot/util/linkprop.m +++ b/scripts/plot/util/linkprop.m @@ -162,7 +162,7 @@ %! close ([hf1 hf2 hf3]); %! end_unwind_protect -%% Test input validation +## Test input validation %!error linkprop () %!error linkprop (1) %!error linkprop (1,2,3)
--- a/scripts/plot/util/meshgrid.m +++ b/scripts/plot/util/meshgrid.m @@ -126,7 +126,7 @@ %! assert (XX1, XX2); %! assert (YY1, YY2); -%% Test input validation +## Test input validation %!error meshgrid () %!error meshgrid (1,2,3,4) %!error <X and Y must be vectors> meshgrid (ones (2,2), 1:3)
--- a/scripts/plot/util/ndgrid.m +++ b/scripts/plot/util/ndgrid.m @@ -121,7 +121,7 @@ %!assert (ndgrid ([]), zeros(0,1)) %!assert (ndgrid ([], []), zeros(0,0)) -%% Test input validation +## Test input validation %!error ndgrid () %!error <wrong number of input arguments> [a,b,c] = ndgrid (1:3,1:3) %!error <arguments must be vectors> ndgrid (ones (2,2))
--- a/scripts/plot/util/newplot.m +++ b/scripts/plot/util/newplot.m @@ -32,28 +32,29 @@ ## @headitem Figure NextPlot @tab Action ## @item @qcode{"new"} @tab Create a new figure and make it the current figure. ## -## @item @qcode{"add"} (default) @tab Add new graphic objects to the current figure. +## @item @qcode{"add"} (default) @tab Add new graphic objects to the current +## figure. ## -## @item @qcode{"replacechildren"} @tab Delete child objects whose HandleVisibility is -## set to @qcode{"on"}. Set NextPlot property to @qcode{"add"}. This -## typically clears a figure, but leaves in place hidden objects such as -## menubars. This is equivalent to @code{clf}. +## @item @qcode{"replacechildren"} @tab Delete child objects whose +## HandleVisibility is set to @qcode{"on"}. Set NextPlot property to +## @qcode{"add"}. This typically clears a figure, but leaves in place hidden +## objects such as menubars. This is equivalent to @code{clf}. ## ## @item @qcode{"replace"} @tab Delete all child objects of the figure and ## reset all figure properties to their defaults. However, the following ## four properties are not reset: Position, Units, PaperPosition, PaperUnits. -## This is equivalent to @code{clf reset}. +## This is equivalent to @code{clf reset}. ## @end multitable ## ## @multitable @columnfractions .25 .75 ## @headitem Axis NextPlot @tab Action -## @item @qcode{"add"} @tab Add new graphic objects to the current axes. This is -## equivalent to @code{hold on}. +## @item @qcode{"add"} @tab Add new graphic objects to the current axes. This +## is equivalent to @code{hold on}. ## -## @item @qcode{"replacechildren"} @tab Delete child objects whose HandleVisibility is -## set to @qcode{"on"}, but leave axis properties unmodified. This typically -## clears a plot, but preserves special settings such as log scaling for -## axes. This is equivalent to @code{cla}. +## @item @qcode{"replacechildren"} @tab Delete child objects whose +## HandleVisibility is set to @qcode{"on"}, but leave axis properties +## unmodified. This typically clears a plot, but preserves special settings +## such as log scaling for axes. This is equivalent to @code{cla}. ## ## @item @qcode{"replace"} (default) @tab Delete all child objects of the ## axis and reset all axis properties to their defaults. However, the
--- a/scripts/plot/util/print.m +++ b/scripts/plot/util/print.m @@ -483,7 +483,7 @@ epsdevice = "eps2write"; endif endif - + dos_shell = (ispc () && ! isunix ()); cleanup = ""; @@ -509,9 +509,9 @@ pipeout = true; fileout = [tempname() ".eps"]; if (dos_shell) - cleanup = horzcat (cleanup, sprintf ("& del %s ", strrep (fileout, '/', '\'))); + cleanup = [cleanup, sprintf("& del %s ", strrep (fileout, '/', '\'))]; else - cleanup = horzcat (cleanup, sprintf ("; rm %s ", fileout)); + cleanup = [cleanup, sprintf("; rm %s ", fileout)]; endif else pipeout = false; @@ -625,7 +625,7 @@ function cmd = fig2dev (opts, devopt) if (nargin < 2) - devopt = opts.devopt; + devopt = opts.devopt; endif dos_shell = (ispc () && ! isunix ()); if (! isempty (opts.fig2dev_binary)) @@ -701,7 +701,7 @@ function cmd = lpr (opts) if (nargin < 2) - devopt = opts.devopt; + devopt = opts.devopt; endif if (! isempty (opts.lpr_binary)) cmd = opts.lpr_binary; @@ -721,7 +721,7 @@ function cmd = pstoedit (opts, devopt) if (nargin < 2) - devopt = opts.devopt; + devopt = opts.devopt; endif dos_shell = (ispc () && ! isunix ()); if (! isempty (opts.pstoedit_binary))
--- a/scripts/plot/util/printd.m +++ b/scripts/plot/util/printd.m @@ -53,8 +53,7 @@ opt = lower (opt); switch (opt) case "pdf" - enscr = sprintf ( - "enscript --no-header -o %s.ps %s ; ps2pdf %s.ps %s.pdf; mv %s.pdf %s;exit",... + enscr = sprintf ("enscript --no-header -o %s.ps %s ; ps2pdf %s.ps %s.pdf; mv %s.pdf %s;exit", ... tempf, tempf, tempf, tempf, tempf, filename); system (enscr); delete ([tempf ".ps"]); @@ -62,8 +61,7 @@ enscr = sprintf ("enscript --no-header -o %s %s ; exit", filename, tempf); system (enscr); case "eps" - enscr = sprintf ( - "enscript --no-header -o %s.ps %s ; ps2eps --ignoreBB %s.ps; mv %s.eps %s; exit",... + enscr = sprintf ("enscript --no-header -o %s.ps %s ; ps2eps --ignoreBB %s.ps; mv %s.eps %s; exit", ... tempf, tempf, tempf, tempf, filename); system (enscr); delete ([tempf ".ps"]); @@ -81,7 +79,7 @@ endswitch fclose (pf); delete (tempf); - pr_out = sprintf ("%s file %s written\n", opt, filename); + pr_out = sprintf ("%s file %s written\n", opt, filename); endfunction
--- a/scripts/plot/util/private/__ghostscript__.m +++ b/scripts/plot/util/private/__ghostscript__.m @@ -33,7 +33,7 @@ opts.output = "-"; opts.device = ""; opts.epscrop = false; - opts.antialiasing = false; + opts.antialiasing = false; opts.antialiasing_textalphabits = 4;, opts.antialiasing_graphicsalphabits = 4; opts.resolution = 150; @@ -66,7 +66,7 @@ format_for_printer = true; endif - gs_opts = sprintf ("-dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=%s", opts.device); + gs_opts = ["-dQUIET -dNOPAUSE -dBATCH -dSAFER -sDEVICE=" opts.device]; if (! isempty (opts.level) && ismember (opts.level, [1, 2, 3])) gs_opts = sprintf ("%s -dLanguageLevel=%d", gs_opts, opts.level);
--- a/scripts/plot/util/private/__gnuplot_ginput__.m +++ b/scripts/plot/util/private/__gnuplot_ginput__.m @@ -117,7 +117,8 @@ endif fclear (istream); endwhile - [x(k), y(k), button(k), count] = sscanf (str{end}(8:end), "%f %f %d", "C"); + [x(k), y(k), button(k), count] = ... + sscanf (str{end}(8:end), "%f %f %d", "C"); endif if ([x(k), y(k), button(k)] == [0, 0, -1])
--- a/scripts/plot/util/private/__go_draw_axes__.m +++ b/scripts/plot/util/private/__go_draw_axes__.m @@ -709,12 +709,12 @@ && (columns (obj.cdata) == nc && (rows (obj.cdata) == 1 || rows (obj.cdata) == 3))) - ccol = cdat (:, i); + ccol = cdat(:, i); elseif (ndims (obj.cdata) == 2 && (rows (obj.cdata) == nc && (columns (obj.cdata) == 1 || columns (obj.cdata) == 3))) - ccol = cdat (i, :); + ccol = cdat(i, :); elseif (ndims (obj.cdata) == 3) ccol = permute (cdat (:, i, :), [1, 3, 2]); else @@ -842,12 +842,12 @@ && (columns (obj.cdata) == nc && (rows (obj.cdata) == 1 || rows (obj.cdata) == 3))) - ccol = cdat (:, i); + ccol = cdat(:, i); elseif (ndims (obj.cdata) == 2 && (rows (obj.cdata) == nc && (columns (obj.cdata) == 1 || columns (obj.cdata) == 3))) - ccol = cdat (i, :); + ccol = cdat(i, :); elseif (ndims (obj.cdata) == 3) ccol = permute (cdat (:, i, :), [1, 3, 2]); else @@ -906,7 +906,7 @@ if (isfield (obj, "linewidth")) lw = sprintf ("linewidth %f", obj.linewidth); else - lw = ""; + lw = ""; endif [pt, pt2, obj] = gnuplot_pointtype (obj); @@ -938,7 +938,7 @@ facesame = true; if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") - && !strcmp (obj.markerfacecolor, "none")) + && ! strcmp (obj.markerfacecolor, "none")) if (strcmp (obj.markerfacecolor, "auto") || ! isnumeric (obj.markerfacecolor) || (isnumeric (obj.markerfacecolor) @@ -988,8 +988,8 @@ endif if (isfield (obj, "markeredgecolor") - && !strcmp (obj.markeredgecolor, "none")) - if (facesame && !isempty (pt) + && ! strcmp (obj.markeredgecolor, "none")) + if (facesame && ! isempty (pt) && (strcmp (obj.markeredgecolor, "auto") || ! isnumeric (obj.markeredgecolor) || (isnumeric (obj.markeredgecolor) @@ -1013,7 +1013,7 @@ colorspec); endif else - if (!isempty (style)) + if (! isempty (style)) if (length (tmpwith) < sidx || isempty (tmpwith{sidx})) tmpwith{sidx} = sprintf ("with %s %s %s %s", style, lw, lt, @@ -1022,7 +1022,7 @@ sidx ++; endif - if (!isempty (pt)) + if (! isempty (pt)) if (! mono) if (strcmp (obj.markeredgecolor, "auto")) colorspec = sprintf ("lc rgb \"#%02x%02x%02x\"", @@ -1208,7 +1208,7 @@ fputs (plot_stream, "set style increment default;\n"); if (flat_interp_edge && facecolor_none_or_white) withpm3d = false; - withclause{data_idx} = sprintf ("with %s palette", style {1}); + withclause{data_idx} = sprintf ("with %s palette", style{1}); fputs (plot_stream, "unset pm3d\n"); if (all (obj.facecolor == 1)) hidden_removal = true; @@ -1236,7 +1236,7 @@ fprintf (plot_stream, "set pm3d explicit at s %s %s corners2color c3;\n", interp_str, dord); - elseif (!facecolor_none_or_white) + elseif (! facecolor_none_or_white) if (strcmp (obj.edgecolor, "none")) if (__gnuplot_has_feature__ ("transparent_surface") && isscalar (obj.facealpha)) @@ -1404,7 +1404,7 @@ ## This is need to prevent warnings for rotations in 3D plots, while ## allowing colorbars with contours. - if (nd == 2 || (data_idx > 1 && !view_map)) + if (nd == 2 || (data_idx > 1 && ! view_map)) fputs (plot_stream, "set pm3d implicit;\n"); else fputs (plot_stream, "set pm3d explicit;\n"); @@ -1776,12 +1776,13 @@ endfunction function spacing_spec = create_spacingspec (f, s, gp_term) - # The gnuplot default font size is 10, and default spacing is 1.25. - # gnuplot has a concept of a figure global font, and sizes everything - # appropriate to that, including the legend spacing. - # - # This means that if an alternative size is used, gnuplot will use an - # inappropriate spacing in the legend by default. + ## The gnuplot default font size is 10, and default spacing is 1.25. + ## gnuplot has a concept of a figure global font, and sizes everything + ## appropriate to that, including the legend spacing. + ## + ## This means that if an alternative size is used, gnuplot will use an + ## inappropriate spacing in the legend by default. + ## ## FIXME: Are fractional spacing specifications allowed? Or should this ## number be rounded? spc = s / 10 * 1.25; @@ -1856,21 +1857,21 @@ sidx = 1; if (isempty (errbars)) if (isempty (lt)) - style {sidx} = ""; + style{sidx} = ""; else - style {sidx} = "lines"; + style{sidx} = "lines"; endif facesame = true; if (! isequal (pt, pt2) && isfield (obj, "markerfacecolor") - && !strcmp (obj.markerfacecolor, "none")) + && ! strcmp (obj.markerfacecolor, "none")) if (strcmp (obj.markerfacecolor, "auto") || ! isnumeric (obj.markerfacecolor) || (isnumeric (obj.markerfacecolor) && isequal (color, obj.markerfacecolor))) if (! isempty (pt2)) fprintf (plot_stream, " pointtype %s", pt2); - style {sidx} = strcat (style{sidx}, "points"); + style{sidx} = strcat (style{sidx}, "points"); endif if (isfield (obj, "markersize")) fprintf (plot_stream, " pointsize %f", obj.markersize / 3); @@ -1881,7 +1882,7 @@ fputs (plot_stream, " default"); endif fputs (plot_stream, ";\n"); - if (! isempty (style {sidx})) + if (! isempty (style{sidx})) sidx ++; idx ++; else @@ -1894,7 +1895,7 @@ round (255*obj.markerfacecolor)); endif if (! isempty (pt2)) - style {sidx} = "points"; + style{sidx} = "points"; fprintf (plot_stream, " pointtype %s", pt2); endif if (isfield (obj, "markersize")) @@ -1903,16 +1904,16 @@ endif endif if (isfield (obj, "markeredgecolor") - && !strcmp (obj.markeredgecolor, "none")) - if (facesame && !isempty (pt) + && ! strcmp (obj.markeredgecolor, "none")) + if (facesame && ! isempty (pt) && (strcmp (obj.markeredgecolor, "auto") || ! isnumeric (obj.markeredgecolor) || (isnumeric (obj.markeredgecolor) && isequal (color, obj.markeredgecolor)))) - if (sidx == 1 && ((length (style {sidx}) == 5 - && strncmp (style{sidx}, "lines", 5)) || isempty (style {sidx}))) + if (sidx == 1 && ((length (style{sidx}) == 5 + && strncmp (style{sidx}, "lines", 5)) || isempty (style{sidx}))) if (! isempty (pt)) - style {sidx} = strcat (style{sidx}, "points"); + style{sidx} = strcat (style{sidx}, "points"); fprintf (plot_stream, " pointtype %s", pt); endif if (isfield (obj, "markersize")) @@ -1924,7 +1925,7 @@ fputs (plot_stream, " default"); endif fputs (plot_stream, ";\n"); - if (!isempty (style {sidx})) + if (! isempty (style{sidx})) sidx ++; idx ++; else @@ -1942,7 +1943,7 @@ endif endif if (! isempty (pt)) - style {sidx} = "points"; + style{sidx} = "points"; fprintf (plot_stream, " pointtype %s", pt); endif if (isfield (obj, "markersize")) @@ -1955,7 +1956,7 @@ fputs (plot_stream, " pointtype 0"); endif - if (! found_style && isempty (style {1})) + if (! found_style && isempty (style{1})) fputs (plot_stream, " default"); endif @@ -2419,10 +2420,10 @@ endif endfor - ## Prepend @ to things things like _0^x or _{-100}^{100} for - ## alignment But need to put the shorter of the two arguments first. - ## Carful of nested {} and unprinted characters when defining - ## shortest.. Don't have to worry about things like ^\theta as they + ## Prepend @ to things like _0^x or _{-100}^{100} for alignment. + ## But need to put the shorter of the two arguments first. + ## Careful of nested {} and unprinted characters when defining + ## shortest.. Don't have to worry about things like ^\theta as they ## are already converted to ^{/Symbol q}. ## FIXME: This is a mess... Is it worth it just for a "@" character? @@ -2504,7 +2505,7 @@ function l = length_string (s) l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}')); m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches'); - if (!isempty (m)) + if (! isempty (m)) l = l - sum (cellfun ("length", m)); endif endfunction @@ -2542,7 +2543,7 @@ sym.lambda = '{/Symbol l}'; sym.mu = '{/Symbol m}'; sym.nu = '{/Symbol n}'; - sym.o = '{/Symbol o}'; + sym.o = '{/Symbol o}'; sym.pi = '{/Symbol p}'; sym.theta = '{/Symbol q}'; sym.rho = '{/Symbol r}'; @@ -2618,9 +2619,9 @@ sym.diamond = '{/Symbol \340}'; # Not in OpenGL sym.copyright = '{/Symbol \343}'; sym.lfloor = '{/Symbol \353}'; - sym.lceil = '{/Symbol \351}'; + sym.lceil = '{/Symbol \351}'; sym.rfloor = '{/Symbol \373}'; - sym.rceil = '{/Symbol \371}'; + sym.rceil = '{/Symbol \371}'; sym.int = '{/Symbol \362}'; endfunction
--- a/scripts/plot/util/private/__go_draw_figure__.m +++ b/scripts/plot/util/private/__go_draw_figure__.m @@ -104,7 +104,7 @@ endfor if (! isempty (ll)) - if (!isempty (lm)) + if (! isempty (lm)) toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(lm,"color"), "linestyle", get(ll,"linestyle"), "marker", get(lm,"marker"), "markeredgecolor", get(lm,"markeredgecolor"), "markerfacecolor", get(lm,"markerfacecolor"), "markersize", get (lm, "markersize"), "displayname", displayname, "parent", kids(i))]; else toberm = [toberm, line("xdata",[0,0],"ydata",[0,0], "color", get(ll,"color"), "linestyle", get(ll,"linestyle"), "marker", "none", "displayname", displayname, "parent", kids(i))];
--- a/scripts/plot/util/private/__opengl_print__.m +++ b/scripts/plot/util/private/__opengl_print__.m @@ -165,10 +165,10 @@ if (strcmp (get (opts.figure, "visible"), "on")) ## Use toolkits "print_figure" method - drawnow (gl2ps_device{n}, strcat ('|', pipeline{n})); + drawnow (gl2ps_device{n}, ['|' pipeline{n}]); else ## Use OpenGL offscreen rendering with OSMesa - __osmesa_print__ (opts.figure, strcat ('|', pipeline{n}), gl2ps_device{n}); + __osmesa_print__ (opts.figure, ['|', pipeline{n}), gl2ps_device{n}]); endif endfor
--- a/scripts/plot/util/private/__print_parse_opts__.m +++ b/scripts/plot/util/private/__print_parse_opts__.m @@ -253,7 +253,7 @@ match = strcmpi (dev_list, arg_st.devopt); if (any (match)) - default_suffix = suffixes {match}; + default_suffix = suffixes{match}; else default_suffix = arg_st.devopt; endif @@ -345,7 +345,8 @@ paperposition = [0.25, 2.50, 8.00, 6.00] * 72; endif arg_st.canvas_size = paperposition(3:4); - if (strcmp (__graphics_toolkit__, "gnuplot") && ! arg_st.ghostscript.epscrop) + if (strcmp (__graphics_toolkit__, "gnuplot") + && ! arg_st.ghostscript.epscrop) arg_st.ghostscript.pageoffset = paperposition(1:2) - 50; else arg_st.ghostscript.pageoffset = paperposition(1:2); @@ -482,10 +483,11 @@ endif if (isunix ()) ## Unix - Includes Mac OSX and Cygwin. - gs_binaries = horzcat (gs_binaries, {"gs", "gs.exe"}); + gs_binaries = [gs_binaries, {"gs", "gs.exe"}]; else ## pc - Includes Win32 and mingw. - gs_binaries = horzcat (gs_binaries, {"gs.exe", "gswin32c.exe", "gswin64c.exe", "mgs.exe"}); + gs_binaries = [gs_binaries, ... + {"gs.exe", "gswin32c.exe", "gswin64c.exe", "mgs.exe"}]; endif n = 0; while (n < numel (gs_binaries) && isempty (ghostscript_binary)) @@ -581,7 +583,8 @@ paperposition = paperposition([2,1,4,3]); endif - if ((! strcmp (papertype, "<custom>")) && (strcmp (paperorientation, "portrait"))) + if (! strcmp (papertype, "<custom>") + && (strcmp (paperorientation, "portrait"))) ## For portrait use the ghostscript name papersize = papertype; papersize(papersize=="-") = ""; @@ -616,8 +619,8 @@ function device_list = gs_device_list (); ## Graphics formats/languages, not printers. device_list = {"bmp16"; "bmp16m"; "bmp256"; "bmp32b"; "bmpgray"; ... - "epswrite"; "eps2write"; "jpeg"; "jpegcymk"; "jpeggray"; "pbm"; ... - "pbmraw"; "pcx16"; "pcx24b"; "pcx256"; "pcx2up"; ... + "epswrite"; "eps2write"; "jpeg"; "jpegcymk"; "jpeggray"; + "pbm"; "pbmraw"; "pcx16"; "pcx24b"; "pcx256"; "pcx2up"; ... "pcxcmyk"; "pcxgray"; "pcxmono"; "pdfwrite"; "pgm"; ... "pgmraw"; "pgnm"; "pgnmraw"; "png16"; "png16m"; ... "png256"; "png48"; "pngalpha"; "pnggray"; "pngmono"; ...
--- a/scripts/plot/util/refreshdata.m +++ b/scripts/plot/util/refreshdata.m @@ -90,7 +90,7 @@ ## properties that are not, in fact, datasources. ## m = regexp (flds, '^.+datasource$'); m = strfind (flds, "datasource"); - m = flds(!cellfun (@isempty, m)); + m = flds(! cellfun (@isempty, m)); for j = 1 : numel (m) if (isempty (obj.(m{j}))) continue; # datasource field doesn't point to anything
--- a/scripts/plot/util/rotate.m +++ b/scripts/plot/util/rotate.m @@ -166,7 +166,7 @@ endfunction -%% Test input validation +## Test input validation %!shared h1, h2, o1, o2, o3 %! h1 = figure ("visible", "off"); %! o1 = line ();
--- a/scripts/plot/util/saveas.m +++ b/scripts/plot/util/saveas.m @@ -61,9 +61,9 @@ ## Author: Kai Habel -function saveas (h, filename, fmt = "pdf") +function saveas (h, filename, fmt = "pdf") - if ((nargin != 2) && (nargin != 3)) + if (nargin != 2 && nargin != 3) print_usage (); endif @@ -77,19 +77,19 @@ error ("saveas: first argument H must be a graphics handle"); endif - if (!ischar (filename)) + if (! ischar (filename)) error ("saveas: FILENAME must be a string"); endif if (nargin == 2) [~, ~, ext] = fileparts (filename); - if (!isempty (ext)) + if (! isempty (ext)) fmt = ext(2:end); endif endif if (nargin == 3) - if (!ischar (filename)) + if (! ischar (filename)) error ("saveas: EXT must be a string"); endif
--- a/scripts/plot/util/struct2hdl.m +++ b/scripts/plot/util/struct2hdl.m @@ -463,7 +463,7 @@ tst = sum (temp) == length (bargroup); - if (isscalar (bargroup) || !tst) + if (isscalar (bargroup) || ! tst) xdata = s.properties.xdata; ydata = s.properties.ydata; @@ -484,7 +484,7 @@ tmp = struct ("handle", NaN, "type", "", "children", [], "special", []); for ii = 1:(nbar - 1) idx = find (p(1:2:end) == bargroup(ii)) * 2; - hdl = p (idx); + hdl = p(idx); xdata = [xdata get(hdl).xdata]; ydata = [ydata get(hdl).ydata]; tmp.children(ii) = hdl2struct (hdl);
--- a/scripts/plot/util/subplot.m +++ b/scripts/plot/util/subplot.m @@ -197,8 +197,8 @@ if (strcmp (get (cf, "__graphics_toolkit__"), "gnuplot")) align_axes = true; endif - - if (! have_position) + + if (! have_position) ## Subplots that cover more that one base subplot are not updated align_axes = (align_axes || (! isscalar (index))); ## Normal case where subplot indices have been given @@ -208,7 +208,7 @@ li = zeros (1,4); align_axes = true; endif - + set (cf, "nextplot", "add"); found = false; @@ -233,7 +233,7 @@ objpos = get (child, "position"); endif if (all (abs (objpos - pos) < eps) && ! replace_axes) - ## If the new axes are in exactly the same position + ## If the new axes are in exactly the same position ## as an existing axes object, or if they share the same ## appdata "__subplotposition__", use the existing axes. found = true; @@ -241,7 +241,7 @@ else ## If the new axes overlap an old axes object, delete the old axes. objpos = get (child, "position"); - + x0 = pos(1); x1 = x0 + pos(3); y0 = pos(2); @@ -272,7 +272,7 @@ if (! align_axes) ## base position (no ticks, no annotation, no cumbersome neighbor) setappdata (hsubplot, "__subplotposition__", pos); - ## max outerposition + ## max outerposition setappdata (hsubplot, "__subplotouterposition__", opos); addlistener (hsubplot, "outerposition", @subplot_align); addlistener (hsubplot, "xaxislocation", @subplot_align); @@ -280,13 +280,13 @@ addlistener (hsubplot, "position", {@subplot_align, true}); subplot_align (hsubplot); endif - + endif unwind_protect_cleanup set (0, "defaultaxesunits", axesunits); set (cf, "units", figureunits); end_unwind_protect - + if (nargout > 0) h = hsubplot; endif @@ -302,13 +302,13 @@ li = get (0, "defaultaxeslooseinset"); return; endif - - ## Row/Column inside the axes array + + ## Row/Column inside the axes array row = ceil (idx / ncols); col = idx .- (row - 1) * ncols; row = [min(row) max(row)]; - col = [min(col) max(col)]; - + col = [min(col) max(col)]; + ## Minimal margins around subplots defined in points fig_units = get (hf, "units"); set (hf, "units", "points"); @@ -319,13 +319,13 @@ ## Column/row separation margin.column = .2 / ncols + 2 * xbasemargin; margin.row = .2 / nrows + 2 * ybasemargin; - + set (hf, "units", fig_units); margin.left = xbasemargin; margin.right = xbasemargin; margin.bottom = ybasemargin; margin.top = ybasemargin; - + ## Boundary axes have default margins borders = get (0, "defaultaxesposition"); if (col(1) == 1) @@ -337,7 +337,7 @@ margin.right = 1 - borders(1) - borders(3); endif - + if (row(2) == nrows) margin.bottom = borders(2); else @@ -357,7 +357,7 @@ y0 = borders(2) + (nrows - row(2)) * (height + margin.row); width += diff (col) * (width + margin.column); height += diff (row) * (height + margin.row); - + pos = [x0 y0 width height]; opos = [(x0 - margin.left), (y0 - margin.bottom), ... (width + margin.left + margin.right), ... @@ -378,12 +378,12 @@ endif return endif - + unwind_protect updating = true; hf = ancestor (h, "figure"); children = get (hf, "children"); - + ## Base position of the subplot pos = getappdata (children, "__subplotposition__"); @@ -394,8 +394,8 @@ return endif hsubplots = children(do_align); - - + + ## There may be mixed subplot series (e.g. 2-by-6 and 1-by-6) in ## the same figure. Only subplots that have the same width and ## height as this one are updated. @@ -417,7 +417,7 @@ for ii = 1:numel (hsubplots); set (hsubplots(ii), "outerposition", opos(ii,:), ... "activepositionproperty", "position"); - endfor + endfor ## Compare current positions to default and compute the new ones curpos = get (hsubplots, "position"); @@ -437,11 +437,11 @@ pos(:,2) += dy0; pos(:,3) -= dx0 + dx1; pos(:,4) -= dy0 + dy1; - + for ii = 1:numel (hsubplots) set (hsubplots(ii), "position", pos(ii,:)); endfor - + unwind_protect_cleanup updating = false; end_unwind_protect
--- a/scripts/plot/util/zoom.m +++ b/scripts/plot/util/zoom.m @@ -60,18 +60,16 @@ function zoom (varargin) - hfig = NaN; - nargs = nargin; - if (nargs > 2) print_usage (); endif - if (nargin == 1 && nargout > 0 && isfigure (varargin{1})) + if (nargs == 1 && nargout > 0 && isfigure (varargin{1})) error ("zoom_object_handle = zoom (hfig): not implemented"); endif + hfig = NaN; if (nargs == 2) hfig = varargin{1}; if (isfigure (hfig)) @@ -176,6 +174,7 @@ endfunction + %!demo %! clf; %! sombrero (); @@ -196,3 +195,4 @@ %! pause (1); %! %% return to zoom level set by last call to "zoom reset" %! zoom out; +
--- a/scripts/polynomial/conv.m +++ b/scripts/polynomial/conv.m @@ -137,7 +137,7 @@ %!assert (conv (b,a,"valid"), zeros (1,0)) -%% Test input validation +## Test input validation %!error conv (1) %!error conv (1,2,3,4) %!error <A and B must be vectors> conv ([1, 2; 3, 4], 3)
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -55,7 +55,7 @@ if (ly > la) x = zeros (size (y) - size (a) + 1); - x (1) = 1; + x(1) = 1; b = filter (y, a, x); elseif (ly == la) b = filter (y, a, 1);
--- a/scripts/polynomial/mkpp.m +++ b/scripts/polynomial/mkpp.m @@ -55,7 +55,7 @@ error ("mkpp: at least one interval is needed"); endif - if (!isvector (x)) + if (! isvector (x)) error ("mkpp: x must be a vector"); endif
--- a/scripts/polynomial/pchip.m +++ b/scripts/polynomial/pchip.m @@ -77,7 +77,7 @@ ## Check the size and shape of y if (isvector (y)) - y = y(:).'; ##row vector + y = y(:).'; # force row vector szy = size (y); if (! size_equal (x, y)) error ("pchip: length of X and Y must match");
--- a/scripts/polynomial/polyeig.m +++ b/scripts/polynomial/polyeig.m @@ -95,7 +95,7 @@ %! d = C0*v + C1*v*z; %! assert (norm (d), 0.0); -%% Input validation tests +## Test input validation %!error polyeig () %!error [a,b,c] = polyeig (1) %!error <coefficients must be square matrices> polyeig (ones (3,2))
--- a/scripts/polynomial/ppder.m +++ b/scripts/polynomial/ppder.m @@ -24,12 +24,10 @@ ## @seealso{mkpp, ppval, ppint} ## @end deftypefn -function ppd = ppder (pp, m) +function ppd = ppder (pp, m = 1) - if ((nargin < 1) || (nargin > 2)) + if (nargin < 1 || nargin > 2) print_usage (); - elseif (nargin == 1) - m = 1; endif if (! (isstruct (pp) && strcmp (pp.form, "pp")))
--- a/scripts/polynomial/ppval.m +++ b/scripts/polynomial/ppval.m @@ -131,7 +131,7 @@ %! ret(:,:,2) = ppval (pp, breaks'); %! assert (ppval (pp, [breaks',breaks']), ret) -%% Test input validation +## Test input validation %!error ppval () %!error ppval (1) %!error ppval (1,2,3)
--- a/scripts/polynomial/residue.m +++ b/scripts/polynomial/residue.m @@ -193,7 +193,7 @@ ## Sort poles so that multiplicity loop will work. [e, indx] = mpoles (p, toler, 1); - p = p (indx); + p = p(indx); ## For each group of pole multiplicity, set the value of each ## pole to the average of the group. This reduces the error in @@ -289,8 +289,8 @@ indx = 1:numel (p); else [e, indx] = mpoles (p, toler, 0); - p = p (indx); - r = r (indx); + p = p(indx); + r = r(indx); endif indx = 1:numel (p);
--- a/scripts/polynomial/unmkpp.m +++ b/scripts/polynomial/unmkpp.m @@ -74,7 +74,7 @@ %! assert (k, 12); %! assert (d, 1); -%% Test input validation +## Test input validation %!error unmkpp () %!error unmkpp (1,2) %!error <piecewise polynomial structure> unmkpp (1)
--- a/scripts/prefs/addpref.m +++ b/scripts/prefs/addpref.m @@ -70,7 +70,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/getpref.m +++ b/scripts/prefs/getpref.m @@ -91,7 +91,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/ispref.m +++ b/scripts/prefs/ispref.m @@ -56,7 +56,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/private/loadprefs.m +++ b/scripts/prefs/private/loadprefs.m @@ -39,7 +39,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/private/prefsfile.m +++ b/scripts/prefs/private/prefsfile.m @@ -30,7 +30,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/private/saveprefs.m +++ b/scripts/prefs/private/saveprefs.m @@ -32,7 +32,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/prefs/setpref.m +++ b/scripts/prefs/setpref.m @@ -63,7 +63,7 @@ endfunction -%% Testing these functions will require some care to avoid wiping out -%% existing (or creating unwanted) preferences for the user running the -%% tests. +## Testing these functions will require some care to avoid wiping out +## existing (or creating unwanted) preferences for the user running the +## tests.
--- a/scripts/set/powerset.m +++ b/scripts/set/powerset.m @@ -100,7 +100,7 @@ %!assert (powerset([]), {}); # always return a cell array -%% Test input validation +## Test input validation %!error powerset () %!error powerset (1,2,3) %!error <expecting second argument to be "rows"> powerset (1, "cols")
--- a/scripts/set/setdiff.m +++ b/scripts/set/setdiff.m @@ -115,7 +115,7 @@ %! assert (c, [5]); %! assert (c, a(ia)); -%% Test output orientation compatibility (bug #42577) +## Test output orientation compatibility (bug #42577) %!assert (setdiff ([1:5], 2), [1,3,4,5]) %!assert (setdiff ([1:5]', 2), [1;3;4;5]) %!assert (setdiff ([1:5], [2:3]), [1,4,5])
--- a/scripts/set/union.m +++ b/scripts/set/union.m @@ -94,8 +94,7 @@ %! assert (y, [1, 2, 3, 4, 5]); %! assert (y, sort ([a(ia), b(ib)])); - -%% Test common input validation for set routines contained in validsetargs +## Test common input validation for set routines contained in validsetargs %!error <cell array of strings cannot be combined> union ({"a"}, 1) %!error <A and B must be arrays or cell arrays> union (@sin, 1) %!error <invalid option: columns> union (1, 2, "columns")
--- a/scripts/set/unique.m +++ b/scripts/set/unique.m @@ -214,7 +214,7 @@ %! assert (A(i,:), a); %! assert (a(j,:), A); -%% Test input validation +## Test input validation %!error unique () %!error <X must be an array or cell array of strings> unique ({1}) %!error <options must be strings> unique (1, 2)
--- a/scripts/signal/arch_fit.m +++ b/scripts/signal/arch_fit.m @@ -52,7 +52,7 @@ function [a, b] = arch_fit (y, x, p, iter, gamma, a0, b0) - if ((nargin < 3) || (nargin == 6) || (nargin > 7)) + if (nargin < 3 || nargin == 6 || nargin > 7) print_usage (); endif @@ -60,8 +60,8 @@ error ("arch_fit: Y must be a vector"); endif - T = length (y); - y = reshape (y, T, 1); + T = length (y); + y = reshape (y, T, 1); [rx, cx] = size (x); if ((rx == 1) && (cx == 1)) x = autoreg_matrix (y, x); @@ -72,12 +72,12 @@ [T, k] = size (x); if (nargin == 7) - a = a0; - b = b0; - e = y - x * b; + a = a0; + b = b0; + e = y - x * b; else [b, v_b, e] = ols (y, x); - a = [v_b, (zeros (1, p))]'; + a = [v_b, (zeros (1, p))]'; if (nargin < 5) gamma = 0.1; if (nargin < 4) @@ -87,20 +87,20 @@ endif esq = e.^2; - Z = autoreg_matrix (esq, p); + Z = autoreg_matrix (esq, p); for i = 1 : iter; - h = Z * a; - tmp = esq ./ h.^2 - 1 ./ h; - s = 1 ./ h(1:T-p); + h = Z * a; + tmp = esq ./ h.^2 - 1 ./ h; + s = 1 ./ h(1:T-p); for j = 1 : p; s = s - a(j+1) * tmp(j+1:T-p+j); endfor - r = 1 ./ h(1:T-p); + r = 1 ./ h(1:T-p); for j = 1:p; r = r + 2 * h(j+1:T-p+j).^2 .* esq(1:T-p); endfor - r = sqrt (r); + r = sqrt (r); X_tilde = x(1:T-p, :) .* (r * ones (1,k)); e_tilde = e(1:T-p) .*s ./ r; delta_b = inv (X_tilde' * X_tilde) * X_tilde' * e_tilde; @@ -112,7 +112,7 @@ f = esq ./ h - ones (T,1); Z_tilde = Z ./ (h * ones (1, p+1)); delta_a = inv (Z_tilde' * Z_tilde) * Z_tilde' * f; - a = a + gamma * delta_a; + a = a + gamma * delta_a; endfor endfunction
--- a/scripts/signal/arch_rnd.m +++ b/scripts/signal/arch_rnd.m @@ -71,11 +71,11 @@ b = [b, 0]; lb = lb + 1; endif - m = max ([la, lb]); + m = max ([la, lb]); - e = zeros (t, 1); - h = zeros (t, 1); - y = zeros (t, 1); + e = zeros (t, 1); + h = zeros (t, 1); + y = zeros (t, 1); h(1) = a(1); e(1) = sqrt (h(1)) * randn;
--- a/scripts/signal/arch_test.m +++ b/scripts/signal/arch_test.m @@ -74,8 +74,8 @@ if (! (isvector (y))) error ("arch_test: Y must be a vector"); endif - T = length (y); - y = reshape (y, T, 1); + T = length (y); + y = reshape (y, T, 1); [rx, cx] = size (x); if ((rx == 1) && (cx == 1)) x = autoreg_matrix (y, x);
--- a/scripts/signal/arma_rnd.m +++ b/scripts/signal/arma_rnd.m @@ -46,7 +46,7 @@ if (nargin == 4) n = 100; elseif (nargin == 5) - if (!isscalar (n)) + if (! isscalar (n)) error ("arma_rnd: N must be a scalar"); endif else @@ -57,7 +57,7 @@ error ("arma_rnd: A and B must not be matrices"); endif - if (!isscalar (t)) + if (! isscalar (t)) error ("arma_rnd: T must be a scalar"); endif
--- a/scripts/signal/detrend.m +++ b/scripts/signal/detrend.m @@ -46,7 +46,7 @@ p = 0; elseif (ischar (p) && strcmpi (p, "linear")) p = 1; - elseif (!isscalar (p) || p < 0 || p != fix (p)) + elseif (! isscalar (p) || p < 0 || p != fix (p)) error ("detrend: second input argument must be 'constant', 'linear' or a positive integer"); endif else
--- a/scripts/signal/diffpara.m +++ b/scripts/signal/diffpara.m @@ -41,23 +41,23 @@ function [d, dd] = diffpara (x, a, b) - if ((nargin < 1) || (nargin > 3)) + if (nargin < 1 || nargin > 3) print_usage (); + endif + + if (isvector (x)) + n = length (x); + k = 1; + x = reshape (x, n, 1); else - if (isvector (x)) - n = length (x); - k = 1; - x = reshape (x, n, 1); - else - [n, k] = size (x); - endif - if (nargin == 1) - a = 0.5 * sqrt (n); - b = 1.5 * sqrt (n); - elseif (nargin == 2) - b = a; - a = 1; - endif + [n, k] = size (x); + endif + if (nargin == 1) + a = 0.5 * sqrt (n); + b = 1.5 * sqrt (n); + elseif (nargin == 2) + b = a; + a = 1; endif if (! (isscalar (a) && isscalar (b)))
--- a/scripts/signal/durbinlevinson.m +++ b/scripts/signal/durbinlevinson.m @@ -34,7 +34,7 @@ function [newphi, newv] = durbinlevinson (c, oldphi, oldv) - if (! ((nargin == 1) || (nargin == 3))) + if (nargin != 1 && nargin != 3) print_usage (); endif
--- a/scripts/signal/fftconv.m +++ b/scripts/signal/fftconv.m @@ -65,7 +65,7 @@ endfunction -%% FIXME: Borrow tests from conv.m. May need a tolerance on the assert comparison +## FIXME: Borrow tests from conv.m. May need tolerance on the assert stmt. %!test %! x = ones (3,1); %! y = ones (1,3); @@ -98,7 +98,7 @@ %! assert (size (conv (a,b)), [1, numel(a)+numel(b)-1]); %! assert (size (conv (b,a)), [1, numel(a)+numel(b)-1]); -%% Test input validation +## Test input validation %!error fftconv (1) %!error fftconv (1,2,3,4) %!error fftconv ([1, 2; 3, 4], 3)
--- a/scripts/signal/fftfilt.m +++ b/scripts/signal/fftfilt.m @@ -185,7 +185,7 @@ %! y = fftfilt (b, x); %! assert (y0, y, 55*eps); -%% Test input validation +## Test input validation %!error fftfilt (1) %!error fftfilt (1, 2, 3, 4) %!error fftfilt (ones (2), 1)
--- a/scripts/signal/freqz.m +++ b/scripts/signal/freqz.m @@ -228,6 +228,6 @@ %! [h3,f3] = freqz (b,a,32,"whole",320); %! assert (f3,[0:31]'*10,10*eps); -%% Test input validation -## FIXME: Need to put tests here and simplify the input validation in the main code. +## Test input validation +## FIXME: Need to put tests here and simplify input validation in the main code.
--- a/scripts/signal/periodogram.m +++ b/scripts/signal/periodogram.m @@ -208,7 +208,7 @@ ## FIXME: Need some functional tests -%% Test input validation +## Test input validation %!error periodogram () %!error periodogram (1,2,3,4,5,6) %!error <X must be a real or complex vector> periodogram (ones (2,2))
--- a/scripts/signal/sinetone.m +++ b/scripts/signal/sinetone.m @@ -28,18 +28,9 @@ ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> ## Description: Compute a sine tone -function retval = sinetone (freq, rate, sec, ampl) +function retval = sinetone (freq, rate = 8000, sec = 1, ampl = 64) - if (nargin == 1) - rate = 8000; - sec = 1; - ampl = 64; - elseif (nargin == 2) - sec = 1; - ampl = 64; - elseif (nargin == 3) - ampl = 64; - elseif ((nargin < 1) || (nargin > 4)) + if (nargin < 1 || nargin > 4) print_usage (); endif
--- a/scripts/signal/spectral_adf.m +++ b/scripts/signal/spectral_adf.m @@ -69,7 +69,7 @@ endfunction -%% Test input validation +## Test input validation %!error spectral_adf (); %!error spectral_adf (1, 2, 3, 4); %!error spectral_adf (1, 2);
--- a/scripts/signal/spectral_xdf.m +++ b/scripts/signal/spectral_xdf.m @@ -70,7 +70,7 @@ endfunction -%% Test input validation +## Test input validation %!error spectral_xdf (); %!error spectral_xdf (1, 2, 3, 4); %!error spectral_xdf (1, 2);
--- a/scripts/signal/unwrap.m +++ b/scripts/signal/unwrap.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isnumeric (x)) + if (! isnumeric (x)) error ("unwrap: X must be a numeric matrix or vector"); endif @@ -78,7 +78,7 @@ ## Find only the peaks, and multiply them by the appropriate amount ## of ranges so that there are kronecker deltas at each wrap point ## multiplied by the appropriate amount of range values. - p = ceil (abs (d)./rng) .* rng .* (((d > tol) > 0) - ((d < -tol) > 0)); + p = ceil (abs (d)./rng) .* rng .* (((d > tol) > 0) - ((d < -tol) > 0)); ## Now need to "integrate" this so that the deltas become steps. r = cumsum (p, dim);
--- a/scripts/sparse/bicg.m +++ b/scripts/sparse/bicg.m @@ -63,7 +63,8 @@ ## ## @item @var{iter} is the number of iterations performed. ## -## @item @var{resvec} is a vector containing the relative residual at each iteration. +## @item @var{resvec} is a vector containing the relative residual at each +## iteration. ## @end itemize ## ## @seealso{bicgstab, cgs, gmres, pcg}
--- a/scripts/sparse/bicgstab.m +++ b/scripts/sparse/bicgstab.m @@ -63,7 +63,8 @@ ## ## @item @var{iter} is the number of iterations performed. ## -## @item @var{resvec} is a vector containing the relative residual at each iteration. +## @item @var{resvec} is a vector containing the relative residual at each +## iteration. ## @end itemize ## ## @seealso{bicg, cgs, gmres, pcg}
--- a/scripts/sparse/cgs.m +++ b/scripts/sparse/cgs.m @@ -159,7 +159,7 @@ ## We reach tolerance tol within maxit iterations. flag = 0; break - elseif (resvec (end) == resvec (end - 1)) + elseif (resvec(end) == resvec(end - 1)) ## The method stagnates. flag = 3; break
--- a/scripts/sparse/eigs.m +++ b/scripts/sparse/eigs.m @@ -490,7 +490,7 @@ %!shared n, k, A, d0 %! n = 20; %! k = 4; -%! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]); +%! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)]); %! d0 = eig (A); %! [~, idx] = sort (abs (d0)); %! d0 = d0(idx); @@ -859,7 +859,7 @@ %!shared n, k, A, d0 %! n = 20; %! k = 4; -%! A = full (sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)])); +%! A = full (sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),1:n,-ones(1,n-2)])); %! d0 = eig (A); %! [~, idx] = sort (abs (d0)); %! d0 = d0(idx);
--- a/scripts/sparse/gmres.m +++ b/scripts/sparse/gmres.m @@ -165,7 +165,7 @@ [V(:,restart_it+1), H(1:restart_it+1, restart_it)] = ... mgorth (tmp, V(:,1:restart_it)); - Y = (H(1:restart_it+1, 1:restart_it) \ B (1:restart_it+1)); + Y = (H(1:restart_it+1, 1:restart_it) \ B(1:restart_it+1)); little_res = B(1:restart_it+1) - ... H(1:restart_it+1, 1:restart_it) * Y(1:restart_it);
--- a/scripts/sparse/gplot.m +++ b/scripts/sparse/gplot.m @@ -79,6 +79,6 @@ %! set (get (gca, ("children")), "markersize", 12); %! title ("gplot() of Binary Tree Adjacency matrix"); -%% Mark graphical function as tested by demo block +## Mark graphical function as tested by demo block %!assert (1)
--- a/scripts/sparse/ichol.m +++ b/scripts/sparse/ichol.m @@ -358,7 +358,7 @@ ## ICHOLT tests -%%!test +#%!test %! opts.type = "ict"; %! opts.droptol = 1e-1; %! opts.michol = "off"; @@ -371,7 +371,7 @@ %! L = ichol (A1, opts); %! assert (norm (A1 - L * L', "fro") / norm (A1, "fro"), 0.2065, 1e-4); %! -%%!test +#%!test %! opts.type = "ict"; %! opts.droptol = 1e-1; %! opts.michol = "on"; @@ -425,8 +425,7 @@ %! L = ichol (A5, opts); %! assert (norm (A5 - L*L', "fro") / norm (A5, "fro"), 0.3231, 1e-4); -%% Input validation tests - +## Test input validation %!error <A must be a sparse square matrix> ichol ([]) %!error <A must be a sparse square matrix> ichol (0) %!error <pivot equal to 0> ichol (sparse (0))
--- a/scripts/sparse/ilu.m +++ b/scripts/sparse/ilu.m @@ -478,7 +478,7 @@ %! opts.milu = "row"; %! #fail ("ilu (a2, opts)"); -%% Tests for input validation +## Tests for input validation %!shared A_tiny %! A_tiny = spconvert ([1 4 2 3 3 4 2 5; 1 1 2 3 4 4 5 5; 1 2 3 4 5 6 7 8]');
--- a/scripts/sparse/pcg.m +++ b/scripts/sparse/pcg.m @@ -526,8 +526,8 @@ %! %! N = 100; %! A = zeros (N, N); -%! for i = 1 : N - 1 # form 1-D Laplacian matrix -%! A (i:i+1, i:i+1) = [2 -1; -1 2]; +%! for i = 1 : N - 1 # form 1-D Laplacian matrix +%! A(i:i+1, i:i+1) = [2 -1; -1 2]; %! endfor %! b = ones (N, 1); %! X = A \ b; # X is the true solution
--- a/scripts/sparse/qmr.m +++ b/scripts/sparse/qmr.m @@ -186,7 +186,7 @@ w = wt / xi1; z = z / xi1; - delta1 = z' * y; ## If delta1 == 0, method fails. + delta1 = z' * y; # If delta1 == 0, method fails. yt = M2m1x (y); zt = M1tm1x (z); @@ -200,8 +200,8 @@ endif pt = Ax (p); - eps0 = q' * pt; ## If eps0 == 0, method fails. - beta1 = eps0 / delta1; ## If beta1 == 0, method fails. + eps0 = q' * pt; # If eps0 == 0, method fails. + beta1 = eps0 / delta1; # If beta1 == 0, method fails. vt = pt - beta1 * v; y = M1m1x (vt); @@ -211,7 +211,7 @@ xi1 = norm(z); theta1 = rho1 / (gamma0 * abs(beta1)); - gamma1 = 1 / sqrt(1 + theta1^2); ## If gamma1 == 0, method fails. + gamma1 = 1 / sqrt(1 + theta1^2); # If gamma1 == 0, method fails. eta1 = -eta0 * rho0 * gamma1^2 / (beta1 * gamma0^2); if (iter == 1)
--- a/scripts/sparse/spaugment.m +++ b/scripts/sparse/spaugment.m @@ -85,7 +85,7 @@ c = max (abs (A(:))) / 1000; endif endif - elseif (!isscalar (c)) + elseif (! isscalar (c)) error ("spaugment: C must be a scalar"); endif
--- a/scripts/sparse/spconvert.m +++ b/scripts/sparse/spconvert.m @@ -60,7 +60,7 @@ %! assert (isequal (i, fi) && isequal (j, fj) && isequal (complex (v, j), fv)); %! assert (size (spconvert ([1, 1, 3; 5, 15, 0])), [5, 15]); -%% Test input validation +## Test input validation %!error spconvert () %!error spconvert (1, 2) %!error spconvert ({[1 2 3]})
--- a/scripts/sparse/spdiags.m +++ b/scripts/sparse/spdiags.m @@ -169,7 +169,7 @@ %!assert (spdiags (zeros (0,1),1,1,1), sparse (0)) %!assert (spdiags ([0.5 -1 0.5], 0:2, 1, 1), sparse (0.5)) -%% Test input validation +## Test input validation %!error spdiags () %!error spdiags (1,2,3,4,5)
--- a/scripts/sparse/sprand.m +++ b/scripts/sparse/sprand.m @@ -65,13 +65,13 @@ endfunction -%% Test 3-input calling form +## Test 3-input calling form %!test %! s = sprand (4, 10, 0.1); %! assert (size (s), [4, 10]); %! assert (nnz (s) / numel (s), 0.1); -%% Test 4-input calling form +## Test 4-input calling form %!test %! d = rand (); %! s1 = sprand (100, 100, d, 0.4); @@ -84,7 +84,7 @@ %! assert (nnz (s2) / (100*100), d, 0.02); %! assert (svd (s3)', [5 4 3 2], sqrt (eps)); -%% Test 1-input calling form +## Test 1-input calling form %!test %! s = sprand (sparse ([1 2 3], [3 2 3], [2 2 2])); %! [i, j, v] = find (s); @@ -92,7 +92,11 @@ %! assert (sort (j), [2 3 3]'); %! assert (all (v > 0 & v < 1)); -%% Test input validation +## Test very large, very low density matrix doesn't fail +%!test +%! s = sprand (1e6, 1e6, 1e-7); + +## Test input validation %!error sprand () %!error sprand (1, 2) %!error sprand (1, 2, 3, 4) @@ -108,7 +112,3 @@ %!error <RC must be between 0 and 1> sprand (2, 2, 0.2, -1) %!error <RC must be between 0 and 1> sprand (2, 2, 0.2, 2) -%% Test very large, very low density matrix doesn't fail -%!test -%! s = sprand (1e6, 1e6, 1e-7); -
--- a/scripts/sparse/sprandn.m +++ b/scripts/sparse/sprandn.m @@ -57,13 +57,13 @@ endfunction -%% Test 3-input calling form +## Test 3-input calling form %!test %! s = sprandn (4, 10, 0.1); %! assert (size (s), [4, 10]); %! assert (nnz (s) / numel (s), 0.1); -%% Test 4-input calling form +## Test 4-input calling form %!test %! d = rand (); %! s1 = sprandn (100, 100, d, 0.4); @@ -76,14 +76,18 @@ %! assert (nnz (s2) / (100*100), d, 0.02); %! assert (svd (s3)', [5 4 3 2], sqrt (eps)); -%% Test 1-input calling form +## Test 1-input calling form %!test %! s = sprandn (sparse ([1 2 3], [3 2 3], [2 2 2])); %! [i, j] = find (s); %! assert (sort (i), [1 2 3]'); %! assert (sort (j), [2 3 3]'); -%% Test input validation +## Test very large, very low density matrix doesn't fail +%!test +%! s = sprandn (1e6,1e6,1e-7); + +## Test input validation %!error sprandn () %!error sprandn (1, 2) %!error sprandn (1, 2, 3, 4) @@ -99,7 +103,3 @@ %!error <RC must be between 0 and 1> sprandn (2, 2, 0.2, -1) %!error <RC must be between 0 and 1> sprandn (2, 2, 0.2, 2) -%% Test very large, very low density matrix doesn't fail -%!test -%! s = sprandn (1e6,1e6,1e-7); -
--- a/scripts/sparse/sprandsym.m +++ b/scripts/sparse/sprandsym.m @@ -159,14 +159,14 @@ %! assert (size (s), [10, 10]); %! assert (nnz (s) / numel (s), 0.1, .01); -%% Test 1-input calling form +## Test 1-input calling form %!test %! s = sprandsym (sparse ([1 2 3], [3 2 3], [2 2 2])); %! [i, j] = find (s); %! assert (sort (i), [2 3]'); %! assert (sort (j), [2 3]'); -%% Test input validation +## Test input validation %!error sprandsym () %!error sprandsym (1, 2, 3) %!error sprandsym (ones (3), 0.5)
--- a/scripts/sparse/spy.m +++ b/scripts/sparse/spy.m @@ -72,6 +72,6 @@ %! clf; %! spy (sprand (10,10, 0.2)); -%% Mark graphical function as tested by demo block +## Mark graphical function as tested by demo block %!assert (1)
--- a/scripts/sparse/svds.m +++ b/scripts/sparse/svds.m @@ -107,16 +107,16 @@ opts.disp = 0; opts.maxit = 300; else - if (!isstruct (opts)) + if (! isstruct (opts)) error ("svds: OPTS must be a structure"); endif - if (!isfield (opts, "tol")) + if (! isfield (opts, "tol")) opts.tol = 0; # use ARPACK default else opts.tol = opts.tol / root2; endif if (isfield (opts, "v0")) - if (!isvector (opts.v0) || (length (opts.v0) != sum (size (A)))) + if (! isvector (opts.v0) || (length (opts.v0) != sum (size (A)))) error ("svds: OPTS.v0 must be a vector with rows(A)+columns(A) entries"); endif endif @@ -160,7 +160,7 @@ ## Call to eigs is always a symmetric matrix by construction b_opts.issym = true; b_sigma = sigma; - if (!ischar (b_sigma)) + if (! ischar (b_sigma)) b_sigma = b_sigma / max_a; endif @@ -219,7 +219,7 @@ if (length (s) < k) warning ("returning fewer singular values than requested"); - if (!ischar (sigma)) + if (! ischar (sigma)) warning ("try increasing the value of sigma"); endif endif
--- a/scripts/sparse/treelayout.m +++ b/scripts/sparse/treelayout.m @@ -32,7 +32,7 @@ if (nargin < 1 || nargin > 2 || nargout > 4) print_usage (); elseif (! isvector (tree) || rows (tree) != 1 || ! isnumeric (tree) - || any (tree > length (tree)) || any (tree < 0)) + || any (tree > length (tree)) || any (tree < 0)) error ("treelayout: the first input argument must be a vector of predecessors"); else ## Make it a row vector.
--- a/scripts/specfun/betaln.m +++ b/scripts/specfun/betaln.m @@ -64,7 +64,7 @@ %!assert (betaln (3,4), log (beta (3,4)), eps) -%% Test input validation +## Test input validation %!error betaln () %!error betaln (1) %!error betaln (1,2,3)
--- a/scripts/specfun/factor.m +++ b/scripts/specfun/factor.m @@ -107,7 +107,7 @@ %! assert (all ([0,pf] != [pf,0])); %! endfor -%% Test input validation +## Test input validation %!error factor () %!error factor (1,2) %!error <Q must be a real integer> factor (6i)
--- a/scripts/specfun/isprime.m +++ b/scripts/specfun/isprime.m @@ -164,7 +164,7 @@ %!assert (isprime (0), false) %!assert (isprime (magic (3)), logical ([0, 0, 0; 1, 1, 1; 0, 0, 1])) -%% Test input validation +## Test input validation %!error isprime () %!error isprime (1, 2) %!error <X contains non-integer entries> isprime (0.5i)
--- a/scripts/specfun/legendre.m +++ b/scripts/specfun/legendre.m @@ -305,7 +305,7 @@ %! expected(:,:,2) = [1,0,-1;0,1.5,0;0,0,0;0,-15,0]; %! assert (result, expected); -%% Check correct invocation +## Test input validation %!error legendre () %!error legendre (1) %!error legendre (1,2,3,4)
--- a/scripts/specfun/nchoosek.m +++ b/scripts/specfun/nchoosek.m @@ -146,7 +146,7 @@ %!assert (nchoosek (1:5,3), [1:3;1,2,4;1,2,5;1,3,4;1,3,5;1,4,5;2:4;2,3,5;2,4,5;3:5]) %!assert (size (nchoosek (1:5,0)), [1 0]) -%% Test input validation +## Test input validation %!error nchoosek () %!error nchoosek (1) %!error nchoosek (1,2,3)
--- a/scripts/specfun/nthroot.m +++ b/scripts/specfun/nthroot.m @@ -99,7 +99,7 @@ %! assert (nthroot (0, 2), 0); %! assert (lastwarn (), warnmsg); -%% Test input validation +## Test input validation %!error nthroot () %!error nthroot (1) %!error nthroot (1,2,3)
--- a/scripts/special-matrix/gallery.m +++ b/scripts/special-matrix/gallery.m @@ -505,26 +505,26 @@ function C = cauchy (x, y) ##CAUCHY Cauchy matrix. - ## C = CAUCHY(X, Y), where X, Y are N-vectors, is the N-by-N matrix - ## with C(i,j) = 1/(X(i)+Y(j)). By default, Y = X. - ## Special case: if X is a scalar CAUCHY(X) is the same as CAUCHY(1:X). - ## Explicit formulas are known for DET(C) (which is nonzero if X and Y - ## both have distinct elements) and the elements of INV(C). - ## C is totally positive if 0 < X(1) < ... < X(N) and - ## 0 < Y(1) < ... < Y(N). + ## C = CAUCHY(X, Y), where X, Y are N-vectors, is the N-by-N matrix + ## with C(i,j) = 1/(X(i)+Y(j)). By default, Y = X. + ## Special case: if X is a scalar CAUCHY(X) is the same as CAUCHY(1:X). + ## Explicit formulas are known for DET(C) (which is nonzero if X and Y + ## both have distinct elements) and the elements of INV(C). + ## C is totally positive if 0 < X(1) < ... < X(N) and + ## 0 < Y(1) < ... < Y(N). ## - ## References: - ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, - ## Society for Industrial and Applied Mathematics, Philadelphia, PA, - ## USA, 1996; sec. 26.1. - ## D.E. Knuth, The Art of Computer Programming, Volume 1, - ## Fundamental Algorithms, second edition, Addison-Wesley, Reading, - ## Massachusetts, 1973, p. 36. - ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, - ## Linear Algebra and Appl., 149 (1991), pp. 1-18. - ## O. Taussky and M. Marcus, Eigenvalues of finite matrices, in - ## Survey of Numerical Analysis, J. Todd, ed., McGraw-Hill, New York, - ## pp. 279-313, 1962. (States the totally positive property on p. 295.) + ## References: + ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, + ## Society for Industrial and Applied Mathematics, Philadelphia, PA, + ## USA, 1996; sec. 26.1. + ## D.E. Knuth, The Art of Computer Programming, Volume 1, + ## Fundamental Algorithms, second edition, Addison-Wesley, Reading, + ## Massachusetts, 1973, p. 36. + ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, + ## Linear Algebra and Appl., 149 (1991), pp. 1-18. + ## O. Taussky and M. Marcus, Eigenvalues of finite matrices, in + ## Survey of Numerical Analysis, J. Todd, ed., McGraw-Hill, New York, + ## pp. 279-313, 1962. (States the totally positive property on p. 295.) if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for cauchy matrix."); @@ -561,23 +561,23 @@ function C = chebspec (n, k = 0) ## CHEBSPEC Chebyshev spectral differentiation matrix. - ## C = CHEBSPEC(N, K) is a Chebyshev spectral differentiation - ## matrix of order N. K = 0 (the default) or 1. - ## For K = 0 (`no boundary conditions'), C is nilpotent, with - ## C^N = 0 and it has the null vector ONES(N,1). - ## C is similar to a Jordan block of size N with eigenvalue zero. - ## For K = 1, C is nonsingular and well-conditioned, and its eigenvalues - ## have negative real parts. - ## For both K, the computed eigenvector matrix X from EIG is - ## ill-conditioned (MESH(REAL(X)) is interesting). + ## C = CHEBSPEC(N, K) is a Chebyshev spectral differentiation + ## matrix of order N. K = 0 (the default) or 1. + ## For K = 0 (`no boundary conditions'), C is nilpotent, with + ## C^N = 0 and it has the null vector ONES(N,1). + ## C is similar to a Jordan block of size N with eigenvalue zero. + ## For K = 1, C is nonsingular and well-conditioned, and its eigenvalues + ## have negative real parts. + ## For both K, the computed eigenvector matrix X from EIG is + ## ill-conditioned (MESH(REAL(X)) is interesting). ## - ## References: - ## C. Canuto, M.Y. Hussaini, A. Quarteroni and T.A. Zang, Spectral - ## Methods in Fluid Dynamics, Springer-Verlag, Berlin, 1988; p. 69. - ## L.N. Trefethen and M.R. Trummer, An instability phenomenon in - ## spectral methods, SIAM J. Numer. Anal., 24 (1987), pp. 1008-1023. - ## D. Funaro, Computing the inverse of the Chebyshev collocation - ## derivative, SIAM J. Sci. Stat. Comput., 9 (1988), pp. 1050-1057. + ## References: + ## C. Canuto, M.Y. Hussaini, A. Quarteroni and T.A. Zang, Spectral + ## Methods in Fluid Dynamics, Springer-Verlag, Berlin, 1988; p. 69. + ## L.N. Trefethen and M.R. Trummer, An instability phenomenon in + ## spectral methods, SIAM J. Numer. Anal., 24 (1987), pp. 1008-1023. + ## D. Funaro, Computing the inverse of the Chebyshev collocation + ## derivative, SIAM J. Sci. Stat. Comput., 9 (1988), pp. 1050-1057. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for chebspec matrix."); @@ -628,18 +628,18 @@ function C = chebvand (m, p) ## CHEBVAND Vandermonde-like matrix for the Chebyshev polynomials. - ## C = CHEBVAND(P), where P is a vector, produces the (primal) - ## Chebyshev Vandermonde matrix based on the points P, - ## i.e., C(i,j) = T_{i-1}(P(j)), where T_{i-1} is the Chebyshev - ## polynomial of degree i-1. - ## CHEBVAND(M,P) is a rectangular version of CHEBVAND(P) with M rows. - ## Special case: If P is a scalar then P equally spaced points on - ## [0,1] are used. + ## C = CHEBVAND(P), where P is a vector, produces the (primal) + ## Chebyshev Vandermonde matrix based on the points P, + ## i.e., C(i,j) = T_{i-1}(P(j)), where T_{i-1} is the Chebyshev + ## polynomial of degree i-1. + ## CHEBVAND(M,P) is a rectangular version of CHEBVAND(P) with M rows. + ## Special case: If P is a scalar then P equally spaced points on + ## [0,1] are used. ## - ## Reference: - ## N.J. Higham, Stability analysis of algorithms for solving confluent - ## Vandermonde-like systems, SIAM J. Matrix Anal. Appl., 11 (1990), - ## pp. 23-41. + ## Reference: + ## N.J. Higham, Stability analysis of algorithms for solving confluent + ## Vandermonde-like systems, SIAM J. Matrix Anal. Appl., 11 (1990), + ## pp. 23-41. if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for chebvand matrix."); @@ -680,17 +680,17 @@ function A = chow (n, alpha = 1, delta = 0) ## CHOW Chow matrix - a singular Toeplitz lower Hessenberg matrix. - ## A = CHOW(N, ALPHA, DELTA) is a Toeplitz lower Hessenberg matrix - ## A = H(ALPHA) + DELTA*EYE, where H(i,j) = ALPHA^(i-j+1). - ## H(ALPHA) has p = FLOOR(N/2) zero eigenvalues, the rest being - ## 4*ALPHA*COS( k*PI/(N+2) )^2, k=1:N-p. - ## Defaults: ALPHA = 1, DELTA = 0. + ## A = CHOW(N, ALPHA, DELTA) is a Toeplitz lower Hessenberg matrix + ## A = H(ALPHA) + DELTA*EYE, where H(i,j) = ALPHA^(i-j+1). + ## H(ALPHA) has p = FLOOR(N/2) zero eigenvalues, the rest being + ## 4*ALPHA*COS( k*PI/(N+2) )^2, k=1:N-p. + ## Defaults: ALPHA = 1, DELTA = 0. ## - ## References: - ## T.S. Chow, A class of Hessenberg matrices with known - ## eigenvalues and inverses, SIAM Review, 11 (1969), pp. 391-395. - ## G. Fairweather, On the eigenvalues and eigenvectors of a class of - ## Hessenberg matrices, SIAM Review, 13 (1971), pp. 220-221. + ## References: + ## T.S. Chow, A class of Hessenberg matrices with known + ## eigenvalues and inverses, SIAM Review, 11 (1969), pp. 391-395. + ## G. Fairweather, On the eigenvalues and eigenvectors of a class of + ## Hessenberg matrices, SIAM Review, 13 (1971), pp. 220-221. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for chow matrix."); @@ -707,18 +707,18 @@ function C = circul (v) ## CIRCUL Circulant matrix. - ## C = CIRCUL(V) is the circulant matrix whose first row is V. - ## (A circulant matrix has the property that each row is obtained - ## from the previous one by cyclically permuting the entries one step - ## forward; it is a special Toeplitz matrix in which the diagonals - ## `wrap round'.) - ## Special case: if V is a scalar then C = CIRCUL(1:V). - ## The eigensystem of C (N-by-N) is known explicitly. If t is an Nth - ## root of unity, then the inner product of V with W = [1 t t^2 ... t^N] - ## is an eigenvalue of C, and W(N:-1:1) is an eigenvector of C. + ## C = CIRCUL(V) is the circulant matrix whose first row is V. + ## (A circulant matrix has the property that each row is obtained + ## from the previous one by cyclically permuting the entries one step + ## forward; it is a special Toeplitz matrix in which the diagonals + ## `wrap round'.) + ## Special case: if V is a scalar then C = CIRCUL(1:V). + ## The eigensystem of C (N-by-N) is known explicitly. If t is an Nth + ## root of unity, then the inner product of V with W = [1 t t^2 ... t^N] + ## is an eigenvalue of C, and W(N:-1:1) is an eigenvector of C. ## - ## Reference: - ## P.J. Davis, Circulant Matrices, John Wiley, 1977. + ## Reference: + ## P.J. Davis, Circulant Matrices, John Wiley, 1977. if (nargin != 1) error ("gallery: 1 argument is required for circul matrix."); @@ -742,28 +742,28 @@ function A = clement (n, k = 0) ## CLEMENT Clement matrix - tridiagonal with zero diagonal entries. - ## CLEMENT(N, K) is a tridiagonal matrix with zero diagonal entries - ## and known eigenvalues. It is singular if N is odd. About 64 - ## percent of the entries of the inverse are zero. The eigenvalues - ## are plus and minus the numbers N-1, N-3, N-5, ..., (1 or 0). - ## For K = 0 (the default) the matrix is unsymmetric, while for - ## K = 1 it is symmetric. - ## CLEMENT(N, 1) is diagonally similar to CLEMENT(N). + ## CLEMENT(N, K) is a tridiagonal matrix with zero diagonal entries + ## and known eigenvalues. It is singular if N is odd. About 64 + ## percent of the entries of the inverse are zero. The eigenvalues + ## are plus and minus the numbers N-1, N-3, N-5, ..., (1 or 0). + ## For K = 0 (the default) the matrix is unsymmetric, while for + ## K = 1 it is symmetric. + ## CLEMENT(N, 1) is diagonally similar to CLEMENT(N). ## - ## Similar properties hold for TRIDIAG(X,Y,Z) where Y = ZEROS(N,1). - ## The eigenvalues still come in plus/minus pairs but they are not - ## known explicitly. + ## Similar properties hold for TRIDIAG(X,Y,Z) where Y = ZEROS(N,1). + ## The eigenvalues still come in plus/minus pairs but they are not + ## known explicitly. ## - ## References: - ## P.A. Clement, A class of triple-diagonal matrices for test - ## purposes, SIAM Review, 1 (1959), pp. 50-52. - ## A. Edelman and E. Kostlan, The road from Kac's matrix to Kac's - ## random polynomials. In John~G. Lewis, editor, Proceedings of - ## the Fifth SIAM Conference on Applied Linear Algebra Society - ## for Industrial and Applied Mathematics, Philadelphia, 1994, - ## pp. 503-507. - ## O. Taussky and J. Todd, Another look at a matrix of Mark Kac, - ## Linear Algebra and Appl., 150 (1991), pp. 341-360. + ## References: + ## P.A. Clement, A class of triple-diagonal matrices for test + ## purposes, SIAM Review, 1 (1959), pp. 50-52. + ## A. Edelman and E. Kostlan, The road from Kac's matrix to Kac's + ## random polynomials. In John~G. Lewis, editor, Proceedings of + ## the Fifth SIAM Conference on Applied Linear Algebra Society + ## for Industrial and Applied Mathematics, Philadelphia, 1994, + ## pp. 503-507. + ## O. Taussky and J. Todd, Another look at a matrix of Mark Kac, + ## Linear Algebra and Appl., 150 (1991), pp. 341-360. if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for clement matrix."); @@ -789,17 +789,17 @@ function C = compar (A, k = 0) ## COMP Comparison matrices. - ## COMP(A) is DIAG(B) - TRIL(B,-1) - TRIU(B,1), where B = ABS(A). - ## COMP(A, 1) is A with each diagonal element replaced by its - ## absolute value, and each off-diagonal element replaced by minus - ## the absolute value of the largest element in absolute value in - ## its row. However, if A is triangular COMP(A, 1) is too. - ## COMP(A, 0) is the same as COMP(A). - ## COMP(A) is often denoted by M(A) in the literature. + ## COMP(A) is DIAG(B) - TRIL(B,-1) - TRIU(B,1), where B = ABS(A). + ## COMP(A, 1) is A with each diagonal element replaced by its + ## absolute value, and each off-diagonal element replaced by minus + ## the absolute value of the largest element in absolute value in + ## its row. However, if A is triangular COMP(A, 1) is too. + ## COMP(A, 0) is the same as COMP(A). + ## COMP(A) is often denoted by M(A) in the literature. ## - ## Reference (e.g.): - ## N.J. Higham, A survey of condition number estimation for - ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. + ## Reference (e.g.): + ## N.J. Higham, A survey of condition number estimation for + ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for compar matrix."); @@ -841,26 +841,26 @@ function A = condex (n, k = 4, theta = 100) ## CONDEX `Counterexamples' to matrix condition number estimators. - ## CONDEX(N, K, THETA) is a `counterexample' matrix to a condition - ## estimator. It has order N and scalar parameter THETA (default 100). - ## If N is not equal to the `natural' size of the matrix then - ## the matrix is padded out with an identity matrix to order N. - ## The matrix, its natural size, and the estimator to which it applies - ## are specified by K (default K = 4) as follows: - ## K = 1: 4-by-4, LINPACK (RCOND) - ## K = 2: 3-by-3, LINPACK (RCOND) - ## K = 3: arbitrary, LINPACK (RCOND) (independent of THETA) - ## K = 4: N >= 4, SONEST (Higham 1988) - ## (Note that in practice the K = 4 matrix is not usually a - ## counterexample because of the rounding errors in forming it.) + ## CONDEX(N, K, THETA) is a `counterexample' matrix to a condition + ## estimator. It has order N and scalar parameter THETA (default 100). + ## If N is not equal to the `natural' size of the matrix then + ## the matrix is padded out with an identity matrix to order N. + ## The matrix, its natural size, and the estimator to which it applies + ## are specified by K (default K = 4) as follows: + ## K = 1: 4-by-4, LINPACK (RCOND) + ## K = 2: 3-by-3, LINPACK (RCOND) + ## K = 3: arbitrary, LINPACK (RCOND) (independent of THETA) + ## K = 4: N >= 4, SONEST (Higham 1988) + ## (Note that in practice the K = 4 matrix is not usually a + ## counterexample because of the rounding errors in forming it.) ## - ## References: - ## A.K. Cline and R.K. Rew, A set of counter-examples to three - ## condition number estimators, SIAM J. Sci. Stat. Comput., - ## 4 (1983), pp. 602-611. - ## N.J. Higham, FORTRAN codes for estimating the one-norm of a real or - ## complex matrix, with applications to condition estimation - ## (Algorithm 674), ACM Trans. Math. Soft., 14 (1988), pp. 381-396. + ## References: + ## A.K. Cline and R.K. Rew, A set of counter-examples to three + ## condition number estimators, SIAM J. Sci. Stat. Comput., + ## 4 (1983), pp. 602-611. + ## N.J. Higham, FORTRAN codes for estimating the one-norm of a real or + ## complex matrix, with applications to condition estimation + ## (Algorithm 674), ACM Trans. Math. Soft., 14 (1988), pp. 381-396. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for condex matrix."); @@ -913,14 +913,14 @@ function A = cycol (n, k) ## 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 - ## cyclically, and A has rank at most K. K need not divide N. - ## K defaults to ROUND(N/4). - ## CYCOL(N, K), where N is a scalar, is the same as CYCOL([N N], K). + ## 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 + ## cyclically, and A has rank at most K. K need not divide N. + ## K defaults to ROUND(N/4). + ## CYCOL(N, K), where N is a scalar, is the same as CYCOL([N N], K). ## - ## This type of matrix can lead to underflow problems for Gaussian - ## elimination: see NA Digest Volume 89, Issue 3 (January 22, 1989). + ## This type of matrix can lead to underflow problems for Gaussian + ## elimination: see NA Digest Volume 89, Issue 3 (January 22, 1989). if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for cycol matrix."); @@ -947,19 +947,19 @@ function [c, d, e] = dorr (n, theta = 0.01) ## DORR Dorr matrix - diagonally dominant, ill conditioned, tridiagonal. - ## [C, D, E] = DORR(N, THETA) returns the vectors defining a row diagonally - ## dominant, tridiagonal M-matrix that is ill conditioned for small - ## values of the parameter THETA >= 0. - ## If only one output parameter is supplied then - ## C = FULL(TRIDIAG(C,D,E)), i.e., the matrix iself is returned. - ## The columns of INV(C) vary greatly in norm. THETA defaults to 0.01. - ## The amount of diagonal dominance is given by (ignoring rounding errors): - ## COMP(C)*ONES(N,1) = THETA*(N+1)^2 * [1 0 0 ... 0 1]'. + ## [C, D, E] = DORR(N, THETA) returns the vectors defining a row diagonally + ## dominant, tridiagonal M-matrix that is ill conditioned for small + ## values of the parameter THETA >= 0. + ## If only one output parameter is supplied then + ## C = FULL(TRIDIAG(C,D,E)), i.e., the matrix iself is returned. + ## The columns of INV(C) vary greatly in norm. THETA defaults to 0.01. + ## The amount of diagonal dominance is given by (ignoring rounding errors): + ## COMP(C)*ONES(N,1) = THETA*(N+1)^2 * [1 0 0 ... 0 1]'. ## - ## Reference: - ## F.W. Dorr, An example of ill-conditioning in the numerical - ## solution of singular perturbation problems, Math. Comp., 25 (1971), - ## pp. 271-283. + ## Reference: + ## F.W. Dorr, An example of ill-conditioning in the numerical + ## solution of singular perturbation problems, Math. Comp., 25 (1971), + ## pp. 271-283. if (nargin < 1 || nargin > 2) error ("gallery: 1 or 2 arguments are required for dorr matrix."); @@ -998,27 +998,27 @@ function A = dramadah (n, k = 1) ## DRAMADAH A (0,1) matrix whose inverse has large integer entries. - ## An anti-Hadamard matrix A is a matrix with elements 0 or 1 for - ## which MU(A) := NORM(INV(A),'FRO') is maximal. - ## A = DRAMADAH(N, K) is an N-by-N (0,1) matrix for which MU(A) is - ## relatively large, although not necessarily maximal. - ## Available types (the default is K = 1): - ## K = 1: A is Toeplitz, with ABS(DET(A)) = 1, and MU(A) > c(1.75)^N, - ## where c is a constant. - ## K = 2: A is upper triangular and Toeplitz. - ## The inverses of both types have integer entries. + ## An anti-Hadamard matrix A is a matrix with elements 0 or 1 for + ## which MU(A) := NORM(INV(A),'FRO') is maximal. + ## A = DRAMADAH(N, K) is an N-by-N (0,1) matrix for which MU(A) is + ## relatively large, although not necessarily maximal. + ## Available types (the default is K = 1): + ## K = 1: A is Toeplitz, with ABS(DET(A)) = 1, and MU(A) > c(1.75)^N, + ## where c is a constant. + ## K = 2: A is upper triangular and Toeplitz. + ## The inverses of both types have integer entries. ## - ## Another interesting (0,1) matrix: - ## K = 3: A has maximal determinant among (0,1) lower Hessenberg - ## matrices: det(A) = the n'th Fibonacci number. A is Toeplitz. - ## The eigenvalues have an interesting distribution in the complex - ## plane. + ## Another interesting (0,1) matrix: + ## K = 3: A has maximal determinant among (0,1) lower Hessenberg + ## matrices: det(A) = the n'th Fibonacci number. A is Toeplitz. + ## The eigenvalues have an interesting distribution in the complex + ## plane. ## - ## References: - ## R.L. Graham and N.J.A. Sloane, Anti-Hadamard matrices, - ## Linear Algebra and Appl., 62 (1984), pp. 113-137. - ## L. Ching, The maximum determinant of an nxn lower Hessenberg - ## (0,1) matrix, Linear Algebra and Appl., 183 (1993), pp. 147-153. + ## References: + ## R.L. Graham and N.J.A. Sloane, Anti-Hadamard matrices, + ## Linear Algebra and Appl., 62 (1984), pp. 113-137. + ## L. Ching, The maximum determinant of an nxn lower Hessenberg + ## (0,1) matrix, Linear Algebra and Appl., 183 (1993), pp. 147-153. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for dramadah matrix."); @@ -1065,24 +1065,24 @@ function A = fiedler (c) ## FIEDLER Fiedler matrix - symmetric. - ## A = FIEDLER(C), where C is an n-vector, is the n-by-n symmetric - ## matrix with elements ABS(C(i)-C(j)). - ## Special case: if C is a scalar, then A = FIEDLER(1:C) - ## (i.e. A(i,j) = ABS(i-j)). - ## Properties: - ## FIEDLER(N) has a dominant positive eigenvalue and all the other - ## eigenvalues are negative (Szego, 1936). - ## Explicit formulas for INV(A) and DET(A) are given by Todd (1977) - ## and attributed to Fiedler. These indicate that INV(A) is - ## tridiagonal except for nonzero (1,n) and (n,1) elements. - ## [I think these formulas are valid only if the elements of - ## C are in increasing or decreasing order---NJH.] + ## FIEDLER(C), where C is an n-vector, is the n-by-n symmetric + ## matrix with elements ABS(C(i)-C(j)). + ## Special case: if C is a scalar, then A = FIEDLER(1:C) + ## (i.e. A(i,j) = ABS(i-j)). + ## Properties: + ## FIEDLER(N) has a dominant positive eigenvalue and all the other + ## eigenvalues are negative (Szego, 1936). + ## Explicit formulas for INV(A) and DET(A) are given by Todd (1977) + ## and attributed to Fiedler. These indicate that INV(A) is + ## tridiagonal except for nonzero (1,n) and (n,1) elements. + ## [I think these formulas are valid only if the elements of + ## C are in increasing or decreasing order---NJH.] ## - ## References: - ## G. Szego, Solution to problem 3705, Amer. Math. Monthly, - ## 43 (1936), pp. 246-259. - ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, - ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 159. + ## References: + ## G. Szego, Solution to problem 3705, Amer. Math. Monthly, + ## 43 (1936), pp. 246-259. + ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, + ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 159. if (nargin != 1) error ("gallery: 1 argument is required for fiedler matrix."); @@ -1107,11 +1107,11 @@ function A = forsythe (n, alpha = sqrt (eps), lambda = 0) ## FORSYTHE Forsythe matrix - a perturbed Jordan block. - ## FORSYTHE(N, ALPHA, LAMBDA) is the N-by-N matrix equal to - ## JORDBLOC(N, LAMBDA) except it has an ALPHA in the (N,1) position. - ## It has the characteristic polynomial - ## DET(A-t*EYE) = (LAMBDA-t)^N - (-1)^N ALPHA. - ## ALPHA defaults to SQRT(EPS) and LAMBDA to 0. + ## FORSYTHE(N, ALPHA, LAMBDA) is the N-by-N matrix equal to + ## JORDBLOC(N, LAMBDA) except it has an ALPHA in the (N,1) position. + ## It has the characteristic polynomial + ## DET(A-t*EYE) = (LAMBDA-t)^N - (-1)^N ALPHA. + ## ALPHA defaults to SQRT(EPS) and LAMBDA to 0. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for forsythe matrix."); @@ -1129,41 +1129,41 @@ function F = frank (n, k = 0) ## FRANK Frank matrix---ill conditioned eigenvalues. - ## F = FRANK(N, K) is the Frank matrix of order N. It is upper - ## Hessenberg with determinant 1. K = 0 is the default; if K = 1 the - ## elements are reflected about the anti-diagonal (1,N)--(N,1). - ## F has all positive eigenvalues and they occur in reciprocal pairs - ## (so that 1 is an eigenvalue if N is odd). - ## The eigenvalues of F may be obtained in terms of the zeros of the - ## Hermite polynomials. - ## The FLOOR(N/2) smallest eigenvalues of F are ill conditioned, - ## the more so for bigger N. + ## F = FRANK(N, K) is the Frank matrix of order N. It is upper + ## Hessenberg with determinant 1. K = 0 is the default; if K = 1 the + ## elements are reflected about the anti-diagonal (1,N)--(N,1). + ## F has all positive eigenvalues and they occur in reciprocal pairs + ## (so that 1 is an eigenvalue if N is odd). + ## The eigenvalues of F may be obtained in terms of the zeros of the + ## Hermite polynomials. + ## The FLOOR(N/2) smallest eigenvalues of F are ill conditioned, + ## the more so for bigger N. ## - ## DET(FRANK(N)') comes out far from 1 for large N---see Frank (1958) - ## and Wilkinson (1960) for discussions. + ## DET(FRANK(N)') comes out far from 1 for large N---see Frank (1958) + ## and Wilkinson (1960) for discussions. ## - ## This version incorporates improvements suggested by W. Kahan. + ## This version incorporates improvements suggested by W. Kahan. ## - ## References: - ## W.L. Frank, Computing eigenvalues of complex matrices by determinant - ## evaluation and by methods of Danilewski and Wielandt, J. Soc. - ## Indust. Appl. Math., 6 (1958), pp. 378-392 (see pp. 385, 388). - ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the - ## computation of the Jordan canonical form, SIAM Review, 18 (1976), - ## pp. 578-619 (Section 13). - ## H. Rutishauser, On test matrices, Programmation en Mathematiques - ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, - ## 1966, pp. 349-365. Section 9. - ## J.H. Wilkinson, Error analysis of floating-point computation, - ## Numer. Math., 2 (1960), pp. 319-340 (Section 8). - ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University - ## Press, 1965 (pp. 92-93). - ## The next two references give details of the eigensystem, as does - ## Rutishauser (see above). - ## P.J. Eberlein, A note on the matrices denoted by B_n, SIAM J. Appl. - ## Math., 20 (1971), pp. 87-92. - ## J.M. Varah, A generalization of the Frank matrix, SIAM J. Sci. Stat. - ## Comput., 7 (1986), pp. 835-839. + ## References: + ## W.L. Frank, Computing eigenvalues of complex matrices by determinant + ## evaluation and by methods of Danilewski and Wielandt, J. Soc. + ## Indust. Appl. Math., 6 (1958), pp. 378-392 (see pp. 385, 388). + ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the + ## computation of the Jordan canonical form, SIAM Review, 18 (1976), + ## pp. 578-619 (Section 13). + ## H. Rutishauser, On test matrices, Programmation en Mathematiques + ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, + ## 1966, pp. 349-365. Section 9. + ## J.H. Wilkinson, Error analysis of floating-point computation, + ## Numer. Math., 2 (1960), pp. 319-340 (Section 8). + ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University + ## Press, 1965 (pp. 92-93). + ## The next two references give details of the eigensystem, as does + ## Rutishauser (see above). + ## P.J. Eberlein, A note on the matrices denoted by B_n, SIAM J. Appl. + ## Math., 20 (1971), pp. 87-92. + ## J.M. Varah, A generalization of the Frank matrix, SIAM J. Sci. Stat. + ## Comput., 7 (1986), pp. 835-839. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for frank matrix."); @@ -1196,20 +1196,20 @@ function A = gearmat (n, i = n, j = -n) ## NOTE: this function was named gearm in the original Test Matrix Toolbox ## GEARMAT Gear matrix. - ## A = GEARMAT(N,I,J) is the N-by-N matrix with ones on the sub- and - ## super-diagonals, SIGN(I) in the (1,ABS(I)) position, SIGN(J) - ## in the (N,N+1-ABS(J)) position, and zeros everywhere else. - ## Defaults: I = N, j = -N. - ## All eigenvalues are of the form 2*COS(a) and the eigenvectors - ## are of the form [SIN(w+a), SIN(w+2a), ..., SIN(w+Na)]. - ## The values of a and w are given in the reference below. - ## A can have double and triple eigenvalues and can be defective. - ## GEARMAT(N) is singular. + ## A = GEARMAT(N,I,J) is the N-by-N matrix with ones on the sub- and + ## super-diagonals, SIGN(I) in the (1,ABS(I)) position, SIGN(J) + ## in the (N,N+1-ABS(J)) position, and zeros everywhere else. + ## Defaults: I = N, j = -N. + ## All eigenvalues are of the form 2*COS(a) and the eigenvectors + ## are of the form [SIN(w+a), SIN(w+2a), ..., SIN(w+Na)]. + ## The values of a and w are given in the reference below. + ## A can have double and triple eigenvalues and can be defective. + ## GEARMAT(N) is singular. ## - ## (GEAR is a Simulink function, hence GEARMAT for Gear matrix.) - ## Reference: - ## C.W. Gear, A simple set of test matrices for eigenvalue programs, - ## Math. Comp., 23 (1969), pp. 119-125. + ## (GEAR is a Simulink function, hence GEARMAT for Gear matrix.) + ## Reference: + ## C.W. Gear, A simple set of test matrices for eigenvalue programs, + ## Math. Comp., 23 (1969), pp. 119-125. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for gearmat matrix."); @@ -1228,18 +1228,18 @@ function G = grcar (n, k = 3) ## GRCAR Grcar matrix - a Toeplitz matrix with sensitive eigenvalues. - ## GRCAR(N, K) is an N-by-N matrix with -1s on the - ## subdiagonal, 1s on the diagonal, and K superdiagonals of 1s. - ## The default is K = 3. The eigenvalues of this matrix form an - ## interesting pattern in the complex plane (try PS(GRCAR(32))). + ## GRCAR(N, K) is an N-by-N matrix with -1s on the + ## subdiagonal, 1s on the diagonal, and K superdiagonals of 1s. + ## The default is K = 3. The eigenvalues of this matrix form an + ## interesting pattern in the complex plane (try PS(GRCAR(32))). ## - ## References: - ## J.F. Grcar, Operator coefficient methods for linear equations, - ## Report SAND89-8691, Sandia National Laboratories, Albuquerque, - ## New Mexico, 1989 (Appendix 2). - ## N.M. Nachtigal, L. Reichel and L.N. Trefethen, A hybrid GMRES - ## algorithm for nonsymmetric linear systems, SIAM J. Matrix Anal. - ## Appl., 13 (1992), pp. 796-825. + ## References: + ## J.F. Grcar, Operator coefficient methods for linear equations, + ## Report SAND89-8691, Sandia National Laboratories, Albuquerque, + ## New Mexico, 1989 (Appendix 2). + ## N.M. Nachtigal, L. Reichel and L.N. Trefethen, A hybrid GMRES + ## algorithm for nonsymmetric linear systems, SIAM J. Matrix Anal. + ## Appl., 13 (1992), pp. 796-825. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for grcar matrix."); @@ -1254,16 +1254,16 @@ function A = hanowa (n, d = -1) ## HANOWA A matrix whose eigenvalues lie on a vertical line in the complex plane. - ## HANOWA(N, d) is the N-by-N block 2x2 matrix (thus N = 2M must be even) - ## [d*EYE(M) -DIAG(1:M) - ## DIAG(1:M) d*EYE(M)] - ## It has complex eigenvalues lambda(k) = d +/- k*i (1 <= k <= M). - ## Parameter d defaults to -1. + ## HANOWA(N, d) is the N-by-N block 2x2 matrix (thus N = 2M must be even) + ## [d*EYE(M) -DIAG(1:M) + ## DIAG(1:M) d*EYE(M)] + ## It has complex eigenvalues lambda(k) = d +/- k*i (1 <= k <= M). + ## Parameter d defaults to -1. ## - ## Reference: - ## E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary - ## Differential Equations I: Nonstiff Problems, Springer-Verlag, - ## Berlin, 1987. (pp. 86-87) + ## Reference: + ## E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary + ## Differential Equations I: Nonstiff Problems, Springer-Verlag, + ## Berlin, 1987. (pp. 86-87) if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for hanowa matrix."); @@ -1282,28 +1282,28 @@ function [v, beta] = house (x) ## HOUSE Householder matrix. - ## If [v, beta] = HOUSE(x) then H = EYE - beta*v*v' is a Householder - ## matrix such that Hx = -sign(x(1))*norm(x)*e_1. - ## NB: If x = 0 then v = 0, beta = 1 is returned. - ## x can be real or complex. - ## sign(x) := exp(i*arg(x)) ( = x./abs(x) when x ~= 0). + ## If [v, beta] = HOUSE(x) then H = EYE - beta*v*v' is a Householder + ## matrix such that Hx = -sign(x(1))*norm(x)*e_1. + ## NB: If x = 0 then v = 0, beta = 1 is returned. + ## x can be real or complex. + ## sign(x) := exp(i*arg(x)) ( = x./abs(x) when x ~= 0). ## - ## Theory: (textbook references Golub & Van Loan 1989, 38-43; - ## Stewart 1973, 231-234, 262; Wilkinson 1965, 48-50). - ## Hx = y: (I - beta*v*v')x = -s*e_1. - ## Must have |s| = norm(x), v = x+s*e_1, and - ## x'y = x'Hx =(x'Hx)' real => arg(s) = arg(x(1)). - ## So take s = sign(x(1))*norm(x) (which avoids cancellation). - ## v'v = (x(1)+s)^2 + x(2)^2 + ... + x(n)^2 - ## = 2*norm(x)*(norm(x) + |x(1)|). + ## Theory: (textbook references Golub & Van Loan 1989, 38-43; + ## Stewart 1973, 231-234, 262; Wilkinson 1965, 48-50). + ## Hx = y: (I - beta*v*v')x = -s*e_1. + ## Must have |s| = norm(x), v = x+s*e_1, and + ## x'y = x'Hx =(x'Hx)' real => arg(s) = arg(x(1)). + ## So take s = sign(x(1))*norm(x) (which avoids cancellation). + ## v'v = (x(1)+s)^2 + x(2)^2 + ... + x(n)^2 + ## = 2*norm(x)*(norm(x) + |x(1)|). ## - ## References: - ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, - ## Johns Hopkins University Press, Baltimore, Maryland, 1989. - ## G.W. Stewart, Introduction to Matrix Computations, Academic Press, - ## New York, 1973, - ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University - ## Press, 1965. + ## References: + ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, + ## Johns Hopkins University Press, Baltimore, Maryland, 1989. + ## G.W. Stewart, Introduction to Matrix Computations, Academic Press, + ## New York, 1973, + ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University + ## Press, 1965. if (nargin != 1) error ("gallery: 1 argument is required for house matrix."); @@ -1371,26 +1371,26 @@ function A = invhess (x, y) ## INVHESS Inverse of an upper Hessenberg matrix. - ## INVHESS(X, Y), where X is an N-vector and Y an N-1 vector, - ## is the matrix whose lower triangle agrees with that of - ## ONES(N,1)*X' and whose strict upper triangle agrees with - ## that of [1 Y]*ONES(1,N). - ## The matrix is nonsingular if X(1) ~= 0 and X(i+1) ~= Y(i) - ## for all i, and its inverse is an upper Hessenberg matrix. - ## If Y is omitted it defaults to -X(1:N-1). - ## Special case: if X is a scalar INVHESS(X) is the same as - ## INVHESS(1:X). + ## INVHESS(X, Y), where X is an N-vector and Y an N-1 vector, + ## is the matrix whose lower triangle agrees with that of + ## ONES(N,1)*X' and whose strict upper triangle agrees with + ## that of [1 Y]*ONES(1,N). + ## The matrix is nonsingular if X(1) ~= 0 and X(i+1) ~= Y(i) + ## for all i, and its inverse is an upper Hessenberg matrix. + ## If Y is omitted it defaults to -X(1:N-1). + ## Special case: if X is a scalar INVHESS(X) is the same as + ## INVHESS(1:X). ## - ## References: - ## F.N. Valvi and V.S. Geroyannis, Analytic inverses and - ## determinants for a class of matrices, IMA Journal of Numerical - ## Analysis, 7 (1987), pp. 123-128. - ## W.-L. Cao and W.J. Stewart, A note on inverses of Hessenberg-like - ## matrices, Linear Algebra and Appl., 76 (1986), pp. 233-240. - ## Y. Ikebe, On inverses of Hessenberg matrices, Linear Algebra and - ## Appl., 24 (1979), pp. 93-97. - ## P. Rozsa, On the inverse of band matrices, Integral Equations and - ## Operator Theory, 10 (1987), pp. 82-95. + ## References: + ## F.N. Valvi and V.S. Geroyannis, Analytic inverses and + ## determinants for a class of matrices, IMA Journal of Numerical + ## Analysis, 7 (1987), pp. 123-128. + ## W.-L. Cao and W.J. Stewart, A note on inverses of Hessenberg-like + ## matrices, Linear Algebra and Appl., 76 (1986), pp. 233-240. + ## Y. Ikebe, On inverses of Hessenberg matrices, Linear Algebra and + ## Appl., 24 (1979), pp. 93-97. + ## P. Rozsa, On the inverse of band matrices, Integral Equations and + ## Operator Theory, 10 (1987), pp. 82-95. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for invhess matrix."); @@ -1425,15 +1425,15 @@ function A = invol (n) ## INVOL An involutory matrix. - ## A = INVOL(N) is an N-by-N involutory (A*A = EYE(N)) and - ## ill-conditioned matrix. - ## It is a diagonally scaled version of HILB(N). - ## NB: B = (EYE(N)-A)/2 and B = (EYE(N)+A)/2 are idempotent (B*B = B). + ## A = INVOL(N) is an N-by-N involutory (A*A = EYE(N)) and + ## ill-conditioned matrix. + ## It is a diagonally scaled version of HILB(N). + ## NB: B = (EYE(N)-A)/2 and B = (EYE(N)+A)/2 are idempotent (B*B = B). ## - ## Reference: - ## A.S. Householder and J.A. Carpenter, The singular values - ## of involutory and of idempotent matrices, Numer. Math. 5 (1963), - ## pp. 234-237. + ## Reference: + ## A.S. Householder and J.A. Carpenter, The singular values + ## of involutory and of idempotent matrices, Numer. Math. 5 (1963), + ## pp. 234-237. if (nargin != 1) error ("gallery: 1 argument is required for invol matrix."); @@ -1454,19 +1454,19 @@ function [A, detA] = ipjfact (n, k = 0) ## IPJFACT A Hankel matrix with factorial elements. - ## A = IPJFACT(N, K) is the matrix with - ## A(i,j) = (i+j)! (K = 0, default) - ## A(i,j) = 1/(i+j)! (K = 1) - ## Both are Hankel matrices. - ## The determinant and inverse are known explicitly. - ## If a second output argument is present, d = DET(A) is returned: - ## [A, d] = IPJFACT(N, K); + ## A = IPJFACT(N, K) is the matrix with + ## A(i,j) = (i+j)! (K = 0, default) + ## A(i,j) = 1/(i+j)! (K = 1) + ## Both are Hankel matrices. + ## The determinant and inverse are known explicitly. + ## If a second output argument is present, d = DET(A) is returned: + ## [A, d] = IPJFACT(N, K); ## - ## Suggested by P. R. Graves-Morris. + ## Suggested by P. R. Graves-Morris. ## - ## Reference: - ## M.J.C. Gover, The explicit inverse of factorial Hankel matrices, - ## Dept. of Mathematics, University of Bradford, 1993. + ## Reference: + ## M.J.C. Gover, The explicit inverse of factorial Hankel matrices, + ## Dept. of Mathematics, University of Bradford, 1993. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for ipjfact matrix."); @@ -1515,8 +1515,8 @@ function J = jordbloc (n, lambda = 1) ## JORDBLOC Jordan block. - ## JORDBLOC(N, LAMBDA) is the N-by-N Jordan block with eigenvalue - ## LAMBDA. LAMBDA = 1 is the default. + ## JORDBLOC(N, LAMBDA) is the N-by-N Jordan block with eigenvalue + ## LAMBDA. LAMBDA = 1 is the default. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for jordbloc matrix."); @@ -1531,30 +1531,30 @@ function U = kahan (n, theta = 1.2, pert = 25) ## KAHAN Kahan matrix - upper trapezoidal. - ## KAHAN(N, THETA) is an upper trapezoidal matrix - ## that has some interesting properties regarding estimation of - ## condition and rank. - ## The matrix is N-by-N unless N is a 2-vector, in which case it - ## is N(1)-by-N(2). - ## The parameter THETA defaults to 1.2. - ## The useful range of THETA is 0 < THETA < PI. + ## KAHAN(N, THETA) is an upper trapezoidal matrix + ## that has some interesting properties regarding estimation of + ## condition and rank. + ## The matrix is N-by-N unless N is a 2-vector, in which case it + ## is N(1)-by-N(2). + ## The parameter THETA defaults to 1.2. + ## The useful range of THETA is 0 < THETA < PI. ## - ## To ensure that the QR factorization with column pivoting does not - ## interchange columns in the presence of rounding errors, the diagonal - ## is perturbed by PERT*EPS*diag( [N:-1:1] ). - ## The default is PERT = 25, which ensures no interchanges for KAHAN(N) - ## up to at least N = 90 in IEEE arithmetic. - ## KAHAN(N, THETA, PERT) uses the given value of PERT. + ## To ensure that the QR factorization with column pivoting does not + ## interchange columns in the presence of rounding errors, the diagonal + ## is perturbed by PERT*EPS*diag( [N:-1:1] ). + ## The default is PERT = 25, which ensures no interchanges for KAHAN(N) + ## up to at least N = 90 in IEEE arithmetic. + ## KAHAN(N, THETA, PERT) uses the given value of PERT. ## - ## The inverse of KAHAN(N, THETA) is known explicitly: see - ## Higham (1987, p. 588), for example. - ## The diagonal perturbation was suggested by Christian Bischof. + ## The inverse of KAHAN(N, THETA) is known explicitly: see + ## Higham (1987, p. 588), for example. + ## The diagonal perturbation was suggested by Christian Bischof. ## - ## References: - ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, - ## 9 (1966), pp. 757-801. - ## N.J. Higham, A survey of condition number estimation for - ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. + ## References: + ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, + ## 9 (1966), pp. 757-801. + ## N.J. Higham, A survey of condition number estimation for + ## triangular matrices, SIAM Review, 29 (1987), pp. 575-596. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for kahan matrix."); @@ -1584,22 +1584,22 @@ function A = kms (n, rho = 0.5) ## KMS Kac-Murdock-Szego Toeplitz matrix. - ## A = KMS(N, RHO) is the N-by-N Kac-Murdock-Szego Toeplitz matrix with - ## A(i,j) = RHO^(ABS((i-j))) (for real RHO). - ## If RHO is complex, then the same formula holds except that elements - ## below the diagonal are conjugated. - ## RHO defaults to 0.5. - ## Properties: - ## A has an LDL' factorization with - ## L = INV(TRIW(N,-RHO,1)'), - ## D(i,i) = (1-ABS(RHO)^2)*EYE(N) except D(1,1) = 1. - ## A is positive definite if and only if 0 < ABS(RHO) < 1. - ## INV(A) is tridiagonal. + ## A = KMS(N, RHO) is the N-by-N Kac-Murdock-Szego Toeplitz matrix with + ## A(i,j) = RHO^(ABS((i-j))) (for real RHO). + ## If RHO is complex, then the same formula holds except that elements + ## below the diagonal are conjugated. + ## RHO defaults to 0.5. + ## Properties: + ## A has an LDL' factorization with + ## L = INV(TRIW(N,-RHO,1)'), + ## D(i,i) = (1-ABS(RHO)^2)*EYE(N) except D(1,1) = 1. + ## A is positive definite if and only if 0 < ABS(RHO) < 1. + ## INV(A) is tridiagonal. ## - ## Reference: - ## W.F. Trench, Numerical solution of the eigenvalue problem - ## for Hermitian Toeplitz matrices, SIAM J. Matrix Analysis and Appl., - ## 10 (1989), pp. 135-146 (and see the references therein). + ## Reference: + ## W.F. Trench, Numerical solution of the eigenvalue problem + ## for Hermitian Toeplitz matrices, SIAM J. Matrix Analysis and Appl., + ## 10 (1989), pp. 135-146 (and see the references therein). if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for lauchli matrix."); @@ -1619,15 +1619,15 @@ function B = krylov (A, x, j) ## KRYLOV Krylov matrix. - ## KRYLOV(A, x, j) is the Krylov matrix - ## [x, Ax, A^2x, ..., A^(j-1)x], - ## where A is an n-by-n matrix and x is an n-vector. - ## Defaults: x = ONES(n,1), j = n. - ## KRYLOV(n) is the same as KRYLOV(RANDN(n)). + ## KRYLOV(A, x, j) is the Krylov matrix + ## [x, Ax, A^2x, ..., A^(j-1)x], + ## where A is an n-by-n matrix and x is an n-vector. + ## Defaults: x = ONES(n,1), j = n. + ## KRYLOV(n) is the same as KRYLOV(RANDN(n)). ## - ## Reference: - ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, - ## Johns Hopkins University Press, Baltimore, Maryland, 1989, p. 369. + ## Reference: + ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, + ## Johns Hopkins University Press, Baltimore, Maryland, 1989, p. 369. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for krylov matrix."); @@ -1662,14 +1662,14 @@ function A = lauchli (n, mu = sqrt (eps)) ## LAUCHLI Lauchli matrix - rectangular. - ## LAUCHLI(N, MU) is the (N+1)-by-N matrix [ONES(1,N); MU*EYE(N))]. - ## It is a well-known example in least squares and other problems - ## that indicates the dangers of forming A'*A. - ## MU defaults to SQRT(EPS). + ## LAUCHLI(N, MU) is the (N+1)-by-N matrix [ONES(1,N); MU*EYE(N))]. + ## It is a well-known example in least squares and other problems + ## that indicates the dangers of forming A'*A. + ## MU defaults to SQRT(EPS). ## - ## Reference: - ## P. Lauchli, Jordan-Elimination und Ausgleichung nach - ## kleinsten Quadraten, Numer. Math, 3 (1961), pp. 226-240. + ## Reference: + ## P. Lauchli, Jordan-Elimination und Ausgleichung nach + ## kleinsten Quadraten, Numer. Math, 3 (1961), pp. 226-240. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for lauchli matrix."); @@ -1685,19 +1685,19 @@ function A = lehmer (n) ## LEHMER Lehmer matrix - symmetric positive definite. - ## A = LEHMER(N) is the symmetric positive definite N-by-N matrix with - ## A(i,j) = i/j for j >= i. - ## A is totally nonnegative. INV(A) is tridiagonal, and explicit - ## formulas are known for its entries. - ## N <= COND(A) <= 4*N*N. + ## A = LEHMER(N) is the symmetric positive definite N-by-N matrix with + ## A(i,j) = i/j for j >= i. + ## A is totally nonnegative. INV(A) is tridiagonal, and explicit + ## formulas are known for its entries. + ## N <= COND(A) <= 4*N*N. ## - ## References: - ## M. Newman and J. Todd, The evaluation of matrix inversion - ## programs, J. Soc. Indust. Appl. Math., 6 (1958), pp. 466-476. - ## Solutions to problem E710 (proposed by D.H. Lehmer): The inverse - ## of a matrix, Amer. Math. Monthly, 53 (1946), pp. 534-535. - ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, - ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 154. + ## References: + ## M. Newman and J. Todd, The evaluation of matrix inversion + ## programs, J. Soc. Indust. Appl. Math., 6 (1958), pp. 466-476. + ## Solutions to problem E710 (proposed by D.H. Lehmer): The inverse + ## of a matrix, Amer. Math. Monthly, 53 (1946), pp. 534-535. + ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, + ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 154. if (nargin != 1) error ("gallery: 1 argument is required for lehmer matrix."); @@ -1712,23 +1712,23 @@ function T = lesp (n) ## LESP A tridiagonal matrix with real, sensitive eigenvalues. - ## LESP(N) is an N-by-N matrix whose eigenvalues are real and smoothly - ## distributed in the interval approximately [-2*N-3.5, -4.5]. - ## The sensitivities of the eigenvalues increase exponentially as - ## the eigenvalues grow more negative. - ## The matrix is similar to the symmetric tridiagonal matrix with - ## the same diagonal entries and with off-diagonal entries 1, - ## via a similarity transformation with D = diag(1!,2!,...,N!). + ## LESP(N) is an N-by-N matrix whose eigenvalues are real and smoothly + ## distributed in the interval approximately [-2*N-3.5, -4.5]. + ## The sensitivities of the eigenvalues increase exponentially as + ## the eigenvalues grow more negative. + ## The matrix is similar to the symmetric tridiagonal matrix with + ## the same diagonal entries and with off-diagonal entries 1, + ## via a similarity transformation with D = diag(1!,2!,...,N!). ## - ## References: - ## H.W.J. Lenferink and M.N. Spijker, On the use of stability regions in - ## the numerical analysis of initial value problems, - ## Math. Comp., 57 (1991), pp. 221-237. - ## L.N. Trefethen, Pseudospectra of matrices, in Numerical Analysis 1991, - ## Proceedings of the 14th Dundee Conference, - ## D.F. Griffiths and G.A. Watson, eds, Pitman Research Notes in - ## Mathematics, volume 260, Longman Scientific and Technical, Essex, - ## UK, 1992, pp. 234-266. + ## References: + ## H.W.J. Lenferink and M.N. Spijker, On the use of stability regions in + ## the numerical analysis of initial value problems, + ## Math. Comp., 57 (1991), pp. 221-237. + ## L.N. Trefethen, Pseudospectra of matrices, in Numerical Analysis 1991, + ## Proceedings of the 14th Dundee Conference, + ## D.F. Griffiths and G.A. Watson, eds, Pitman Research Notes in + ## Mathematics, volume 260, Longman Scientific and Technical, Essex, + ## UK, 1992, pp. 234-266. if (nargin != 1) error ("gallery: 1 argument is required for lesp matrix."); @@ -1742,13 +1742,13 @@ function A = lotkin (n) ## LOTKIN Lotkin matrix. - ## A = LOTKIN(N) is the Hilbert matrix with its first row altered to - ## all ones. A is unsymmetric, ill-conditioned, and has many negative - ## eigenvalues of small magnitude. - ## The inverse has integer entries and is known explicitly. + ## A = LOTKIN(N) is the Hilbert matrix with its first row altered to + ## all ones. A is unsymmetric, ill-conditioned, and has many negative + ## eigenvalues of small magnitude. + ## The inverse has integer entries and is known explicitly. ## - ## Reference: - ## M. Lotkin, A set of test matrices, MTAC, 9 (1955), pp. 153-161. + ## Reference: + ## M. Lotkin, A set of test matrices, MTAC, 9 (1955), pp. 153-161. if (nargin != 1) error ("gallery: 1 argument is required for lotkin matrix."); @@ -1762,21 +1762,21 @@ function A = minij (n) ## MINIJ Symmetric positive definite matrix MIN(i,j). - ## A = MINIJ(N) is the N-by-N symmetric positive definite matrix with - ## A(i,j) = MIN(i,j). - ## Properties, variations: - ## INV(A) is tridiagonal: it is minus the second difference matrix - ## except its (N,N) element is 1. - ## 2*A-ONES(N) (Givens' matrix) has tridiagonal inverse and - ## eigenvalues .5*sec^2([2r-1)PI/4N], r=1:N. - ## (N+1)*ONES(N)-A also has a tridiagonal inverse. + ## A = MINIJ(N) is the N-by-N symmetric positive definite matrix with + ## A(i,j) = MIN(i,j). + ## Properties, variations: + ## INV(A) is tridiagonal: it is minus the second difference matrix + ## except its (N,N) element is 1. + ## 2*A-ONES(N) (Givens' matrix) has tridiagonal inverse and + ## eigenvalues .5*sec^2([2r-1)PI/4N], r=1:N. + ## (N+1)*ONES(N)-A also has a tridiagonal inverse. ## - ## References: - ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, - ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 158. - ## D.E. Rutherford, Some continuant determinants arising in physics and - ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. - ## (For the eigenvalues of Givens' matrix.) + ## References: + ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, + ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 158. + ## D.E. Rutherford, Some continuant determinants arising in physics and + ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. + ## (For the eigenvalues of Givens' matrix.) if (nargin != 1) error ("gallery: 1 argument is required for minij matrix."); @@ -1789,17 +1789,17 @@ function A = moler (n, alpha = -1) ## MOLER Moler matrix - symmetric positive definite. - ## A = MOLER(N, ALPHA) is the symmetric positive definite N-by-N matrix - ## U'*U where U = TRIW(N, ALPHA). - ## For ALPHA = -1 (the default) A(i,j) = MIN(i,j)-2, A(i,i) = i. - ## A has one small eigenvalue. + ## A = MOLER(N, ALPHA) is the symmetric positive definite N-by-N matrix + ## U'*U where U = TRIW(N, ALPHA). + ## For ALPHA = -1 (the default) A(i,j) = MIN(i,j)-2, A(i,i) = i. + ## A has one small eigenvalue. ## - ## Nash (1990) attributes the ALPHA = -1 matrix to Moler. + ## Nash (1990) attributes the ALPHA = -1 matrix to Moler. ## - ## Reference: - ## J.C. Nash, Compact Numerical Methods for Computers: Linear - ## Algebra and Function Minimisation, second edition, Adam Hilger, - ## Bristol, 1990 (Appendix 1). + ## Reference: + ## J.C. Nash, Compact Numerical Methods for Computers: Linear + ## Algebra and Function Minimisation, second edition, Adam Hilger, + ## Bristol, 1990 (Appendix 1). if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for moler matrix."); @@ -1814,16 +1814,16 @@ function [A, T] = neumann (n) ## NEUMANN Singular matrix from the discrete Neumann problem (sparse). - ## NEUMANN(N) is the singular, row diagonally dominant matrix resulting - ## from discretizing the Neumann problem with the usual five point - ## operator on a regular mesh. - ## It has a one-dimensional null space with null vector ONES(N,1). - ## The dimension N should be a perfect square, or else a 2-vector, - ## in which case the dimension of the matrix is N(1)*N(2). + ## NEUMANN(N) is the singular, row diagonally dominant matrix resulting + ## from discretizing the Neumann problem with the usual five point + ## operator on a regular mesh. + ## It has a one-dimensional null space with null vector ONES(N,1). + ## The dimension N should be a perfect square, or else a 2-vector, + ## in which case the dimension of the matrix is N(1)*N(2). ## - ## Reference: - ## R.J. Plemmons, Regular splittings and the discrete Neumann - ## problem, Numer. Math., 25 (1976), pp. 153-161. + ## Reference: + ## R.J. Plemmons, Regular splittings and the discrete Neumann + ## problem, Numer. Math., 25 (1976), pp. 153-161. if (nargin != 1) error ("gallery: 1 argument is required for neumann matrix."); @@ -1890,37 +1890,37 @@ function Q = orthog (n, k = 1) ## ORTHOG Orthogonal and nearly orthogonal matrices. - ## Q = ORTHOG(N, K) selects the K'th type of matrix of order N. - ## K > 0 for exactly orthogonal matrices, K < 0 for diagonal scalings of - ## orthogonal matrices. - ## Available types: (K = 1 is the default) - ## K = 1: Q(i,j) = SQRT(2/(n+1)) * SIN( i*j*PI/(n+1) ) - ## Symmetric eigenvector matrix for second difference matrix. - ## K = 2: Q(i,j) = 2/SQRT(2*n+1)) * SIN( 2*i*j*PI/(2*n+1) ) - ## Symmetric. - ## K = 3: Q(r,s) = EXP(2*PI*i*(r-1)*(s-1)/n) / SQRT(n) (i=SQRT(-1)) - ## Unitary, the Fourier matrix. Q^4 is the identity. - ## This is essentially the same matrix as FFT(EYE(N))/SQRT(N)! - ## K = 4: Helmert matrix: a permutation of a lower Hessenberg matrix, - ## whose first row is ONES(1:N)/SQRT(N). - ## K = 5: Q(i,j) = SIN( 2*PI*(i-1)*(j-1)/n ) + COS( 2*PI*(i-1)*(j-1)/n ). - ## Symmetric matrix arising in the Hartley transform. - ## K = -1: Q(i,j) = COS( (i-1)*(j-1)*PI/(n-1) ) - ## Chebyshev Vandermonde-like matrix, based on extrema of T(n-1). - ## K = -2: Q(i,j) = COS( (i-1)*(j-1/2)*PI/n) ) - ## Chebyshev Vandermonde-like matrix, based on zeros of T(n). + ## Q = ORTHOG(N, K) selects the K'th type of matrix of order N. + ## K > 0 for exactly orthogonal matrices, K < 0 for diagonal scalings of + ## orthogonal matrices. + ## Available types: (K = 1 is the default) + ## K = 1: Q(i,j) = SQRT(2/(n+1)) * SIN( i*j*PI/(n+1) ) + ## Symmetric eigenvector matrix for second difference matrix. + ## K = 2: Q(i,j) = 2/SQRT(2*n+1)) * SIN( 2*i*j*PI/(2*n+1) ) + ## Symmetric. + ## K = 3: Q(r,s) = EXP(2*PI*i*(r-1)*(s-1)/n) / SQRT(n) (i=SQRT(-1)) + ## Unitary, the Fourier matrix. Q^4 is the identity. + ## This is essentially the same matrix as FFT(EYE(N))/SQRT(N)! + ## K = 4: Helmert matrix: a permutation of a lower Hessenberg matrix, + ## whose first row is ONES(1:N)/SQRT(N). + ## K = 5: Q(i,j) = SIN( 2*PI*(i-1)*(j-1)/n ) + COS( 2*PI*(i-1)*(j-1)/n ). + ## Symmetric matrix arising in the Hartley transform. + ## K = -1: Q(i,j) = COS( (i-1)*(j-1)*PI/(n-1) ) + ## Chebyshev Vandermonde-like matrix, based on extrema of T(n-1). + ## K = -2: Q(i,j) = COS( (i-1)*(j-1/2)*PI/n) ) + ## Chebyshev Vandermonde-like matrix, based on zeros of T(n). ## - ## References: - ## N.J. Higham and D.J. Higham, Large growth factors in Gaussian - ## elimination with pivoting, SIAM J. Matrix Analysis and Appl., - ## 10 (1989), pp. 155-164. - ## P. Morton, On the eigenvectors of Schur's matrix, J. Number Theory, - ## 12 (1980), pp. 122-127. (Re. ORTHOG(N, 3)) - ## H.O. Lancaster, The Helmert Matrices, Amer. Math. Monthly, 72 (1965), - ## pp. 4-12. - ## D. Bini and P. Favati, On a matrix algebra related to the discrete - ## Hartley transform, SIAM J. Matrix Anal. Appl., 14 (1993), - ## pp. 500-507. + ## References: + ## N.J. Higham and D.J. Higham, Large growth factors in Gaussian + ## elimination with pivoting, SIAM J. Matrix Analysis and Appl., + ## 10 (1989), pp. 155-164. + ## P. Morton, On the eigenvectors of Schur's matrix, J. Number Theory, + ## 12 (1980), pp. 122-127. (Re. ORTHOG(N, 3)) + ## H.O. Lancaster, The Helmert Matrices, Amer. Math. Monthly, 72 (1965), + ## pp. 4-12. + ## D. Bini and P. Favati, On a matrix algebra related to the discrete + ## Hartley transform, SIAM J. Matrix Anal. Appl., 14 (1993), + ## pp. 500-507. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for orthog matrix."); @@ -1976,20 +1976,20 @@ function A = parter (n) ## PARTER Parter matrix - a Toeplitz matrix with singular values near PI. - ## PARTER(N) is the matrix with (i,j) element 1/(i-j+0.5). - ## It is a Cauchy matrix and a Toeplitz matrix. + ## PARTER(N) is the matrix with (i,j) element 1/(i-j+0.5). + ## It is a Cauchy matrix and a Toeplitz matrix. ## - ## At the Second SIAM Conference on Linear Algebra, Raleigh, N.C., - ## 1985, Cleve Moler noted that most of the singular values of - ## PARTER(N) are very close to PI. An explanation of the phenomenon - ## was given by Parter; see also the paper by Tyrtyshnikov. + ## At the Second SIAM Conference on Linear Algebra, Raleigh, N.C., + ## 1985, Cleve Moler noted that most of the singular values of + ## PARTER(N) are very close to PI. An explanation of the phenomenon + ## was given by Parter; see also the paper by Tyrtyshnikov. ## - ## References: - ## The MathWorks Newsletter, Volume 1, Issue 1, March 1986, page 2. - ## S.V. Parter, On the distribution of the singular values of Toeplitz - ## matrices, Linear Algebra and Appl., 80 (1986), pp. 115-130. - ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, - ## Linear Algebra and Appl., 149 (1991), pp. 1-18. + ## References: + ## The MathWorks Newsletter, Volume 1, Issue 1, March 1986, page 2. + ## S.V. Parter, On the distribution of the singular values of Toeplitz + ## matrices, Linear Algebra and Appl., 80 (1986), pp. 115-130. + ## E.E. Tyrtyshnikov, Cauchy-Toeplitz matrices and some applications, + ## Linear Algebra and Appl., 149 (1991), pp. 1-18. if (nargin != 1) error ("gallery: 1 argument is required for parter matrix."); @@ -2002,14 +2002,14 @@ function P = pei (n, alpha = 1) ## PEI Pei matrix. - ## PEI(N, ALPHA), where ALPHA is a scalar, is the symmetric matrix - ## ALPHA*EYE(N) + ONES(N). - ## If ALPHA is omitted then ALPHA = 1 is used. - ## The matrix is singular for ALPHA = 0, -N. + ## PEI(N, ALPHA), where ALPHA is a scalar, is the symmetric matrix + ## ALPHA*EYE(N) + ONES(N). + ## If ALPHA is omitted then ALPHA = 1 is used. + ## The matrix is singular for ALPHA = 0, -N. ## - ## Reference: - ## M.L. Pei, A test matrix for inversion procedures, - ## Comm. ACM, 5 (1962), p. 508. + ## Reference: + ## M.L. Pei, A test matrix for inversion procedures, + ## Comm. ACM, 5 (1962), p. 508. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for pei matrix."); @@ -2024,14 +2024,14 @@ function A = poisson (n) ## POISSON Block tridiagonal matrix from Poisson's equation (sparse). - ## POISSON(N) is the block tridiagonal matrix of order N^2 - ## resulting from discretizing Poisson's equation with the - ## 5-point operator on an N-by-N mesh. + ## POISSON(N) is the block tridiagonal matrix of order N^2 + ## resulting from discretizing Poisson's equation with the + ## 5-point operator on an N-by-N mesh. ## - ## Reference: - ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, - ## Johns Hopkins University Press, Baltimore, Maryland, 1989 - ## (Section 4.5.4). + ## Reference: + ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, + ## Johns Hopkins University Press, Baltimore, Maryland, 1989 + ## (Section 4.5.4). if (nargin != 1) error ("gallery: 1 argument is required for poisson matrix."); @@ -2046,17 +2046,17 @@ function A = prolate (n, w = 0.25) ## PROLATE Prolate matrix - symmetric, ill-conditioned Toeplitz matrix. - ## A = PROLATE(N, W) is the N-by-N prolate matrix with parameter W. - ## It is a symmetric Toeplitz matrix. - ## If 0 < W < 0.5 then - ## - A is positive definite - ## - the eigenvalues of A are distinct, lie in (0, 1), and - ## tend to cluster around 0 and 1. - ## W defaults to 0.25. + ## A = PROLATE(N, W) is the N-by-N prolate matrix with parameter W. + ## It is a symmetric Toeplitz matrix. + ## If 0 < W < 0.5 then + ## - A is positive definite + ## - the eigenvalues of A are distinct, lie in (0, 1), and + ## tend to cluster around 0 and 1. + ## W defaults to 0.25. ## - ## Reference: - ## J.M. Varah. The Prolate matrix. Linear Algebra and Appl., - ## 187:269--278, 1993. + ## Reference: + ## J.M. Varah. The Prolate matrix. Linear Algebra and Appl., + ## 187:269--278, 1993. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for prolate matrix."); @@ -2076,23 +2076,23 @@ function H = randhess (x) ## NOTE: this function was named ohess in the original Test Matrix Toolbox ## RANDHESS Random, orthogonal upper Hessenberg matrix. - ## H = RANDHESS(N) is an N-by-N real, random, orthogonal - ## upper Hessenberg matrix. - ## Alternatively, H = RANDHESS(X), where X is an arbitrary real - ## N-vector (N > 1) constructs H non-randomly using the elements - ## of X as parameters. - ## In both cases H is constructed via a product of N-1 Givens rotations. + ## H = RANDHESS(N) is an N-by-N real, random, orthogonal + ## upper Hessenberg matrix. + ## Alternatively, H = RANDHESS(X), where X is an arbitrary real + ## N-vector (N > 1) constructs H non-randomly using the elements + ## of X as parameters. + ## In both cases H is constructed via a product of N-1 Givens rotations. ## - ## Note: See Gragg (1986) for how to represent an N-by-N (complex) - ## unitary Hessenberg matrix with positive subdiagonal elements in terms - ## of 2N-1 real parameters (the Schur parametrization). - ## This M-file handles the real case only and is intended simply as a - ## convenient way to generate random or non-random orthogonal Hessenberg - ## matrices. + ## Note: See Gragg (1986) for how to represent an N-by-N (complex) + ## unitary Hessenberg matrix with positive subdiagonal elements in terms + ## of 2N-1 real parameters (the Schur parametrization). + ## This M-file handles the real case only and is intended simply as a + ## convenient way to generate random or non-random orthogonal Hessenberg + ## matrices. ## - ## Reference: - ## W.B. Gragg, The QR algorithm for unitary Hessenberg matrices, - ## J. Comp. Appl. Math., 16 (1986), pp. 1-8. + ## Reference: + ## W.B. Gragg, The QR algorithm for unitary Hessenberg matrices, + ## J. Comp. Appl. Math., 16 (1986), pp. 1-8. if (nargin != 1) error ("gallery: 1 argument is required for randhess matrix."); @@ -2125,12 +2125,12 @@ function A = rando (n, k = 1) ## RANDO Random matrix with elements -1, 0 or 1. - ## A = RANDO(N, K) is a random N-by-N matrix with elements from - ## one of the following discrete distributions (default K = 1): - ## K = 1: A(i,j) = 0 or 1 with equal probability, - ## K = 2: A(i,j) = -1 or 1 with equal probability, - ## K = 3: A(i,j) = -1, 0 or 1 with equal probability. - ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). + ## A = RANDO(N, K) is a random N-by-N matrix with elements from + ## one of the following discrete distributions (default K = 1): + ## K = 1: A(i,j) = 0 or 1 with equal probability, + ## K = 2: A(i,j) = -1 or 1 with equal probability, + ## K = 3: A(i,j) = -1, 0 or 1 with equal probability. + ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for rando matrix."); @@ -2156,37 +2156,37 @@ function A = randsvd (n, kappa = sqrt (1/eps), mode = 3, kl = n-1, ku = kl) ## RANDSVD Random matrix with pre-assigned singular values. - ## RANDSVD(N, KAPPA, MODE, KL, KU) is a (banded) random matrix of order N - ## with COND(A) = KAPPA and singular values from the distribution MODE. - ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). - ## Available types: - ## MODE = 1: one large singular value, - ## MODE = 2: one small singular value, - ## MODE = 3: geometrically distributed singular values, - ## MODE = 4: arithmetically distributed singular values, - ## MODE = 5: random singular values with unif. dist. logarithm. - ## If omitted, MODE defaults to 3, and KAPPA defaults to SQRT(1/EPS). - ## If MODE < 0 then the effect is as for ABS(MODE) except that in the - ## original matrix of singular values the order of the diagonal entries - ## is reversed: small to large instead of large to small. - ## KL and KU are the lower and upper bandwidths respectively; if they - ## are omitted a full matrix is produced. - ## If only KL is present, KU defaults to KL. - ## Special case: if KAPPA < 0 then a random full symmetric positive - ## definite matrix is produced with COND(A) = -KAPPA and - ## eigenvalues distributed according to MODE. - ## KL and KU, if present, are ignored. + ## RANDSVD(N, KAPPA, MODE, KL, KU) is a (banded) random matrix of order N + ## with COND(A) = KAPPA and singular values from the distribution MODE. + ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2). + ## Available types: + ## MODE = 1: one large singular value, + ## MODE = 2: one small singular value, + ## MODE = 3: geometrically distributed singular values, + ## MODE = 4: arithmetically distributed singular values, + ## MODE = 5: random singular values with unif. dist. logarithm. + ## If omitted, MODE defaults to 3, and KAPPA defaults to SQRT(1/EPS). + ## If MODE < 0 then the effect is as for ABS(MODE) except that in the + ## original matrix of singular values the order of the diagonal entries + ## is reversed: small to large instead of large to small. + ## KL and KU are the lower and upper bandwidths respectively; if they + ## are omitted a full matrix is produced. + ## If only KL is present, KU defaults to KL. + ## Special case: if KAPPA < 0 then a random full symmetric positive + ## definite matrix is produced with COND(A) = -KAPPA and + ## eigenvalues distributed according to MODE. + ## KL and KU, if present, are ignored. ## - ## Reference: - ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, - ## Society for Industrial and Applied Mathematics, Philadelphia, PA, - ## USA, 1996; sec. 26.3. + ## Reference: + ## N.J. Higham, Accuracy and Stability of Numerical Algorithms, + ## Society for Industrial and Applied Mathematics, Philadelphia, PA, + ## USA, 1996; sec. 26.3. ## - ## This routine is similar to the more comprehensive Fortran routine xLATMS - ## in the following reference: - ## J.W. Demmel and A. McKenney, A test matrix generation suite, - ## LAPACK Working Note #9, Courant Institute of Mathematical Sciences, - ## New York, 1989. + ## This routine is similar to the more comprehensive Fortran routine xLATMS + ## in the following reference: + ## J.W. Demmel and A. McKenney, A test matrix generation suite, + ## LAPACK Working Note #9, Courant Institute of Mathematical Sciences, + ## New York, 1989. if (nargin < 1 || nargin > 5) error ("gallery: 1 to 5 arguments are required for randsvd matrix."); @@ -2245,7 +2245,7 @@ ## Convert to diagonal matrix of singular values. if (mode < 0) - sigma = sigma (p:-1:1); + sigma = sigma(p:-1:1); endif sigma = diag (sigma); @@ -2280,28 +2280,28 @@ function A = redheff (n) ## REDHEFF A (0,1) matrix of Redheffer associated with the Riemann hypothesis. - ## A = REDHEFF(N) is an N-by-N matrix of 0s and 1s defined by - ## A(i,j) = 1 if j = 1 or if i divides j, - ## A(i,j) = 0 otherwise. - ## It has N - FLOOR(LOG2(N)) - 1 eigenvalues equal to 1, - ## a real eigenvalue (the spectral radius) approximately SQRT(N), - ## a negative eigenvalue approximately -SQRT(N), - ## and the remaining eigenvalues are provably ``small''. - ## Barrett and Jarvis (1992) conjecture that - ## ``the small eigenvalues all lie inside the unit circle - ## ABS(Z) = 1'', - ## and a proof of this conjecture, together with a proof that some - ## eigenvalue tends to zero as N tends to infinity, would yield - ## a new proof of the prime number theorem. - ## The Riemann hypothesis is true if and only if - ## DET(A) = O( N^(1/2+epsilon) ) for every epsilon > 0 - ## (`!' denotes factorial). - ## See also RIEMANN. + ## A = REDHEFF(N) is an N-by-N matrix of 0s and 1s defined by + ## A(i,j) = 1 if j = 1 or if i divides j, + ## A(i,j) = 0 otherwise. + ## It has N - FLOOR(LOG2(N)) - 1 eigenvalues equal to 1, + ## a real eigenvalue (the spectral radius) approximately SQRT(N), + ## a negative eigenvalue approximately -SQRT(N), + ## and the remaining eigenvalues are provably ``small''. + ## Barrett and Jarvis (1992) conjecture that + ## ``the small eigenvalues all lie inside the unit circle + ## ABS(Z) = 1'', + ## and a proof of this conjecture, together with a proof that some + ## eigenvalue tends to zero as N tends to infinity, would yield + ## a new proof of the prime number theorem. + ## The Riemann hypothesis is true if and only if + ## DET(A) = O( N^(1/2+epsilon) ) for every epsilon > 0 + ## (`!' denotes factorial). + ## See also RIEMANN. ## - ## Reference: - ## W.W. Barrett and T.J. Jarvis, - ## Spectral Properties of a Matrix of Redheffer, - ## Linear Algebra and Appl., 162 (1992), pp. 673-683. + ## Reference: + ## W.W. Barrett and T.J. Jarvis, + ## Spectral Properties of a Matrix of Redheffer, + ## Linear Algebra and Appl., 162 (1992), pp. 673-683. if (nargin != 1) error ("gallery: 1 argument is required for redheff matrix."); @@ -2316,22 +2316,22 @@ function A = riemann (n) ## RIEMANN A matrix associated with the Riemann hypothesis. - ## A = RIEMANN(N) is an N-by-N matrix for which the - ## Riemann hypothesis is true if and only if - ## DET(A) = O( N! N^(-1/2+epsilon) ) for every epsilon > 0 - ## (`!' denotes factorial). - ## A = B(2:N+1, 2:N+1), where - ## B(i,j) = i-1 if i divides j and -1 otherwise. - ## Properties include, with M = N+1: - ## Each eigenvalue E(i) satisfies ABS(E(i)) <= M - 1/M. - ## i <= E(i) <= i+1 with at most M-SQRT(M) exceptions. - ## All integers in the interval (M/3, M/2] are eigenvalues. + ## A = RIEMANN(N) is an N-by-N matrix for which the + ## Riemann hypothesis is true if and only if + ## DET(A) = O( N! N^(-1/2+epsilon) ) for every epsilon > 0 + ## (`!' denotes factorial). + ## A = B(2:N+1, 2:N+1), where + ## B(i,j) = i-1 if i divides j and -1 otherwise. + ## Properties include, with M = N+1: + ## Each eigenvalue E(i) satisfies ABS(E(i)) <= M - 1/M. + ## i <= E(i) <= i+1 with at most M-SQRT(M) exceptions. + ## All integers in the interval (M/3, M/2] are eigenvalues. ## - ## See also REDHEFF. + ## See also REDHEFF. ## - ## Reference: - ## F. Roesler, Riemann's hypothesis as an eigenvalue problem, - ## Linear Algebra and Appl., 81 (1986), pp. 153-198. + ## Reference: + ## F. Roesler, Riemann's hypothesis as an eigenvalue problem, + ## Linear Algebra and Appl., 81 (1986), pp. 153-198. if (nargin != 1) error ("gallery: 1 argument is required for riemann matrix."); @@ -2348,16 +2348,16 @@ function A = ris (n) ## NOTE: this function was named dingdong in the original Test Matrix Toolbox ## RIS Dingdong matrix - a symmetric Hankel matrix. - ## A = RIS(N) is the symmetric N-by-N Hankel matrix with - ## A(i,j) = 0.5/(N-i-j+1.5). - ## The eigenvalues of A cluster around PI/2 and -PI/2. + ## A = RIS(N) is the symmetric N-by-N Hankel matrix with + ## A(i,j) = 0.5/(N-i-j+1.5). + ## The eigenvalues of A cluster around PI/2 and -PI/2. ## - ## Invented by F.N. Ris. + ## Invented by F.N. Ris. ## - ## Reference: - ## J.C. Nash, Compact Numerical Methods for Computers: Linear - ## Algebra and Function Minimisation, second edition, Adam Hilger, - ## Bristol, 1990 (Appendix 1). + ## Reference: + ## J.C. Nash, Compact Numerical Methods for Computers: Linear + ## Algebra and Function Minimisation, second edition, Adam Hilger, + ## Bristol, 1990 (Appendix 1). if (nargin != 1) error ("gallery: 1 argument is required for ris matrix."); @@ -2371,20 +2371,20 @@ function A = smoke (n, k = 0) ## SMOKE Smoke matrix - complex, with a `smoke ring' pseudospectrum. - ## SMOKE(N) is an N-by-N matrix with 1s on the - ## superdiagonal, 1 in the (N,1) position, and powers of - ## roots of unity along the diagonal. - ## SMOKE(N, 1) is the same except for a zero (N,1) element. - ## The eigenvalues of SMOKE(N, 1) are the N'th roots of unity; - ## those of SMOKE(N) are the N'th roots of unity times 2^(1/N). + ## SMOKE(N) is an N-by-N matrix with 1s on the + ## superdiagonal, 1 in the (N,1) position, and powers of + ## roots of unity along the diagonal. + ## SMOKE(N, 1) is the same except for a zero (N,1) element. + ## The eigenvalues of SMOKE(N, 1) are the N'th roots of unity; + ## those of SMOKE(N) are the N'th roots of unity times 2^(1/N). ## - ## Try PS(SMOKE(32)). For SMOKE(N, 1) the pseudospectrum looks - ## like a sausage folded back on itself. - ## GERSH(SMOKE(N, 1)) is interesting. + ## Try PS(SMOKE(32)). For SMOKE(N, 1) the pseudospectrum looks + ## like a sausage folded back on itself. + ## GERSH(SMOKE(N, 1)) is interesting. ## - ## Reference: - ## L. Reichel and L.N. Trefethen, Eigenvalues and pseudo-eigenvalues of - ## Toeplitz matrices, Linear Algebra and Appl., 162-164:153-185, 1992. + ## Reference: + ## L. Reichel and L.N. Trefethen, Eigenvalues and pseudo-eigenvalues of + ## Toeplitz matrices, Linear Algebra and Appl., 162-164:153-185, 1992. if (nargin < 1 || nargin > 2) error ("gallery: 1 to 2 arguments are required for smoke matrix."); @@ -2408,18 +2408,18 @@ function T = toeppd (n, m = n, w = rand (m,1), theta = rand (m,1)) ## NOTE: this function was named pdtoep in the original Test Matrix Toolbox ## TOEPPD Symmetric positive definite Toeplitz matrix. - ## TOEPPD(N, M, W, THETA) is an N-by-N symmetric positive (semi-) - ## definite (SPD) Toeplitz matrix, comprised of the sum of M rank 2 - ## (or, for certain THETA, rank 1) SPD Toeplitz matrices. - ## Specifically, - ## T = W(1)*T(THETA(1)) + ... + W(M)*T(THETA(M)), - ## where T(THETA(k)) has (i,j) element COS(2*PI*THETA(k)*(i-j)). - ## Defaults: M = N, W = RAND(M,1), THETA = RAND(M,1). + ## TOEPPD(N, M, W, THETA) is an N-by-N symmetric positive (semi-) + ## definite (SPD) Toeplitz matrix, comprised of the sum of M rank 2 + ## (or, for certain THETA, rank 1) SPD Toeplitz matrices. + ## Specifically, + ## T = W(1)*T(THETA(1)) + ... + W(M)*T(THETA(M)), + ## where T(THETA(k)) has (i,j) element COS(2*PI*THETA(k)*(i-j)). + ## Defaults: M = N, W = RAND(M,1), THETA = RAND(M,1). ## - ## Reference: - ## G. Cybenko and C.F. Van Loan, Computing the minimum eigenvalue of - ## a symmetric positive definite Toeplitz matrix, SIAM J. Sci. Stat. - ## Comput., 7 (1986), pp. 123-131. + ## Reference: + ## G. Cybenko and C.F. Van Loan, Computing the minimum eigenvalue of + ## a symmetric positive definite Toeplitz matrix, SIAM J. Sci. Stat. + ## Comput., 7 (1986), pp. 123-131. if (nargin < 1 || nargin > 4) error ("gallery: 1 to 4 arguments are required for toeppd matrix."); @@ -2442,25 +2442,25 @@ function P = toeppen (n, a = 1, b = -10, c = 0, d = 10, e = 1) ## NOTE: this function was named pentoep in the original Test Matrix Toolbox ## TOEPPEN Pentadiagonal Toeplitz matrix (sparse). - ## P = TOEPPEN(N, A, B, C, D, E) is the N-by-N pentadiagonal - ## Toeplitz matrix with diagonals composed of the numbers - ## A =: P(3,1), B =: P(2,1), C =: P(1,1), D =: P(1,2), E =: P(1,3). - ## Default: (A,B,C,D,E) = (1,-10,0,10,1) (a matrix of Rutishauser). - ## This matrix has eigenvalues lying approximately on - ## the line segment 2*cos(2*t) + 20*i*sin(t). + ## P = TOEPPEN(N, A, B, C, D, E) is the N-by-N pentadiagonal + ## Toeplitz matrix with diagonals composed of the numbers + ## A =: P(3,1), B =: P(2,1), C =: P(1,1), D =: P(1,2), E =: P(1,3). + ## Default: (A,B,C,D,E) = (1,-10,0,10,1) (a matrix of Rutishauser). + ## This matrix has eigenvalues lying approximately on + ## the line segment 2*cos(2*t) + 20*i*sin(t). ## - ## Interesting plots are - ## PS(FULL(TOEPPEN(32,0,1,0,0,1/4))) - `triangle' - ## PS(FULL(TOEPPEN(32,0,1/2,0,0,1))) - `propeller' - ## PS(FULL(TOEPPEN(32,0,1/2,1,1,1))) - `fish' + ## Interesting plots are + ## PS(FULL(TOEPPEN(32,0,1,0,0,1/4))) - `triangle' + ## PS(FULL(TOEPPEN(32,0,1/2,0,0,1))) - `propeller' + ## PS(FULL(TOEPPEN(32,0,1/2,1,1,1))) - `fish' ## - ## References: - ## R.M. Beam and R.F. Warming, The asymptotic spectra of - ## banded Toeplitz and quasi-Toeplitz matrices, SIAM J. Sci. - ## Comput. 14 (4), 1993, pp. 971-1006. - ## H. Rutishauser, On test matrices, Programmation en Mathematiques - ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, - ## 1966, pp. 349-365. + ## References: + ## R.M. Beam and R.F. Warming, The asymptotic spectra of + ## banded Toeplitz and quasi-Toeplitz matrices, SIAM J. Sci. + ## Comput. 14 (4), 1993, pp. 971-1006. + ## H. Rutishauser, On test matrices, Programmation en Mathematiques + ## Numeriques, Editions Centre Nat. Recherche Sci., Paris, 165, + ## 1966, pp. 349-365. if (nargin < 1 || nargin > 6) error ("gallery: 1 to 6 arguments are required for toeppen matrix."); @@ -2476,23 +2476,23 @@ function T = tridiag (n, x = -1, y = 2, z = -1) ## TRIDIAG Tridiagonal matrix (sparse). - ## TRIDIAG(X, Y, Z) is the tridiagonal matrix with subdiagonal X, - ## diagonal Y, and superdiagonal Z. - ## X and Z must be vectors of dimension one less than Y. - ## Alternatively TRIDIAG(N, C, D, E), where C, D, and E are all - ## scalars, yields the Toeplitz tridiagonal matrix of order N - ## with subdiagonal elements C, diagonal elements D, and superdiagonal - ## elements E. This matrix has eigenvalues (Todd 1977) - ## D + 2*SQRT(C*E)*COS(k*PI/(N+1)), k=1:N. - ## TRIDIAG(N) is the same as TRIDIAG(N,-1,2,-1), which is - ## a symmetric positive definite M-matrix (the negative of the - ## second difference matrix). + ## TRIDIAG(X, Y, Z) is the tridiagonal matrix with subdiagonal X, + ## diagonal Y, and superdiagonal Z. + ## X and Z must be vectors of dimension one less than Y. + ## Alternatively TRIDIAG(N, C, D, E), where C, D, and E are all + ## scalars, yields the Toeplitz tridiagonal matrix of order N + ## with subdiagonal elements C, diagonal elements D, and superdiagonal + ## elements E. This matrix has eigenvalues (Todd 1977) + ## D + 2*SQRT(C*E)*COS(k*PI/(N+1)), k=1:N. + ## TRIDIAG(N) is the same as TRIDIAG(N,-1,2,-1), which is + ## a symmetric positive definite M-matrix (the negative of the + ## second difference matrix). ## - ## References: - ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, - ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 155. - ## D.E. Rutherford, Some continuant determinants arising in physics and - ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. + ## References: + ## J. Todd, Basic Numerical Mathematics, Vol. 2: Numerical Algebra, + ## Birkhauser, Basel, and Academic Press, New York, 1977, p. 155. + ## D.E. Rutherford, Some continuant determinants arising in physics and + ## chemistry---II, Proc. Royal Soc. Edin., 63, A (1952), pp. 232-241. if (nargin != 1 && nargin != 3 && nargin != 4) error ("gallery: 1, 3, or 4 arguments are required for tridiag matrix."); @@ -2524,33 +2524,33 @@ function t = triw (n, alpha = -1, k = n(end) - 1) ## TRIW Upper triangular matrix discussed by Wilkinson and others. - ## TRIW(N, ALPHA, K) is the upper triangular matrix with ones on - ## the diagonal and ALPHAs on the first K >= 0 superdiagonals. - ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2) and - ## upper trapezoidal. - ## Defaults: ALPHA = -1, - ## K = N - 1 (full upper triangle). - ## TRIW(N) is a matrix discussed by Kahan, Golub and Wilkinson. + ## TRIW(N, ALPHA, K) is the upper triangular matrix with ones on + ## the diagonal and ALPHAs on the first K >= 0 superdiagonals. + ## N may be a 2-vector, in which case the matrix is N(1)-by-N(2) and + ## upper trapezoidal. + ## Defaults: ALPHA = -1, + ## K = N - 1 (full upper triangle). + ## TRIW(N) is a matrix discussed by Kahan, Golub and Wilkinson. ## - ## Ostrowski (1954) shows that - ## COND(TRIW(N,2)) = COT(PI/(4*N))^2, - ## and for large ABS(ALPHA), - ## COND(TRIW(N,ALPHA)) is approximately ABS(ALPHA)^N*SIN(PI/(4*N-2)). + ## Ostrowski (1954) shows that + ## COND(TRIW(N,2)) = COT(PI/(4*N))^2, + ## and for large ABS(ALPHA), + ## COND(TRIW(N,ALPHA)) is approximately ABS(ALPHA)^N*SIN(PI/(4*N-2)). ## - ## Adding -2^(2-N) to the (N,1) element makes TRIW(N) singular, - ## as does adding -2^(1-N) to all elements in the first column. + ## Adding -2^(2-N) to the (N,1) element makes TRIW(N) singular, + ## as does adding -2^(1-N) to all elements in the first column. ## - ## References: - ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the - ## computation of the Jordan canonical form, SIAM Review, - ## 18(4), 1976, pp. 578-619. - ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, - ## 9 (1966), pp. 757-801. - ## A.M. Ostrowski, On the spectrum of a one-parametric family of - ## matrices, J. Reine Angew. Math., 193 (3/4), 1954, pp. 143-160. - ## J.H. Wilkinson, Singular-value decomposition---basic aspects, - ## in D.A.H. Jacobs, ed., Numerical Software---Needs and Availability, - ## Academic Press, London, 1978, pp. 109-135. + ## References: + ## G.H. Golub and J.H. Wilkinson, Ill-conditioned eigensystems and the + ## computation of the Jordan canonical form, SIAM Review, + ## 18(4), 1976, pp. 578-619. + ## W. Kahan, Numerical linear algebra, Canadian Math. Bulletin, + ## 9 (1966), pp. 757-801. + ## A.M. Ostrowski, On the spectrum of a one-parametric family of + ## matrices, J. Reine Angew. Math., 193 (3/4), 1954, pp. 143-160. + ## J.H. Wilkinson, Singular-value decomposition---basic aspects, + ## in D.A.H. Jacobs, ed., Numerical Software---Needs and Availability, + ## Academic Press, London, 1978, pp. 109-135. if (nargin < 1 || nargin > 3) error ("gallery: 1 to 3 arguments are required for triw matrix."); @@ -2610,79 +2610,79 @@ endfunction function A = wathen (nx, ny, k = 0) - ## # WATHEN returns the Wathen matrix. + ## WATHEN returns the Wathen matrix. ## - ## Discussion: + ## Discussion: ## - ## The Wathen matrix is a finite element matrix which is sparse. + ## The Wathen matrix is a finite element matrix which is sparse. ## - ## The entries of the matrix depend in part on a physical quantity - ## related to density. That density is here assigned random values between - ## 0 and 100. + ## The entries of the matrix depend in part on a physical quantity + ## related to density. That density is here assigned random values between + ## 0 and 100. ## - ## A = WATHEN ( NX, NY ) is a sparse random N-by-N finite element matrix - ## where N = 3*NX*NY + 2*NX + 2*NY + 1. + ## A = WATHEN ( NX, NY ) is a sparse random N-by-N finite element matrix + ## where N = 3*NX*NY + 2*NX + 2*NY + 1. ## - ## A is the consistent mass matrix for a regular NX-by-NY - ## grid of 8-node (serendipity) elements in 2 space dimensions. + ## A is the consistent mass matrix for a regular NX-by-NY + ## grid of 8-node (serendipity) elements in 2 space dimensions. ## - ## Here is an illustration for NX = 3, NX = 2: + ## Here is an illustration for NX = 3, NX = 2: ## - ## 23-24-25-26-27-28-29 - ## | | | | - ## 19 20 21 22 - ## | | | | - ## 12-13-14-15-16-17-18 - ## | | | | - ## 8 9 10 11 - ## | | | | - ## 1--2--3--4--5--6--7 + ## 23-24-25-26-27-28-29 + ## | | | | + ## 19 20 21 22 + ## | | | | + ## 12-13-14-15-16-17-18 + ## | | | | + ## 8 9 10 11 + ## | | | | + ## 1--2--3--4--5--6--7 ## - ## For this example, the total number of nodes is, as expected, + ## For this example, the total number of nodes is, as expected, ## - ## N = 3 * 3 * 2 + 2 * 2 + 2 * 3 + 1 = 29. + ## N = 3 * 3 * 2 + 2 * 2 + 2 * 3 + 1 = 29. ## - ## A is symmetric positive definite for any (positive) values of - ## the density, RHO(NX,NY), which is chosen randomly in this routine. + ## A is symmetric positive definite for any (positive) values of + ## the density, RHO(NX,NY), which is chosen randomly in this routine. ## - ## In particular, if D = DIAG(DIAG(A)), then - ## 0.25 <= EIG(INV(D)*A) <= 4.5 - ## for any positive integers NX and NY and any densities RHO(NX,NY). + ## In particular, if D = DIAG(DIAG(A)), then + ## 0.25 <= EIG(INV(D)*A) <= 4.5 + ## for any positive integers NX and NY and any densities RHO(NX,NY). ## - ## A = WATHEN ( NX, NY, 1 ) returns the diagonally scaled matrix. + ## A = WATHEN ( NX, NY, 1 ) returns the diagonally scaled matrix. ## - ## Modified: + ## Modified: ## - ## 17 September 2007 + ## 17 September 2007 ## - ## Author: + ## Author: ## - ## Nicholas Higham + ## Nicholas Higham ## - ## Reference: + ## Reference: ## - ## Nicholas Higham, - ## Algorithm 694: A Collection of Test Matrices in MATLAB, - ## ACM Transactions on Mathematical Software, - ## Volume 17, Number 3, September 1991, pages 289-305. + ## Nicholas Higham, + ## Algorithm 694: A Collection of Test Matrices in MATLAB, + ## ACM Transactions on Mathematical Software, + ## Volume 17, Number 3, September 1991, pages 289-305. ## - ## Andrew Wathen, - ## Realistic eigenvalue bounds for the Galerkin mass matrix, - ## IMA Journal of Numerical Analysis, - ## Volume 7, 1987, pages 449-457. + ## Andrew Wathen, + ## Realistic eigenvalue bounds for the Galerkin mass matrix, + ## IMA Journal of Numerical Analysis, + ## Volume 7, 1987, pages 449-457. ## - ## Parameters: + ## Parameters: ## - ## Input, integer NX, NY, the number of elements in the X and Y directions - ## of the finite element grid. NX and NY must each be at least 1. + ## Input, integer NX, NY, the number of elements in the X and Y directions + ## of the finite element grid. NX and NY must each be at least 1. ## - ## Optional input, integer K, is used to request that the diagonally scaled - ## version of the matrix be returned. This happens if K is specified with - ## the value 1. + ## Optional input, integer K, is used to request that the diagonally scaled + ## version of the matrix be returned. This happens if K is specified with + ## the value 1. ## - ## Output, sparse real A(N,N), the matrix. The dimension N is determined by - ## NX and NY, as described above. A is stored in the MATLAB sparse matrix - ## format. + ## Output, sparse real A(N,N), the matrix. The dimension N is determined by + ## NX and NY, as described above. A is stored in the MATLAB sparse matrix + ## format. if (nargin < 2 || nargin > 3) error ("gallery: 2 or 3 arguments are required for wathen matrix."); @@ -2746,19 +2746,19 @@ function [A, b] = wilk (n) ## WILK Various specific matrices devised/discussed by Wilkinson. - ## [A, b] = WILK(N) is the matrix or system of order N. - ## N = 3: upper triangular system Ux=b illustrating inaccurate solution. - ## N = 4: lower triangular system Lx=b, ill-conditioned. - ## N = 5: HILB(6)(1:5,2:6)*1.8144. Symmetric positive definite. - ## N = 21: W21+, tridiagonal. Eigenvalue problem. + ## [A, b] = WILK(N) is the matrix or system of order N. + ## N = 3: upper triangular system Ux=b illustrating inaccurate solution. + ## N = 4: lower triangular system Lx=b, ill-conditioned. + ## N = 5: HILB(6)(1:5,2:6)*1.8144. Symmetric positive definite. + ## N = 21: W21+, tridiagonal. Eigenvalue problem. ## - ## References: - ## J.H. Wilkinson, Error analysis of direct methods of matrix inversion, - ## J. Assoc. Comput. Mach., 8 (1961), pp. 281-330. - ## J.H. Wilkinson, Rounding Errors in Algebraic Processes, Notes on Applied - ## Science No. 32, Her Majesty's Stationery Office, London, 1963. - ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University - ## Press, 1965. + ## References: + ## J.H. Wilkinson, Error analysis of direct methods of matrix inversion, + ## J. Assoc. Comput. Mach., 8 (1961), pp. 281-330. + ## J.H. Wilkinson, Rounding Errors in Algebraic Processes, Notes on Applied + ## Science No. 32, Her Majesty's Stationery Office, London, 1963. + ## J.H. Wilkinson, The Algebraic Eigenvalue Problem, Oxford University + ## Press, 1965. if (nargin != 1) error ("gallery: 1 argument is required for wilk matrix."); @@ -2807,21 +2807,21 @@ ## NOTE: bandred is part of the Test Matrix Toolbox and is used by randsvd() function A = bandred (A, kl, ku) ## BANDRED Band reduction by two-sided unitary transformations. - ## B = BANDRED(A, KL, KU) is a matrix unitarily equivalent to A - ## with lower bandwidth KL and upper bandwidth KU - ## (i.e. B(i,j) = 0 if i > j+KL or j > i+KU). - ## The reduction is performed using Householder transformations. - ## If KU is omitted it defaults to KL. + ## B = BANDRED(A, KL, KU) is a matrix unitarily equivalent to A + ## with lower bandwidth KL and upper bandwidth KU + ## (i.e. B(i,j) = 0 if i > j+KL or j > i+KU). + ## The reduction is performed using Householder transformations. + ## If KU is omitted it defaults to KL. ## - ## Called by RANDSVD. - ## This is a `standard' reduction. Cf. reduction to bidiagonal form - ## prior to computing the SVD. This code is a little wasteful in that - ## it computes certain elements which are immediately set to zero! + ## Called by RANDSVD. + ## This is a `standard' reduction. Cf. reduction to bidiagonal form + ## prior to computing the SVD. This code is a little wasteful in that + ## it computes certain elements which are immediately set to zero! ## - ## Reference: - ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, - ## Johns Hopkins University Press, Baltimore, Maryland, 1989. - ## Section 5.4.3. + ## Reference: + ## G.H. Golub and C.F. Van Loan, Matrix Computations, second edition, + ## Johns Hopkins University Press, Baltimore, Maryland, 1989. + ## Section 5.4.3. ## Check for special case where order of left/right transformations matters. ## Easiest approach is to work on the transpose, flipping back at the end.
--- a/scripts/special-matrix/magic.m +++ b/scripts/special-matrix/magic.m @@ -88,7 +88,7 @@ %!assert (isempty (magic (0))) %!assert (magic (1), 1) -%% Test input validation +## Test input validation %!error magic () %!error magic (1, 2) %!error <N must be a positive integer not equal to 2> magic (1.5)
--- a/scripts/special-matrix/pascal.m +++ b/scripts/special-matrix/pascal.m @@ -80,7 +80,7 @@ %!assert (pascal (3,2), [1,1,1;-2,-1,0;1,0,0]) %!assert (pascal (0,2), []) -%% Test input validation +## Test input validation %!error pascal () %!error pascal (1,2,3) %!error <N and T must be scalars> pascal ([1 2])
--- a/scripts/special-matrix/toeplitz.m +++ b/scripts/special-matrix/toeplitz.m @@ -125,7 +125,7 @@ %!assert (toeplitz ([1, 2, 3], [1; -3; -5]), [1, -3, -5; 2, 1, -3; 3, 2, 1]) %!assert (toeplitz ([1, 2, 3], [1; -3i; -5i]), [1, -3i, -5i; 2, 1, -3i; 3, 2, 1]) -%% Test input validation +## Test input validation %!error toeplitz () %!error toeplitz (1, 2, 3) %!error <C must be a vector> toeplitz ([1, 2; 3, 4])
--- a/scripts/special-matrix/wilkinson.m +++ b/scripts/special-matrix/wilkinson.m @@ -52,7 +52,7 @@ %!assert (wilkinson (3), [1,1,0;1,0,1;0,1,1]) %!assert (wilkinson (4), [1.5,1,0,0;1,0.5,1,0;0,1,0.5,1;0,0,1,1.5]) -%% Test input validation +## Test input validation %!error wilkinson () %!error wilkinson (1,2) %!error <N must be a non-negative integer> wilkinson (ones (2))
--- a/scripts/statistics/base/center.m +++ b/scripts/statistics/base/center.m @@ -75,7 +75,7 @@ %!assert (center (magic (3)), [3,-4,1;-2,0,2;-1,4,-3]) %!assert (center ([1 2 3; 6 5 4], 2), [-1 0 1; 1 0 -1]) -%% Test input validation +## Test input validation %!error center () %!error center (1, 2, 3) %!error center (1, ones (2,2))
--- a/scripts/statistics/base/cloglog.m +++ b/scripts/statistics/base/cloglog.m @@ -51,7 +51,7 @@ %!assert (cloglog (1), Inf) %!assert (cloglog (1/e), 0) -%% Test input validation +## Test input validation %!error cloglog () %!error cloglog (1, 2)
--- a/scripts/statistics/base/corr.m +++ b/scripts/statistics/base/corr.m @@ -103,7 +103,7 @@ %!assert (corr (5), 1) %!assert (corr (single (5)), single (1)) -%% Test input validation +## Test input validation %!error corr () %!error corr (1, 2, 3) %!error corr ([1; 2], ["A", "B"])
--- a/scripts/statistics/base/cov.m +++ b/scripts/statistics/base/cov.m @@ -161,7 +161,7 @@ %! c = cov (x, 1); %! assert (c, 2); -%% Test input validation +## Test input validation %!error cov () %!error cov (1, 2, 3, 4) %!error cov ([1; 2], ["A", "B"])
--- a/scripts/statistics/base/gls.m +++ b/scripts/statistics/base/gls.m @@ -82,7 +82,7 @@ if (rx != ry) error ("gls: number of rows of X and Y must be equal"); endif - if (!issquare (o) || ro != ry*cy) + if (! issquare (o) || ro != ry*cy) error ("gls: matrix O must be square matrix with rows = rows (Y) * cols (Y)"); endif @@ -129,7 +129,7 @@ %! o = diag (ones (5,1)); %! assert (gls (y,x,o), [3; 2], 50*eps); -%% Test input validation +## Test input validation %!error gls () %!error gls (1) %!error gls (1, 2)
--- a/scripts/statistics/base/histc.m +++ b/scripts/statistics/base/histc.m @@ -48,7 +48,7 @@ print_usage (); endif - if (!isreal (x)) + if (! isreal (x)) error ("histc: X argument must be real-valued, not complex"); endif @@ -57,12 +57,12 @@ error ("histc: EDGES must not be empty"); endif - if (!isreal (edges)) + if (! isreal (edges)) error ("histc: EDGES must be real-valued, not complex"); else ## Make sure 'edges' is sorted edges = edges(:); - if (!issorted (edges) || edges(1) > edges(end)) + if (! issorted (edges) || edges(1) > edges(end)) warning ("histc: edge values not sorted on input"); edges = sort (edges); endif @@ -109,13 +109,13 @@ ## Compute the histograms for k = 1:num_edges-1 - b = (edges (k) <= x & x < edges (k+1)); + b = (edges(k) <= x & x < edges(k+1)); n(idx1{:}, k, idx2{:}) = sum (b, dim); if (nargout > 1) idx(b) = k; endif endfor - b = (x == edges (end)); + b = (x == edges(end)); n(idx1{:}, num_edges, idx2{:}) = sum (b, dim); if (nargout > 1) idx(b) = num_edges;
--- a/scripts/statistics/base/iqr.m +++ b/scripts/statistics/base/iqr.m @@ -85,10 +85,11 @@ %!assert (iqr (1:101), 50) %!assert (iqr (single (1:101)), single (50)) -%%!test -%%! x = [1:100]; -%%! n = iqr (x, 0:10); -%%! assert (n, [repmat(100, 1, 10), 1]); +## FIXME: iqr throws horrible error when running across a dimension that is 1. +%!test +%! x = [1:100]'; +%! assert (iqr (x, 1), 50); +%! assert (iqr (x', 2), 50); %!error iqr () %!error iqr (1, 2, 3)
--- a/scripts/statistics/base/kendall.m +++ b/scripts/statistics/base/kendall.m @@ -124,7 +124,7 @@ %!assert (kendall (logical (1)), 1) %!assert (kendall (single (1)), single (1)) -%% Test input validation +## Test input validation %!error kendall () %!error kendall (1, 2, 3) %!error kendall (['A'; 'B'])
--- a/scripts/statistics/base/kurtosis.m +++ b/scripts/statistics/base/kurtosis.m @@ -92,7 +92,7 @@ if (nargin < 2 || isempty (flag)) flag = 1; # default: do not use the "bias corrected" version else - if ((! isscalar (flag)) || (flag != 0 && flag != 1)) + if (! isscalar (flag) || (flag != 0 && flag != 1)) error ("kurtosis: FLAG must be 0 or 1"); endif endif @@ -159,7 +159,7 @@ %! warning (wstate, "Octave:divide-by-zero"); %! end_unwind_protect -%% Test input validation +## Test input validation %!error kurtosis () %!error kurtosis (1, 2, 3) %!error <X must be a numeric vector or matrix> kurtosis (['A'; 'B'])
--- a/scripts/statistics/base/logit.m +++ b/scripts/statistics/base/logit.m @@ -54,7 +54,7 @@ %!assert (logit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, +Inf, NaN]) -%% Test input validation +## Test input validation %!error logit () %!error logit (1, 2)
--- a/scripts/statistics/base/lscov.m +++ b/scripts/statistics/base/lscov.m @@ -113,6 +113,7 @@ endif endfunction + %!test %! ## Longley data from the NIST Statistical Reference Dataset %! Z = [ 60323 83.0 234289 2356 1590 107608 1947
--- a/scripts/statistics/base/mahalanobis.m +++ b/scripts/statistics/base/mahalanobis.m @@ -70,7 +70,7 @@ endfunction -%% Test input validation +## Test input validation %!error mahalanobis () %!error mahalanobis (1, 2, 3) %!error mahalanobis ('A', 'B')
--- a/scripts/statistics/base/mean.m +++ b/scripts/statistics/base/mean.m @@ -145,7 +145,7 @@ %!assert (mean (logical ([1 0 1 1])), 0.75) %!assert (mean (single ([1 0 1 1])), single (0.75)) -%% Test input validation +## Test input validation %!error mean () %!error mean (1, 2, 3, 4) %!error mean ({1:5})
--- a/scripts/statistics/base/meansq.m +++ b/scripts/statistics/base/meansq.m @@ -78,7 +78,7 @@ %!assert (meansq (magic (4)), [94.5, 92.5, 92.5, 94.5]) %!assert (meansq (magic (4), 2), [109.5; 77.5; 77.5; 109.5]) -%% Test input validation +## Test input validation %!error meansq () %!error meansq (1, 2, 3) %!error meansq (['A'; 'B'])
--- a/scripts/statistics/base/median.m +++ b/scripts/statistics/base/median.m @@ -102,7 +102,7 @@ %!assert (median (single ([1,2,3])), single (2)) %!assert (median ([1,2,NaN;4,5,6;NaN,8,9]), [NaN, 5, NaN]) -%% Test multidimensional arrays (bug #35679) +## Test multidimensional arrays (bug #35679) %!shared a, b, x, y %! rand ("seed", 2); %! a = rand (2,3,4,5); @@ -112,7 +112,7 @@ %!assert (median (a, 4), x(:, :, :, 3)); %!assert (median (b, 3), (y(:, :, 3, :) + y(:, :, 4, :))/2); -%% Test input validation +## Test input validation %!error median () %!error median (1, 2, 3) %!error median ({1:5})
--- a/scripts/statistics/base/mode.m +++ b/scripts/statistics/base/mode.m @@ -155,7 +155,7 @@ %! assert (c{2}, [1; 2; 3]); %! assert (c{3}, [1; 2; 3]); -%% Test input validation +## Test input validation %!error mode () %!error mode (1, 2, 3) %!error mode ({1 2 3})
--- a/scripts/statistics/base/moment.m +++ b/scripts/statistics/base/moment.m @@ -161,8 +161,7 @@ ## Find the first non-singleton dimension. (dim = find (sz > 1, 1)) || (dim = 1); else - if (!(isscalar (dim) && dim == fix (dim)) || - !(1 <= dim && dim <= nd)) + if (! (isscalar (dim) && dim == fix (dim)) || ! (1 <= dim && dim <= nd)) error ("moment: DIM must be an integer and a valid dimension"); endif endif @@ -192,7 +191,7 @@ %!assert (moment (single ([1 2 3]), 1, "r"), single (2)) -%% Test input validation +## Test input validation %!error moment () %!error moment (1) %!error moment (1, 2, 3, 4, 5)
--- a/scripts/statistics/base/ols.m +++ b/scripts/statistics/base/ols.m @@ -162,7 +162,7 @@ %! b = ols (x, y); %! assert (b, [1.4, 2], 2*eps); -%% Test input validation +## Test input validation %!error ols () %!error ols (1) %!error ols (1, 2, 3)
--- a/scripts/statistics/base/ppplot.m +++ b/scripts/statistics/base/ppplot.m @@ -78,7 +78,7 @@ endfunction -%% Test input validation +## Test input validation %!error ppplot () %!error ppplot (ones (2,2))
--- a/scripts/statistics/base/prctile.m +++ b/scripts/statistics/base/prctile.m @@ -173,7 +173,7 @@ %! qa = [0.1270; 0.2041; 0.6437; 0.6477; 0.9322]; %! assert (q, qa, tol); -%% Test input validation +## Test input validation %!error prctile () %!error prctile (1, 2, 3, 4) %!error prctile (['A'; 'B'], 10)
--- a/scripts/statistics/base/probit.m +++ b/scripts/statistics/base/probit.m @@ -39,7 +39,7 @@ %!assert (probit ([-1, 0, 0.5, 1, 2]), [NaN, -Inf, 0, Inf, NaN]) -%% Test input validation +## Test input validation %!error probit () %!error probit (1, 2)
--- a/scripts/statistics/base/quantile.m +++ b/scripts/statistics/base/quantile.m @@ -104,7 +104,8 @@ ## @end deftypefn ## Author: Ben Abbott <bpabbott@mac.com> -## Description: Matlab style quantile function of a discrete/continuous distribution +## Description: Matlab style quantile function of a discrete/continuous +## distribution. function q = quantile (x, p = [], dim, method = 5) @@ -320,7 +321,7 @@ %! yexp = median (x, dim); %! assert (yobs, yexp); -%% Test input validation +## Test input validation %!error quantile () %!error quantile (1, 2, 3, 4, 5) %!error quantile (['A'; 'B'], 10)
--- a/scripts/statistics/base/range.m +++ b/scripts/statistics/base/range.m @@ -56,7 +56,7 @@ %!assert (range (magic (3), 2), [7; 4; 7]) %!assert (range (2), 0) -%% Test input validation +## Test input validation %!error range () %!error range (1, 2, 3)
--- a/scripts/statistics/base/ranks.m +++ b/scripts/statistics/base/ranks.m @@ -93,7 +93,7 @@ %!assert (ranks (1e6*ones (1, 5)), 3*ones (1, 5)) %!assert (ranks (rand (1, 5), 1), ones (1, 5)) -%% Test input validation +## Test input validation %!error ranks () %!error ranks (1, 2, 3) %!error ranks ({1, 2})
--- a/scripts/statistics/base/run_count.m +++ b/scripts/statistics/base/run_count.m @@ -98,7 +98,7 @@ %!assert (run_count (5:-1:1, 5), [5, 0, 0, 0, 0]) %!assert (run_count (ones (3), 4), [0,0,0;0,0,0;1,1,1;0,0,0]) -%% Test input validation +## Test input validation %!error run_count () %!error run_count (1) %!error run_count (1, 2, 3, 4)
--- a/scripts/statistics/base/runlength.m +++ b/scripts/statistics/base/runlength.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!(isnumeric (x) || islogical (x)) || !isvector (x)) + if (! (isnumeric (x) || islogical (x)) || ! isvector (x)) error ("runlength: X must be a numeric vector"); endif @@ -59,7 +59,7 @@ %! assert (c, [2 1 3 1 4]); %! assert (v, [2 0 4 0 1]); -%% Test input validation +## Test input validation %!error runlength () %!error runlength (1, 2) %!error runlength (['A'; 'B'])
--- a/scripts/statistics/base/skewness.m +++ b/scripts/statistics/base/skewness.m @@ -91,7 +91,7 @@ if (nargin < 2 || isempty (flag)) flag = 1; # default: do not use the "bias corrected" version else - if ((! isscalar (flag)) || (flag != 0 && flag != 1)) + if (! isscalar (flag) || (flag != 0 && flag != 1)) error ("skewness: FLAG must be 0 or 1"); endif endif
--- a/scripts/statistics/base/spearman.m +++ b/scripts/statistics/base/spearman.m @@ -84,7 +84,7 @@ %!assert (spearman ([1 2 3], [-1 1 -2]), -0.5, 5*eps) -%% Test input validation +## Test input validation %!error spearman () %!error spearman (1, 2, 3) %!error spearman (['A'; 'B'])
--- a/scripts/statistics/base/statistics.m +++ b/scripts/statistics/base/statistics.m @@ -87,7 +87,7 @@ %! assert (skewness (x, [], 2), s(:,8), eps); %! assert (kurtosis (x, [], 2), s(:,9), eps); -%% Test input validation +## Test input validation %!error statistics () %!error statistics (1, 2, 3) %!error statistics (['A'; 'B'])
--- a/scripts/statistics/base/std.m +++ b/scripts/statistics/base/std.m @@ -119,7 +119,7 @@ %!assert (std ([]), []); %!assert (std (ones (1,3,0,2)), ones (1,3,0,2)); -%% Test input validation +## Test input validation %!error std () %!error std (1, 2, 3, 4) %!error std (['A'; 'B'])
--- a/scripts/statistics/base/table.m +++ b/scripts/statistics/base/table.m @@ -35,7 +35,7 @@ endif if (nargin == 1) - if (!isnumeric (x) || !isvector (x)) + if (! isnumeric (x) || ! isvector (x)) error ("table: X must be a numeric vector"); endif v = unique (x); @@ -61,7 +61,7 @@ endfunction -%% Test input validation +## Test input validation %!error table () %!error table (1, 2, 3) %!error table (ones (2))
--- a/scripts/statistics/base/var.m +++ b/scripts/statistics/base/var.m @@ -112,7 +112,7 @@ %!assert (var ([1,2,3], 1), 2/3, eps) %!assert (var ([1,2,3], [], 1), [0,0,0]) -%% Test input validation +## Test input validation %!error var () %!error var (1,2,3,4) %!error var (['A'; 'B'])
--- a/scripts/statistics/base/zscore.m +++ b/scripts/statistics/base/zscore.m @@ -95,7 +95,7 @@ %!assert (zscore (ones (3,2,2,2)), zeros (3,2,2,2)) %!assert (zscore ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1]) -%% Test input validation +## Test input validation %!error zscore () %!error zscore (1, 2, 3) %!error zscore (['A'; 'B'])
--- a/scripts/statistics/distributions/betacdf.m +++ b/scripts/statistics/distributions/betacdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("betacdf: X, A, and B must be of common size or scalars"); @@ -76,13 +76,13 @@ %!assert (betacdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]) %!assert (betacdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (betacdf ([x, NaN], 1, 2), [y, NaN]) %!assert (betacdf (single ([x, NaN]), 1, 2), single ([y, NaN])) %!assert (betacdf ([x, NaN], single (1), 2), single ([y, NaN])) %!assert (betacdf ([x, NaN], 1, single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error betacdf () %!error betacdf (1) %!error betacdf (1,2)
--- a/scripts/statistics/distributions/betainv.m +++ b/scripts/statistics/distributions/betainv.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("betainv: X, A, and B must be of common size or scalars"); @@ -58,7 +58,7 @@ k = find ((x > 0) & (x < 1) & (a > 0) & (b > 0)); if (any (k)) - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) a = a(k); b = b(k); y = a ./ (a + b); @@ -88,11 +88,11 @@ y_new = y_old - h; ind = find (y_new <= myeps); if (any (ind)) - y_new (ind) = y_old (ind) / 10; + y_new(ind) = y_old(ind) / 10; endif ind = find (y_new >= 1 - myeps); if (any (ind)) - y_new (ind) = 1 - (1 - y_old (ind)) / 10; + y_new(ind) = 1 - (1 - y_old(ind)) / 10; endif h = y_old - y_new; if (max (abs (h)) < sqrt (myeps)) @@ -116,13 +116,13 @@ %!assert (betainv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 1 NaN]) %!assert (betainv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN 1 NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (betainv ([x, NaN], 1, 2), [NaN 0 0.5 1 NaN NaN]) %!assert (betainv (single ([x, NaN]), 1, 2), single ([NaN 0 0.5 1 NaN NaN])) %!assert (betainv ([x, NaN], single (1), 2), single ([NaN 0 0.5 1 NaN NaN])) %!assert (betainv ([x, NaN], 1, single (2)), single ([NaN 0 0.5 1 NaN NaN])) -%% Test input validation +## Test input validation %!error betainv () %!error betainv (1) %!error betainv (1,2)
--- a/scripts/statistics/distributions/betapdf.m +++ b/scripts/statistics/distributions/betapdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("betapdf: X, A, and B must be of common size or scalars"); @@ -102,21 +102,21 @@ %!assert (betapdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]) %!assert (betapdf ([x, NaN], 1, 2), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (betapdf (single ([x, NaN]), 1, 2), single ([y, NaN])) %!assert (betapdf ([x, NaN], single (1), 2), single ([y, NaN])) %!assert (betapdf ([x, NaN], 1, single (2)), single ([y, NaN])) -%% Beta (1/2,1/2) == arcsine distribution +## Beta (1/2,1/2) == arcsine distribution %!test %! x = rand (10,1); %! y = 1./(pi * sqrt (x.*(1-x))); %! assert (betapdf (x, 1/2, 1/2), y, 50*eps); -%% Test large input values to betapdf +## Test large input values to betapdf %!assert (betapdf (0.5, 1000, 1000), 35.678, 1e-3) -%% Test input validation +## Test input validation %!error betapdf () %!error betapdf (1) %!error betapdf (1,2)
--- a/scripts/statistics/distributions/betarnd.m +++ b/scripts/statistics/distributions/betarnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, a, b] = common_size (a, b); if (retval > 0) error ("betarnd: A and B must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("betarnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("betarnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (a) && !isequal (size (a), sz)) + if (! isscalar (a) && ! isequal (size (a), sz)) error ("betarnd: A and B must be scalar or of size SZ"); endif @@ -109,14 +109,14 @@ %!assert (size (betarnd (1, 2, [4 1])), [4, 1]) %!assert (size (betarnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (betarnd (1, 2)), "double") %!assert (class (betarnd (single (1), 2)), "single") %!assert (class (betarnd (single ([1 1]), 2)), "single") %!assert (class (betarnd (1, single (2))), "single") %!assert (class (betarnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error betarnd () %!error betarnd (1) %!error betarnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/binocdf.m +++ b/scripts/statistics/distributions/binocdf.m @@ -34,7 +34,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, x, n, p] = common_size (x, n, p); if (retval > 0) error ("binocdf: X, N, and P must be of common size or scalars"); @@ -78,13 +78,13 @@ %!assert (binocdf (x, 2, 0.5*[0 -1 NaN 3 1]), [0 NaN NaN NaN 1]) %!assert (binocdf ([x(1:2) NaN x(4:5)], 2, 0.5), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (binocdf ([x, NaN], 2, 0.5), [y, NaN]) %!assert (binocdf (single ([x, NaN]), 2, 0.5), single ([y, NaN])) %!assert (binocdf ([x, NaN], single (2), 0.5), single ([y, NaN])) %!assert (binocdf ([x, NaN], 2, single (0.5)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error binocdf () %!error binocdf (1) %!error binocdf (1,2)
--- a/scripts/statistics/distributions/binoinv.m +++ b/scripts/statistics/distributions/binoinv.m @@ -34,7 +34,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, x, n, p] = common_size (x, n, p); if (retval > 0) error ("binoinv: X, N, and P must be of common size or scalars"); @@ -95,13 +95,13 @@ %!assert (binoinv (x, 2, 0.5*[0 -1 NaN 3 1]), [NaN NaN NaN NaN NaN]) %!assert (binoinv ([x(1:2) NaN x(4:5)], 2, 0.5), [NaN 0 NaN 2 NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (binoinv ([x, NaN], 2, 0.5), [NaN 0 1 2 NaN NaN]) %!assert (binoinv (single ([x, NaN]), 2, 0.5), single ([NaN 0 1 2 NaN NaN])) %!assert (binoinv ([x, NaN], single (2), 0.5), single ([NaN 0 1 2 NaN NaN])) %!assert (binoinv ([x, NaN], 2, single (0.5)), single ([NaN 0 1 2 NaN NaN])) -%% Test input validation +## Test input validation %!error binoinv () %!error binoinv (1) %!error binoinv (1,2)
--- a/scripts/statistics/distributions/binopdf.m +++ b/scripts/statistics/distributions/binopdf.m @@ -93,12 +93,12 @@ %!assert (binopdf (2, 2, 1), 1); %!assert (binopdf (1, 2, 1), 0); -%% Test class of input preserved +## Test class of input preserved %!assert (binopdf (single ([x, NaN]), 2, 0.5), single ([y, NaN])) %!assert (binopdf ([x, NaN], single (2), 0.5), single ([y, NaN])) %!assert (binopdf ([x, NaN], 2, single (0.5)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error binopdf () %!error binopdf (1) %!error binopdf (1,2)
--- a/scripts/statistics/distributions/binornd.m +++ b/scripts/statistics/distributions/binornd.m @@ -45,7 +45,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, n, p] = common_size (n, p); if (retval > 0) error ("binornd: N and P must be of common size or scalars"); @@ -67,13 +67,13 @@ error ("binornd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("binornd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (n) && !isequal (size (n), sz)) + if (! isscalar (n) && ! isequal (size (n), sz)) error ("binornd: N and P must be scalar or of size SZ"); endif @@ -129,14 +129,14 @@ %!assert (size (binornd (2, 1/2, [4 1])), [4, 1]) %!assert (size (binornd (2, 1/2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (binornd (2, 0.5)), "double") %!assert (class (binornd (single (2), 0.5)), "single") %!assert (class (binornd (single ([2 2]), 0.5)), "single") %!assert (class (binornd (2, single (0.5))), "single") %!assert (class (binornd (2, single ([0.5 0.5]))), "single") -%% Test input validation +## Test input validation %!error binornd () %!error binornd (1) %!error binornd (ones (3), ones (2))
--- a/scripts/statistics/distributions/cauchy_cdf.m +++ b/scripts/statistics/distributions/cauchy_cdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (location) || !isscalar (scale)) + if (! isscalar (location) || ! isscalar (scale)) [retval, x, location, scale] = common_size (x, location, scale); if (retval > 0) error ("cauchy_cdf: X, LOCATION, and SCALE must be of common size or scalars"); @@ -52,7 +52,7 @@ cdf = NaN (size (x)); endif - k = !isinf (location) & (scale > 0) & (scale < Inf); + k = ! isinf (location) & (scale > 0) & (scale < Inf); if (isscalar (location) && isscalar (scale)) cdf = 0.5 + atan ((x - location) / scale) / pi; else @@ -72,13 +72,13 @@ %!assert (cauchy_cdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]) %!assert (cauchy_cdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (cauchy_cdf ([x, NaN], 1, 2), [y, NaN]) %!assert (cauchy_cdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single")) %!assert (cauchy_cdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single")) %!assert (cauchy_cdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error cauchy_cdf () %!error cauchy_cdf (1,2) %!error cauchy_cdf (1,2,3,4)
--- a/scripts/statistics/distributions/cauchy_inv.m +++ b/scripts/statistics/distributions/cauchy_inv.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (location) || !isscalar (scale)) + if (! isscalar (location) || ! isscalar (scale)) [retval, x, location, scale] = common_size (x, location, scale); if (retval > 0) error ("cauchy_inv: X, LOCATION, and SCALE must be of common size or scalars"); @@ -52,7 +52,7 @@ inv = NaN (size (x)); endif - ok = !isinf (location) & (scale > 0) & (scale < Inf); + ok = ! isinf (location) & (scale > 0) & (scale < Inf); k = (x == 0) & ok; inv(k) = -Inf; @@ -79,13 +79,13 @@ %!assert (cauchy_inv (x, 1, 2*[1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (cauchy_inv ([x(1:2) NaN x(4:5)], 1, 2), [NaN -Inf NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (cauchy_inv ([x, NaN], 1, 2), [NaN -Inf 1 Inf NaN NaN], eps) %!assert (cauchy_inv (single ([x, NaN]), 1, 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) %!assert (cauchy_inv ([x, NaN], single (1), 2), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) %!assert (cauchy_inv ([x, NaN], 1, single (2)), single ([NaN -Inf 1 Inf NaN NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error cauchy_inv () %!error cauchy_inv (1,2) %!error cauchy_inv (1,2,3,4)
--- a/scripts/statistics/distributions/cauchy_pdf.m +++ b/scripts/statistics/distributions/cauchy_pdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (location) || !isscalar (scale)) + if (! isscalar (location) || ! isscalar (scale)) [retval, x, location, scale] = common_size (x, location, scale); if (retval > 0) error ("cauchy_pdf: X, LOCATION, and SCALE must be of common size or scalars"); @@ -52,7 +52,7 @@ pdf = NaN (size (x)); endif - k = !isinf (location) & (scale > 0) & (scale < Inf); + k = ! isinf (location) & (scale > 0) & (scale < Inf); if (isscalar (location) && isscalar (scale)) pdf = ((1 ./ (1 + ((x - location) / scale) .^ 2)) / pi / scale); @@ -74,17 +74,17 @@ %!assert (cauchy_pdf (x, 1, 2*[0 1 NaN 1 Inf]), [NaN y(2) NaN y(4) NaN]) %!assert (cauchy_pdf ([x, NaN], 1, 2), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (cauchy_pdf (single ([x, NaN]), 1, 2), single ([y, NaN]), eps ("single")) %!assert (cauchy_pdf ([x, NaN], single (1), 2), single ([y, NaN]), eps ("single")) %!assert (cauchy_pdf ([x, NaN], 1, single (2)), single ([y, NaN]), eps ("single")) -%% Cauchy (0,1) == Student's T distribution with 1 DOF +## Cauchy (0,1) == Student's T distribution with 1 DOF %!test %! x = rand (10, 1); %! assert (cauchy_pdf (x, 0, 1), tpdf (x, 1), eps); -%% Test input validation +## Test input validation %!error cauchy_pdf () %!error cauchy_pdf (1,2) %!error cauchy_pdf (1,2,3,4)
--- a/scripts/statistics/distributions/cauchy_rnd.m +++ b/scripts/statistics/distributions/cauchy_rnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (location) || !isscalar (scale)) + if (! isscalar (location) || ! isscalar (scale)) [retval, location, scale] = common_size (location, scale); if (retval > 0) error ("cauchy_rnd: LOCATION and SCALE must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("cauchy_rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("cauchy_rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (location) && !isequal (size (location), sz)) + if (! isscalar (location) && ! isequal (size (location), sz)) error ("cauchy_rnd: LOCATION and SCALE must be scalar or of size SZ"); endif @@ -83,7 +83,7 @@ endif if (isscalar (location) && isscalar (scale)) - if (!isinf (location) && (scale > 0) && (scale < Inf)) + if (! isinf (location) && (scale > 0) && (scale < Inf)) rnd = location - cot (pi * rand (sz, cls)) * scale; else rnd = NaN (sz, cls); @@ -91,8 +91,9 @@ else rnd = NaN (sz, cls); - k = !isinf (location) & (scale > 0) & (scale < Inf); - rnd(k) = location(k)(:) - cot (pi * rand (sum (k(:)), 1, cls)) .* scale(k)(:); + k = ! isinf (location) & (scale > 0) & (scale < Inf); + rnd(k) = location(k)(:) ... + - cot (pi * rand (sum (k(:)), 1, cls)) .* scale(k)(:); endif endfunction @@ -107,14 +108,14 @@ %!assert (size (cauchy_rnd (1, 2, [4 1])), [4, 1]) %!assert (size (cauchy_rnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (cauchy_rnd (1, 2)), "double") %!assert (class (cauchy_rnd (single (1), 2)), "single") %!assert (class (cauchy_rnd (single ([1 1]), 2)), "single") %!assert (class (cauchy_rnd (1, single (2))), "single") %!assert (class (cauchy_rnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error cauchy_rnd () %!error cauchy_rnd (1) %!error cauchy_rnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/chi2cdf.m +++ b/scripts/statistics/distributions/chi2cdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("chi2cdf: X and N must be of common size or scalars"); @@ -57,12 +57,12 @@ %!assert (chi2cdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps) %!assert (chi2cdf ([x(1:2) NaN x(4:5)], 2), [y(1:2) NaN y(4:5)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (chi2cdf ([x, NaN], 2), [y, NaN], eps) %!assert (chi2cdf (single ([x, NaN]), 2), single ([y, NaN]), eps ("single")) %!assert (chi2cdf ([x, NaN], single (2)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error chi2cdf () %!error chi2cdf (1) %!error chi2cdf (1,2,3)
--- a/scripts/statistics/distributions/chi2inv.m +++ b/scripts/statistics/distributions/chi2inv.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("chi2inv: X and N must be of common size or scalars"); @@ -56,12 +56,12 @@ %!assert (chi2inv (x, 2*[0 1 NaN 1 1]), [NaN 0 NaN Inf NaN], 5*eps) %!assert (chi2inv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], 5*eps) -%% Test class of input preserved +## Test class of input preserved %!assert (chi2inv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], 5*eps) %!assert (chi2inv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single")) %!assert (chi2inv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), 5*eps ("single")) -%% Test input validation +## Test input validation %!error chi2inv () %!error chi2inv (1) %!error chi2inv (1,2,3)
--- a/scripts/statistics/distributions/chi2pdf.m +++ b/scripts/statistics/distributions/chi2pdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("chi2pdf: X and N must be of common size or scalars"); @@ -57,11 +57,11 @@ %!assert (chi2pdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) %!assert (chi2pdf ([x, NaN], 2), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (chi2pdf (single ([x, NaN]), 2), single ([y, NaN])) %!assert (chi2pdf ([x, NaN], single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error chi2pdf () %!error chi2pdf (1) %!error chi2pdf (1,2,3)
--- a/scripts/statistics/distributions/chi2rnd.m +++ b/scripts/statistics/distributions/chi2rnd.m @@ -55,13 +55,13 @@ error ("chi2rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("chi2rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (n) && !isequal (size (n), sz)) + if (! isscalar (n) && ! isequal (size (n), sz)) error ("chi2rnd: N must be scalar or of size SZ"); endif @@ -98,12 +98,12 @@ %!assert (size (chi2rnd (1, [4 1])), [4, 1]) %!assert (size (chi2rnd (1, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (chi2rnd (2)), "double") %!assert (class (chi2rnd (single (2))), "single") %!assert (class (chi2rnd (single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error chi2rnd () %!error chi2rnd (ones (3), ones (2)) %!error chi2rnd (ones (2), ones (3))
--- a/scripts/statistics/distributions/discrete_cdf.m +++ b/scripts/statistics/distributions/discrete_cdf.m @@ -48,7 +48,7 @@ cdf = NaN (size (x)); endif - k = !isnan (x); + k = ! isnan (x); [vs, vi] = sort (v); cdf(k) = [0 ; cumsum(p(vi))](lookup (vs, x(k)) + 1); @@ -62,12 +62,12 @@ %! y = [0 0.1 0.6 1 1]; %!assert (discrete_cdf ([x, NaN], v, p), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (discrete_cdf (single ([x, NaN]), v, p), single ([y, NaN]), 2*eps ("single")) %!assert (discrete_cdf ([x, NaN], single (v), p), single ([y, NaN]), 2*eps ("single")) %!assert (discrete_cdf ([x, NaN], v, single (p)), single ([y, NaN]), 2*eps ("single")) -%% Test input validation +## Test input validation %!error discrete_cdf () %!error discrete_cdf (1) %!error discrete_cdf (1,2)
--- a/scripts/statistics/distributions/discrete_inv.m +++ b/scripts/statistics/distributions/discrete_inv.m @@ -77,12 +77,12 @@ %! y = [NaN v(1) v(1) v(end/2) v(end) NaN]; %!assert (discrete_inv ([x, NaN], v, p), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (discrete_inv (single ([x, NaN]), v, p), single ([y, NaN]), eps ("single")) %!assert (discrete_inv ([x, NaN], single (v), p), single ([y, NaN]), eps ("single")) %!assert (discrete_inv ([x, NaN], v, single (p)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error discrete_inv () %!error discrete_inv (1) %!error discrete_inv (1,2)
--- a/scripts/statistics/distributions/discrete_pdf.m +++ b/scripts/statistics/distributions/discrete_pdf.m @@ -52,7 +52,7 @@ pdf = NaN (size (x)); endif - k = !isnan (x); + k = ! isnan (x); [vs, vi] = sort (v(:)); pdf(k) = p([0 ; vi](lookup (vs, x(k), 'm') + 1) + 1); @@ -66,12 +66,12 @@ %! y = [0 0.1 0.1 0.1 0]; %!assert (discrete_pdf ([x, NaN], v, p), [y, NaN], 5*eps) -%% Test class of input preserved +## Test class of input preserved %!assert (discrete_pdf (single ([x, NaN]), v, p), single ([y, NaN]), 5*eps ("single")) %!assert (discrete_pdf ([x, NaN], single (v), p), single ([y, NaN]), 5*eps ("single")) %!assert (discrete_pdf ([x, NaN], v, single (p)), single ([y, NaN]), 5*eps ("single")) -%% Test input validation +## Test input validation %!error discrete_pdf () %!error discrete_pdf (1) %!error discrete_pdf (1,2)
--- a/scripts/statistics/distributions/discrete_rnd.m +++ b/scripts/statistics/distributions/discrete_rnd.m @@ -65,7 +65,7 @@ error ("discrete_rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("discrete_rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; @@ -81,13 +81,13 @@ %!assert (size (discrete_rnd (1:2, 1:2, [4 1])), [4, 1]) %!assert (size (discrete_rnd (1:2, 1:2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (discrete_rnd (1:2, 1:2)), "double") %!assert (class (discrete_rnd (single (1:2), 1:2)), "single") ## FIXME: Maybe this should work, maybe it shouldn't. #%!assert(class (discrete_rnd (1:2, single(1:2))), "single"); -%% Test input validation +## Test input validation %!error discrete_rnd () %!error discrete_rnd (1) %!error discrete_rnd (1:2,1:2, -1) @@ -95,7 +95,7 @@ %!error discrete_rnd (1:2,1:2, [2 -1 2]) %!error discrete_rnd (1:2,1:2, 1, ones (2)) %!error discrete_rnd (1:2,1:2, 1, -1) -%% test v,p verification +## test v,p verification %!error discrete_rnd (1, ones (2), ones (2,1)) %!error discrete_rnd (1, ones (2,1), ones (1,1)) %!error discrete_rnd (1, ones (2,1), [1 -1])
--- a/scripts/statistics/distributions/empirical_cdf.m +++ b/scripts/statistics/distributions/empirical_cdf.m @@ -49,12 +49,12 @@ %!assert (empirical_cdf (x, v), y, eps) %!assert (empirical_cdf ([x(1) NaN x(3:5)], v), [0 NaN 0.6 1 1], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (empirical_cdf ([x, NaN], v), [y, NaN], eps) %!assert (empirical_cdf (single ([x, NaN]), v), single ([y, NaN]), eps) %!assert (empirical_cdf ([x, NaN], single (v)), single ([y, NaN]), eps) -%% Test input validation +## Test input validation %!error empirical_cdf () %!error empirical_cdf (1) %!error empirical_cdf (1,2,3)
--- a/scripts/statistics/distributions/empirical_inv.m +++ b/scripts/statistics/distributions/empirical_inv.m @@ -48,12 +48,12 @@ %! y = [NaN v(1) v(1) v(end/2) v(end) NaN]; %!assert (empirical_inv (x, v), y, eps) -%% Test class of input preserved +## Test class of input preserved %!assert (empirical_inv ([x, NaN], v), [y, NaN], eps) %!assert (empirical_inv (single ([x, NaN]), v), single ([y, NaN]), eps) %!assert (empirical_inv ([x, NaN], single (v)), single ([y, NaN]), eps) -%% Test input validation +## Test input validation %!error empirical_inv () %!error empirical_inv (1) %!error empirical_inv (1,2,3)
--- a/scripts/statistics/distributions/empirical_pdf.m +++ b/scripts/statistics/distributions/empirical_pdf.m @@ -57,14 +57,14 @@ %! y = [0 0.1 0.1 0.1 0]; %!assert (empirical_pdf (x, v), y) -%% Test class of input preserved +## Test class of input preserved %!assert (empirical_pdf (single (x), v), single (y)) %!assert (empirical_pdf (x, single (v)), single (y)) -%% Test distribution with ties +## Test distribution with ties %!assert (empirical_pdf (2, [1 2 3 2]), 0.5) -%% Test input validation +## Test input validation %!error empirical_pdf () %!error empirical_pdf (1) %!error empirical_pdf (1,2,3)
--- a/scripts/statistics/distributions/empirical_rnd.m +++ b/scripts/statistics/distributions/empirical_rnd.m @@ -57,13 +57,12 @@ %!assert (size (empirical_rnd (1:2, [4 1])), [4, 1]) %!assert (size (empirical_rnd (1:2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (empirical_rnd (1:2, 1)), "double") %!assert (class (empirical_rnd (single (1:2), 1)), "single") -%% Test input validation +## Test input validation %!error empirical_rnd () %!error empirical_rnd (ones (2), 1) -%% test data verification %!error empirical_rnd (ones (2), 1, 1)
--- a/scripts/statistics/distributions/expcdf.m +++ b/scripts/statistics/distributions/expcdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("expcdf: X and LAMBDA must be of common size or scalars"); @@ -75,12 +75,12 @@ %!assert (expcdf (x, 2), y) %!assert (expcdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (expcdf ([x, NaN], 2), [y, NaN]) %!assert (expcdf (single ([x, NaN]), 2), single ([y, NaN])) %!assert (expcdf ([x, NaN], single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error expcdf () %!error expcdf (1) %!error expcdf (1,2,3)
--- a/scripts/statistics/distributions/expinv.m +++ b/scripts/statistics/distributions/expinv.m @@ -32,7 +32,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("expinv: X and LAMBDA must be of common size or scalars"); @@ -43,7 +43,7 @@ error ("expinv: X and LAMBDA must not be complex"); endif - if (!isscalar (x)) + if (! isscalar (x)) sz = size (x); else sz = size (lambda); @@ -79,12 +79,12 @@ %!assert (expinv (x, 2*[1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps) %!assert (expinv ([x(1:2) NaN x(4:5)], 2), [NaN 0 NaN Inf NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (expinv ([x, NaN], 2), [NaN 0 1 Inf NaN NaN], eps) %!assert (expinv (single ([x, NaN]), 2), single ([NaN 0 1 Inf NaN NaN]), eps) %!assert (expinv ([x, NaN], single (2)), single ([NaN 0 1 Inf NaN NaN]), eps) -%% Test input validation +## Test input validation %!error expinv () %!error expinv (1) %!error expinv (1,2,3)
--- a/scripts/statistics/distributions/exppdf.m +++ b/scripts/statistics/distributions/exppdf.m @@ -32,7 +32,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("exppdf: X and LAMBDA must be of common size or scalars"); @@ -69,11 +69,11 @@ %!assert (exppdf (x, 2*[1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) %!assert (exppdf ([x, NaN], 2), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (exppdf (single ([x, NaN]), 2), single ([y, NaN])) %!assert (exppdf ([x, NaN], single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error exppdf () %!error exppdf (1) %!error exppdf (1,2,3)
--- a/scripts/statistics/distributions/exprnd.m +++ b/scripts/statistics/distributions/exprnd.m @@ -55,13 +55,13 @@ error ("exprnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("exprnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (lambda) && !isequal (size (lambda), sz)) + if (! isscalar (lambda) && ! isequal (size (lambda), sz)) error ("exprnd: LAMBDA must be scalar or of size SZ"); endif @@ -98,12 +98,12 @@ %!assert (size (exprnd (1, [4 1])), [4, 1]) %!assert (size (exprnd (1, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (exprnd (1)), "double") %!assert (class (exprnd (single (1))), "single") %!assert (class (exprnd (single ([1 1]))), "single") -%% Test input validation +## Test input validation %!error exprnd () %!error exprnd (1, -1) %!error exprnd (1, ones (2))
--- a/scripts/statistics/distributions/fcdf.m +++ b/scripts/statistics/distributions/fcdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (m) || !isscalar (n)) + if (! isscalar (m) || ! isscalar (n)) [retval, x, m, n] = common_size (x, m, n); if (retval > 0) error ("fcdf: X, M, and N must be of common size or scalars"); @@ -76,13 +76,13 @@ %!assert (fcdf (x, 2, [0 NaN Inf 2 2 2]), [NaN NaN NaN y(4:6)], eps) %!assert (fcdf ([x(1:2) NaN x(4:6)], 2, 2), [y(1:2) NaN y(4:6)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (fcdf ([x, NaN], 2, 2), [y, NaN], eps) %!assert (fcdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single")) %!assert (fcdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single")) %!assert (fcdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error fcdf () %!error fcdf (1) %!error fcdf (1,2)
--- a/scripts/statistics/distributions/finv.m +++ b/scripts/statistics/distributions/finv.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (m) || !isscalar (n)) + if (! isscalar (m) || ! isscalar (n)) [retval, x, m, n] = common_size (x, m, n); if (retval > 0) error ("finv: X, M, and N must be of common size or scalars"); @@ -73,13 +73,13 @@ %!assert (finv (x, 2, [2 -Inf NaN Inf 2]), [NaN NaN NaN NaN NaN]) %!assert (finv ([x(1:2) NaN x(4:5)], 2, 2), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (finv ([x, NaN], 2, 2), [NaN 0 1 Inf NaN NaN]) %!assert (finv (single ([x, NaN]), 2, 2), single ([NaN 0 1 Inf NaN NaN])) %!assert (finv ([x, NaN], single (2), 2), single ([NaN 0 1 Inf NaN NaN])) %!assert (finv ([x, NaN], 2, single (2)), single ([NaN 0 1 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error finv () %!error finv (1) %!error finv (1,2)
--- a/scripts/statistics/distributions/fpdf.m +++ b/scripts/statistics/distributions/fpdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (m) || !isscalar (n)) + if (! isscalar (m) || ! isscalar (n)) [retval, x, m, n] = common_size (x, m, n); if (retval > 0) error ("fpdf: X, M, and N must be of common size or scalars"); @@ -69,7 +69,7 @@ endfunction -%% F (x, 1, m) == T distribution (sqrt (x), m) / sqrt (x) +## F (x, 1, m) == T distribution (sqrt (x), m) / sqrt (x) %!test %! x = rand (10,1); %! x = x(x > 0.1 & x < 0.9); @@ -86,12 +86,12 @@ %!assert (fpdf (x, 2, [0 NaN Inf 2 2]), [NaN NaN NaN y(4:5)], eps) %!assert (fpdf ([x, NaN], 2, 2), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (fpdf (single ([x, NaN]), 2, 2), single ([y, NaN]), eps ("single")) %!assert (fpdf ([x, NaN], single (2), 2), single ([y, NaN]), eps ("single")) %!assert (fpdf ([x, NaN], 2, single (2)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error fpdf () %!error fpdf (1) %!error fpdf (1,2)
--- a/scripts/statistics/distributions/frnd.m +++ b/scripts/statistics/distributions/frnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (m) || !isscalar (n)) + if (! isscalar (m) || ! isscalar (n)) [retval, m, n] = common_size (m, n); if (retval > 0) error ("frnd: M and N must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("frnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("frnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (m) && !isequal (size (m), sz)) + if (! isscalar (m) && ! isequal (size (m), sz)) error ("frnd: M and N must be scalar or of size SZ"); endif @@ -107,14 +107,14 @@ %!assert (size (frnd (1, 2, [4 1])), [4, 1]) %!assert (size (frnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (frnd (1, 2)), "double") %!assert (class (frnd (single (1), 2)), "single") %!assert (class (frnd (single ([1 1]), 2)), "single") %!assert (class (frnd (1, single (2))), "single") %!assert (class (frnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error frnd () %!error frnd (1) %!error frnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/gamcdf.m +++ b/scripts/statistics/distributions/gamcdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("gamcdf: X, A, and B must be of common size or scalars"); @@ -73,11 +73,11 @@ %!assert (gamcdf (x, 1, [0 -Inf NaN Inf 1 1]), [NaN NaN NaN NaN y(5:6)]) %!assert (gamcdf ([x(1:2) NaN x(4:6)], 1, 1), [y(1:2) NaN y(4:6)]) -%% Test class of input preserved +## Test class of input preserved %!assert (gamcdf ([x, NaN], 1, 1), [y, NaN]) %!assert (gamcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error gamcdf () %!error gamcdf (1) %!error gamcdf (1,2)
--- a/scripts/statistics/distributions/gaminv.m +++ b/scripts/statistics/distributions/gaminv.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("gaminv: X, A, and B must be of common size or scalars"); @@ -59,7 +59,7 @@ k = find ((x > 0) & (x < 1) & (a > 0) & (a < Inf) & (b > 0) & (b < Inf)); if (any (k)) - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) a = a(k); b = b(k); y = a .* b; @@ -85,7 +85,7 @@ y_new = y_old - h; ind = find (y_new <= myeps); if (any (ind)) - y_new (ind) = y_old (ind) / 10; + y_new(ind) = y_old(ind) / 10; h = y_old - y_new; endif if (max (abs (h)) < sqrt (myeps)) @@ -109,13 +109,13 @@ %!assert (gaminv (x, 1, [1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (gaminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (gaminv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps) %!assert (gaminv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %!assert (gaminv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %!assert (gaminv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error gaminv () %!error gaminv (1) %!error gaminv (1,2)
--- a/scripts/statistics/distributions/gampdf.m +++ b/scripts/statistics/distributions/gampdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("gampdf: X, A, and B must be of common size or scalars"); @@ -84,12 +84,12 @@ %!assert (gampdf (x, 1, [0 -Inf NaN Inf 1]), [NaN NaN NaN 0 y(5)]) %!assert (gampdf ([x, NaN], 1, 1), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (gampdf (single ([x, NaN]), 1, 1), single ([y, NaN])) %!assert (gampdf ([x, NaN], single (1), 1), single ([y, NaN])) %!assert (gampdf ([x, NaN], 1, single (1)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error gampdf () %!error gampdf (1) %!error gampdf (1,2)
--- a/scripts/statistics/distributions/gamrnd.m +++ b/scripts/statistics/distributions/gamrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, a, b] = common_size (a, b); if (retval > 0) error ("gamrnd: A and B must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("gamrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("gamrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (a) && !isequal (size (a), sz)) + if (! isscalar (a) && ! isequal (size (a), sz)) error ("gamrnd: A and B must be scalar or of size SZ"); endif @@ -107,14 +107,14 @@ %!assert (size (gamrnd (1, 2, [4 1])), [4, 1]) %!assert (size (gamrnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (gamrnd (1, 2)), "double") %!assert (class (gamrnd (single (1), 2)), "single") %!assert (class (gamrnd (single ([1 1]), 2)), "single") %!assert (class (gamrnd (1, single (2))), "single") %!assert (class (gamrnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error gamrnd () %!error gamrnd (1) %!error gamrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/geocdf.m +++ b/scripts/statistics/distributions/geocdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (p)) + if (! isscalar (p)) [retval, x, p] = common_size (x, p); if (retval > 0) error ("geocdf: X and P must be of common size or scalars"); @@ -76,12 +76,12 @@ %!assert (geocdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]) %!assert (geocdf ([x(1:2) NaN x(4)], 0.5), [y(1:2) NaN y(4)]) -%% Test class of input preserved +## Test class of input preserved %!assert (geocdf ([x, NaN], 0.5), [y, NaN]) %!assert (geocdf (single ([x, NaN]), 0.5), single ([y, NaN])) %!assert (geocdf ([x, NaN], single (0.5)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error geocdf () %!error geocdf (1) %!error geocdf (1,2,3)
--- a/scripts/statistics/distributions/geoinv.m +++ b/scripts/statistics/distributions/geoinv.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (p)) + if (! isscalar (p)) [retval, x, p] = common_size (x, p); if (retval > 0) error ("geoinv: X and P must be of common size or scalars"); @@ -72,12 +72,12 @@ %!assert (geoinv (x, 0.5*[1 -1 NaN 4 1]), [NaN NaN NaN NaN NaN]) %!assert (geoinv ([x(1:2) NaN x(4:5)], 0.5), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (geoinv ([x, NaN], 0.5), [NaN 0 1 Inf NaN NaN]) %!assert (geoinv (single ([x, NaN]), 0.5), single ([NaN 0 1 Inf NaN NaN])) %!assert (geoinv ([x, NaN], single (0.5)), single ([NaN 0 1 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error geoinv () %!error geoinv (1) %!error geoinv (1,2,3)
--- a/scripts/statistics/distributions/geopdf.m +++ b/scripts/statistics/distributions/geopdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (p)) + if (! isscalar (p)) [retval, x, p] = common_size (x, p); if (retval > 0) error ("geopdf: X and P must be of common size or scalars"); @@ -73,11 +73,11 @@ %!assert (geopdf (x, 0.5*[-1 NaN 4 1]), [NaN NaN NaN y(4)]) %!assert (geopdf ([x, NaN], 0.5), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (geopdf (single ([x, NaN]), 0.5), single ([y, NaN]), 5*eps ("single")) %!assert (geopdf ([x, NaN], single (0.5)), single ([y, NaN]), 5*eps ("single")) -%% Test input validation +## Test input validation %!error geopdf () %!error geopdf (1) %!error geopdf (1,2,3)
--- a/scripts/statistics/distributions/geornd.m +++ b/scripts/statistics/distributions/geornd.m @@ -58,13 +58,13 @@ error ("geornd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("geornd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (p) && !isequal (size (p), sz)) + if (! isscalar (p) && ! isequal (size (p), sz)) error ("geornd: P must be scalar or of size SZ"); endif @@ -108,14 +108,14 @@ %!assert (size (geornd (0.5, [4 1])), [4, 1]) %!assert (size (geornd (0.5, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (geornd (0.5)), "double") %!assert (class (geornd (single (0.5))), "single") %!assert (class (geornd (single ([0.5 0.5]))), "single") %!assert (class (geornd (single (0))), "single") %!assert (class (geornd (single (1))), "single") -%% Test input validation +## Test input validation %!error geornd () %!error geornd (ones (3), ones (2)) %!error geornd (ones (2), ones (3))
--- a/scripts/statistics/distributions/hygecdf.m +++ b/scripts/statistics/distributions/hygecdf.m @@ -39,7 +39,7 @@ print_usage (); endif - if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + if (! isscalar (t) || ! isscalar (m) || ! isscalar (n)) [retval, x, t, m, n] = common_size (x, t, m, n); if (retval > 0) error ("hygecdf: X, T, M, and N must be of common size or scalars"); @@ -50,7 +50,8 @@ error ("hygecdf: X, T, M, and N must not be complex"); endif - if (isa (x, "single") || isa (t, "single") || isa (m, "single") || isa (n, "single")) + if (isa (x, "single") || isa (t, "single") + || isa (m, "single") || isa (n, "single")) cdf = NaN (size (x), "single"); else cdf = NaN (size (x)); @@ -86,14 +87,14 @@ %!assert (hygecdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) %!assert (hygecdf ([x(1:2) NaN x(4:5)], 4, 2, 2), [y(1:2) NaN y(4:5)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (hygecdf ([x, NaN], 4, 2, 2), [y, NaN], eps) %!assert (hygecdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN]), eps ("single")) %!assert (hygecdf ([x, NaN], single (4), 2, 2), single ([y, NaN]), eps ("single")) %!assert (hygecdf ([x, NaN], 4, single (2), 2), single ([y, NaN]), eps ("single")) %!assert (hygecdf ([x, NaN], 4, 2, single (2)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error hygecdf () %!error hygecdf (1) %!error hygecdf (1,2)
--- a/scripts/statistics/distributions/hygeinv.m +++ b/scripts/statistics/distributions/hygeinv.m @@ -39,7 +39,7 @@ print_usage (); endif - if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + if (! isscalar (t) || ! isscalar (m) || ! isscalar (n)) [retval, x, t, m, n] = common_size (x, t, m, n); if (retval > 0) error ("hygeinv: X, T, M, and N must be of common size or scalars"); @@ -50,7 +50,8 @@ error ("hygeinv: X, T, M, and N must not be complex"); endif - if (isa (x, "single") || isa (t, "single") || isa (m, "single") || isa (n, "single")) + if (isa (x, "single") || isa (t, "single") + || isa (m, "single") || isa (n, "single")) inv = NaN (size (x), "single"); else inv = NaN (size (x)); @@ -91,14 +92,14 @@ %!assert (hygeinv (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) %!assert (hygeinv ([x(1:2) NaN x(4:5)], 4, 2, 2), [NaN 0 NaN 2 NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (hygeinv ([x, NaN], 4, 2, 2), [NaN 0 1 2 NaN NaN]) %!assert (hygeinv (single ([x, NaN]), 4, 2, 2), single ([NaN 0 1 2 NaN NaN])) %!assert (hygeinv ([x, NaN], single (4), 2, 2), single ([NaN 0 1 2 NaN NaN])) %!assert (hygeinv ([x, NaN], 4, single (2), 2), single ([NaN 0 1 2 NaN NaN])) %!assert (hygeinv ([x, NaN], 4, 2, single (2)), single ([NaN 0 1 2 NaN NaN])) -%% Test input validation +## Test input validation %!error hygeinv () %!error hygeinv (1) %!error hygeinv (1,2)
--- a/scripts/statistics/distributions/hygepdf.m +++ b/scripts/statistics/distributions/hygepdf.m @@ -38,7 +38,7 @@ print_usage (); endif - if (!isscalar (t) || !isscalar (m) || !isscalar (n)) + if (! isscalar (t) || ! isscalar (m) || ! isscalar (n)) [retval, x, t, m, n] = common_size (x, t, m, n); if (retval > 0) error ("hygepdf: X, T, M, and N must be of common size or scalars"); @@ -49,7 +49,8 @@ error ("hygepdf: X, T, M, and N must not be complex"); endif - if (isa (x, "single") || isa (t, "single") || isa (m, "single") || isa (n, "single")) + if (isa (x, "single") || isa (t, "single") + || isa (m, "single") || isa (n, "single")) pdf = zeros (size (x), "single"); else pdf = zeros (size (x)); @@ -90,13 +91,13 @@ %!assert (hygepdf (x, 4, 2, 5), [NaN NaN NaN NaN NaN]) %!assert (hygepdf ([x, NaN], 4, 2, 2), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (hygepdf (single ([x, NaN]), 4, 2, 2), single ([y, NaN])) %!assert (hygepdf ([x, NaN], single (4), 2, 2), single ([y, NaN])) %!assert (hygepdf ([x, NaN], 4, single (2), 2), single ([y, NaN])) %!assert (hygepdf ([x, NaN], 4, 2, single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error hygepdf () %!error hygepdf (1) %!error hygepdf (1,2)
--- a/scripts/statistics/distributions/hygernd.m +++ b/scripts/statistics/distributions/hygernd.m @@ -66,13 +66,13 @@ error ("hygernd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 4) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("hygernd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (t) && !isequal (size (t), sz)) + if (! isscalar (t) && ! isequal (size (t), sz)) error ("hygernd: T, M, and N must be scalar or of size SZ"); endif @@ -129,7 +129,7 @@ %!assert (class (hygernd (4,2,single (2))), "single") %!assert (class (hygernd (4,2,single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error hygernd () %!error hygernd (1) %!error hygernd (1,2)
--- a/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m +++ b/scripts/statistics/distributions/kolmogorov_smirnov_cdf.m @@ -87,7 +87,7 @@ endfunction -%% Test input validation +## Test input validation %!error kolmogorov_smirnov_cdf () %!error kolmogorov_smirnov_cdf (1,2,3) %!error kolmogorov_smirnov_cdf (1, ones (2))
--- a/scripts/statistics/distributions/laplace_cdf.m +++ b/scripts/statistics/distributions/laplace_cdf.m @@ -46,10 +46,10 @@ %! y = [0, 1/4, 1/2, 3/4, 1]; %!assert (laplace_cdf ([x, NaN]), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (laplace_cdf (single ([x, NaN])), single ([y, NaN])) -%% Test input validation +## Test input validation %!error laplace_cdf () %!error laplace_cdf (1,2) %!error laplace_cdf (i)
--- a/scripts/statistics/distributions/laplace_inv.m +++ b/scripts/statistics/distributions/laplace_inv.m @@ -53,11 +53,11 @@ %! x = [-1 0 0.5 1 2]; %!assert (laplace_inv (x), [NaN -Inf 0 Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (laplace_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) %!assert (laplace_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error laplace_inv () %!error laplace_inv (1,2) %!error laplace_inv (i)
--- a/scripts/statistics/distributions/laplace_pdf.m +++ b/scripts/statistics/distributions/laplace_pdf.m @@ -46,10 +46,10 @@ %! y = [0, 1/4, 1/2, 1/4, 0]; %!assert (laplace_pdf ([x, NaN]), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (laplace_pdf (single ([x, NaN])), single ([y, NaN])) -%% Test input validation +## Test input validation %!error laplace_pdf () %!error laplace_pdf (1,2) %!error laplace_pdf (i)
--- a/scripts/statistics/distributions/laplace_rnd.m +++ b/scripts/statistics/distributions/laplace_rnd.m @@ -48,7 +48,7 @@ error ("laplace_rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 1) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("laplace_rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; @@ -64,7 +64,7 @@ %!assert (size (laplace_rnd ([4 1])), [4, 1]) %!assert (size (laplace_rnd (4,1)), [4, 1]) -%% Test input validation +## Test input validation %!error laplace_rnd () %!error laplace_rnd (-1) %!error laplace_rnd (ones (2))
--- a/scripts/statistics/distributions/logistic_cdf.m +++ b/scripts/statistics/distributions/logistic_cdf.m @@ -46,10 +46,10 @@ %! y = [0, 1/4, 1/2, 3/4, 1]; %!assert (logistic_cdf ([x, NaN]), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (logistic_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error logistic_cdf () %!error logistic_cdf (1,2) %!error logistic_cdf (i)
--- a/scripts/statistics/distributions/logistic_inv.m +++ b/scripts/statistics/distributions/logistic_inv.m @@ -58,11 +58,11 @@ %! x = [-1 0 0.5 1 2]; %!assert (logistic_inv (x), [NaN -Inf 0 Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (logistic_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) %!assert (logistic_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error logistic_inv () %!error logistic_inv (1,2) %!error logistic_inv (i)
--- a/scripts/statistics/distributions/logistic_pdf.m +++ b/scripts/statistics/distributions/logistic_pdf.m @@ -46,10 +46,10 @@ %! y = [0, 0.16, 1/4, 0.16, 0]; %!assert (logistic_pdf ([x, NaN]), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (logistic_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error logistic_pdf () %!error logistic_pdf (1,2) %!error logistic_pdf (i)
--- a/scripts/statistics/distributions/logistic_rnd.m +++ b/scripts/statistics/distributions/logistic_rnd.m @@ -48,7 +48,7 @@ error ("logistic_rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 1) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("logistic_rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; @@ -63,7 +63,7 @@ %!assert (size (logistic_rnd ([4 1])), [4, 1]) %!assert (size (logistic_rnd (4,1)), [4, 1]) -%% Test input validation +## Test input validation %!error logistic_rnd () %!error logistic_rnd (-1) %!error logistic_rnd (ones (2))
--- a/scripts/statistics/distributions/logncdf.m +++ b/scripts/statistics/distributions/logncdf.m @@ -38,7 +38,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("logncdf: X, MU, and SIGMA must be of common size or scalars"); @@ -81,13 +81,13 @@ %!assert (logncdf (x, 0, sqrt(2)*[0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)], eps) %!assert (logncdf ([x(1:3) NaN x(5)], 0, sqrt(2)), [y(1:3) NaN y(5)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (logncdf ([x, NaN], 0, sqrt(2)), [y, NaN], eps) %!assert (logncdf (single ([x, NaN]), 0, sqrt(2)), single ([y, NaN]), eps ("single")) %!assert (logncdf ([x, NaN], single (0), sqrt(2)), single ([y, NaN]), eps ("single")) %!assert (logncdf ([x, NaN], 0, single (sqrt(2))), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error logncdf () %!error logncdf (1,2) %!error logncdf (1,2,3,4)
--- a/scripts/statistics/distributions/logninv.m +++ b/scripts/statistics/distributions/logninv.m @@ -38,7 +38,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("logninv: X, MU, and SIGMA must be of common size or scalars"); @@ -80,13 +80,13 @@ %!assert (logninv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (logninv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (logninv ([x, NaN], 1, 1), [NaN 0 e Inf NaN NaN]) %!assert (logninv (single ([x, NaN]), 1, 1), single ([NaN 0 e Inf NaN NaN])) %!assert (logninv ([x, NaN], single (1), 1), single ([NaN 0 e Inf NaN NaN])) %!assert (logninv ([x, NaN], 1, single (1)), single ([NaN 0 e Inf NaN NaN])) -%% Test input validation +## Test input validation %!error logninv () %!error logninv (1,2) %!error logninv (1,2,3,4)
--- a/scripts/statistics/distributions/lognpdf.m +++ b/scripts/statistics/distributions/lognpdf.m @@ -38,7 +38,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("lognpdf: X, MU, and SIGMA must be of common size or scalars"); @@ -78,12 +78,12 @@ %!assert (lognpdf (x, 0, [0 NaN Inf 1]), [NaN NaN NaN y(4)], eps) %!assert (lognpdf ([x, NaN], 0, 1), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (lognpdf (single ([x, NaN]), 0, 1), single ([y, NaN]), eps ("single")) %!assert (lognpdf ([x, NaN], single (0), 1), single ([y, NaN]), eps ("single")) %!assert (lognpdf ([x, NaN], 0, single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error lognpdf () %!error lognpdf (1,2) %!error lognpdf (1,2,3,4)
--- a/scripts/statistics/distributions/lognrnd.m +++ b/scripts/statistics/distributions/lognrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, mu, sigma] = common_size (mu, sigma); if (retval > 0) error ("lognrnd: MU and SIGMA must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("lognrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("lognrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (mu) && !isequal (size (mu), sz)) + if (! isscalar (mu) && ! isequal (size (mu), sz)) error ("lognrnd: MU and SIGMA must be scalar or of size SZ"); endif @@ -107,14 +107,14 @@ %!assert (size (lognrnd (1, 2, [4 1])), [4, 1]) %!assert (size (lognrnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (lognrnd (1, 2)), "double") %!assert (class (lognrnd (single (1), 2)), "single") %!assert (class (lognrnd (single ([1 1]), 2)), "single") %!assert (class (lognrnd (1, single (2))), "single") %!assert (class (lognrnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error lognrnd () %!error lognrnd (1) %!error lognrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/nbincdf.m +++ b/scripts/statistics/distributions/nbincdf.m @@ -40,7 +40,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, x, n, p] = common_size (x, n, p); if (retval > 0) error ("nbincdf: X, N, and P must be of common size or scalars"); @@ -85,13 +85,13 @@ %!assert (nbincdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]) %!assert (nbincdf ([x(1:2) NaN x(4:5)], 1, 0.5), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (nbincdf ([x, NaN], 1, 0.5), [y, NaN]) %!assert (nbincdf (single ([x, NaN]), 1, 0.5), single ([y, NaN])) %!assert (nbincdf ([x, NaN], single (1), 0.5), single ([y, NaN])) %!assert (nbincdf ([x, NaN], 1, single (0.5)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error nbincdf () %!error nbincdf (1) %!error nbincdf (1,2)
--- a/scripts/statistics/distributions/nbininv.m +++ b/scripts/statistics/distributions/nbininv.m @@ -40,7 +40,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, x, n, p] = common_size (x, n, p); if (retval > 0) error ("nbininv: X, N, and P must be of common size or scalars"); @@ -108,13 +108,13 @@ %!assert (nbininv (x, 1, 0.5*[1 -Inf NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (nbininv ([x(1:2) NaN x(4:5)], 1, 0.5), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (nbininv ([x, NaN], 1, 0.5), [NaN 0 1 Inf NaN NaN]) %!assert (nbininv (single ([x, NaN]), 1, 0.5), single ([NaN 0 1 Inf NaN NaN])) %!assert (nbininv ([x, NaN], single (1), 0.5), single ([NaN 0 1 Inf NaN NaN])) %!assert (nbininv ([x, NaN], 1, single (0.5)), single ([NaN 0 1 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error nbininv () %!error nbininv (1) %!error nbininv (1,2)
--- a/scripts/statistics/distributions/nbinpdf.m +++ b/scripts/statistics/distributions/nbinpdf.m @@ -40,7 +40,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, x, n, p] = common_size (x, n, p); if (retval > 0) error ("nbinpdf: X, N, and P must be of common size or scalars"); @@ -83,12 +83,12 @@ %!assert (nbinpdf (x, 1, 0.5*[-1 NaN 4 1 1]), [NaN NaN NaN y(4:5)]) %!assert (nbinpdf ([x, NaN], 1, 0.5), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (nbinpdf (single ([x, NaN]), 1, 0.5), single ([y, NaN])) %!assert (nbinpdf ([x, NaN], single (1), 0.5), single ([y, NaN])) %!assert (nbinpdf ([x, NaN], 1, single (0.5)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error nbinpdf () %!error nbinpdf (1) %!error nbinpdf (1,2)
--- a/scripts/statistics/distributions/nbinrnd.m +++ b/scripts/statistics/distributions/nbinrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (n) || !isscalar (p)) + if (! isscalar (n) || ! isscalar (p)) [retval, n, p] = common_size (n, p); if (retval > 0) error ("nbinrnd: N and P must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("nbinrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("nbinrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (n) && !isequal (size (n), sz)) + if (! isscalar (n) && ! isequal (size (n), sz)) error ("nbinrnd: N and P must be scalar or of size SZ"); endif @@ -112,14 +112,14 @@ %!assert (size (nbinrnd (2, 1/2, [4 1])), [4, 1]) %!assert (size (nbinrnd (2, 1/2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (nbinrnd (2, 1/2)), "double") %!assert (class (nbinrnd (single (2), 1/2)), "single") %!assert (class (nbinrnd (single ([2 2]), 1/2)), "single") %!assert (class (nbinrnd (2, single (1/2))), "single") %!assert (class (nbinrnd (2, single ([1/2 1/2]))), "single") -%% Test input validation +## Test input validation %!error nbinrnd () %!error nbinrnd (1) %!error nbinrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/normcdf.m +++ b/scripts/statistics/distributions/normcdf.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("normcdf: X, MU, and SIGMA must be of common size or scalars"); @@ -80,13 +80,13 @@ %!assert (normcdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) %!assert (normcdf ([x(1:2) NaN x(4)], 1, 1), [y(1:2) NaN y(4)]) -%% Test class of input preserved +## Test class of input preserved %!assert (normcdf ([x, NaN], 1, 1), [y, NaN]) %!assert (normcdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) %!assert (normcdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) %!assert (normcdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error normcdf () %!error normcdf (1,2) %!error normcdf (1,2,3,4)
--- a/scripts/statistics/distributions/norminv.m +++ b/scripts/statistics/distributions/norminv.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("norminv: X, MU, and SIGMA must be of common size or scalars"); @@ -55,7 +55,7 @@ if (isscalar (mu) && isscalar (sigma)) if (isfinite (mu) && (sigma > 0) && (sigma < Inf)) - inv = mu + sigma * stdnormal_inv (x); + inv = mu + sigma * stdnormal_inv (x); endif else k = isfinite (mu) & (sigma > 0) & (sigma < Inf); @@ -74,13 +74,13 @@ %!assert (norminv (x, 1, [1 0 NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (norminv ([x(1:2) NaN x(4:5)], 1, 1), [NaN -Inf NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (norminv ([x, NaN], 1, 1), [NaN -Inf 1 Inf NaN NaN]) %!assert (norminv (single ([x, NaN]), 1, 1), single ([NaN -Inf 1 Inf NaN NaN])) %!assert (norminv ([x, NaN], single (1), 1), single ([NaN -Inf 1 Inf NaN NaN])) %!assert (norminv ([x, NaN], 1, single (1)), single ([NaN -Inf 1 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error norminv () %!error norminv (1,2) %!error norminv (1,2,3,4)
--- a/scripts/statistics/distributions/normpdf.m +++ b/scripts/statistics/distributions/normpdf.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, x, mu, sigma] = common_size (x, mu, sigma); if (retval > 0) error ("normpdf: X, MU, and SIGMA must be of common size or scalars"); @@ -63,7 +63,7 @@ k = isinf (mu) | !(sigma > 0) | !(sigma < Inf); pdf(k) = NaN; - k = !isinf (mu) & (sigma > 0) & (sigma < Inf); + k = ! isinf (mu) & (sigma > 0) & (sigma < Inf); pdf(k) = stdnormal_pdf ((x(k) - mu(k)) ./ sigma(k)) ./ sigma(k); endif @@ -80,12 +80,12 @@ %!assert (normpdf (x, 1, [Inf NaN -1 0]), [NaN NaN NaN NaN]) %!assert (normpdf ([x, NaN], 1, 1), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (normpdf (single ([x, NaN]), 1, 1), single ([y, NaN]), eps ("single")) %!assert (normpdf ([x, NaN], single (1), 1), single ([y, NaN]), eps ("single")) %!assert (normpdf ([x, NaN], 1, single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error normpdf () %!error normpdf (1,2) %!error normpdf (1,2,3,4)
--- a/scripts/statistics/distributions/normrnd.m +++ b/scripts/statistics/distributions/normrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (mu) || !isscalar (sigma)) + if (! isscalar (mu) || ! isscalar (sigma)) [retval, mu, sigma] = common_size (mu, sigma); if (retval > 0) error ("normrnd: mu and sigma must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("normrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("normrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (mu) && !isequal (size (mu), sz)) + if (! isscalar (mu) && ! isequal (size (mu), sz)) error ("normrnd: mu and sigma must be scalar or of size SZ"); endif @@ -84,7 +84,7 @@ if (isscalar (mu) && isscalar (sigma)) if (isfinite (mu) && (sigma >= 0) && (sigma < Inf)) - rnd = mu + sigma * randn (sz, cls); + rnd = mu + sigma * randn (sz, cls); else rnd = NaN (sz, cls); endif @@ -106,14 +106,14 @@ %!assert (size (normrnd (1, 2, [4 1])), [4, 1]) %!assert (size (normrnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (normrnd (1, 2)), "double") %!assert (class (normrnd (single (1), 2)), "single") %!assert (class (normrnd (single ([1 1]), 2)), "single") %!assert (class (normrnd (1, single (2))), "single") %!assert (class (normrnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error normrnd () %!error normrnd (1) %!error normrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/poisscdf.m +++ b/scripts/statistics/distributions/poisscdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("poisscdf: X and LAMBDA must be of common size or scalars"); @@ -74,12 +74,12 @@ %!assert (poisscdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)]) %!assert (poisscdf ([x(1:2) NaN Inf x(5)], 1), [y(1:2) NaN 1 y(5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (poisscdf ([x, NaN], 1), [y, NaN]) %!assert (poisscdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) %!assert (poisscdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error poisscdf () %!error poisscdf (1) %!error poisscdf (1,2,3)
--- a/scripts/statistics/distributions/poissinv.m +++ b/scripts/statistics/distributions/poissinv.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("poissinv: X and LAMBDA must be of common size or scalars"); @@ -87,12 +87,12 @@ %!assert (poissinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN]) %!assert (poissinv ([x(1:2) NaN x(4:5)], 1), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (poissinv ([x, NaN], 1), [NaN 0 1 Inf NaN NaN]) %!assert (poissinv (single ([x, NaN]), 1), single ([NaN 0 1 Inf NaN NaN])) %!assert (poissinv ([x, NaN], single (1)), single ([NaN 0 1 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error poissinv () %!error poissinv (1) %!error poissinv (1,2,3)
--- a/scripts/statistics/distributions/poisspdf.m +++ b/scripts/statistics/distributions/poisspdf.m @@ -32,7 +32,7 @@ print_usage (); endif - if (!isscalar (lambda)) + if (! isscalar (lambda)) [retval, x, lambda] = common_size (x, lambda); if (retval > 0) error ("poisspdf: X and LAMBDA must be of common size or scalars"); @@ -70,11 +70,11 @@ %!assert (poisspdf (x, [1 0 NaN 1 1]), [y(1) NaN NaN y(4:5)], eps) %!assert (poisspdf ([x, NaN], 1), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (poisspdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) %!assert (poisspdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error poisspdf () %!error poisspdf (1) %!error poisspdf (1,2,3)
--- a/scripts/statistics/distributions/poissrnd.m +++ b/scripts/statistics/distributions/poissrnd.m @@ -55,13 +55,13 @@ error ("poissrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("poissrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (lambda) && !isequal (size (lambda), sz)) + if (! isscalar (lambda) && ! isequal (size (lambda), sz)) error ("poissrnd: LAMBDA must be scalar or of size SZ"); endif @@ -98,12 +98,12 @@ %!assert (size (poissrnd (1, [4 1])), [4, 1]) %!assert (size (poissrnd (1, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (poissrnd (2)), "double") %!assert (class (poissrnd (single (2))), "single") %!assert (class (poissrnd (single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error poissrnd () %!error poissrnd (1, -1) %!error poissrnd (1, ones (2))
--- a/scripts/statistics/distributions/stdnormal_cdf.m +++ b/scripts/statistics/distributions/stdnormal_cdf.m @@ -47,10 +47,10 @@ %! y = [0, 0.5, 1/2*(1+erf(1/sqrt(2))), 1]; %!assert (stdnormal_cdf ([x, NaN]), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (stdnormal_cdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error stdnormal_cdf () %!error stdnormal_cdf (1,2) %!error stdnormal_cdf (i)
--- a/scripts/statistics/distributions/stdnormal_inv.m +++ b/scripts/statistics/distributions/stdnormal_inv.m @@ -46,11 +46,11 @@ %! x = [-1 0 0.5 1 2]; %!assert (stdnormal_inv (x), [NaN -Inf 0 Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (stdnormal_inv ([x, NaN]), [NaN -Inf 0 Inf NaN NaN]) %!assert (stdnormal_inv (single ([x, NaN])), single ([NaN -Inf 0 Inf NaN NaN])) -%% Test input validation +## Test input validation %!error stdnormal_inv () %!error stdnormal_inv (1,2) %!error stdnormal_inv (i)
--- a/scripts/statistics/distributions/stdnormal_pdf.m +++ b/scripts/statistics/distributions/stdnormal_pdf.m @@ -47,10 +47,10 @@ %! y = 1/sqrt(2*pi)*exp (-x.^2/2); %!assert (stdnormal_pdf ([x, NaN]), [y, NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (stdnormal_pdf (single ([x, NaN])), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error stdnormal_pdf () %!error stdnormal_pdf (1,2) %!error stdnormal_pdf (i)
--- a/scripts/statistics/distributions/stdnormal_rnd.m +++ b/scripts/statistics/distributions/stdnormal_rnd.m @@ -49,7 +49,7 @@ error ("stdnormal_rnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 1) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("stdnormal_rnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; @@ -64,7 +64,7 @@ %!assert (size (stdnormal_rnd ([4 1])), [4, 1]) %!assert (size (stdnormal_rnd (4,1)), [4, 1]) -%% Test input validation +## Test input validation %!error stdnormal_rnd () %!error stdnormal_rnd (-1) %!error stdnormal_rnd (ones (2))
--- a/scripts/statistics/distributions/tcdf.m +++ b/scripts/statistics/distributions/tcdf.m @@ -34,7 +34,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("tcdf: X and N must be of common size or scalars"); @@ -51,7 +51,7 @@ cdf = zeros (size (x)); endif - k = !isinf (x) & (n > 0); + k = ! isinf (x) & (n > 0); xx = x .^ 2; x_big_abs = (xx > n); @@ -94,12 +94,12 @@ %!assert (tcdf (x, [0 1 NaN 1]), [NaN 1/2 NaN 1], eps) %!assert (tcdf ([x(1:2) NaN x(4)], 1), [y(1:2) NaN y(4)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (tcdf ([x, NaN], 1), [y, NaN], eps) %!assert (tcdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) %!assert (tcdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error tcdf () %!error tcdf (1) %!error tcdf (1,2,3)
--- a/scripts/statistics/distributions/tinv.m +++ b/scripts/statistics/distributions/tinv.m @@ -38,7 +38,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("tinv: X and N must be of common size or scalars"); @@ -92,12 +92,12 @@ %!assert (tinv (x, [1 0 NaN 1 1]), [NaN NaN NaN Inf NaN], eps) %!assert (tinv ([x(1:2) NaN x(4:5)], 1), [NaN -Inf NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (tinv ([x, NaN], 1), [NaN -Inf 0 Inf NaN NaN], eps) %!assert (tinv (single ([x, NaN]), 1), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single")) %!assert (tinv ([x, NaN], single (1)), single ([NaN -Inf 0 Inf NaN NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error tinv () %!error tinv (1) %!error tinv (1,2,3)
--- a/scripts/statistics/distributions/tpdf.m +++ b/scripts/statistics/distributions/tpdf.m @@ -33,7 +33,7 @@ print_usage (); endif - if (!isscalar (n)) + if (! isscalar (n)) [retval, x, n] = common_size (x, n); if (retval > 0) error ("tpdf: X and N must be of common size or scalars"); @@ -77,12 +77,12 @@ %!assert (tpdf (x, 1), y, eps) %!assert (tpdf (x, [0 NaN 1 1 1]), [NaN NaN y(3:5)], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (tpdf ([x, NaN], 1), [y, NaN], eps) %!assert (tpdf (single ([x, NaN]), 1), single ([y, NaN]), eps ("single")) %!assert (tpdf ([x, NaN], single (1)), single ([y, NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error tpdf () %!error tpdf (1) %!error tpdf (1,2,3)
--- a/scripts/statistics/distributions/trnd.m +++ b/scripts/statistics/distributions/trnd.m @@ -55,13 +55,13 @@ error ("trnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("trnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (n) && !isequal (size (n), sz)) + if (! isscalar (n) && ! isequal (size (n), sz)) error ("trnd: N must be scalar or of size SZ"); endif @@ -85,7 +85,8 @@ rnd = NaN (sz, cls); k = (n > 0) & (n < Inf); - rnd(k) = randn (sum (k(:)), 1, cls) ./ sqrt (2*randg (n(k)/2, cls) ./ n(k))(:); + rnd(k) = randn (sum (k(:)), 1, cls) ... + ./ sqrt (2*randg (n(k)/2, cls) ./ n(k))(:); endif endfunction @@ -98,12 +99,12 @@ %!assert (size (trnd (1, [4 1])), [4, 1]) %!assert (size (trnd (1, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (trnd (1)), "double") %!assert (class (trnd (single (1))), "single") %!assert (class (trnd (single ([1 1]))), "single") -%% Test input validation +## Test input validation %!error trnd () %!error trnd (1, -1) %!error trnd (1, ones (2))
--- a/scripts/statistics/distributions/unidcdf.m +++ b/scripts/statistics/distributions/unidcdf.m @@ -73,12 +73,12 @@ %!assert (unidcdf (x, 10*[0 1 NaN 1 1]), [NaN 0.1 NaN y(4:5)]) %!assert (unidcdf ([x(1:2) NaN Inf x(5)], 10), [y(1:2) NaN 1 y(5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (unidcdf ([x, NaN], 10), [y, NaN]) %!assert (unidcdf (single ([x, NaN]), 10), single ([y, NaN])) %!assert (unidcdf ([x, NaN], single (10)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error unidcdf () %!error unidcdf (1) %!error unidcdf (1,2,3)
--- a/scripts/statistics/distributions/unidinv.m +++ b/scripts/statistics/distributions/unidinv.m @@ -65,12 +65,12 @@ %!assert (unidinv (x, 10*[0 1 NaN 1 1]), [NaN NaN NaN 10 NaN], eps) %!assert (unidinv ([x(1:2) NaN x(4:5)], 10), [NaN NaN NaN 10 NaN], eps) -%% Test class of input preserved +## Test class of input preserved %!assert (unidinv ([x, NaN], 10), [NaN NaN 5 10 NaN NaN], eps) %!assert (unidinv (single ([x, NaN]), 10), single ([NaN NaN 5 10 NaN NaN]), eps) %!assert (unidinv ([x, NaN], single (10)), single ([NaN NaN 5 10 NaN NaN]), eps) -%% Test input validation +## Test input validation %!error unidinv () %!error unidinv (1) %!error unidinv (1,2,3)
--- a/scripts/statistics/distributions/unidpdf.m +++ b/scripts/statistics/distributions/unidpdf.m @@ -72,11 +72,11 @@ %!assert (unidpdf (x, 10*[0 NaN 1 1 1 1]), [NaN NaN y(3:6)]) %!assert (unidpdf ([x, NaN], 10), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (unidpdf (single ([x, NaN]), 10), single ([y, NaN])) %!assert (unidpdf ([x, NaN], single (10)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error unidpdf () %!error unidpdf (1) %!error unidpdf (1,2,3)
--- a/scripts/statistics/distributions/unidrnd.m +++ b/scripts/statistics/distributions/unidrnd.m @@ -55,13 +55,13 @@ error ("unidrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 2) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("unidrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (n) && !isequal (size (n), sz)) + if (! isscalar (n) && ! isequal (size (n), sz)) error ("unidrnd: N must be scalar or of size SZ"); endif @@ -97,12 +97,12 @@ %!assert (size (unidrnd (10, [4 1])), [4, 1]) %!assert (size (unidrnd (10, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (unidrnd (2)), "double") %!assert (class (unidrnd (single (2))), "single") %!assert (class (unidrnd (single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error unidrnd () %!error unidrnd (10, [1;2;3]) %!error unidrnd (10, 2, ones (2))
--- a/scripts/statistics/distributions/unifcdf.m +++ b/scripts/statistics/distributions/unifcdf.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("unifcdf: X, A, and B must be of common size or scalars"); @@ -79,13 +79,13 @@ %!assert (unifcdf (x, 1, 2*[0 1 NaN 1 1]), [NaN 0 NaN 1 1]) %!assert (unifcdf ([x(1:2) NaN x(4:5)], 1, 2), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (unifcdf ([x, NaN], 1, 2), [y, NaN]) %!assert (unifcdf (single ([x, NaN]), 1, 2), single ([y, NaN])) %!assert (unifcdf ([x, NaN], single (1), 2), single ([y, NaN])) %!assert (unifcdf ([x, NaN], 1, single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error unifcdf () %!error unifcdf (1,2) %!error unifcdf (1,2,3,4)
--- a/scripts/statistics/distributions/unifinv.m +++ b/scripts/statistics/distributions/unifinv.m @@ -36,7 +36,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("unifinv: X, A, and B must be of common size or scalars"); @@ -72,13 +72,13 @@ %!assert (unifinv (x, 1, 2*[1 0 NaN 1 1]), [NaN NaN NaN 2 NaN]) %!assert (unifinv ([x(1:2) NaN x(4:5)], 1, 2), [NaN 1 NaN 2 NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (unifinv ([x, NaN], 1, 2), [NaN 1 1.5 2 NaN NaN]) %!assert (unifinv (single ([x, NaN]), 1, 2), single ([NaN 1 1.5 2 NaN NaN])) %!assert (unifinv ([x, NaN], single (1), 2), single ([NaN 1 1.5 2 NaN NaN])) %!assert (unifinv ([x, NaN], 1, single (2)), single ([NaN 1 1.5 2 NaN NaN])) -%% Test input validation +## Test input validation %!error unifinv () %!error unifinv (1,2) %!error unifinv (1,2,3,4)
--- a/scripts/statistics/distributions/unifpdf.m +++ b/scripts/statistics/distributions/unifpdf.m @@ -35,7 +35,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, x, a, b] = common_size (x, a, b); if (retval > 0) error ("unifpdf: X, A, and B must be of common size or scalars"); @@ -75,12 +75,12 @@ %!assert (unifpdf (x, 1, 2*[0 NaN 1 1 1]), [NaN NaN y(3:5)]) %!assert (unifpdf ([x, NaN], 1, 2), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (unifpdf (single ([x, NaN]), 1, 2), single ([y, NaN])) %!assert (unifpdf (single ([x, NaN]), single (1), 2), single ([y, NaN])) %!assert (unifpdf ([x, NaN], 1, single (2)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error unifpdf () %!error unifpdf (1,2) %!error unifpdf (1,2,3,4)
--- a/scripts/statistics/distributions/unifrnd.m +++ b/scripts/statistics/distributions/unifrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (a) || !isscalar (b)) + if (! isscalar (a) || ! isscalar (b)) [retval, a, b] = common_size (a, b); if (retval > 0) error ("unifrnd: A and B must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("unifrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("unifrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (a) && !isequal (size (a), sz)) + if (! isscalar (a) && ! isequal (size (a), sz)) error ("unifrnd: A and B must be scalar or of size SZ"); endif @@ -84,12 +84,12 @@ if (isscalar (a) && isscalar (b)) if ((-Inf < a) && (a < b) && (b < Inf)) - rnd = a + (b - a) * rand (sz, cls); + rnd = a + (b - a) * rand (sz, cls); else rnd = NaN (sz, cls); endif else - rnd = a + (b - a) .* rand (sz, cls); + rnd = a + (b - a) .* rand (sz, cls); k = !(-Inf < a) | !(a < b) | !(b < Inf); rnd(k) = NaN; @@ -107,14 +107,14 @@ %!assert (size (unifrnd (1, 2, [4 1])), [4, 1]) %!assert (size (unifrnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (unifrnd (1, 2)), "double") %!assert (class (unifrnd (single (1), 2)), "single") %!assert (class (unifrnd (single ([1 1]), 2)), "single") %!assert (class (unifrnd (1, single (2))), "single") %!assert (class (unifrnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error unifrnd () %!error unifrnd (1) %!error unifrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/wblcdf.m +++ b/scripts/statistics/distributions/wblcdf.m @@ -50,7 +50,7 @@ print_usage (); endif - if (!isscalar (shape) || !isscalar (scale)) + if (! isscalar (shape) || ! isscalar (scale)) [retval, x, shape, scale] = common_size (x, shape, scale); if (retval > 0) error ("wblcdf: X, SCALE, and SHAPE must be of common size or scalars"); @@ -95,13 +95,13 @@ %!assert (wblcdf (x, 1, [0 1 NaN Inf 1]), [NaN 0 NaN NaN 1]) %!assert (wblcdf ([x(1:2) NaN x(4:5)], 1, 1), [y(1:2) NaN y(4:5)]) -%% Test class of input preserved +## Test class of input preserved %!assert (wblcdf ([x, NaN], 1, 1), [y, NaN]) %!assert (wblcdf (single ([x, NaN]), 1, 1), single ([y, NaN])) %!assert (wblcdf ([x, NaN], single (1), 1), single ([y, NaN])) %!assert (wblcdf ([x, NaN], 1, single (1)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error wblcdf () %!error wblcdf (1,2,3,4) %!error wblcdf (ones (3), ones (2), ones (2))
--- a/scripts/statistics/distributions/wblinv.m +++ b/scripts/statistics/distributions/wblinv.m @@ -37,7 +37,7 @@ print_usage (); endif - if (!isscalar (scale) || !isscalar (shape)) + if (! isscalar (scale) || ! isscalar (shape)) [retval, x, scale, shape] = common_size (x, scale, shape); if (retval > 0) error ("wblinv: X, SCALE, and SHAPE must be of common size or scalars"); @@ -81,13 +81,13 @@ %!assert (wblinv (x, 1, [1 -1 NaN Inf 1]), [NaN NaN NaN NaN NaN]) %!assert (wblinv ([x(1:2) NaN x(4:5)], 1, 1), [NaN 0 NaN Inf NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (wblinv ([x, NaN], 1, 1), [NaN 0 1 Inf NaN NaN], eps) %!assert (wblinv (single ([x, NaN]), 1, 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %!assert (wblinv ([x, NaN], single (1), 1), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) %!assert (wblinv ([x, NaN], 1, single (1)), single ([NaN 0 1 Inf NaN NaN]), eps ("single")) -%% Test input validation +## Test input validation %!error wblinv () %!error wblinv (1,2,3,4) %!error wblinv (ones (3), ones (2), ones (2))
--- a/scripts/statistics/distributions/wblpdf.m +++ b/scripts/statistics/distributions/wblpdf.m @@ -49,7 +49,7 @@ print_usage (); endif - if (!isscalar (scale) || !isscalar (shape)) + if (! isscalar (scale) || ! isscalar (shape)) [retval, x, scale, shape] = common_size (x, scale, shape); if (retval > 0) error ("wblpdf: X, SCALE, and SHAPE must be of common size or scalars"); @@ -95,12 +95,12 @@ %!assert (wblpdf (x, 1, [0 NaN Inf 1 1]), [NaN NaN NaN y(4:5)]) %!assert (wblpdf ([x, NaN], 1, 1), [y, NaN]) -%% Test class of input preserved +## Test class of input preserved %!assert (wblpdf (single ([x, NaN]), 1, 1), single ([y, NaN])) %!assert (wblpdf ([x, NaN], single (1), 1), single ([y, NaN])) %!assert (wblpdf ([x, NaN], 1, single (1)), single ([y, NaN])) -%% Test input validation +## Test input validation %!error wblpdf () %!error wblpdf (1,2,3,4) %!error wblpdf (ones (3), ones (2), ones (2))
--- a/scripts/statistics/distributions/wblrnd.m +++ b/scripts/statistics/distributions/wblrnd.m @@ -44,7 +44,7 @@ print_usage (); endif - if (!isscalar (scale) || !isscalar (shape)) + if (! isscalar (scale) || ! isscalar (shape)) [retval, scale, shape] = common_size (scale, shape); if (retval > 0) error ("wblrnd: SCALE and SHAPE must be of common size or scalars"); @@ -66,13 +66,13 @@ error ("wblrnd: dimension vector must be row vector of non-negative integers"); endif elseif (nargin > 3) - if (any (cellfun (@(x) (!isscalar (x) || x < 0), varargin))) + if (any (cellfun (@(x) (! isscalar (x) || x < 0), varargin))) error ("wblrnd: dimensions must be non-negative integers"); endif sz = [varargin{:}]; endif - if (!isscalar (scale) && !isequal (size (scale), sz)) + if (! isscalar (scale) && ! isequal (size (scale), sz)) error ("wblrnd: SCALE and SHAPE must be scalar or of size SZ"); endif @@ -107,14 +107,14 @@ %!assert (size (wblrnd (1, 2, [4 1])), [4, 1]) %!assert (size (wblrnd (1, 2, 4, 1)), [4, 1]) -%% Test class of input preserved +## Test class of input preserved %!assert (class (wblrnd (1, 2)), "double") %!assert (class (wblrnd (single (1), 2)), "single") %!assert (class (wblrnd (single ([1 1]), 2)), "single") %!assert (class (wblrnd (1, single (2))), "single") %!assert (class (wblrnd (1, single ([2 2]))), "single") -%% Test input validation +## Test input validation %!error wblrnd () %!error wblrnd (1) %!error wblrnd (ones (3), ones (2))
--- a/scripts/statistics/distributions/wienrnd.m +++ b/scripts/statistics/distributions/wienrnd.m @@ -42,7 +42,7 @@ print_usage (); endif - if (!isscalar (t) || !isscalar (d) || !isscalar (n)) + if (! isscalar (t) || ! isscalar (d) || ! isscalar (n)) error ("wienrnd: T, D and N must all be positive integers"); endif
--- a/scripts/statistics/models/logistic_regression.m +++ b/scripts/statistics/models/logistic_regression.m @@ -104,7 +104,7 @@ z = (y * ones (1, yrange)) == ((y * 0 + 1) * (ymin : (ymax - 1))); z1 = (y * ones (1, yrange)) == ((y * 0 + 1) * ((ymin + 1) : ymax)); z = z(:, any (z)); - z1 = z1 (:, any(z1)); + z1 = z1(:, any(z1)); [mz, nz] = size (z); ## starting values @@ -157,8 +157,8 @@ ## tidy up output - theta = tb (1 : nz, 1); - beta = tb ((nz + 1) : (nz + nx), 1); + theta = tb(1 : nz, 1); + beta = tb((nz + 1) : (nz + nx), 1); if (print >= 1) printf ("\n");
--- a/scripts/statistics/tests/anova.m +++ b/scripts/statistics/tests/anova.m @@ -46,7 +46,7 @@ function [pval, f, df_b, df_w] = anova (y, g) - if ((nargin < 1) || (nargin > 2)) + if (nargin < 1 || nargin > 2) print_usage (); elseif (nargin == 1) if (isvector (y))
--- a/scripts/statistics/tests/chisquare_test_independence.m +++ b/scripts/statistics/tests/chisquare_test_independence.m @@ -44,7 +44,7 @@ y = sum (x')' * sum (x) / n; x = (x - y) .^2 ./ y; chisq = sum (sum (x)); - pval = 1 - chi2cdf (chisq, df); + pval = 1 - chi2cdf (chisq, df); if (nargout == 0) printf (" pval: %g\n", pval);
--- a/scripts/statistics/tests/cor_test.m +++ b/scripts/statistics/tests/cor_test.m @@ -67,11 +67,11 @@ function t = cor_test (x, y, alt, method) - if ((nargin < 2) || (nargin > 4)) + if (nargin < 2 || nargin > 4) print_usage (); endif - if (!isvector (x) || !isvector (y) || length (x) != length (y)) + if (! isvector (x) || ! isvector (y) || length (x) != length (y)) error ("cor_test: X and Y must be vectors of the same length"); endif @@ -88,7 +88,7 @@ endif n = length (x); - m = method (1); + m = method(1); if (m == "p") r = corr (x, y); @@ -97,7 +97,7 @@ t.params = df; t.stat = sqrt (df) .* r / sqrt (1 - r.^2); t.dist = "t"; - cdf = tcdf (t.stat, df); + cdf = tcdf (t.stat, df); elseif (m == "k") tau = kendall (x, y); t.method = "Kendall's rank correlation tau";
--- a/scripts/statistics/tests/f_test_regression.m +++ b/scripts/statistics/tests/f_test_regression.m @@ -68,7 +68,7 @@ [b, v] = ols (y, x); diff = rr * b - r; f = diff' * inv (rr * inv (x' * x) * rr') * diff / (q * v); - pval = 1 - fcdf (f, df_num, df_den); + pval = 1 - fcdf (f, df_num, df_den); if (nargout == 0) printf (" pval: %g\n", pval);
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -76,7 +76,7 @@ end_try_catch end_try_catch - alt = "!="; + alt = "!="; args{1} = s; nvargs = numel (varargin);
--- a/scripts/statistics/tests/manova.m +++ b/scripts/statistics/tests/manova.m @@ -53,7 +53,7 @@ [n, p] = size (x); - if (!isvector (g) || (length (g) != n)) + if (! isvector (g) || (length (g) != n)) error ("manova: G must be a vector of length rows (X)"); endif @@ -85,9 +85,9 @@ l = real (eig (SSB / SSW)); if (isa (l, "single")) - l (l < eps ("single")) = 0; + l(l < eps ("single")) = 0; else - l (l < eps) = 0; + l(l < eps) = 0; endif ## Wilks' Lambda
--- a/scripts/statistics/tests/mcnemar_test.m +++ b/scripts/statistics/tests/mcnemar_test.m @@ -42,7 +42,7 @@ if (! (min (size (x)) > 1) && issquare (x)) error ("mcnemar_test: X must be a square matrix of size > 1"); - elseif (! (all (all (x >= 0)) && all (all (x == fix (x))))) + elseif (! (all ((x(:) >= 0)) && all (x(:) == fix (x(:))))) error ("mcnemar_test: all entries of X must be non-negative integers"); endif
--- a/scripts/statistics/tests/prop_test_2.m +++ b/scripts/statistics/tests/prop_test_2.m @@ -42,22 +42,22 @@ function [pval, z] = prop_test_2 (x1, n1, x2, n2, alt) - if ((nargin < 4) || (nargin > 5)) - print_usage (); + if (nargin < 4 || nargin > 5) + print_usage (); endif ## Could do sanity checking on x1, n1, x2, n2 here - p1 = x1 / n1; - p2 = x2 / n2; - pc = (x1 + x2) / (n1 + n2); + p1 = x1 / n1; + p2 = x2 / n2; + pc = (x1 + x2) / (n1 + n2); - z = (p1 - p2) / sqrt (pc * (1 - pc) * (1/n1 + 1/n2)); + z = (p1 - p2) / sqrt (pc * (1 - pc) * (1/n1 + 1/n2)); cdf = stdnormal_cdf (z); if (nargin == 4) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/sign_test.m +++ b/scripts/statistics/tests/sign_test.m @@ -44,7 +44,7 @@ function [pval, b, n] = sign_test (x, y, alt) - if ((nargin < 2) || (nargin > 3)) + if (nargin < 2 || nargin > 3) print_usage (); endif @@ -60,7 +60,7 @@ cdf = binocdf (b, n, 1/2); if (nargin == 2) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/t_test.m +++ b/scripts/statistics/tests/t_test.m @@ -43,7 +43,7 @@ function [pval, t, df] = t_test (x, m, alt) - if ((nargin < 2) || (nargin > 3)) + if (nargin < 2 || nargin > 3) print_usage (); endif @@ -60,7 +60,7 @@ cdf = tcdf (t, df); if (nargin == 2) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/t_test_2.m +++ b/scripts/statistics/tests/t_test_2.m @@ -43,8 +43,8 @@ function [pval, t, df] = t_test_2 (x, y, alt) - if ((nargin < 2) || (nargin > 3)) - print_usage (); + if (nargin < 2 || nargin > 3) + print_usage (); endif if (! (isvector (x) && isvector (y)))
--- a/scripts/statistics/tests/t_test_regression.m +++ b/scripts/statistics/tests/t_test_regression.m @@ -70,7 +70,7 @@ if (! (isvector (y) && (length (y) == T))) error ("t_test_regression: Y must be a vector of length rows (X)"); endif - s = size (rr); + s = size (rr); if (! ((max (s) == k) && (min (s) == 1))) error ("t_test_regression: RR must be a vector of length columns (X)"); endif
--- a/scripts/statistics/tests/u_test.m +++ b/scripts/statistics/tests/u_test.m @@ -45,7 +45,7 @@ function [pval, z] = u_test (x, y, alt) - if ((nargin < 2) || (nargin > 3)) + if (nargin < 2 || nargin > 3) print_usage (); endif @@ -53,16 +53,16 @@ error ("u_test: both X and Y must be vectors"); endif - n_x = length (x); - n_y = length (y); - r = ranks ([(reshape (x, 1, n_x)), (reshape (y, 1, n_y))]); - z = (sum (r(1 : n_x)) - n_x * (n_x + n_y + 1) / 2) ... - / sqrt (n_x * n_y * (n_x + n_y + 1) / 12); + n_x = length (x); + n_y = length (y); + r = ranks ([(reshape (x, 1, n_x)), (reshape (y, 1, n_y))]); + z = (sum (r(1 : n_x)) - n_x * (n_x + n_y + 1) / 2) ... + / sqrt (n_x * n_y * (n_x + n_y + 1) / 12); - cdf = stdnormal_cdf (z); + cdf = stdnormal_cdf (z); if (nargin == 2) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/var_test.m +++ b/scripts/statistics/tests/var_test.m @@ -43,7 +43,7 @@ function [pval, f, df_num, df_den] = var_test (x, y, alt) - if ((nargin < 2) || (nargin > 3)) + if (nargin < 2 || nargin > 3) print_usage (); endif @@ -57,7 +57,7 @@ cdf = fcdf (f, df_num, df_den); if (nargin == 2) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/welch_test.m +++ b/scripts/statistics/tests/welch_test.m @@ -42,7 +42,7 @@ function [pval, t, df] = welch_test (x, y, alt) - if ((nargin < 2) || (nargin > 3)) + if (nargin < 2 || nargin > 3) print_usage (); endif @@ -62,7 +62,7 @@ cdf = tcdf (t, df); if (nargin == 2) - alt = "!="; + alt = "!="; endif if (! ischar (alt))
--- a/scripts/statistics/tests/z_test.m +++ b/scripts/statistics/tests/z_test.m @@ -43,7 +43,7 @@ function [pval, z] = z_test (x, m, v, alt) - if ((nargin < 3) || (nargin > 4)) + if (nargin < 3 || nargin > 4) print_usage (); endif
--- a/scripts/statistics/tests/z_test_2.m +++ b/scripts/statistics/tests/z_test_2.m @@ -43,7 +43,7 @@ function [pval, z] = z_test_2 (x, y, v_x, v_y, alt) - if ((nargin < 4) || (nargin > 5)) + if (nargin < 4 || nargin > 5) print_usage (); endif
--- a/scripts/strings/base2dec.m +++ b/scripts/strings/base2dec.m @@ -122,10 +122,10 @@ %!assert (base2dec ("-1", 2), NaN) %!assert (base2dec ({"A1", "1A"}, 16), [161; 26]) -%% Bug #35621 +## Bug #35621 %!assert (base2dec (["0"; "1"], 2), [0; 1]) -%%Test input validation +## Test input validation %!error base2dec () %!error base2dec ("11120") %!error base2dec ("11120", 3, 4)
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -67,7 +67,7 @@ %!assert (bin2dec ("1 0 1"), 5) %!assert (bin2dec (char ("1 0 1", " 1111")), [5; 15]) -%%Test input validation +## Test input validation %!error bin2dec () %!error bin2dec (1) %!error bin2dec ("1", 2)
--- a/scripts/strings/blanks.m +++ b/scripts/strings/blanks.m @@ -56,7 +56,7 @@ %!assert (blanks (5), " ") %!assert (blanks (10), " ") -%% Test input validation +## Test input validation %!error blanks () %!error blanks (1, 2) %!error blanks (ones (2))
--- a/scripts/strings/cstrcat.m +++ b/scripts/strings/cstrcat.m @@ -63,7 +63,7 @@ %!assert (cstrcat ("foo", "bar"), "foobar") %!assert (cstrcat (["a"; "bb"], ["foo"; "bar"]), ["a foo"; "bbbar"]) -%% Test input validation +## Test input validation %!error cstrcat () %!error cstrcat (1, 2)
--- a/scripts/strings/dec2base.m +++ b/scripts/strings/dec2base.m @@ -158,7 +158,7 @@ %! a = 0:3; %! assert (dec2base (!a, 2, 1), ["1"; "0"; "0"; "0"]) -%%Test input validation +## Test input validation %!error dec2base () %!error dec2base (1) %!error dec2base (1, 2, 3, 4)
--- a/scripts/strings/dec2bin.m +++ b/scripts/strings/dec2bin.m @@ -57,7 +57,7 @@ %!assert (dec2bin (14, 6), "001110") %!assert (dec2bin ({1, 2; 3, 4}), ["001"; "011"; "010"; "100"]) -%%Test input validation +## Test input validation %!error dec2bin () %!error dec2bin (1, 2, 3)
--- a/scripts/strings/dec2hex.m +++ b/scripts/strings/dec2hex.m @@ -57,7 +57,7 @@ %!assert (dec2hex (2748, 5), "00ABC") %!assert (dec2hex ({2748, 2746}), ["ABC"; "ABA"]) -%% Test input validation +## Test input validation %!error dec2hex () %!error dec2hex (1, 2, 3)
--- a/scripts/strings/findstr.m +++ b/scripts/strings/findstr.m @@ -78,9 +78,9 @@ ## length three or more: match the first three by find then go through ## the much smaller list to determine which of them are real matches limit = l_s - l_t + 1; - v = find (s(1:limit) == t(1) + v = find ( s(1:limit) == t(1) & s(2:limit+1) == t(2) - & s (3:limit+2) == t(3)); + & s(3:limit+2) == t(3)); endif ## Need to search the index vector if our find was too short @@ -136,7 +136,7 @@ %!assert (findstr ("abababa", "aba"), [1, 3, 5]) %!assert (findstr ("aba", "abababa", 0), [1, 5]) -%% Test input validation +## Test input validation %!error findstr () %!error findstr ("foo", "bar", 3, 4) %!error <must have only one non-singleton dimension> findstr (["AB" ; "CD"], "C")
--- a/scripts/strings/hex2dec.m +++ b/scripts/strings/hex2dec.m @@ -58,7 +58,7 @@ %!assert (hex2dec (["12b"; "12B"]), [299; 299]) %!assert (hex2dec ({"A1", "1A"}), [161; 26]) -%%Test input validation +## Test input validation %!error hex2dec () %!error hex2dec (1) %!error hex2dec ("1", 2)
--- a/scripts/strings/index.m +++ b/scripts/strings/index.m @@ -108,7 +108,7 @@ %! assert (index (str, "o"), [5; 2; 2; 2]); %! assert (index (str, "o", "last"), [5; 2; 3; 2]); -%% Test input validation +## Test input validation %!error index () %!error index ("a") %!error index ("a", "b", "first", "d")
--- a/scripts/strings/isstrprop.m +++ b/scripts/strings/isstrprop.m @@ -127,7 +127,7 @@ %!assert (isstrprop (char ("AbC", "123"), "upper"), logical ([1 0 1; 0 0 0])) %!assert (isstrprop ({"AbC", "123"}, "lower"), {logical([0 1 0]), logical([0 0 0])}) -%%Input Validation +## Test input validation %!error isstrprop () %!error isstrprop ("abc123") %!error isstrprop ("abc123", "alpha", "alpha")
--- a/scripts/strings/mat2str.m +++ b/scripts/strings/mat2str.m @@ -143,7 +143,7 @@ %!assert (mat2str (false), "false") %!assert (mat2str (logical (eye (2))), "[true false;false true]") -%% Test input validation +## Test input validation %!error mat2str () %!error mat2str (1,2,3,4) %!error mat2str (["Hello"])
--- a/scripts/strings/ostrsplit.m +++ b/scripts/strings/ostrsplit.m @@ -108,7 +108,7 @@ %!assert (ostrsplit (["a,bc";",de"], ",", true), {"a", "bc", "de "}) %!assert (ostrsplit (["a,bc";",de"], ", ", true), {"a", "bc", "de"}) -%% Test input validation +## Test input validation %!error ostrsplit () %!error ostrsplit ("abc") %!error ostrsplit ("abc", "b", true, 4)
--- a/scripts/strings/regexptranslate.m +++ b/scripts/strings/regexptranslate.m @@ -78,7 +78,7 @@ %!assert (regexptranslate ("wildcard", "/a*b?c."), "/a.*b.c\\.") %!assert (regexptranslate ("escape", '$.?[abc]'), '\$\.\?\[abc\]') -%% Test input validation +## Test input validation %!error <Invalid call to regexptranslate> regexptranslate () %!error <Invalid call to regexptranslate> regexptranslate ("wildcard") %!error <Invalid call to regexptranslate> regexptranslate ("a", "b", "c")
--- a/scripts/strings/rindex.m +++ b/scripts/strings/rindex.m @@ -61,7 +61,7 @@ %! str = cellstr (str); %! assert (rindex (str, "o"), [5; 2; 3; 2]); -%% Test input validation +## Test input validation %!error rindex () %!error rindex ("foo") %!error rindex ("foo", "bar", "last")
--- a/scripts/strings/str2num.m +++ b/scripts/strings/str2num.m @@ -77,7 +77,7 @@ %! [x, state] = str2num ("Hello World"); %! assert (! state); -%% Test input validation +## Test input validation %!error str2num () %!error str2num ("string", 1) %!error <S must be a string> str2num ({"string"})
--- a/scripts/strings/strchr.m +++ b/scripts/strings/strchr.m @@ -72,7 +72,7 @@ %!assert (strchr ("Octave is the best software", "best"), [3, 6, 9, 11, 13, 15, 16, 17, 18, 20, 23, 27]) %!assert (strchr ("Octave is the best software", "software"), [3, 4, 6, 9, 11, 13, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27]) -%% Test input validation +## Test input validation %!error strchr () %!error strchr (1) %!error <STR argument must be a string> strchr (1, "aeiou")
--- a/scripts/strings/strjoin.m +++ b/scripts/strings/strjoin.m @@ -40,7 +40,7 @@ ## @result{} 'Octave*Scilab*Lush*Yorick' ## @end group ## @end example -## @seealso {strsplit} +## @seealso{strsplit} ## @end deftypefn ## Author: Muthiah Annamalai <muthiah.annamalai@uta.edu>
--- a/scripts/strings/strjust.m +++ b/scripts/strings/strjust.m @@ -104,7 +104,7 @@ %! [" a "; " ab"; "abc "; "abcd"]) %!assert (strjust (["";""]), "") -%% Test input validation +## Test input validation %!error <Invalid call to strjust> strjust () %!error <Invalid call to strjust> strjust (["a";"ab"], "center", 1) %!error <S must be a string> strjust (ones (3,3))
--- a/scripts/strings/strsplit.m +++ b/scripts/strings/strsplit.m @@ -83,7 +83,7 @@ ## ## Example: ## -## @example +## @smallexample ## strsplit ("a foo b,bar c", ",|\\s|foo|bar", "delimitertype", "regularexpression") ## @result{} ## @{ @@ -120,7 +120,7 @@ ## [1,5] = ## [1,6] = c ## @} -## @end example +## @end smallexample ## ## @seealso{ostrsplit, strjoin, strtok, regexp} ## @end deftypefn @@ -280,13 +280,13 @@ %! assert (s, {"hello", "world"}); %! assert (m, {" \t "}); -%% Compatibility +## Compatibility %! assert (strsplit ("", "a"), {""}) %! assert (strsplit ("a", "a"), {"", ""}) %! assert (strsplit ("aa", "a"), {"", ""}) %! assert (strsplit ("aaa", "a"), {"", ""}) -%% Test input validation +## Test input validation %!error strsplit () %!error strsplit ("abc", "b", true, 4) %!error <S and DEL must be string values> strsplit (123, "b")
--- a/scripts/strings/strtok.m +++ b/scripts/strings/strtok.m @@ -152,7 +152,7 @@ %! % a variety of delimiters. Tokens and delimiters are %! % printed one after another in angle brackets. -%% Test the tokens for all cases +## Test the tokens for all cases %!assert (strtok (""), ""); # no string %!assert (strtok ("this"), "this"); # no delimiter in string %!assert (strtok ("this "), "this"); # delimiter at end @@ -161,7 +161,7 @@ %!assert (strtok (" this "), "this"); # delimiter at start and end %!assert (strtok (" "), ""(1:0)); # delimiter only -%% Test the remainder for all cases +## Test the remainder for all cases %!test [t,r] = strtok (""); assert (r, ""); %!test [t,r] = strtok ("this"); assert (r, ""); %!test [t,r] = strtok ("this "); assert (r, " "); @@ -170,7 +170,7 @@ %!test [t,r] = strtok (" this "); assert (r, " "); %!test [t,r] = strtok (" "); assert (r, ""); -%% Test all tokens and remainders with cell array input +## Test all tokens and remainders with cell array input %!test %! str = {"", "this", "this ", "this is", " this", " this ", " "}; %! [t, r] = strtok (str); @@ -189,12 +189,12 @@ %! assert (t{7}, ""); %! assert (r{7}, ""); -%% Simple check for 2, 3, and 4 delimeters +## Simple check for 2, 3, and 4 delimeters %!assert (strtok ("this is", "i "), "th") %!assert (strtok ("this is", "ij "), "th") %!assert (strtok ("this is", "ijk "), "th") -%% Test all cases for 8 delimiters since a different +## Test all cases for 8 delimiters since a different %!# algorithm is used when more than 7 delimiters %!assert (strtok ("","jklmnop "), "") %!assert (strtok ("this","jklmnop "), "this") @@ -204,11 +204,11 @@ %!assert (strtok (" this ","jklmnop "), "this") %!assert (strtok (" ","jklmnop "), ""(1:0)) -%% Test 'bad' string orientations +## Test 'bad' string orientations %!assert (strtok (" this ".'), "this".'); # delimiter at start and end %!assert (strtok (" this ".',"jkl "), "this".'); -%% Test with TAB, LF, VT, FF, and CR +## Test with TAB, LF, VT, FF, and CR %!test %! for ch = "\t\n\v\f\r" %! [t, r] = strtok (["beg", ch, "end"]); @@ -216,7 +216,7 @@ %! assert (r, [ch, "end"]); %! endfor -%% Test input validation +## Test input validation %!error strtok () %!error strtok ("a", "b", "c") %!error <STR must be a string> strtok (1, "b")
--- a/scripts/strings/strtrunc.m +++ b/scripts/strings/strtrunc.m @@ -68,7 +68,7 @@ %! assert (size (y{2}), [2, 4]); %! assert (y{2}, repmat ("line", 2, 1)); -%% Test input validation +## Test input validation %!error strtrunc () %!error strtrunc ("abcd") %!error strtrunc ("abcd", 4, 5)
--- a/scripts/strings/substr.m +++ b/scripts/strings/substr.m @@ -99,7 +99,7 @@ %!assert (substr ("This is a test string", 1, -7), "This is a test") %!assert (isempty (substr ("This is a test string", 1, 0))) -%% Test input validation +## Test input validation %!error substr () %!error substr ("foo", 2, 3, 4) %!error substr (ones (5, 1), 1, 1)
--- a/scripts/strings/validatestring.m +++ b/scripts/strings/validatestring.m @@ -151,7 +151,7 @@ %!error <DUMMY_TEST: DUMMY_VAR \(argument #5\) does> validatestring ("xyz", strarray, "DUMMY_TEST", "DUMMY_VAR", 5) %!error <'abc' allows multiple unique matches> validatestring ("abc", strarray) -%% Test input validation +## Test input validation %!error validatestring ("xyz") %!error validatestring ("xyz", {"xyz"}, "3", "4", 5, 6) %!error <invalid number of character inputs> validatestring ("xyz", {"xyz"}, "3", "4", "5")
--- a/scripts/testfun/assert.m +++ b/scripts/testfun/assert.m @@ -296,12 +296,14 @@ ## Replace exceptional values already checked above by zero. A_null_real = real (A); B_null_real = real (B); - exclude = errseen | ! isfinite (A_null_real) & ! isfinite (B_null_real); + exclude = errseen ... + | ! isfinite (A_null_real) & ! isfinite (B_null_real); A_null_real(exclude) = 0; B_null_real(exclude) = 0; A_null_imag = imag (A); B_null_imag = imag (B); - exclude = errseen | ! isfinite (A_null_imag) & ! isfinite (B_null_imag); + exclude = errseen ... + | ! isfinite (A_null_imag) & ! isfinite (B_null_imag); A_null_imag(exclude) = 0; B_null_imag(exclude) = 0; A_null = complex (A_null_real, A_null_imag); @@ -625,10 +627,10 @@ %! if (sum (errmsg () == "\n") != 6) %! error ("Incorrect number of errors reported"); %! endif -%! assert (!isempty (regexp (errmsg, '\(1,2\).*Abs err 3 exceeds tol 0\>'))); -%! assert (!isempty (regexp (errmsg, '\(2,2\).*Abs err 2 exceeds tol 0.3'))); -%! assert (!isempty (regexp (errmsg, '\(1,1\).*Abs err 1 exceeds tol 0.1'))); -%! assert (!isempty (regexp (errmsg, '\(2,1\).*Rel err 2 exceeds tol 0.2'))); +%! assert (! isempty (regexp (errmsg, '\(1,2\).*Abs err 3 exceeds tol 0\>'))); +%! assert (! isempty (regexp (errmsg, '\(2,2\).*Abs err 2 exceeds tol 0.3'))); +%! assert (! isempty (regexp (errmsg, '\(1,1\).*Abs err 1 exceeds tol 0.1'))); +%! assert (! isempty (regexp (errmsg, '\(2,1\).*Rel err 2 exceeds tol 0.2'))); %! end_try_catch ## test input validation
--- a/scripts/testfun/example.m +++ b/scripts/testfun/example.m @@ -110,7 +110,7 @@ %! "\n example (\"example\");\n clf;\n t = 0:0.01:2*pi;\n x = sin (t);\n plot (t,x)"); %! assert (idx, [1, 23, 73]); -%% Test input validation +## Test input validation %!error example () %!error example ("example", 3, 5) %!error <N must be a scalar integer> example ("example", {1})
--- a/scripts/testfun/fail.m +++ b/scripts/testfun/fail.m @@ -142,15 +142,15 @@ %!fail ("fail ('[1,2]*[2,3]', 'usage:')", "expected error <usage:>\nbut got.*nonconformant") %!fail ("warning ('test warning')", "warning", "test warning"); -##% !fail ("warning ('next test')",'warning','next test'); ## only allowed one warning test?!? +#%!fail ("warning ('next test')",'warning','next test'); # only allowed one warning test?!? -%% Test that fail() itself will generate an error +## Test that fail() itself will generate an error %!error <expected error> fail ("1") %!error <'a' undefined> fail ("a*[2;3]", "nonconformant") %!error <expected error .usage:> fail ("a*[2,3]", "usage:") %!error <warning failure> fail ("warning ('warning failure')", "warning", "success") -%% Test input validation +## Test input validation %!error fail () %!error fail (1,2,3,4)
--- a/scripts/testfun/private/compare_plot_demos.m +++ b/scripts/testfun/private/compare_plot_demos.m @@ -98,7 +98,8 @@ try eval (fcn_name); catch - printf ("Error running plot demos for ""%s"" toolkit\n", arg.toolkits{n}); + printf ("Error running plot demos for ""%s"" toolkit\n", + arg.toolkits{n}); disp (lasterror); end_try_catch endif
--- a/scripts/testfun/private/dump_demos.m +++ b/scripts/testfun/private/dump_demos.m @@ -117,9 +117,9 @@ fprintf (fid, "\ntry\n"); ## First check if the file already exists, skip demo if found fprintf (fid, " if (! exist ('%s', 'file'))\n", fn); - ## Invoke the ancient, deprecated random seed - ## generators, but there is an initialization mismatch with the more modern - ## generators reported here (https://savannah.gnu.org/bugs/?42557). + ## Invoke the ancient, deprecated random seed generators, but there is an + ## initialization mismatch with the more modern generators reported + ## here (https://savannah.gnu.org/bugs/?42557). fprintf (fid, " rand ('seed', 1);\n"); fprintf (fid, " tic ();\n"); fprintf (fid, " %s\n\n", demos{d}); @@ -133,7 +133,7 @@ fprintf (fid, " t_print = toc ();\n"); fprintf (fid, " fprintf ('[%%f %%f] done\\n',t_plot, t_print);\n"); fprintf (fid, " end\n"); - # Temporary fix for cruft accumulating in figure window. + ## Temporary fix for cruft accumulating in figure window. fprintf (fid, " close ('all');\n"); fprintf (fid, " else\n"); fprintf (fid, " fprintf ('File ""%s"" already exists.\\n');\n", fn);
--- a/scripts/testfun/private/html_compare_plot_demos.m +++ b/scripts/testfun/private/html_compare_plot_demos.m @@ -45,11 +45,9 @@ ## Additional toolkit description can be added to the column header ## with a parameter named equal to the toolkit. For example: ## -## @example -## @group -## @code{html_compare_plot_demos ({"gnuplot", "fltk"}, "gnuplot", " 4.6 patchlevel 5")} -## @end group -## @end example +## @smallexample +## @code{html_compare_plot_demos ({"gnuplot", "fltk"}, "gnuplot", " 4.6 patchlevel 5")} +## @end smallexample ## ## @seealso{compare_plot_demos, dump_demos, demo} ## @end deftypefn @@ -99,7 +97,8 @@ if (isfield (in, toolkits{t})) column_header = strcat (column_header, in.(toolkits{t})); endif - fprintf (fid, '<th>%s <a href="%s/diary.log">diary</a></th>\n', column_header, toolkits{t}); + fprintf (fid, '<th>%s <a href="%s/diary.log">diary</a></th>\n', ... + column_header, toolkits{t}); endfor fprintf (fid, "</tr>\n"); @@ -111,7 +110,8 @@ ffn = fullfile (k{:}, fn); fprintf (fid, " <td>%s<br>", ffn); if (exist (ffn, "file")) - fprintf (fid, "<img src='%s' style='width: %dpx;'>", ffn, in.column_width); + fprintf (fid, "<img src='%s' style='width: %dpx;'>", ... + ffn, in.column_width); else err_fn = regexprep(ffn, ".png", ".err"); if (! exist (err_fn, "file"))
--- a/scripts/testfun/speed.m +++ b/scripts/testfun/speed.m @@ -348,11 +348,11 @@ endfunction -%% FIXME: Demos with declared functions do not work. See bug #31815. -%% A workaround has been hacked by not declaring the functions -%% but using eval to create them in the proper context. -%% Unfortunately, we can't remove them from the user's workspace -%% because of another bug (#34497). +## FIXME: Demos with declared functions do not work. See bug #31815. +## A workaround has been hacked by not declaring the functions +## but using eval to create them in the proper context. +## Unfortunately, we can't remove them from the user's workspace +## because of another bug (#34497). %!demo %! fstr_build_orig = cstrcat ( %! "function x = build_orig (n)\n", @@ -440,7 +440,7 @@ %! assert (isnumeric (T_f2)); %! assert (length (T_f2) > 10); -%% Test input validation +## Test input validation %!error speed () %!error speed (1, 2, 3, 4, 5, 6, 7)
--- a/scripts/testfun/test.m +++ b/scripts/testfun/test.m @@ -575,7 +575,7 @@ if (! isempty(__code)) try ## FIXME: Must check for embedded test functions, which cause - ## segfaults, until issues with subfunctions in functions are resolved. + ## segfaults, until issues with subfunctions in functions are fixed. embed_func = regexp (__code, '^\s*function ', 'once', 'lineanchors'); if (isempty (embed_func)) eval (sprintf ("function %s__test__(%s)\n%s\nendfunction", @@ -820,7 +820,7 @@ %!test a = 3; # assign to a shared variable %!test assert (a, 3) # variable should equal 3 %!shared b,c # replace shared variables -%!test assert (!exist ("a", "var")); # a no longer exists +%!test assert (! exist ("a", "var")); # a no longer exists %!test assert (isempty (b)); # variables start off empty %!shared a,b,c # recreate a shared variable %!test assert (isempty (a)); # value is empty even if it had a previous value @@ -829,7 +829,7 @@ %!test c=6; # update a value %!test assert ([a,b,c], [1,2,6]); # show that the update sticks %!shared # clear all shared variables -%!test assert (!exist ("a", "var")) # show that they are cleared +%!test assert (! exist ("a", "var")) # show that they are cleared %!shared a,b,c # support for initializer shorthand %! a=1; b=2; c=4; %!shared # clear all shared variables for remainder of tests @@ -889,7 +889,7 @@ %! and it stays as a comment even through continuation lines %! which means that it works well with commenting out whole tests -%% Test test() input validation +## Test test() input validation %!error <NAME must be a string> test (1) %!error <second argument must be a string> test ("ls", 1) %!error test ([], "normal")
--- a/scripts/time/addtodate.m +++ b/scripts/time/addtodate.m @@ -115,7 +115,7 @@ %!assert (addtodate ([d;d+1], 1, "month"), [d+31;d+1+31]) %!assert (addtodate ([d d+1], 1, "month"), [d+31 d+1+31]) -%% Test input validation +## Test input validation %!error addtodate () %!error addtodate (1) %!error addtodate (1,2)
--- a/scripts/time/calendar.m +++ b/scripts/time/calendar.m @@ -99,6 +99,6 @@ %!assert ((calendar(2000,2))'(2:31), [0:29]) %!assert ((calendar(1957,10))'(2:33), [0:31]) -%% Test input validation +## Test input validation %!error calendar (1,2,3)
--- a/scripts/time/datenum.m +++ b/scripts/time/datenum.m @@ -118,12 +118,13 @@ endif endif - if (! (isa (year, "double") && isa (month, "double") && isa (day, "double") && - isa (hour, "double") && isa (minute, "double") && isa (second, "double"))) + if (! (isa (year, "double") && isa (month, "double") + && isa (day, "double") && isa (hour, "double") + && isa (minute, "double") && isa (second, "double"))) error ("datenum: all inputs must be of class double"); endif - month(month<1) = 1; # For compatibility. Otherwise allow negative months. + month(month < 1) = 1; # For compatibility. Otherwise allow negative months. ## Treat fractional months, by converting the fraction to days if (floor (month) != month) @@ -208,7 +209,7 @@ ## Test string input with format string %!assert (datenum ("5-19, 2001", "mm-dd, yyyy"), 730990) -%% Test input validation +## Test input validation %!error datenum () %!error datenum (1,2,3,4,5,6,7) %!error <expected date vector containing> datenum ([1, 2])
--- a/scripts/time/datestr.m +++ b/scripts/time/datestr.m @@ -340,7 +340,7 @@ ## Test fractional millisecond time extension %!assert (datestr (testtime, "HH:MM:SS:FFF"), "02:33:17:382") -%% Test input validation +## Test input validation %!error datestr () %!error datestr (1, 2, 3, 4)
--- a/scripts/time/datevec.m +++ b/scripts/time/datevec.m @@ -125,8 +125,10 @@ for k = 1:nd found = false; for l = 1:nfmt - [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (std_formats{l}); - [found y(k) m(k) d(k) h(k) mi(k) s(k)] = __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs); + [f, rY, ry, fy, fm, fd, fh, fmi, fs] = ... + __date_vfmt2sfmt__ (std_formats{l}); + [found y(k) m(k) d(k) h(k) mi(k) s(k)] = ... + __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs); if (found) break; endif @@ -139,7 +141,8 @@ ## Decipher the format string just once for speed. [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (f); for k = 1:nd - [found y(k) m(k) d(k) h(k) mi(k) s(k)] = __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs); + [found y(k) m(k) d(k) h(k) mi(k) s(k)] = ... + __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs); if (! found) error ("datevec: DATE not parsed correctly with given format"); endif @@ -335,7 +338,7 @@ %!assert (double (datevec (int64 (datenum ([2014 6 1])))), datevec (datenum ([2014 6 1]))) %!assert (double (datevec (int64 (datenum ([2014 6 18])))), datevec (datenum ([2014 6 18]))) -%% Test input validation +## Test input validation %!error datevec () %!error datevec (1,2,3,4) %!error <none of the standard formats match> datevec ("foobar")
--- a/scripts/time/eomday.m +++ b/scripts/time/eomday.m @@ -45,7 +45,6 @@ %! e = eomday (y, repmat (2, [1, 100])); %! y(find (e == 29)) -# tests %!assert (eomday ([-4:4],2), [29,28,28,28,29,28,28,28,29]) %!assert (eomday ([-901,901],2), [28,28]) %!assert (eomday ([-100,100],2), [28,28]) @@ -58,7 +57,7 @@ %!assert ([1900:1999](find(eomday(1900:1999,2*ones(1,100))==29)), [1904,1908,1912,1916,1920,1924,1928,1932,1936,1940,1944,1948,1952,1956,1960,1964,1968,1972,1976,1980,1984,1988,1992,1996]) %!assert (eomday ([2004;2005], [2;2]), [29;28]) -%% Test input validation +## Test input validation %!error eomday () %!error eomday (1) %!error eomday (1,2,3)