# HG changeset patch # User Rik # Date 1602865676 25200 # Node ID 6e460773bdda65c82861926348d319d51c463864 # Parent d39b09b4c5db71ad25f6f641ee29eee5a07e046d maint: Use newlines after "function" and before "endfunction" for clarity. * quad2d.m, rng.m, __ok_cancel_dlg__.m, __unimplemented__.m, get_first_help_sentence.m, imformats.m, vectorize.m, ordeig.m, inputParser.m, tar_is_bsd.m, publish.m, axis.m, legend.m, polar.m, __plt__.m, print.m, __add_default_menu__.m, __gnuplot_draw_axes__.m, struct2hdl.m, movfun.m, gmres.m, pcg.m, __alltohandles__.m, tfqmr.m, betaincinv.m, gammainc.m, gammaincinv.m, mean.m, weboptions.m: Use newlines after "function" and before "endfunction" for clarity. diff -r d39b09b4c5db -r 6e460773bdda scripts/general/quad2d.m --- a/scripts/general/quad2d.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/general/quad2d.m Fri Oct 16 09:27:56 2020 -0700 @@ -408,6 +408,7 @@ z = yhalfwidth .* f (x, y) .* ztrans(tx, ty) .* xhalfwidth; q = weights15 * (weights15 * z)'; qerr = abs (weights7 * (weights7 * z)' - q); + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/general/rng.m --- a/scripts/general/rng.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/general/rng.m Fri Oct 16 09:27:56 2020 -0700 @@ -165,18 +165,21 @@ function gen = check_generator (val) + if (isempty (val)) gen = ""; return; elseif (! iscellstr (val)) error ("rng: GENERATOR must be a string"); endif + gen = tolower (char (val)); if (any (strcmp (gen, {"simdtwister", "combrecursive", "philox", "threefry", "multfibonacci", "v4"}))) error ('rng: random number generator "%s" is not available in Octave', gen); elseif (! any (strcmp (gen, {"twister", "v5uniform", "v5normal"}))) error ('rng: unknown random number generator "%s"', gen); endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/gui/private/__ok_cancel_dlg__.m --- a/scripts/gui/private/__ok_cancel_dlg__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/gui/private/__ok_cancel_dlg__.m Fri Oct 16 09:27:56 2020 -0700 @@ -46,6 +46,7 @@ endfunction function cb_fix_button_position (hf, evt, hcancel, hok, hpanel) + persistent margin = 20; persistent hgt = 30; persistent wd = 70; @@ -62,4 +63,5 @@ unwind_protect_cleanup set (hf, "units", units); end_unwind_protect + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/help/__unimplemented__.m --- a/scripts/help/__unimplemented__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/help/__unimplemented__.m Fri Oct 16 09:27:56 2020 -0700 @@ -1343,6 +1343,7 @@ }; rlist = list; + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/help/get_first_help_sentence.m --- a/scripts/help/get_first_help_sentence.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/help/get_first_help_sentence.m Fri Oct 16 09:27:56 2020 -0700 @@ -109,7 +109,9 @@ text = help_text(1:max_len); endif endif + status = 0; + endfunction ## This function extracts the first sentence from a Texinfo help text. diff -r d39b09b4c5db -r 6e460773bdda scripts/image/imformats.m --- a/scripts/image/imformats.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/image/imformats.m Fri Oct 16 09:27:56 2020 -0700 @@ -77,7 +77,7 @@ function varargout = imformats (arg1, arg2, arg3) - mlock (); # prevent formats to be removed by "clear all" + mlock (); # prevent formats being removed by "clear all" persistent formats = default_formats (); if (nargin == 0 && nargout == 0) @@ -102,7 +102,7 @@ if (! ischar (arg2)) error ("imformats: EXT to %s must be a string", arg1); endif - ## FIXME: suppose a format with multiple extensions. If one of + ## FIXME: Suppose a format with multiple extensions; if one of ## them is requested to be removed, should we remove the ## whole format, or just that extension from the format? match = find_ext_idx (formats, arg2); @@ -126,7 +126,7 @@ otherwise ## then we look for a format with that extension. match = find_ext_idx (formats, arg1); - ## For matlab compatibility, if we don't find any format we must + ## For Matlab compatibility, if we don't find any format we must ## return an empty struct with NO fields. We can't use match as mask if (any (match)) varargout{1} = formats(match); @@ -264,6 +264,7 @@ endfunction function is_valid_format (format) + ## the minimal list of fields required in the structure. We don't ## require multipage because it doesn't exist in matlab min_fields = {"ext", "read", "isa", "write", "info", "alpha", "description"}; @@ -275,10 +276,12 @@ endfunction function match = find_ext_idx (formats, ext) + ## FIXME: what should we do if there's more than one hit? ## Should this function prevent the addition of ## duplicated extensions? match = cellfun (@(x) any (strcmpi (x, ext)), {formats.ext}); + endfunction function bool = isa_magick (coder, filename) diff -r d39b09b4c5db -r 6e460773bdda scripts/legacy/vectorize.m --- a/scripts/legacy/vectorize.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/legacy/vectorize.m Fri Oct 16 09:27:56 2020 -0700 @@ -68,6 +68,7 @@ else error ("vectorize: FUN must be a string or anonymous function handle"); endif + endfunction @@ -94,4 +95,3 @@ ## Test input validation %!error vectorize () %!error vectorize (1) - diff -r d39b09b4c5db -r 6e460773bdda scripts/linear-algebra/ordeig.m --- a/scripts/linear-algebra/ordeig.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/linear-algebra/ordeig.m Fri Oct 16 09:27:56 2020 -0700 @@ -53,7 +53,7 @@ if (nargin == 1) B = eye (n); if (isreal (A)) - if (! isquasitri (A)) + if (! is_quasitri (A)) error ("ordeig: A must be quasi-triangular (i.e., upper block triangular with 1x1 or 2x2 blocks on the diagonal)"); endif else @@ -68,7 +68,7 @@ error ("ordeig: A and B must be the same size"); endif if (isreal (A) && isreal (B)) - if (! isquasitri (A) || ! isquasitri (B)) + if (! is_quasitri (A) || ! is_quasitri (B)) error ("ordeig: A and B must be quasi-triangular (i.e., upper block triangular with 1x1 or 2x2 blocks on the diagonal)"); endif else @@ -106,7 +106,7 @@ endfunction ## Check whether a matrix is quasi-triangular -function retval = isquasitri (A) +function retval = is_quasitri (A) if (length (A) <= 2) retval = true; else diff -r d39b09b4c5db -r 6e460773bdda scripts/miscellaneous/inputParser.m --- a/scripts/miscellaneous/inputParser.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/miscellaneous/inputParser.m Fri Oct 16 09:27:56 2020 -0700 @@ -194,6 +194,7 @@ endproperties methods + function set.PartialMatching (this, val) if (val) error ("inputParser: PartialMatching is not yet implemented"); @@ -514,9 +515,11 @@ printf ("Defined parameters:\n\n {%s}\n", strjoin (this.Parameters, ", ")); endfunction + endmethods methods (Access = private) + function validate_name (this, type, name) if (! isvarname (name)) error ("inputParser.add%s: NAME is an invalid identifier", method); @@ -572,10 +575,12 @@ endif error ("%s%s", where, msg); endfunction + endmethods endclassdef + %!function p = create_p () %! p = inputParser (); %! p.CaseSensitive = true; @@ -698,7 +703,6 @@ %! assert (p.Results.err, "foo"); %! assert (p.Results.not_err, "qux"); - ## With more Parameters to test StructExpand %!function p3 = create_p3 (); %! p3 = inputParser (); @@ -838,7 +842,7 @@ %! assert (p.Unmatched, struct ()); ## Test for patch #9241 -%!error +%!error %! p = inputParser (); %! p.addParameter ("a", [], @ischar); %! p.parse ("a", 1); diff -r d39b09b4c5db -r 6e460773bdda scripts/miscellaneous/private/tar_is_bsd.m --- a/scripts/miscellaneous/private/tar_is_bsd.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/miscellaneous/private/tar_is_bsd.m Fri Oct 16 09:27:56 2020 -0700 @@ -36,6 +36,7 @@ ## @end deftypefn function out = tar_is_bsd () + ## BSD tar needs to be handled differently from GNU tar persistent cache if (isempty (cache)) @@ -46,4 +47,5 @@ cache = ! isempty (regexp (tar_ver_str, "bsdtar")); endif out = cache; + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/miscellaneous/publish.m --- a/scripts/miscellaneous/publish.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/miscellaneous/publish.m Fri Oct 16 09:27:56 2020 -0700 @@ -709,6 +709,7 @@ p_content{end+1}.type = "text"; p_content{end}.content = strjoin (block, "\n"); endfor + endfunction @@ -722,6 +723,7 @@ until (! ischar (m_source{i})) fclose (fid); m_source = m_source(1:end-1); # No EOL + endfunction @@ -770,6 +772,7 @@ endfor endif endif + endfunction @@ -783,6 +786,7 @@ toc_cstr{end+1} = format_text (cstr{i}.content, formatter); endif endfor + endfunction @@ -1067,6 +1071,7 @@ ## Split string by lines and preserve blank lines. cstr = strsplit (strrep (cstr, "\n\n", "\n \n"), "\n"); eval_context ("save"); + endfunction @@ -1107,6 +1112,7 @@ ## Do nothing endswitch + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/appearance/axis.m --- a/scripts/plot/appearance/axis.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/appearance/axis.m Fri Oct 16 09:27:56 2020 -0700 @@ -373,6 +373,7 @@ endif endfor + endfunction ## Find the limits for axis ("tight"). diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/appearance/legend.m --- a/scripts/plot/appearance/legend.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/appearance/legend.m Fri Oct 16 09:27:56 2020 -0700 @@ -1346,6 +1346,7 @@ set (hicon, "markerxdata", xdata(2), "markerydata", mean (ydata), ... "xdata", xdata, "ydata", [mean(ydata), mean(ydata)]); endswitch + endfunction function pos = boxposition (axpos, pba, pbam, dam) diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/draw/polar.m --- a/scripts/plot/draw/polar.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/draw/polar.m Fri Oct 16 09:27:56 2020 -0700 @@ -398,6 +398,7 @@ endfunction function resetaxis (~, ~, hax) + if (isaxes (hax)) dellistener (hax, "rtick"); dellistener (hax, "ttick"); @@ -412,6 +413,7 @@ dellistener (hax, "gridlinestyle"); dellistener (hax, "linewidth"); endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/draw/private/__plt__.m --- a/scripts/plot/draw/private/__plt__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/draw/private/__plt__.m Fri Oct 16 09:27:56 2020 -0700 @@ -364,6 +364,7 @@ retval = __go_line__ (hp, "xdata", x, "ydata", y, "color", color, "linestyle", linestyle, "marker", marker, properties{:}); + endfunction function retval = __plt2sv__ (hp, x, y, options, properties = {}) diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/util/print.m --- a/scripts/plot/util/print.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/util/print.m Fri Oct 16 09:27:56 2020 -0700 @@ -802,6 +802,7 @@ if (isfigure (orig_figure)) set (0, "currentfigure", orig_figure); endif + endfunction function cmd = epstool (opts, filein, fileout) diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/util/private/__add_default_menu__.m --- a/scripts/plot/util/private/__add_default_menu__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/util/private/__add_default_menu__.m Fri Oct 16 09:27:56 2020 -0700 @@ -242,6 +242,7 @@ set (hf, "filename", fname); saveas (hf, fname, fmt); endif + endfunction function close_cb (~, ~) @@ -276,6 +277,7 @@ endfunction function guimode_cb (h, ~) + [hax, fig] = __get_axes__ (h); id = get (h, "tag"); switch (id) @@ -295,6 +297,7 @@ case "zoom_off" arrayfun (@(h) set (h, "mousewheelzoom", 0.0), hax); endswitch + endfunction function mouse_tools_cb (h, ~, htools, typ = "") @@ -413,6 +416,7 @@ endfunction function clipboard_cb (h, ~) + hf = gcbf (); fname = tempname (); props = {"inverthardcopy", "paperposition", "paperpositionmode"}; @@ -424,4 +428,5 @@ unwind_protect_cleanup set (hf, props, values); end_unwind_protect + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/util/private/__gnuplot_draw_axes__.m --- a/scripts/plot/util/private/__gnuplot_draw_axes__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/util/private/__gnuplot_draw_axes__.m Fri Oct 16 09:27:56 2020 -0700 @@ -2657,6 +2657,7 @@ endfunction function sym = __setup_sym_table__ () + ## Setup the translation table for TeX to gnuplot enhanced mode. sym.forall = '{/Symbol \042}'; sym.exists = '{/Symbol \044}'; @@ -2769,6 +2770,7 @@ sym.rfloor = '{/Symbol \373}'; sym.rceil = '{/Symbol \371}'; sym.int = '{/Symbol \362}'; + endfunction function retval = __do_enhanced_option__ (enhanced, obj) @@ -2851,6 +2853,7 @@ endfunction function cdata = mapcdata (cdata, mode, clim, cmap_sz) + if (ndims (cdata) == 3) ## True Color, clamp data to 8-bit clim = double (clim); @@ -2881,4 +2884,5 @@ endif cdata = max (1, min (cdata, cmap_sz)); endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/plot/util/struct2hdl.m --- a/scripts/plot/util/struct2hdl.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/plot/util/struct2hdl.m Fri Oct 16 09:27:56 2020 -0700 @@ -232,6 +232,7 @@ endfunction function [h, sout] = createfigure (s) + ## Create figure initially invisible to speed up loading. opts = {"visible", "off"}; if (isfield (s.properties, "integerhandle")) # see also bug #53342. @@ -248,6 +249,7 @@ endif addmissingprops (h, s.properties); sout = s; + endfunction function [h, sout] = createaxes (s, p, par) diff -r d39b09b4c5db -r 6e460773bdda scripts/signal/movfun.m --- a/scripts/signal/movfun.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/signal/movfun.m Fri Oct 16 09:27:56 2020 -0700 @@ -311,6 +311,7 @@ ## Apply "shrink" boundary conditions ## Function is not applied to any window elements outside the original data. function y = shrink_bc (fcn, x, idxp, win, wlen, odim) + N = length (x); idx = idxp + win; tf = (idx > 0) & (idx <= N); # idx inside boundaries @@ -324,6 +325,7 @@ k = idx(tf(:,i),i); y(i,:) = fcn (x(k)); endfor + endfunction ## Apply replacement value boundary conditions diff -r d39b09b4c5db -r 6e460773bdda scripts/sparse/gmres.m --- a/scripts/sparse/gmres.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/sparse/gmres.m Fri Oct 16 09:27:56 2020 -0700 @@ -447,6 +447,7 @@ printf ("has relative residual %d \n", relres); endswitch endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/sparse/pcg.m --- a/scripts/sparse/pcg.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/sparse/pcg.m Fri Oct 16 09:27:56 2020 -0700 @@ -454,6 +454,7 @@ printf ("has relative residual %d \n", relres); endswitch endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/sparse/private/__alltohandles__.m --- a/scripts/sparse/private/__alltohandles__.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/sparse/private/__alltohandles__.m Fri Oct 16 09:27:56 2020 -0700 @@ -146,6 +146,7 @@ otherwise error (["__alltohandles__: unknown method: ", solver_name]); endswitch + endfunction function y = A_sub (A, x, trans) diff -r d39b09b4c5db -r 6e460773bdda scripts/sparse/tfqmr.m --- a/scripts/sparse/tfqmr.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/sparse/tfqmr.m Fri Oct 16 09:27:56 2020 -0700 @@ -344,6 +344,7 @@ printf ("has relative residual %e\n", relres); endswitch endif + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/specfun/betaincinv.m --- a/scripts/specfun/betaincinv.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/specfun/betaincinv.m Fri Oct 16 09:27:56 2020 -0700 @@ -207,6 +207,7 @@ ## subfunctions: Bisection and Newton Methods function xc = bisection_method (F, xl, xr, a, b, y, maxit) + F_l = F (xl, a, b, y); F_r = F (xr, a, b, y); for it = 1:maxit @@ -222,9 +223,11 @@ F_r(flag_r) = F_c(flag_r); F_l(flag_c) = F_r(flag_c) = 0; endfor + endfunction function x = newton_method (F, JF, x0, a, b, y, tol, maxit); + l = numel (y); res = -F (x0, a, b, y) ./ JF (x0, a, b); todo = (abs (res) >= tol * abs (x0)); @@ -238,6 +241,7 @@ todo = (abs (res) >= tol * abs (x)); endwhile x += res; + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/specfun/gammainc.m --- a/scripts/specfun/gammainc.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/specfun/gammainc.m Fri Oct 16 09:27:56 2020 -0700 @@ -299,6 +299,7 @@ ## a == 1. function y = gammainc_a1 (x, tail) + if (strcmp (tail, "lower")) if (abs (x) < 1/2) y = - expm1 (-x); @@ -316,12 +317,14 @@ else y = 1 ./ x; endif + endfunction ## positive integer a; exp (x) and a! both under 1/eps ## uses closed-form expressions for nonnegative integer a ## -- http://mathworld.wolfram.com/IncompleteGammaFunction.html. function y = gammainc_an (x, a, tail) + y = t = ones (size (x), class (x)); i = 1; while (any (a(:) > i)) @@ -339,12 +342,14 @@ elseif (strcmp (tail, "scaledupper")) y .*= exp (-x) ./ D(x, a); endif + endfunction ## x + 0.25 < a | x < 0 | abs(x) < 1. ## Numerical Recipes in Fortran 77 (6.2.5) ## series function y = gammainc_s (x, a, tail) + if (strcmp (tail, "scaledlower") || strcmp (tail, "scaledupper")) y = ones (size (x), class (x)); term = x ./ (a + 1); @@ -367,6 +372,7 @@ elseif (strcmp (tail, "scaledupper")) y = 1 ./ D (x,a) - y; endif + endfunction ## x positive and large relative to a @@ -375,6 +381,7 @@ ## Lentz's algorithm ## __gammainc__ in libinterp/corefcn/__gammainc__.cc function y = gammainc_l (x, a, tail) + y = __gammainc__ (x, a); if (strcmp (tail, "lower")) y = 1 - y .* D (x, a); @@ -383,6 +390,7 @@ elseif (strcmp (tail, "scaledlower")) y = 1 ./ D (x, a) - y; endif + endfunction ## Compute exp(-x)*x^a/Gamma(a+1) in a stable way for x and a large. @@ -391,6 +399,7 @@ ## SIAM J. Sci. Stat. Comput., 7(3), 1986 ## which quotes Section 5, Abramowitz&Stegun 6.1.40, 6.1.41. function y = D (x, a) + athresh = 10; # FIXME: can this be better tuned? y = zeros (size (x), class (x)); diff -r d39b09b4c5db -r 6e460773bdda scripts/specfun/gammaincinv.m --- a/scripts/specfun/gammaincinv.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/specfun/gammaincinv.m Fri Oct 16 09:27:56 2020 -0700 @@ -256,6 +256,7 @@ ## subfunction: Newton's Method function x = newton_method (F, JF, y, a, x0, tol, maxit); + l = numel (y); res = -F (y, a, x0) ./ JF (a, x0); todo = (abs (res) >= tol * abs (x0)); @@ -267,6 +268,7 @@ todo = (abs (res) >= tol * abs (x)); endwhile x += res; + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/statistics/mean.m --- a/scripts/statistics/mean.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/statistics/mean.m Fri Oct 16 09:27:56 2020 -0700 @@ -179,6 +179,7 @@ ## this should have been filtered out during input check, but... error ("mean: OUTTYPE '%s' not recognized", out_type); endswitch + endfunction diff -r d39b09b4c5db -r 6e460773bdda scripts/web/weboptions.m --- a/scripts/web/weboptions.m Thu Oct 15 21:24:06 2020 -0700 +++ b/scripts/web/weboptions.m Fri Oct 16 09:27:56 2020 -0700 @@ -160,6 +160,7 @@ endproperties methods + function f = weboptions (varargin) if (rem (numel (varargin), 2) != 0) error ("weboptions: invalid number of arguments"); @@ -244,6 +245,7 @@ error (["weboptions: Undefined field " field]); endif endif + endfunction function f = set.CharacterEncoding (f, value) @@ -355,6 +357,7 @@ endfunction function display (f) + Timeout = int2str (f.Timeout); Password = repmat ("*", 1, numel (num2str (f.Password))); @@ -393,6 +396,7 @@ "\n HeaderFields: " , HeaderFields,... "\n CertificateFilename: '", f.CertificateFilename, "'\n"]; disp (output); + endfunction endmethods