Mercurial > octave
changeset 22765:01aae08a0105
maint: Rename variables to match documentation in m-files.
* fminbnd.m, javaclasspath.m, ls_command.m, isprop.m, roots.m, bicg.m, cgs.m,
qmr.m, dump_demos.m:
Rename variables in function to match documentation.
* normest1.m, AbsRel_norm.m, colstyle.m, frame2im.m, rotate.m:
Rename variables in documentation to match function.
* recycle.m: Rename variable 'state' to 'val' in documentation, and then
throughout code.
* untabify.m: Rename variable 'dblank' to 'deblank_arg'.
* speed.m: Add comment about why variable names can't match documentation.
line wrap: on
line diff
--- a/scripts/general/interp1.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/general/interp1.m Mon Nov 14 14:55:41 2016 -0800 @@ -366,7 +366,7 @@ endif otherwise - error ("interp1: invalid METHOD '%s'", METHOD); + error ("interp1: invalid METHOD '%s'", method); endswitch @@ -793,5 +793,5 @@ %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "pchip") %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "cubic") %!error <discontinuities not supported> interp1 ([1 1],[1 2],1, "spline") -%!error <invalid method 'invalid'> interp1 (1:2,1:2,1, "invalid") +%!error <invalid METHOD 'invalid'> interp1 (1:2,1:2,1, "invalid")
--- a/scripts/general/randi.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/general/randi.m Mon Nov 14 14:55:41 2016 -0800 @@ -209,5 +209,5 @@ %!error <require IMIN <= IMAX> randi ([10, 1]) %!error <IMIN and IMAX must be smaller than flintmax\(\)> randi (flintmax ()) %!error <range must be smaller than flintmax\(\)-1> randi ([-1, flintmax() - 1]) -%!error <unknown requested output class 'foo'> randi (10, "foo") +%!error <unknown requested output CLASS 'foo'> randi (10, "foo")
--- a/scripts/image/rgbplot.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/image/rgbplot.m Mon Nov 14 14:55:41 2016 -0800 @@ -90,5 +90,5 @@ %!error rgbplot (1,2) %!error <CMAP must be a valid colormap> rgbplot ({0 1 0}) %!error <STYLE must be a string> rgbplot ([0 1 0], 2) -%!error <unknown style 'nostyle'> rgbplot ([0 1 0], "nostyle") +%!error <unknown STYLE 'nostyle'> rgbplot ([0 1 0], "nostyle")
--- a/scripts/java/javachk.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/java/javachk.m Mon Nov 14 14:55:41 2016 -0800 @@ -148,5 +148,5 @@ %! assert (javachk ("jvm"), ""); ## Test input validation -%!error <javachk: unrecognized feature 'foobar'> javachk ("foobar") +%!error <javachk: unrecognized FEATURE 'foobar'> javachk ("foobar")
--- a/scripts/java/javaclasspath.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/java/javaclasspath.m Mon Nov 14 14:55:41 2016 -0800 @@ -54,7 +54,7 @@ ## @seealso{javaaddpath, javarmpath} ## @end deftypefn -function [path1, path2] = javaclasspath (which) +function [path1, path2] = javaclasspath (what = "") if (nargin > 1) print_usage (); @@ -77,9 +77,9 @@ if (nargout == 0) if (! nargin) - which = "-all"; + what = "-all"; endif - switch (tolower (which)) + switch (tolower (what)) case "-dynamic", disp_path_list ("DYNAMIC", dynamic_path_list); case "-static", disp_path_list ("STATIC", static_path_list); case "-all" @@ -98,7 +98,7 @@ path1 = cellstr (dynamic_path_list); path2 = cellstr (static_path_list); else - switch (tolower (which)) + switch (tolower (what)) case "-all", path1 = cellstr ([static_path_list,dynamic_path_list]); case "-dynamic", path1 = cellstr (dynamic_path_list); case "-static", path1 = cellstr (static_path_list); @@ -112,8 +112,8 @@ ## Display cell array of paths -function disp_path_list (which, path_list) - printf (" %s JAVA PATH\n\n", which); +function disp_path_list (what, path_list) + printf (" %s JAVA PATH\n\n", what); if (numel (path_list) > 0) printf (" %s\n", path_list{:}); else
--- a/scripts/java/usejava.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/java/usejava.m Mon Nov 14 14:55:41 2016 -0800 @@ -95,5 +95,5 @@ %!error usejava () %!error usejava (1, 2) %!error usejava (1) -%!error <unrecognized feature> usejava ("abc") +%!error <unrecognized FEATURE> usejava ("abc")
--- a/scripts/linear-algebra/normest1.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/linear-algebra/normest1.m Mon Nov 14 14:55:41 2016 -0800 @@ -17,40 +17,40 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{c} =} normest1 (@var{a}) -## @deftypefnx {} {@var{c} =} normest1 (@var{a}, @var{t}) -## @deftypefnx {} {@var{c} =} normest1 (@var{a}, @var{t}, @var{x0}) -## @deftypefnx {} {@var{c} =} normest1 (@var{afun}, @var{t}, @var{x0}, @var{p1}, @var{p2}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}] =} normest1 (@var{a}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}, @var{w}] =} normest1 (@var{a}, @dots{}) -## @deftypefnx {} {[@var{c}, @var{v}, @var{w}, @var{it}] =} normest1 (@var{a}, @dots{}) -## Estimate the 1-norm of the matrix @var{a} using a block algorithm. +## @deftypefn {} {@var{c} =} normest1 (@var{A}) +## @deftypefnx {} {@var{c} =} normest1 (@var{A}, @var{t}) +## @deftypefnx {} {@var{c} =} normest1 (@var{A}, @var{t}, @var{x0}) +## @deftypefnx {} {@var{c} =} normest1 (@var{Afun}, @var{t}, @var{x0}, @var{p1}, @var{p2}, @dots{}) +## @deftypefnx {} {[@var{c}, @var{v}] =} normest1 (@var{A}, @dots{}) +## @deftypefnx {} {[@var{c}, @var{v}, @var{w}] =} normest1 (@var{A}, @dots{}) +## @deftypefnx {} {[@var{c}, @var{v}, @var{w}, @var{it}] =} normest1 (@var{A}, @dots{}) +## Estimate the 1-norm of the matrix @var{A} using a block algorithm. ## -## For a medium size matrix @var{a}, @code{norm (@var{a}, 1)} should be +## For a medium size matrix @var{A}, @code{norm (@var{A}, 1)} should be ## used instead. For a large sparse matrix, when only an estimate of the norm -## is needed, @code{normest1 (@var{a})} might be faster. Moreover, it can be +## is needed, @code{normest1 (@var{A})} might be faster. Moreover, it can be ## used for the estimate of the 1-norm of a linear -## operator @var{a} when matrix-vector products @code{@var{a} * @var{x}} and -## @code{@var{a}' * @var{x}} can be cheaply computed. In this case, -## instead of the matrix @var{a}, a function -## @code{@var{afun} (@var{flag}, @var{x})} can be used. It should return: +## operator @var{A} when matrix-vector products @code{@var{A} * @var{x}} and +## @code{@var{A}' * @var{x}} can be cheaply computed. In this case, +## instead of the matrix @var{A}, a function +## @code{@var{Afun} (@var{flag}, @var{x})} can be used. It should return: ## ## @itemize @bullet ## @item -## the dimension @var{n} of @var{a}, if @var{flag} is @qcode{"dim"} +## the dimension @var{n} of @var{A}, if @var{flag} is @qcode{"dim"} ## ## @item -## true if @var{a} is a real operator, if @var{flag} is @qcode{"real"} +## true if @var{A} is a real operator, if @var{flag} is @qcode{"real"} ## ## @item -## the result @code{@var{a} * @var{x}}, if @var{flag} is @qcode{"notransp"} +## the result @code{@var{A} * @var{x}}, if @var{flag} is @qcode{"notransp"} ## ## @item -## the result @code{@var{a}' * @var{x}}, if @var{flag} is @qcode{"transp"} +## the result @code{@var{A}' * @var{x}}, if @var{flag} is @qcode{"transp"} ## @end itemize ## -## A typical case is @var{a} defined by @code{@var{b} ^ @var{m}}, -## in which the result @code{@var{a} * @var{x}} can be computed without +## A typical case is @var{A} defined by @code{@var{b} ^ @var{m}}, +## in which the result @code{@var{A} * @var{x}} can be computed without ## even forming explicitly @code{@var{b} ^ @var{m}} by: ## ## @example @@ -63,7 +63,7 @@ ## @end example ## ## The parameters @var{p1}, @var{p2}, @dots{} are arguments of -## @code{@var{afun} (@var{flag}, @var{x}, @var{p1}, @var{p2}, @dots{})}. +## @code{@var{Afun} (@var{flag}, @var{x}, @var{p1}, @var{p2}, @dots{})}. ## ## The default value for @var{t} is 2. The algorithm requires ## matrix-matrix products with sizes @var{n} x @var{n} and @@ -78,12 +78,12 @@ ## random generator should be fixed before invoking @code{normest1}. ## ## On output, @var{c} is the desired estimate, @var{v} and @var{w} -## vectors such that @code{@var{w} = @var{a} * @var{v}}, with +## vectors such that @code{@var{w} = @var{A} * @var{v}}, with ## @code{norm (@var{w}, 1)} = @code{@var{c} * norm (@var{v}, 1)}. ## @var{it} contains in @code{@var{it}(1)} the number of iterations ## (the maximum number is hardcoded to 5) and in @code{@var{it}(2)} -## the total number of products @code{@var{a} * @var{x}} or -## @code{@var{a}' * @var{x}} performed by the algorithm. +## the total number of products @code{@var{A} * @var{x}} or +## @code{@var{A}' * @var{x}} performed by the algorithm. ## ## Reference: @nospell{N. J. Higham and F. Tisseur}, ## @cite{A block algorithm for matrix 1-norm estimation, with and @@ -97,7 +97,7 @@ ## Ideally, we would set t and X to their default values but Matlab ## compatibility would require we set the default even when they are ## empty. -function [est, v, w, k] = normest1 (A, t = [], X = [], varargin) +function [est, v, w, k] = normest1 (A, t = [], x0 = [], varargin) if (nargin < 1) print_usage (); @@ -137,7 +137,7 @@ t = min (t, n); - if (isempty (X)) + if (isempty (x0)) X = [ones(n, 1), sign(2 * rand(n, t - 1) - 1)]; i = 2; imax = min (t, 2 ^ (n - 1)); @@ -151,8 +151,10 @@ endif endwhile X /= n; - elseif (columns (X) < t) + elseif (columns (x0) < t) error ("normest1: X should have %d columns", t); + else + X = x0; endif itmax = 5; @@ -245,8 +247,10 @@ endwhile v = zeros (n, 1); v(ind_best) = 1; + endfunction + %!function z = afun_A (flag, x, A, n) %! switch flag %! case {"dim"} @@ -370,3 +374,4 @@ %! assert (iscolumn (it)) %! [~, ~, ~, it] = normest1 (rand (50), 20); %! assert (iscolumn (it)) +
--- a/scripts/miscellaneous/ls_command.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/miscellaneous/ls_command.m Mon Nov 14 14:55:41 2016 -0800 @@ -25,7 +25,7 @@ ## Author: jwe -function old_cmd = ls_command (cmd) +function old_val = ls_command (new_val) global __ls_command__; @@ -41,14 +41,14 @@ if (nargin == 0 || nargin == 1) - old_cmd = __ls_command__; + old_val = __ls_command__; if (nargin == 1) - if (ischar (cmd)) - __ls_command__ = cmd; - else + if (! ischar (new_val)) error ("ls_command: argument must be a character string"); endif + + __ls_command__ = new_val; endif endif
--- a/scripts/miscellaneous/recycle.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/miscellaneous/recycle.m Mon Nov 14 14:55:41 2016 -0800 @@ -17,8 +17,8 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {@var{current_state} =} recycle () -## @deftypefnx {} {@var{old_state} =} recycle (@var{new_state}) +## @deftypefn {} {@var{val} =} recycle () +## @deftypefnx {} {@var{old_val} =} recycle (@var{new_val}) ## Query or set the preference for recycling deleted files. ## ## When recycling is enabled, commands which would permanently erase files @@ -33,7 +33,7 @@ ## Author: jwe -function retval = recycle (state) +function val = recycle (new_val) persistent current_state = "off"; @@ -42,20 +42,20 @@ endif if (nargin == 0 || nargout > 0) - retval = current_state; + val = current_state; endif if (nargin == 1) - if (! ischar (state)) - error ("recycle: STATE must be a character string"); + if (! ischar (new_val)) + error ("recycle: NEW_VAL must be a character string"); endif - if (strcmpi (state, "on")) + if (strcmpi (new_val, "on")) error ("recycle: recycling files is not implemented"); - elseif (strcmpi (state, "off")) + elseif (strcmpi (new_val, "off")) current_state = "off"; else - error ("recycle: invalid value of STATE = '%s'", state); + error ("recycle: invalid value '%s'", new_val); endif endif @@ -67,7 +67,7 @@ %! assert (recycle ("off"), "off"); %!error recycle ("on", "and I mean it") -%!error <STATE must be a character string> recycle (1) +%!error <NEW_VAL must be a character string> recycle (1) %!error <recycling files is not implemented> recycle ("on") -%!error <invalid value of STATE = 'foobar'> recycle ("foobar") +%!error <invalid value 'foobar'> recycle ("foobar")
--- a/scripts/miscellaneous/unpack.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/miscellaneous/unpack.m Mon Nov 14 14:55:41 2016 -0800 @@ -342,9 +342,9 @@ %!error unpack () %!error unpack (1,2,3,4) %!error <FILE must be a string or cell array of strings> unpack (1) -%!error <file "_%NOT_A_FILENAME%_" not found> unpack ("_%NOT_A_FILENAME%_") -%!error <file "_%NOT_A_FILENAME%_" not found> unpack ({"_%NOT_A_FILENAME%_"}) -%!error <file "_%NOT_A_FILENAME%_" not found> unpack ({"_%NOT_A_FILENAME%_", "2nd_filename"}) +%!error <FILE "_%NOT_A_FILENAME%_" not found> unpack ("_%NOT_A_FILENAME%_") +%!error <FILE "_%NOT_A_FILENAME%_" not found> unpack ({"_%NOT_A_FILENAME%_"}) +%!error <FILE "_%NOT_A_FILENAME%_" not found> unpack ({"_%NOT_A_FILENAME%_", "2nd_filename"}) %!error <FILETYPE must be given for a directory> %! if (isunix || ismac) %! unpack ("/");
--- a/scripts/ode/private/AbsRel_norm.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/ode/private/AbsRel_norm.m Mon Nov 14 14:55:41 2016 -0800 @@ -18,7 +18,7 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {retval =} AbsRel_norm (@var{x}, @var{x_old}, @var{AbsTol}, @var{RelTol}, @var{normcoontrol}, @var{y}) +## @deftypefn {} {retval =} AbsRel_norm (@var{x}, @var{x_old}, @var{AbsTol}, @var{RelTol}, @var{normcontrol}, @var{y}) ## Undocumented internal function. ## @end deftypefn
--- a/scripts/optimization/fminbnd.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/optimization/fminbnd.m Mon Nov 14 14:55:41 2016 -0800 @@ -60,7 +60,7 @@ ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup. ## PKG_ADD: [~] = __all_opts__ ("fminbnd"); -function [x, fval, info, output] = fminbnd (fun, xmin, xmax, options = struct ()) +function [x, fval, info, output] = fminbnd (fun, a, b, options = struct ()) ## Get default options if requested. if (nargin == 1 && ischar (fun) && strcmp (fun, 'defaults')) @@ -73,7 +73,7 @@ print_usage (); endif - if (xmin > xmax) + if (a > b) error ("Octave:invalid-input-arg", "fminbnd: the lower bound cannot be greater than the upper one"); endif @@ -100,14 +100,13 @@ nfev = 0; c = 0.5*(3 - sqrt (5)); - a = xmin; b = xmax; v = a + c*(b-a); w = x = v; e = 0; fv = fw = fval = fun (x); nfev += 1; - if (isa (xmin, "single") || isa (xmax, "single") || isa (fval, "single")) + if (isa (a, "single") || isa (b, "single") || isa (fval, "single")) sqrteps = eps ("single"); else sqrteps = eps ("double");
--- a/scripts/pkg/private/describe.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/pkg/private/describe.m Mon Nov 14 14:55:41 2016 -0800 @@ -22,8 +22,7 @@ ## Undocumented internal function. ## @end deftypefn -function [pkg_desc_list, flag] = describe (pkgnames, verbose, - local_list, global_list) +function [pkg_desc_list, flag] = describe (pkgnames, verbose, local_list, global_list) ## Get the list of installed packages. installed_pkgs_lst = installed_packages(local_list, global_list);
--- a/scripts/plot/appearance/annotation.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/plot/appearance/annotation.m Mon Nov 14 14:55:41 2016 -0800 @@ -1525,7 +1525,7 @@ %! end_unwind_protect ## Test input validation -%!error <unknown annotation type foo> annotation ("foo") +%!error <unknown annotation TYPE foo> annotation ("foo") %!error annotation ([], "foo") %!error annotation ({}) %!error annotation ("line", [.5 .6])
--- a/scripts/plot/util/colstyle.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/plot/util/colstyle.m Mon Nov 14 14:55:41 2016 -0800 @@ -17,8 +17,9 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {[@var{style}, @var{color}, @var{marker}, @var{msg}] =} colstyle (@var{linespec}) -## Parse @var{linespec} and return the line style, color, and markers given. +## @deftypefn {} {[@var{style}, @var{color}, @var{marker}, @var{msg}] =} colstyle (@var{style}) +## Parse the line specification @var{style} and return the line style, color, +## and markers given. ## ## In the case of an error, the string @var{msg} will return the text of the ## error.
--- a/scripts/plot/util/frame2im.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/plot/util/frame2im.m Mon Nov 14 14:55:41 2016 -0800 @@ -17,13 +17,13 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {[@var{x}, @var{map}] =} frame2im (@var{f}) +## @deftypefn {} {[@var{x}, @var{map}] =} frame2im (@var{frame}) ## Convert movie frame to indexed image. ## ## A movie frame is simply a struct with the fields @qcode{"cdata"} and ## @qcode{"colormap"}. ## -## Support for N-dimensional images or movies is given when @var{f} is a +## Support for N-dimensional images or movies is given when @var{frame} is a ## struct array. In such cases, @var{x} will be a @nospell{MxNx1xK or MxNx3xK} ## for indexed and RGB movies respectively, with each frame concatenated ## along the 4th dimension.
--- a/scripts/plot/util/isprop.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/plot/util/isprop.m Mon Nov 14 14:55:41 2016 -0800 @@ -30,22 +30,22 @@ ## Author: Ben Abbott <bpabbott@mac.com> -function res = isprop (h, prop) +function res = isprop (obj, prop) if (nargin != 2) print_usage (); endif - if (! all (ishandle (h))) - error ("isprop: H must be a graphics handle or vector of handles"); + if (! all (ishandle (obj))) + error ("isprop: OBJ must be a graphics handle, vector of handles, or instance of a class"); elseif (! ischar (prop)) error ("isprop: PROP name must be a string"); endif - res = false (size (h)); + res = false (size (obj)); for i = 1:numel (res) try - v = get (h(i), prop); + v = get (obj(i), prop); res(i) = true; end_try_catch endfor @@ -60,6 +60,6 @@ %!error isprop () %!error isprop (1) %!error isprop (1,2,3) -%!error <H must be a graphics handle> isprop ({1}, "visible") +%!error <OBJ must be a graphics handle> isprop ({1}, "visible") %!error <PROP name must be a string> isprop (0, {"visible"})
--- a/scripts/plot/util/rotate.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/plot/util/rotate.m Mon Nov 14 14:55:41 2016 -0800 @@ -17,10 +17,10 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {} {} rotate (@var{h}, @var{dir}, @var{alpha}) +## @deftypefn {} {} rotate (@var{h}, @var{direction}, @var{alpha}) ## @deftypefnx {} {} rotate (@dots{}, @var{origin}) ## Rotate the plot object @var{h} through @var{alpha} degrees around the line -## with direction @var{dir} and origin @var{origin}. +## with direction @var{direction} and origin @var{origin}. ## ## The default value of @var{origin} is the center of the axes object that is ## the parent of @var{h}. @@ -180,10 +180,11 @@ %!error <all handles must be children of the same axes object> rotate ([o1, o2], [0,0,0], 90) %!error <invalid direction> rotate (o1, "foo", 90) %!error <invalid rotation angle> rotate (o1, [0,0,0], "foo") -%!error <invalid origin> rotate (o1, [0,0,0], 90, "foo") +%!error <invalid ORIGIN> rotate (o1, [0,0,0], 90, "foo") %!error rotate (o1, [0,0,0], 90, [0,0,0], 1) %!error <H must be an array of one or more graphics handles> rotate (NaN, [0,0,0], 90) %!error <expecting image, line, patch, or surface objects> rotate (o3, [0,0,0], 90) %!test %! close (h1); %! close (h2); +
--- a/scripts/polynomial/roots.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/polynomial/roots.m Mon Nov 14 14:55:41 2016 -0800 @@ -79,35 +79,35 @@ ## Created: 24 December 1993 ## Adapted-By: jwe -function r = roots (v) +function r = roots (c) - if (nargin != 1 || (! isvector (v) && ! isempty (v))) + if (nargin != 1 || (! isvector (c) && ! isempty (c))) print_usage (); - elseif (any (! isfinite (v))) + elseif (any (! isfinite (c))) error ("roots: inputs must not contain Inf or NaN"); endif - v = v(:); - n = numel (v); + c = c(:); + n = numel (c); - ## If v = [ 0 ... 0 v(k+1) ... v(k+l) 0 ... 0 ], + ## If c = [ 0 ... 0 c(k+1) ... c(k+l) 0 ... 0 ], ## we can remove the leading k zeros, ## and n - k - l roots of the polynomial are zero. - v_max = max (abs (v)); - if (isempty (v) || v_max == 0) + c_max = max (abs (c)); + if (isempty (c) || c_max == 0) r = []; return; endif - f = find (v ./ v_max); + f = find (c ./ c_max); m = numel (f); - v = v(f(1):f(m)); - l = numel (v); + c = c(f(1):f(m)); + l = numel (c); if (l > 1) A = diag (ones (1, l-2), -1); - A(1,:) = -v(2:l) ./ v(1); + A(1,:) = -c(2:l) ./ c(1); r = eig (A); if (f(m) < n) r = [r; zeros(n - f(m), 1)];
--- a/scripts/prefs/addpref.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/prefs/addpref.m Mon Nov 14 14:55:41 2016 -0800 @@ -88,11 +88,11 @@ %! assert (getpref ("group2", "prefB"), {"StringB"}); %! %! fail ('addpref ("group1", "pref1", 4)', ... -%! "preference pref1 already exists in group group1"); +%! "preference pref1 already exists in GROUP group1"); %! fail ('setpref ("group1", {"p1", "p2"}, 1)', ... %! "size mismatch for PREF and VAL"); %! fail ('addpref ("group2", {"prefC", "prefA"}, {1, 2})', -%! "preference prefA already exists in group group2"); +%! "preference prefA already exists in GROUP group2"); %! %! unwind_protect_cleanup %! unlink (fullfile (P_tmpdir (), ".octave_prefs"));
--- a/scripts/prefs/getpref.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/prefs/getpref.m Mon Nov 14 14:55:41 2016 -0800 @@ -129,7 +129,7 @@ %! assert (getpref ("group1", "pref2", "New_Value"), "New_Value"); %! assert (getpref ("group1", "pref2"), "New_Value"); %! fail ('getpref ("group1", "no_such_pref")', ... -%! "preference no_such_pref does not exist in group group1"); +%! "preference no_such_pref does not exist in GROUP group1"); %! %! assert (getpref ("group2", {"prefA", "prefB"}), {"StringA", {"StringB"}}); %! assert (getpref ("group2", {"prefA", "prefC"}, {1, "StringC"}), @@ -138,7 +138,7 @@ %! fail ('getpref ("group1", {"p1", "p2"}, 1)', ... %! "size mismatch for PREF and DEFAULT"); %! fail ('getpref ("group2", {"prefA", "prefD"})', -%! "preference prefD does not exist in group group2"); +%! "preference prefD does not exist in GROUP group2"); %! %! unwind_protect_cleanup %! unlink (fullfile (P_tmpdir (), ".octave_prefs"));
--- a/scripts/prefs/rmpref.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/prefs/rmpref.m Mon Nov 14 14:55:41 2016 -0800 @@ -89,9 +89,9 @@ %! assert (! ispref ("group2", "prefB")); %! %! fail ('rmpref ("group3")', ... -%! "group group3 does not exist"); +%! "GROUP group3 does not exist"); %! fail ('rmpref ("group3", "prefA")', ... -%! "group group3 does not exist"); +%! "GROUP group3 does not exist"); %! fail ('rmpref ("group2", "prefB")', %! "preference prefB does not exist"); %! fail ('rmpref ("group2", {"prefA", "prefB"})',
--- a/scripts/sparse/bicg.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/sparse/bicg.m Mon Nov 14 14:55:41 2016 -0800 @@ -74,7 +74,7 @@ ## Author: Sylvain Pelissier <sylvain.pelissier@gmail.com> ## Author: Carlo de Falco -function [x, flag, res1, k, resvec] = bicg (A, b, tol, maxit, M1, M2, x0) +function [x, flag, res1, k, resvec] = bicg (A, b, rtol, maxit, M1, M2, x0) if (nargin >= 2 && isvector (full (b))) @@ -92,8 +92,8 @@ error ("bicg: A must be a square matrix or function"); endif - if (nargin < 3 || isempty (tol)) - tol = 1e-6; + if (nargin < 3 || isempty (rtol)) + rtol = 1e-6; endif if (nargin < 4 || isempty (maxit)) @@ -176,7 +176,7 @@ s0 = s1; res1 = norm (b - Ax (x)) / bnorm; - if (res1 < tol) + if (res1 < rtol) flag = 0; if (nargout < 2) printf ("bicg converged at iteration %i ", k); @@ -188,7 +188,7 @@ if (res0 <= res1) flag = 3; printf ("bicg stopped at iteration %i ", k); - printf ("without converging to the desired tolerance %e\n", tol); + printf ("without converging to the desired tolerance %e\n", rtol); printf ("because the method stagnated.\n"); printf ("The iterate returned (number %i) ", k-1); printf ("has relative residual %e\n", res0); @@ -203,7 +203,7 @@ if (k == maxit) flag = 1; printf ("bicg stopped at iteration %i ", maxit); - printf ("without converging to the desired tolerance %e\n", tol); + printf ("without converging to the desired tolerance %e\n", rtol); printf ("because the maximum number of iterations was reached. "); printf ("The iterate returned (number %i) has ", maxit); printf ("relative residual %e\n", res1); @@ -227,11 +227,11 @@ %! n = 100; %! A = spdiags ([-2*ones(n,1) 4*ones(n,1) -ones(n,1)], -1:1, n, n); %! b = sum (A, 2); -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 15; %! M1 = spdiags ([ones(n,1)/(-2) ones(n,1)],-1:0, n, n); %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n); -%! [x, flag, relres, iter, resvec] = bicg (A, b, tol, maxit, M1, M2); +%! [x, flag, relres, iter, resvec] = bicg (A, b, rtol, maxit, M1, M2); %! assert (x, ones (size (b)), 1e-7); %!function y = afun (x, t, a) @@ -247,21 +247,21 @@ %! n = 100; %! A = spdiags ([-2*ones(n,1) 4*ones(n,1) -ones(n,1)], -1:1, n, n); %! b = sum (A, 2); -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 15; %! M1 = spdiags ([ones(n,1)/(-2) ones(n,1)],-1:0, n, n); %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n); %! %! [x, flag, relres, iter, resvec] = bicg (@(x, t) afun (x, t, A), -%! b, tol, maxit, M1, M2); +%! b, rtol, maxit, M1, M2); %! assert (x, ones (size (b)), 1e-7); %!test %! n = 100; -%! tol = 1e-8; +%! rtol = 1e-8; %! a = sprand (n, n, .1); %! A = a' * a + 100 * eye (n); %! b = sum (A, 2); -%! [x, flag, relres, iter, resvec] = bicg (A, b, tol, [], diag (diag (A))); +%! [x, flag, relres, iter, resvec] = bicg (A, b, rtol, [], diag (diag (A))); %! assert (x, ones (size (b)), 1e-7);
--- a/scripts/sparse/cgs.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/sparse/cgs.m Mon Nov 14 14:55:41 2016 -0800 @@ -68,7 +68,7 @@ ## @seealso{pcg, bicgstab, bicg, gmres, qmr} ## @end deftypefn -function [x, flag, relres, iter, resvec] = cgs (A, b, tol, maxit, M1, M2, x0) +function [x, flag, relres, iter, resvec] = cgs (A, b, rtol, maxit, M1, M2, x0) if (nargin >= 2 && nargin <= 7 && isvector (full (b))) @@ -82,8 +82,8 @@ error ("cgs: A must be a square matrix or function"); endif - if (nargin < 3 || isempty (tol)) - tol = 1e-6; + if (nargin < 3 || isempty (rtol)) + rtol = 1e-6; endif if (nargin < 4 || isempty (maxit)) @@ -128,7 +128,7 @@ ## Vector of the residual norms for each iteration. resvec = norm (res) / norm_b; ro = 0; - ## Default behavior we don't reach tolerance tol within maxit iterations. + ## Default behavior we don't reach tolerance rtol within maxit iterations. flag = 1; for iter = 1:maxit @@ -152,8 +152,8 @@ relres = norm (res) / norm_b; resvec = [resvec; relres]; - if (relres <= tol) - ## We reach tolerance tol within maxit iterations. + if (relres <= rtol) + ## We reach tolerance rtol within maxit iterations. flag = 0; break elseif (resvec(end) == resvec(end - 1)) @@ -171,12 +171,12 @@ printf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", "because the method stagnated.\n", "The iterate returned (number %i) has relative residual %e\n"], - iter, tol, iter, relres); + iter, rtol, iter, relres); else printf (["cgs stopped at iteration %i without converging to the desired tolerance %e\n", "because the maximum number of iterations was reached.\n", "The iterate returned (number %i) has relative residual %e\n"], - iter, tol, iter, relres); + iter, rtol, iter, relres); endif endif @@ -199,25 +199,25 @@ %! n = 100; %! A = spdiags ([-ones(n,1) 4*ones(n,1) -ones(n,1)], -1:1, n, n); %! b = sum (A, 2); -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 1000; %! M = 4*eye (n); -%! [x, flag, relres, iter, resvec] = cgs (A, b, tol, maxit, M); +%! [x, flag, relres, iter, resvec] = cgs (A, b, rtol, maxit, M); %! assert (x, ones (size (b)), 1e-7); %! %!test -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 15; %! -%! [x, flag, relres, iter, resvec] = cgs (@(x) A * x, b, tol, maxit, M); +%! [x, flag, relres, iter, resvec] = cgs (@(x) A * x, b, rtol, maxit, M); %! assert (x, ones (size (b)), 1e-7); %!test %! n = 100; -%! tol = 1e-8; +%! rtol = 1e-8; %! a = sprand (n, n, .1); %! A = a'*a + 100 * eye (n); %! b = sum (A, 2); -%! [x, flag, relres, iter, resvec] = cgs (A, b, tol, [], diag (diag (A))); +%! [x, flag, relres, iter, resvec] = cgs (A, b, rtol, [], diag (diag (A))); %! assert (x, ones (size (b)), 1e-7);
--- a/scripts/sparse/qmr.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/sparse/qmr.m Mon Nov 14 14:55:41 2016 -0800 @@ -87,7 +87,7 @@ ## Author: Nathan Podlich <nathan.podlich@gmail.com> -function [x, flag, relres, iter, resvec] = qmr (A, b, tol, maxit, M1, M2, x0) +function [x, flag, relres, iter, resvec] = qmr (A, b, rtol, maxit, M1, M2, x0) if (nargin >= 2 && isvector (full (b))) @@ -105,8 +105,8 @@ error ("qmr: A must be a square matrix or function"); endif - if (nargin < 3 || isempty (tol)) - tol = 1e-6; + if (nargin < 3 || isempty (rtol)) + rtol = 1e-6; endif if (nargin < 4 || isempty (maxit)) @@ -225,7 +225,7 @@ resvec(iter + 1, 1) = norm (r); endif - if (res1 < tol) + if (res1 < rtol) ## Convergence achieved. flag = 0; break; @@ -244,7 +244,7 @@ if (flag == 1) if (nargout < 2) printf ("qmr stopped at iteration %i ", iter); - printf ("without converging to the desired tolerance %e\n", tol); + printf ("without converging to the desired tolerance %e\n", rtol); printf ("because the maximum number of iterations was reached. "); printf ("The iterate returned (number %i) has ", maxit); printf ("relative residual %e\n", res1); @@ -252,7 +252,7 @@ elseif (flag == 3) if (nargout < 2) printf ("qmr stopped at iteration %i ", iter); - printf (" without converging to the desired tolerance %e\n", tol); + printf (" without converging to the desired tolerance %e\n", rtol); printf ("because the method stagnated.\n"); printf ("The iterate returned (number %i) ", iter); printf ("has relative residual %e\n", res1); @@ -278,11 +278,11 @@ %! n = 100; %! A = spdiags ([-2*ones(n,1) 4*ones(n,1) -ones(n,1)], -1:1, n, n); %! b = sum (A, 2); -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 15; %! M1 = spdiags ([ones(n,1)/(-2) ones(n,1)],-1:0, n, n); %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n); -%! [x, flag, relres, iter, resvec] = qmr (A, b, tol, maxit, M1, M2); +%! [x, flag, relres, iter, resvec] = qmr (A, b, rtol, maxit, M1, M2); %! assert (x, ones (size (b)), 1e-7); %!function y = afun (x, t, a) @@ -298,22 +298,22 @@ %! n = 100; %! A = spdiags ([-2*ones(n,1) 4*ones(n,1) -ones(n,1)], -1:1, n, n); %! b = sum (A, 2); -%! tol = 1e-8; +%! rtol = 1e-8; %! maxit = 15; %! M1 = spdiags ([ones(n,1)/(-2) ones(n,1)],-1:0, n, n); %! M2 = spdiags ([4*ones(n,1) -ones(n,1)], 0:1, n, n); %! %! [x, flag, relres, iter, resvec] = qmr (@(x, t) afun (x, t, A), -%! b, tol, maxit, M1, M2); +%! b, rtol, maxit, M1, M2); %! assert (x, ones (size (b)), 1e-7); %!test %! n = 100; -%! tol = 1e-8; +%! rtol = 1e-8; %! a = sprand (n, n, .1); %! A = a' * a + 100 * eye (n); %! b = sum (A, 2); -%! [x, flag, relres, iter, resvec] = qmr (A, b, tol, [], diag (diag (A))); +%! [x, flag, relres, iter, resvec] = qmr (A, b, rtol, [], diag (diag (A))); %! assert (x, ones (size (b)), 1e-7); %!test
--- a/scripts/strings/untabify.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/strings/untabify.m Mon Nov 14 14:55:41 2016 -0800 @@ -51,7 +51,7 @@ ## Author: Ben Abbott <bpabbott@mac.com> ## Created: 2010-10-15 -function s = untabify (t, tw = 8, dblank = false) +function s = untabify (t, tw = 8, deblank_arg = false) if (nargin < 1 || nargin > 3) print_usage (); @@ -65,7 +65,7 @@ s = cellfun (@replace_tabs, t, {tw}, "uniformoutput", false); endif - if (dblank) + if (deblank_arg) s = deblank (s); endif
--- a/scripts/testfun/private/dump_demos.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/testfun/private/dump_demos.m Mon Nov 14 14:55:41 2016 -0800 @@ -50,7 +50,7 @@ ## Author: Søren Hauberg <soren@hauberg.org> -function dump_demos (dirs={"plot/appearance", "plot/draw", "plot/util", "image"}, output="dump_plot_demos.m", fmt="png") +function dump_demos (dirs={"plot/appearance", "plot/draw", "plot/util", "image"}, mfile="dump_plot_demos.m", fmt="png") if (nargin > 3) print_usage (); @@ -66,13 +66,13 @@ dirs = strrep (dirs, "/", filesep ()); endif - [~, funcname, ext] = fileparts (output); + [~, funcname, ext] = fileparts (mfile); if (isempty (ext)) - output = [output ".m"]; + mfile = [mfile ".m"]; endif ## Create script beginning (close figures, etc.) - fid = fopen (output, "w"); + fid = fopen (mfile, "w"); fprintf (fid, "%% DO NOT EDIT! Generated automatically by dump_demos.m\n"); fprintf (fid, "function %s ()\n", funcname); fprintf (fid, "set (0, 'DefaultAxesColorOrder', ...\n");
--- a/scripts/testfun/speed.m Mon Nov 14 12:53:43 2016 -0800 +++ b/scripts/testfun/speed.m Mon Nov 14 14:55:41 2016 -0800 @@ -144,6 +144,10 @@ ## @kbd{demo ("speed")} to run them. ## @end deftypefn +## Programming Note: All variables for speed() must use the internal prefix "__". +## Shared variables are eval'ed into the current workspace and therefore might +## collide with the names used in the speed.m function itself. + ## FIXME: consider two dimensional speedup surfaces for functions like kron. function [__order, __test_n, __tnew, __torig] = speed (__f1, __init, __max_n = 100, __f2 = "", __tol = eps)