Mercurial > hg > octave-terminal
changeset 14995:0ef151f9fdc9
Merge in JIT branch \o/
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 20 Jul 2012 16:13:35 -0400 |
parents | f8bb15f6a19b (diff) bbc825cb2ea0 (current diff) |
children | 894cf2c07f92 |
files | src/pt-id.cc |
diffstat | 340 files changed, 3127 insertions(+), 1461 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS +++ b/NEWS @@ -74,10 +74,13 @@ ** Other new functions added in 3.8.0: - betaincinv lines tetramesh - colorcube rgbplot - erfcinv shrinkfaces - findfigs splinefit + betaincinv erfcinv splinefit + cmpermute findfigs tetramesh + cmunique fminsearch rgbplot + colorcube lines shrinkfaces + + ** The default name of the Octave crash dump file is now called + octave-workspace instead of octave-core. ** Deprecated functions.
--- a/doc/interpreter/contrib.txi +++ b/doc/interpreter/contrib.txi @@ -135,7 +135,11 @@ @section Basics of Generating a Changeset The preferable form of contribution is creating a Mercurial changeset -and sending it via e-mail to the octave-maintainers mailing list. +and submit it to the @uref{http://savannah.gnu.org/bugs/?group=octave, bug} or +@uref{http://savannah.gnu.org/patch/?func=additem&group=octave, patch} +trackers@footnote{Please use the patch tracker only for patches which add new +features. If you have a patch to submit that fixes a bug, you should use the +bug tracker instead.}. Mercurial is the source code management system currently used to develop Octave. Other forms of contributions (e.g., simple diff patches) are also acceptable, but they slow down the review process. If you want to @@ -159,15 +163,14 @@ hg export -o ../cool.diff tip # export the changeset to a diff # file -# send ../cool.diff via email +# attach ../cool.diff to your bug report @end group @end example You may want to get familiar with Mercurial queues to manage your changesets. Here is a slightly more complex example using Mercurial queues, where work on two unrelated changesets is done in parallel and -one of the changesets is updated after discussion on the maintainers -mailing list: +one of the changesets is updated after discussion on the bug tracker: @example hg qnew nasty_bug # create a new patch @@ -178,7 +181,7 @@ # save again with commit message hg export -o ../nasty.diff tip # export the patch -# send ../nasty.diff via email +# attach ../nasty.diff to your bug report hg qpop # undo the application of the patch # and remove the changes from the # source tree @@ -188,14 +191,14 @@ # save the changes into the patch hg export -o ../doc.diff tip # export the second patch -# send ../doc.diff tip via email +# attach ../doc.diff to your bug report hg qpop -# discussion in the maintainers mailing list @dots{} +# discussion in the bug tracker @dots{} hg qpush nasty_bug # apply the patch again # change sources yet again @dots{} hg qref hg export -o ../nasty2.diff tip -# send ../nasty2.diff via email +# attach ../nasty2.diff to your bug report @end example @node General Guidelines
--- a/doc/interpreter/image.txi +++ b/doc/interpreter/image.txi @@ -93,15 +93,15 @@ @node Representing Images @section Representing Images -In general Octave supports four different kinds of images, gray-scale -images, RGB images, binary images, and indexed images. A gray-scale +In general Octave supports four different kinds of images, grayscale +images, RGB images, binary images, and indexed images. A grayscale image is represented with an M-by-N matrix in which each element corresponds to the intensity of a pixel. An RGB image is represented with an M-by-N-by-3 array where each 3-vector corresponds to the red, green, and blue intensities of each pixel. -The actual meaning of the value of a pixel in a gray-scale or RGB +The actual meaning of the value of a pixel in a grayscale or RGB image depends on the class of the matrix. If the matrix is of class @code{double} pixel intensities are between 0 and 1, if it is of class @code{uint8} intensities are between 0 and 255, and if it is of class @@ -187,6 +187,12 @@ @DOCSTRING(whitebg) +The following functions can be used to manipulate colormaps. + +@DOCSTRING(cmunique) + +@DOCSTRING(cmpermute) + @node Plotting on top of Images @section Plotting on top of Images
--- a/doc/interpreter/io.txi +++ b/doc/interpreter/io.txi @@ -239,7 +239,7 @@ If Octave for some reason exits unexpectedly it will by default save the variables available in the workspace to a file in the current directory. -By default this file is named @samp{octave-core} and can be loaded +By default this file is named @samp{octave-workspace} and can be loaded into memory with the @code{load} command. While the default behavior most often is reasonable it can be changed through the following functions.
--- a/doc/interpreter/nonlin.txi +++ b/doc/interpreter/nonlin.txi @@ -172,7 +172,11 @@ the zeroes where it crosses the x-axis. @code{fminbnd} is designed for the simpler, but very common, case of a univariate function where the interval to search is bounded. For unbounded minimization of a function with -potentially many variables use @code{fminunc}. @xref{Optimization}, for +potentially many variables use @code{fminunc} or @code{fminsearch}. The two +functions use different internal algorithms and some knowledge of the objective +function is required. For functions which can be differentiated, @code{fminunc} +is appropriate. For functions with discontinuities, or for which a gradient +search would fail, use @code{fminsearch}. @xref{Optimization}, for minimization with the presence of constraint functions. Note that searches can be made for maxima by simply inverting the objective function @tex @@ -186,3 +190,5 @@ @DOCSTRING(fminunc) +@DOCSTRING(fminsearch) +
--- a/scripts/audio/lin2mu.m +++ b/scripts/audio/lin2mu.m @@ -62,7 +62,7 @@ endif ## Determine sign of x, set sign(0) = 1. - sig = sign(x) + (x == 0); + sig = sign (x) + (x == 0); ## Take absolute value of x, but force it to be smaller than 32636; ## add bias.
--- a/scripts/audio/loadaudio.m +++ b/scripts/audio/loadaudio.m @@ -63,7 +63,7 @@ [X, c] = fread (num, inf, "short"); endif elseif (strcmp (ext, "mu") || strcmp (ext, "au") - || strcmp (ext, "snd") || strcmp(ext, "ul")) + || strcmp (ext, "snd") || strcmp (ext, "ul")) [Y, c] = fread (num, inf, "uchar"); ## remove file header m = find (Y(1:64) == 0, 1, "last");
--- a/scripts/audio/wavread.m +++ b/scripts/audio/wavread.m @@ -87,7 +87,7 @@ ## Find format chunk inside the RIFF chunk. fseek (fid, riff_pos, "bof"); fmt_size = find_chunk (fid, "fmt ", riff_size); - fmt_pos = ftell(fid); + fmt_pos = ftell (fid); if (fmt_size == -1) error ("wavread: file contains no format chunk"); endif @@ -196,7 +196,7 @@ endif if (bits_per_sample == 24) - yi = reshape (yi, 3, rows(yi)/3)'; + yi = reshape (yi, 3, rows (yi) / 3)'; yi(yi(:,3) >= 128, 3) -= 256; yi = yi * [1; 256; 65536]; endif @@ -246,5 +246,5 @@ ## Mark file as tested. Tests for wavread/wavwrite pair are in wavwrite.m. -%!assert(1) +%!assert (1)
--- a/scripts/general/accumarray.m +++ b/scripts/general/accumarray.m @@ -370,7 +370,7 @@ %!assert (accumarray ([1;2;4;2;4],101:105), [101;206;0;208]) -%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105), cat(3, [101,0,0;0,0,0],[0,0,0;206,0,208])) +%!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105), cat (3, [101,0,0;0,0,0],[0,0,0;206,0,208])) %!assert (accumarray ([1,1,1;2,1,2;2,3,2;2,1,2;2,3,2],101:105,[],@(x)sin(sum(x))), sin (cat (3, [101,0,0;0,0,0],[0,0,0;206,0,208]))) %!assert (accumarray ({[1 3 3 2 3 1 2 2 3 3 1 2],[3 4 2 1 4 3 4 2 2 4 3 4],[1 1 2 2 1 1 2 1 1 1 2 2]},101:112), cat (3, [0,0,207,0;0,108,0,0;0,109,0,317], [0,0,111,0;104,0,0,219;0,103,0,0])) %!assert (accumarray ([1,1;2,1;2,3;2,1;2,3],101:105,[2,4],@max,NaN), [101,NaN,NaN,NaN;104,NaN,105,NaN])
--- a/scripts/general/bicubic.m +++ b/scripts/general/bicubic.m @@ -38,7 +38,7 @@ print_usage (); endif - if (nargin == 7 && isscalar(spline_alpha)) + if (nargin == 7 && isscalar (spline_alpha)) a = spline_alpha; else a = 0.5; @@ -240,8 +240,8 @@ %! x = linspace (1, -1, 30); %! [xx2, yy2] = meshgrid (x); %! z1 = interp2 (xx, yy, z, xx2, yy2, "cubic"); -%! z2 = interp2 (fliplr(xx), flipud(yy), fliplr(flipud(z)), -%! fliplr(xx2), flipud(yy2), "cubic"); +%! z2 = interp2 (fliplr (xx), flipud (yy), fliplr (flipud(z)), +%! fliplr (xx2), flipud (yy2), "cubic"); %! z2 = fliplr (flipud (z2)); %! assert (z1, z2, 100 * eps ())
--- a/scripts/general/celldisp.m +++ b/scripts/general/celldisp.m @@ -71,10 +71,10 @@ if (sum (dv != 1) > 1) c = cell (size (dv)); [c{:}] = ind2sub (dv, i); - s = sprintf("%i,", c{:}); + s = sprintf ("%i,", c{:}); s(end) = []; else - s = sprintf("%i", i); + s = sprintf ("%i", i); endif endfunction
--- a/scripts/general/colon.m +++ b/scripts/general/colon.m @@ -35,7 +35,7 @@ function r = colon (varargin) if (nargin != 0) - error ("colon: not defined for class \"%s\"", class(varargin{1})); + error ('colon: not defined for class "%s"', class (varargin{1})); endif endfunction
--- a/scripts/general/cplxpair.m +++ b/scripts/general/cplxpair.m @@ -44,9 +44,9 @@ ## @end deftypefn ## FIXME: subsort returned pairs by imaginary magnitude -## FIXME: Why doesn't exp(2i*pi*[0:4]'/5) produce exact conjugates. Does -## FIXME: it in Matlab? The reason is that complex pairs are supposed -## FIXME: to be exact conjugates, and not rely on a tolerance test. +## FIXME: Why doesn't exp (2i*pi*[0:4]'/5) produce exact conjugates. Does +## FIXME: it in Matlab? The reason is that complex pairs are supposed +## FIXME: to be exact conjugates, and not rely on a tolerance test. ## 2006-05-12 David Bateman - Modified for NDArrays @@ -82,7 +82,7 @@ dim = 1; endif else - dim = floor(dim); + dim = floor (dim); if (dim < 1 || dim > nd) error ("cplxpair: invalid dimension along which to sort"); endif @@ -105,7 +105,7 @@ if (isa (z, "single")) cls = "single"; endif - [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin(cls)) < tol); + [idxi, idxj] = find (abs (imag (z)) ./ (abs (z) + realmin (cls)) < tol); q = sparse (idxi, idxj, 1, n, m); nr = sum (q, 1); [q, idx] = sort (q, 1);
--- a/scripts/general/dblquad.m +++ b/scripts/general/dblquad.m @@ -67,7 +67,7 @@ endfunction function q = __dblquad_inner__ (y, f, xa, xb, tol, quadf, varargin) - q = zeros (size(y)); + q = zeros (size (y)); for i = 1 : length (y) q(i) = feval (quadf, @(x) f(x, y(i), varargin{:}), xa, xb, tol); endfor
--- a/scripts/general/divergence.m +++ b/scripts/general/divergence.m @@ -81,8 +81,8 @@ 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).'; + 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}))
--- a/scripts/general/genvarname.m +++ b/scripts/general/genvarname.m @@ -160,7 +160,7 @@ idx = 0; while (excluded) idx++; - varname{i} = sprintf("%s%d", str{i}, idx); + varname{i} = sprintf ("%s%d", str{i}, idx); excluded = any (strcmp (varname{i}, exclusions)); endwhile exclusions(end+1) = varname(i);
--- a/scripts/general/gradient.m +++ b/scripts/general/gradient.m @@ -70,12 +70,12 @@ print_usage (); endif - nargout_with_ans = max(1,nargout); + nargout_with_ans = max (1,nargout); if (ismatrix (m)) [varargout{1:nargout_with_ans}] = matrix_gradient (m, varargin{:}); elseif (isa (m, "function_handle")) [varargout{1:nargout_with_ans}] = handle_gradient (m, varargin{:}); - elseif (ischar(m)) + elseif (ischar (m)) [varargout{1:nargout_with_ans}] = handle_gradient (str2func (m), varargin{:}); else error ("gradient: first input must be an array or a function"); @@ -87,13 +87,13 @@ transposed = false; if (isvector (m)) ## make a row vector. - transposed = (size (m, 2) == 1); + transposed = (columns (m) == 1); m = m(:).'; endif nd = ndims (m); sz = size (m); - if (length(sz) > 1) + if (length (sz) > 1) tmp = sz(1); sz(1) = sz(2); sz(2) = tmp; endif @@ -281,7 +281,7 @@ %! assert (all (dY(:) == 0)); %! assert (all (dZ(:) == 0)); %! assert (all (dU(:) == 5)); -%! assert (size_equal(dX, dY, dZ, dU, X, Y, Z, U)); +%! assert (size_equal (dX, dY, dZ, dU, X, Y, Z, U)); %! [dX,dY,dZ,dU] = gradient (U, 5.0); %! assert (all (dU(:) == 1)); %! [dX,dY,dZ,dU] = gradient (U, 1.0, 2.0, 3.0, 2.5);
--- a/scripts/general/int2str.m +++ b/scripts/general/int2str.m @@ -57,8 +57,8 @@ return; endif - n = round (real(n)); - sz = size(n); + n = round (real (n)); + sz = size (n); nd = ndims (n); nc = columns (n); if (nc > 1)
--- a/scripts/general/interp1.m +++ b/scripts/general/interp1.m @@ -141,7 +141,7 @@ if (isempty (xi) && firstnumeric && ! ispp) xi = y; y = x; - x = 1:numel(y); + x = 1:numel (y); endif ## reshape matrices for convenience @@ -204,7 +204,7 @@ if (ispp) yi = pp; else - yi = ppval(pp, reshape (xi, szx)); + yi = ppval (pp, reshape (xi, szx)); endif case "linear" dy = diff (y); @@ -225,7 +225,7 @@ if (ispp) yi = pp; else - yi = ppval(pp, reshape (xi, szx)); + yi = ppval (pp, reshape (xi, szx)); endif case "*linear" @@ -237,7 +237,7 @@ if (ispp) yi = pp; else - yi = ppval(pp, reshape (xi, szx)); + yi = ppval (pp, reshape (xi, szx)); endif case {"pchip", "*pchip", "cubic", "*cubic"} @@ -258,7 +258,7 @@ endif case {"spline", "*spline"} if (nx == 2 || starmethod) - x = linspace(x(1), x(nx), ny); + x = linspace (x(1), x(nx), ny); endif if (ispp)
--- a/scripts/general/interp1q.m +++ b/scripts/general/interp1q.m @@ -37,7 +37,7 @@ function yi = interp1q (x, y, xi) x = x(:); - nx = size (x, 1); + nx = rows (x); szy = size (y); y = y(:,:); [ny, nc] = size (y); @@ -59,7 +59,7 @@ %!shared xp, yp, xi, yi -%! xp = [0:2:10].'; yp = sin(2*pi*xp/5); +%! xp = [0:2:10].'; yp = sin (2*pi*xp/5); %! xi = [-1; 0; 2.2; 4; 6.6; 10; 11]; %! yi = interp1 (xp,yp,xi); %!assert (interp1q (xp,yp, [min(xp)-1; max(xp)+1]), [NA; NA]);
--- a/scripts/general/interp2.m +++ b/scripts/general/interp2.m @@ -377,7 +377,7 @@ AX_2 = bc ((XI - K - 2)); ## Perform interpolation - sz = size(Z); + sz = size (Z); ZI = AY_2 .* AX_2 .* Z (sym_sub2ind (sz, L+2, K+2)) ... + AY_2 .* AX_1 .* Z (sym_sub2ind (sz, L+2, K+1)) ... + AY_2 .* AX0 .* Z (sym_sub2ind (sz, L+2, K)) ... @@ -420,9 +420,9 @@ endfunction ## Compute the bicubic interpolation coefficients -function o = bc(x) - x = abs(x); - o = zeros(size(x)); +function o = bc (x) + x = abs (x); + o = zeros (size (x)); idx1 = (x < 1); idx2 = !idx1 & (x < 2); o(idx1) = 1 - 2.*x(idx1).^2 + x(idx1).^3; @@ -430,7 +430,7 @@ endfunction ## This version of sub2ind behaves as if the data was symmetrically padded -function ind = sym_sub2ind(sz, Y, X) +function ind = sym_sub2ind (sz, Y, X) Y (Y < 1) = 1 - Y (Y < 1); while (any (Y (:) > 2 * sz (1))) Y (Y > 2 * sz (1)) = round (Y (Y > 2 * sz (1)) / 2); @@ -441,7 +441,7 @@ X (X > 2 * sz (2)) = round (X (X > 2 * sz (2)) / 2); endwhile X (X > sz (2)) = 1 + 2 * sz (2) - X (X > sz (2)); - ind = sub2ind(sz, Y, X); + ind = sub2ind (sz, Y, X); endfunction
--- a/scripts/general/interpn.m +++ b/scripts/general/interpn.m @@ -198,8 +198,8 @@ q(:) = i; idx {i} = q; endfor - vi = vi (cellfun (@(x) sub2ind (size(vi), x{:}), idx)); - vi = reshape (vi, size(y{1})); + vi = vi (cellfun (@(x) sub2ind (size (vi), x{:}), idx)); + vi = reshape (vi, size (y{1})); endif elseif (strcmp (method, "cubic")) error ("interpn: cubic interpolation not yet implemented");
--- a/scripts/general/loadobj.m +++ b/scripts/general/loadobj.m @@ -37,5 +37,5 @@ ## @end deftypefn function b = loadobj (a) - error ("loadobj: not defined for class \"%s\"", class(a)); + error ('loadobj: not defined for class "%s"', class (a)); endfunction
--- a/scripts/general/nthargout.m +++ b/scripts/general/nthargout.m @@ -34,7 +34,7 @@ ## @example ## @group ## @var{m} = magic (5); -## cell2mat (nthargout ([1, 2], @@ind2sub, size(@var{m}), +## cell2mat (nthargout ([1, 2], @@ind2sub, size (@var{m}), ## nthargout (2, @@max, @var{m}(:)))) ## @result{} 5 3 ## @end group @@ -45,7 +45,7 @@ ## ## @example ## @group -## @var{m} = magic(5); +## @var{m} = magic (5); ## [~, idx] = max (@var{M}(:)); ## [i, j] = ind2sub (size (@var{m}), idx); ## [i, j]
--- a/scripts/general/private/__isequal__.m +++ b/scripts/general/private/__isequal__.m @@ -58,7 +58,7 @@ ## All arguments must either be of the same class or they must be ## numeric values. - t = (all (strcmp (class(x), + t = (all (strcmp (class (x), cellfun ("class", varargin, "uniformoutput", false))) || ((isnumeric (x) || islogical (x)) && all (cellfun ("isnumeric", varargin)
--- a/scripts/general/private/__splinen__.m +++ b/scripts/general/private/__splinen__.m @@ -31,18 +31,18 @@ endif ## 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; - for i = length(x):-1:1 + for i = length (x):-1:1 yi = permute (spline (x{i}, yi, xi{i}(:)), [length(x),1:length(x)-1]); endfor [xi{:}] = ndgrid (cellfun (@(x) x(:), xi, "uniformoutput", false){:}); - idx = zeros (size(xi{1})); - for i = 1 : length(x) + idx = zeros (size (xi{1})); + for i = 1 : length (x) idx |= xi{i} < min (x{i}(:)) | xi{i} > max (x{i}(:)); endfor yi(idx) = extrapval;
--- a/scripts/general/quadgk.m +++ b/scripts/general/quadgk.m @@ -162,7 +162,7 @@ abstol = varargin{idx++}; elseif (strcmpi (str, "waypoints")) waypoints = varargin{idx++} (:); - if (isreal(waypoints)) + if (isreal (waypoints)) waypoints (waypoints < a | waypoints > b) = []; endif elseif (strcmpi (str, "maxintervalcount")) @@ -190,13 +190,13 @@ ## Use variable subsitution to weaken endpoint singularities and to ## perform integration with endpoints at infinity. No transform for ## contour integrals - if (iscomplex (a) || iscomplex (b) || iscomplex(waypoints)) + if (iscomplex (a) || iscomplex (b) || iscomplex (waypoints)) ## contour integral, no transform subs = [a; waypoints; b]; h = sum (abs (diff (subs))); h0 = h; trans = @(t) t; - elseif (isinf (a) && isinf(b)) + elseif (isinf (a) && isinf (b)) ## Standard Infinite to finite integral transformation. ## \int_{-\infinity_^\infinity f(x) dx = \int_-1^1 f (g(t)) g'(t) dt ## where @@ -205,7 +205,7 @@ ## waypoint transform is then ## t = (2 * g(t)) ./ (1 + sqrt(1 + 4 * g(t) .^ 2)) if (!isempty (waypoints)) - trans = @(x) (2 * x) ./ (1 + sqrt(1 + 4 * x .^ 2)); + trans = @(x) (2 * x) ./ (1 + sqrt (1 + 4 * x .^ 2)); subs = [-1; trans(waypoints); 1]; else subs = linspace (-1, 1, 11)'; @@ -240,7 +240,7 @@ h0 = b - a; trans = @(t) b - (t ./ (1 + t)).^2; f = @(s) - 2 * s .* f (b - (s ./ (1 + s)) .^ 2) ./ ((1 + s) .^ 3); - elseif (isinf(b)) + elseif (isinf (b)) ## Formula defined in Shampine paper as two separate steps. One to ## weaken singularity at finite end, then a second to transform to ## a finite interval. The singularity weakening transform is @@ -281,7 +281,7 @@ trans = @__quadgk_finite_waypoint__; subs = [-1; trans(waypoints, a, b); 1]; else - subs = linspace(-1, 1, 11)'; + subs = linspace (-1, 1, 11)'; endif h = 2; h0 = b - a; @@ -343,7 +343,7 @@ endif ## Accept the subintervals that meet the convergence criteria - idx = find (abs (q_errs) < tol .* abs(diff (subs, [], 2)) ./ h); + idx = find (abs (q_errs) < tol .* abs (diff (subs, [], 2)) ./ h); if (first) q = sum (q_subs (idx)); err = sum (q_errs(idx)); @@ -362,7 +362,7 @@ endif if (trace) - disp([rows(subs), err, q0]); + disp ([rows(subs), err, q0]); endif ## Split remaining subintervals in two @@ -382,7 +382,7 @@ [q_subs, q_errs] = __quadgk_eval__ (f, subs); endwhile - if (err > max (abstol, reltol * abs(q))) + if (err > max (abstol, reltol * abs (q))) warning ("quadgk: Error tolerance not met. Estimated error %g", err); endif unwind_protect_cleanup @@ -425,7 +425,7 @@ halfwidth = diff (subs, [], 2) ./ 2; center = sum (subs, 2) ./ 2;; x = bsxfun (@plus, halfwidth * abscissa, center); - y = reshape (f (x(:)), size(x)); + y = reshape (f (x(:)), size (x)); ## This is faster than using bsxfun as the * operator can use a ## single BLAS call, rather than rows(sub) calls to the @times @@ -436,7 +436,7 @@ function t = __quadgk_finite_waypoint__ (x, a, b) c = (-4 .* x + 2.* (b + a)) ./ (b - a); - k = ((sqrt(c .^ 2 - 4) + c) ./ 2) .^ (1/3); + k = ((sqrt (c .^ 2 - 4) + c) ./ 2) .^ (1/3); t = real ((sqrt(3) .* 1i * (1 - k .^ 2) - (1 + k .^ 2)) ./ 2 ./ k); endfunction
--- a/scripts/general/quadl.m +++ b/scripts/general/quadl.m @@ -136,7 +136,7 @@ if (R > 0 && R < 1) tol = tol/R; endif - is = s * abs(is) * tol/myeps; + is = s * abs (is) * tol/myeps; if (is == 0) is = b-a; endif @@ -162,7 +162,7 @@ h = (b-a)/2; m = (a+b)/2; alpha = sqrt (2/3); - beta = 1 / sqrt(5); + beta = 1 / sqrt (5); mll = m-alpha*h; ml = m-beta*h; mr = m+beta*h;
--- a/scripts/general/quadv.m +++ b/scripts/general/quadv.m @@ -153,7 +153,7 @@ %!assert (quadv (@sin, 0, pi), 2, 1e-5) %% Handles weak singularities at the edge -%!assert (quadv (@(x) 1 ./ sqrt(x), 0, 1), 2, 1e-5) +%!assert (quadv (@(x) 1 ./ sqrt (x), 0, 1), 2, 1e-5) %% Handles vector-valued functions %!assert (quadv (@(x) [(sin (x)), (sin (2 * x))], 0, pi), [2, 0], 1e-5)
--- a/scripts/general/rat.m +++ b/scripts/general/rat.m @@ -36,7 +36,7 @@ ## @seealso{rats} ## @end deftypefn -function [n,d] = rat(x,tol) +function [n,d] = rat (x,tol) if (nargin != [1,2] || nargout > 2) print_usage (); @@ -49,27 +49,27 @@ ## default norm if (nargin < 2) - tol = 1e-6 * norm(y,1); + tol = 1e-6 * norm (y,1); endif ## First step in the approximation is the integer portion ## First element in the continued fraction. - n = round(y); - d = ones(size(y)); + n = round (y); + d = ones (size (y)); frac = y-n; - lastn = ones(size(y)); - lastd = zeros(size(y)); + lastn = ones (size (y)); + lastd = zeros (size (y)); - nd = ndims(y); + nd = ndims (y); nsz = numel (y); - steps = zeros([nsz, 0]); + steps = zeros ([nsz, 0]); ## Grab new factors until all continued fractions converge. while (1) ## Determine which fractions have not yet converged. - idx = find(abs (y-n./d) >= tol); - if (isempty(idx)) + idx = find (abs (y-n./d) >= tol); + if (isempty (idx)) if (isempty (steps)) steps = NaN (nsz, 1); endif @@ -79,7 +79,7 @@ ## Grab the next step in the continued fraction. flip = 1./frac(idx); ## Next element in the continued fraction. - step = round(flip); + step = round (flip); if (nargout < 2) tsteps = NaN (nsz, 1); @@ -100,23 +100,23 @@ if (nargout == 2) ## Move the minus sign to the top. - n = n.*sign(d); - d = abs(d); + n = n .* sign (d); + d = abs (d); ## Return the same shape as you receive. - n = reshape(n, size(x)); - d = reshape(d, size(x)); + n = reshape (n, size (x)); + d = reshape (d, size (x)); ## Use 1/0 for Inf. - n(isinf(x)) = sign(x(isinf(x))); - d(isinf(x)) = 0; + n(isinf (x)) = sign (x(isinf (x))); + d(isinf (x)) = 0; ## Reshape the output. n = reshape (n, size (x)); d = reshape (d, size (x)); else n = ""; - nsteps = size(steps, 2); + nsteps = columns (steps); for i = 1: nsz s = [int2str(y(i))," "]; j = 1;
--- a/scripts/general/rot90.m +++ b/scripts/general/rot90.m @@ -87,17 +87,17 @@ %! x3 = [4, 3; 2, 1]; %! x4 = [3, 1; 4, 2]; %! -%! assert(rot90 (x1), x2); -%! assert(rot90 (x1, 2), x3); -%! assert(rot90 (x1, 3), x4); -%! assert(rot90 (x1, 4), x1); -%! assert(rot90 (x1, 5), x2); -%! assert(rot90 (x1, -1), x4); +%! assert (rot90 (x1), x2); +%! assert (rot90 (x1, 2), x3); +%! assert (rot90 (x1, 3), x4); +%! assert (rot90 (x1, 4), x1); +%! assert (rot90 (x1, 5), x2); +%! assert (rot90 (x1, -1), x4); %% Test input validation %!error rot90 () %!error rot90 (1, 2, 3) -%!error rot90 (1, ones(2)) +%!error rot90 (1, ones (2)) %!error rot90 (1, 1.5) %!error rot90 (1, 1+i)
--- a/scripts/general/rotdim.m +++ b/scripts/general/rotdim.m @@ -60,8 +60,8 @@ print_usage (); endif - if (nargin > 1 && ! isempty(n)) - if (!isscalar (n) || !isreal(n) || fix (n) != n) + if (nargin > 1 && ! isempty (n)) + if (!isscalar (n) || !isreal (n) || fix (n) != n) error ("rotdim: N must be a scalar integer"); endif else
--- a/scripts/general/saveobj.m +++ b/scripts/general/saveobj.m @@ -40,5 +40,5 @@ ## @end deftypefn function b = saveobj (a) - error ("saveobj: not defined for class \"%s\"", class(a)); + error ('saveobj: not defined for class "%s"', class (a)); endfunction
--- a/scripts/general/subsindex.m +++ b/scripts/general/subsindex.m @@ -60,6 +60,6 @@ ## @end deftypefn function idx = subsindex (a) - error ("subsindex: not defined for class \"%s\"", class(a)); + error ("subsindex: not defined for class \"%s\"", class (a)); endfunction
--- a/scripts/general/triplequad.m +++ b/scripts/general/triplequad.m @@ -69,7 +69,7 @@ endfunction function q = __triplequad_inner__ (y, z, f, xa, xb, tol, quadf, varargin) - q = zeros (size(y)); + q = zeros (size (y)); for i = 1 : length (y) q(i) = feval (quadf, @(x) f (x, y(i), z, varargin{:}), xa, xb, tol); endfor
--- a/scripts/geometry/delaunay3.m +++ b/scripts/geometry/delaunay3.m @@ -54,7 +54,7 @@ endif if (! (isvector (x) && isvector (y) && isvector (z) - && length (x) == length (y) && length(x) == length (z))) + && length (x) == length (y) && length (x) == length (z))) error ("delaunay: X, Y, and Z must be the same size"); elseif (nargin == 4 && ! (ischar (options) || iscellstr (options))) error ("delaunay3: OPTIONS must be a string or cell array of strings");
--- a/scripts/geometry/griddata.m +++ b/scripts/geometry/griddata.m @@ -178,9 +178,9 @@ %!testif HAVE_QHULL %! [xx,yy] = meshgrid (linspace (-1,1,32)); %! x = xx(:); -%! x = x + 10*(2*round (rand (size(x))) - 1) * eps; +%! x = x + 10*(2*round (rand (size (x))) - 1) * eps; %! y = yy(:); -%! y = y + 10*(2*round (rand (size(y))) - 1) * eps; +%! y = y + 10*(2*round (rand (size (y))) - 1) * eps; %! z = sin (2*(x.^2 + y.^2)); %! zz = griddata (x,y,z,xx,yy,"linear"); %! zz2 = sin (2*(xx.^2 + yy.^2));
--- a/scripts/geometry/inpolygon.m +++ b/scripts/geometry/inpolygon.m @@ -54,9 +54,9 @@ npol = length (xv); do_boundary = (nargout >= 2); - in = zeros (size(x), "logical"); + in = zeros (size (x), "logical"); if (do_boundary) - on = zeros (size(x), "logical"); + on = zeros (size (x), "logical"); endif j = npol;
--- a/scripts/geometry/tsearchn.m +++ b/scripts/geometry/tsearchn.m @@ -31,9 +31,9 @@ print_usage (); endif - nt = size (t, 1); + nt = rows (t); [m, n] = size (x); - mi = size (xi, 1); + mi = rows (xi); idx = NaN (mi, 1); p = NaN (mi, n + 1); @@ -44,8 +44,8 @@ b = cart2bary (x (t (i, :), :), xi(ni,:)); ## Our points xi are in the current triangle if - ## (all(b >= 0) && all (b <= 1)). However as we impose that - ## sum(b,2) == 1 we only need to test all(b>=0). Note need to add + ## (all (b >= 0) && all (b <= 1)). However as we impose that + ## sum (b,2) == 1 we only need to test all(b>=0). Note need to add ## a small margin for rounding errors intri = all (b >= -1e-12, 2); idx(ni(intri)) = i; @@ -69,17 +69,17 @@ ## ## and therefore we can write the above as ## - ## P - T(end, :) = Beta(1:end-1) * (T(1:end-1,:) - ones(N,1) * T(end,:)) + ## P - T(end, :) = Beta(1:end-1) * (T(1:end-1,:) - ones (N,1) * T(end,:)) ## ## and then we can solve for Beta as ## - ## Beta(1:end-1) = (P - T(end,:)) / (T(1:end-1,:) - ones(N,1) * T(end,:)) - ## Beta(end) = sum(Beta) + ## Beta(1:end-1) = (P - T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:)) + ## Beta(end) = sum (Beta) ## ## Note below is generalize for multiple values of P, one per row. [M, N] = size (P); - Beta = (P - ones (M,1) * T(end,:)) / (T(1:end-1,:) - ones(N,1) * T(end,:)); - Beta (:,end+1) = 1 - sum(Beta, 2); + Beta = (P - ones (M,1) * T(end,:)) / (T(1:end-1,:) - ones (N,1) * T(end,:)); + Beta (:,end+1) = 1 - sum (Beta, 2); endfunction
--- a/scripts/geometry/voronoi.m +++ b/scripts/geometry/voronoi.m @@ -37,7 +37,7 @@ ## ## If a single output argument is requested then the Voronoi diagram will be ## plotted and a graphics handle @var{h} to the plot is returned. -## [@var{vx}, @var{vy}] = voronoi(@dots{}) returns the Voronoi vertices +## [@var{vx}, @var{vy}] = voronoi (@dots{}) returns the Voronoi vertices ## instead of plotting the diagram. ## ## @example @@ -126,8 +126,8 @@ xbox = [xmin - scale * xdelta; xmin - scale * xdelta; ... xmax + scale * xdelta; xmax + scale * xdelta]; - ybox = [xmin - scale * xdelta; xmax + scale * xdelta; ... - xmax + scale * xdelta; xmin - scale * xdelta]; + ybox = [ymin - scale * ydelta; ymax + scale * ydelta; ... + ymax + scale * ydelta; ymin - scale * ydelta]; [p, c, infi] = __voronoi__ ("voronoi", [[x(:) ; xbox(:)], [y(:); ybox(:)]], @@ -146,7 +146,7 @@ edges(2, 1 :end - 1) != edges(2, 2 : end)), true]); ## Eliminate the edges of the diagram representing the box - poutside = (1 : rows(p)) ... + poutside = (1 : rows (p)) ... (p (:, 1) < xmin - xdelta | p (:, 1) > xmax + xdelta | ... p (:, 2) < ymin - ydelta | p (:, 2) > ymax + ydelta); edgeoutside = ismember (edges (1, :), poutside) & ... @@ -180,8 +180,8 @@ %! phi = linspace (-pi, 3/4*pi, 8); %! [x,y] = pol2cart (phi, 1); %! [vx,vy] = voronoi (x,y); -%! assert(vx(2,:), zeros (1, columns (vx)), eps); -%! assert(vy(2,:), zeros (1, columns (vy)), eps); +%! assert (vx(2,:), zeros (1, columns (vx)), eps); +%! assert (vy(2,:), zeros (1, columns (vy)), eps); %% FIXME: Need input validation tests
--- a/scripts/help/get_first_help_sentence.m +++ b/scripts/help/get_first_help_sentence.m @@ -105,11 +105,11 @@ if (! isempty (def_idx)) endl_idx = find (help_text == "\n"); 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)) - keep (def_idx(k) : end) = false; + keep(def_idx(k):end) = false; else - keep (def_idx(k) : endl) = false; + keep(def_idx(k):endl) = false; endif endfor
--- a/scripts/help/unimplemented.m +++ b/scripts/help/unimplemented.m @@ -143,7 +143,6 @@ "condeig", "coneplot", "contourslice", - "copyobj", "createClassFromWsdl", "createSoapMessage", "customverctrl",
--- a/scripts/help/which.m +++ b/scripts/help/which.m @@ -57,7 +57,7 @@ %!test %! str = which ("ls"); -%! assert (str(end-17:end), strcat ("miscellaneous", filesep(), "ls.m")); +%! assert (str(end-17:end), strcat ("miscellaneous", filesep (), "ls.m")); %!test %! str = which ("dot"); %! assert (str(end-6:end), "dot.oct");
new file mode 100644 --- /dev/null +++ b/scripts/image/cmpermute.m @@ -0,0 +1,144 @@ +## Copyright (C) 2004 Josep Mones i Teixidor +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## 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. +## +## Octave 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{Y}, @var{newmap}] =} cmpermute (@var{X}, @var{map}) +## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmpermute (@var{X}, @var{map}, @var{index}) +## Reorder colors in a colormap. +## +## When called with only two arguments, @code{cmpermute} randomly rearranges +## the colormap @var{map} and returns a new colormap @var{newmap}. It also +## returns the indexed image @var{Y} which is the equivalent of the original +## input image @var{X} when displayed using @var{newmap}. The input image +## @var{X} must be an indexed image of class uint8 or double. +## +## When called with an optional third argument the order of colors in the +## new colormap is defined by @var{index}. +## +## @strong{Caution:} @code{index} should not have repeated elements or the +## function will fail. +## +## @end deftypefn + +## Author: Josep Mones i Teixidor <jmones@puntbarra.com> + +function [Y, newmap] = cmpermute (X, map, index) + + if (nargin < 2 || nargin > 3) + print_usage (); + endif + + ## FIXME: Matlab only accepts 2 types. Expand to uint16 & single?? + if (! (isa (X, "uint8") || isa (X, "double"))) + error ("cmpermute: X must be of class uint8 or double"); + endif + + if (! isreal (X) || issparse (X) + || (isfloat (X) && (any (X(:) < 1 || any (X(:) != fix (X(:))))))) + error ("cmpermute: X must be an indexed image"); + endif + + if (! isnumeric (map) || iscomplex (map) + || ndims (map) != 2 || columns (map) != 3 + || any (map(:) < 0) || any (map(:) > 1)) + error ("cmpermute: MAP must be a valid colormap"); + endif + + if (nargin < 3) + index = randperm (rows (map)); + elseif (! isvector (index) || length (index) != rows (map)) + error ("cmpermute: invalid parameter INDEX"); + endif + + ## new colormap + newmap = map(index,:); + + ## build reverse index + rindex = zeros (size (index)); + rindex(index) = 1:length (index); + + ## adapt indices + if (isa (X, "uint8")) + rindex = uint8 (rindex-1); + ## 0-based indices + Y = rindex(double (X) + 1); + else + Y = rindex(X); + endif + +endfunction + + +%!demo +%! [Y, newmap] = cmpermute ([1:4], hot (4), 4:-1:1) +%! ## colormap will be arranged in reverse order (so will image) + +%!shared X, map +%! X = uint8 (magic (16)); +%! [X, map] = cmunique (X); + +%!test # random permutation, 0-based index +%! [Y, newmap] = cmpermute (X, map); +%! ## test we didn't lose colors +%! assert (sort (map), sortrows (newmap)); +%! ## test if images are equal +%! assert (map(double (X)+1), newmap(double (Y)+1)); + +%!test # reverse map, 0-based index +%! [Y, newmap] = cmpermute (X, map, rows (map):-1:1); +%! ## we expect a reversed colormap +%! assert (flipud (newmap), map); +%! ## we expect reversed indices in image +%! assert (X, max (Y(:)) - Y); + +%!shared X,map +%! X = uint16 (magic (20)); +%! [X, map] = cmunique (X); + +%!test # random permutation, 1-based index +%! [Y, newmap] = cmpermute (X, map); +%! ## test we didn't lose colors +%! assert (sort (map), sortrows (newmap)); +%! ## test if images are equal +%! assert (map(X), newmap(Y)); + +%!test # reverse map, 1-based index +%! [Y, newmap] = cmpermute (X, map, rows (map):-1:1); +%! ## we expect a reversed colormap +%! assert (newmap (rows (newmap):-1:1,:), map); +%! ## we expect reversed indices in image +%! assert (X, max (Y(:)) + 1 - Y); + +## Test input validation +%!error cmpermute () +%!error cmpermute (1,2,3,4) +%!error <X must be of class uint8> cmpermute (uint16 (magic (16)), jet (256)) +%!error <X must be an indexed image> cmpermute (1+i, jet (256)) +%!error <X must be an indexed image> cmpermute (sparse (1), jet (256)) +%!error <X must be an indexed image> cmpermute (0, jet (256)) +%!error <X must be an indexed image> cmpermute (1.5, jet (256)) +%!error <MAP must be a valid colormap> cmpermute (1, "a") +%!error <MAP must be a valid colormap> cmpermute (1, i) +%!error <MAP must be a valid colormap> cmpermute (1, ones (3,3,3)) +%!error <MAP must be a valid colormap> cmpermute (1, ones (3,2)) +%!error <MAP must be a valid colormap> cmpermute (1, [-1 1 1]) +%!error <MAP must be a valid colormap> cmpermute (1, [2 1 1]) +%!error <invalid parameter INDEX> cmpermute (1, [0 1 0;1 0 1], ones (3)) +%!error <invalid parameter INDEX> cmpermute (1, [0 1 0;1 0 1], 1:3) +
new file mode 100644 --- /dev/null +++ b/scripts/image/cmunique.m @@ -0,0 +1,204 @@ +## Copyright (C) 2004 Josep Mones i Teixidor +## Copyright (C) 2012 Rik Wehbring +## +## This file is part of Octave. +## +## 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. +## +## Octave 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{X}, @var{map}) +## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{RGB}) +## @deftypefnx {Function File} {[@var{Y}, @var{newmap}] =} cmunique (@var{I}) +## Convert an input image @var{X} to an ouput indexed image @var{Y} which uses +## the smallest colormap possible @var{newmap}. +## +## When the input is an indexed image (@var{X} with colormap @var{map}) the +## output is a colormap @var{newmap} from which any repeated rows have been +## eliminated. The output image, @var{Y}, is the original input image with +## the indices adjusted to match the new, possibly smaller, colormap. +## +## When the input is an RGB image (an MxNx3 array), the output colormap +## will contain one entry for every unique color in the original image. +## In the worst case the new map could have as many rows as the number of +## pixels in the original image. +## +## When the input is a grayscale image @var{I}, the output colormap will +## contain one entry for every unique intensity value in the original image. +## In the worst case the new map could have as many rows as the number of +## pixels in the original image. +## +## Implementation Details: +## +## @var{newmap} is always an Mx3 matrix, even if the input image is +## an intensity grayscale image @var{I} (all three RGB planes are +## assigned the same value). +## +## The output image is of class uint8 if the size of the new colormap is +## less than or equal to 256. Otherwise, the output image is of class double. +## +## @seealso{rgb2ind, gray2ind} +## @end deftypefn + + +## Author: Josep Mones i Teixidor <jmones@puntbarra.com> + +function [Y, newmap] = cmunique (X, map) + + if (nargin < 1 || nargin > 2) + print_usage (); + endif + + cls = class (X); + ## FIXME: Documentation accepts only 3 classes. Could easily add 'single'. + if (! any (isa (X, {"uint8", "uint16", "double"}))) + error ("cmunique: X is of invalid data type '%s'", cls); + endif + + if (nargin == 2) + ## (X, map) case + if (! isnumeric (map) || iscomplex (map) + || ndims (map) != 2 || columns (map) != 3 + || any (map(:) < 0) || any (map(:) > 1)) + error ("cmunique: MAP must be a valid colormap"); + endif + [newmap,i,j] = unique (map, "rows"); # calculate unique colormap + if (isa (X, "double")) + Y = j(X); # find new indices + else + Y = j(double (X) + 1); # find new indices + endif + else + switch (size (X,3)) + case (1) + ## I case + [newmap,i,j] = unique (X); # calculate unique colormap + newmap = repmat (newmap,1,3); # get a RGB colormap + Y = reshape (j, rows (X), columns (X)); # Y is j reshaped + case (3) + ## RGB case + ## build a map with all values + map = [X(:,:,1)(:), X(:,:,2)(:), X(:,:,3)(:)]; + [newmap,i,j] = unique (map, "rows"); # calculate unique colormap + Y = reshape (j, rows (X), columns (X)); # Y is j reshaped + otherwise + error ("cmunique: X is not a valid image"); + endswitch + + ## if image was uint8 or uint16 we have to convert newmap to [0,1] range + if (! isa (X, "double")) + newmap = double (newmap) / double (intmax (class (X))); + endif + endif + + if (rows (newmap) <= 256) + ## convert Y to uint8 (0-based indices then) + Y = uint8 (Y-1); + endif + +endfunction + + +%!demo +%! [Y, newmap] = cmunique ([1:4;5:8], [hot(4);hot(4)]) +%! ## Both rows are equal since map maps colors to the same value +%! ## cmunique will give the same indices to both + +## Check that output is uint8 in short colormaps +%!test +%! [Y, newmap] = cmunique ([1:4;5:8], [hot(4);hot(4)]); +%! assert (Y, uint8 ([0:3;0:3])); +%! assert (newmap, hot (4)); + +## Check that output is double in bigger +%!test +%! [Y, newmap] = cmunique ([1:300;301:600], [hot(300);hot(300)]); +%! assert (Y, [1:300;1:300]); +%! assert (newmap, hot (300)); + +## Check boundary case 256 +%!test +%! [Y, newmap] = cmunique ([1:256;257:512], [hot(256);hot(256)]); +%! assert (Y, uint8 ([0:255;0:255])); +%! assert (newmap, hot (256)); + +## Check boundary case 257 +%!test +%! [Y, newmap] = cmunique ([1:257;258:514], [hot(257);hot(257)]); +%! assert (Y, [1:257;1:257]); +%! assert (newmap, hot (257)); + +## Random RGB image +%!test +%! RGB = rand (10,10,3); +%! [Y, newmap] = cmunique (RGB); +%! assert (RGB(:,:,1), newmap(:,1)(Y+1)); +%! assert (RGB(:,:,2), newmap(:,2)(Y+1)); +%! assert (RGB(:,:,3), newmap(:,3)(Y+1)); + +## Random uint8 RGB image +%!test +%! RGB = uint8 (rand (10,10,3)*255); +%! RGBd = double (RGB) / 255; +%! [Y, newmap] = cmunique (RGB); +%! assert (RGBd(:,:,1), newmap(:,1)(Y+1)); +%! assert (RGBd(:,:,2), newmap(:,2)(Y+1)); +%! assert (RGBd(:,:,3), newmap(:,3)(Y+1)); + +## Random uint16 RGB image +%!test +%! RGB = uint16 (rand (10,10,3)*65535); +%! RGBd = double (RGB) / 65535; +%! [Y, newmap] = cmunique (RGB); +%! assert (RGBd(:,:,1), newmap(:,1)(Y+1)); +%! assert (RGBd(:,:,2), newmap(:,2)(Y+1)); +%! assert (RGBd(:,:,3), newmap(:,3)(Y+1)); + +## Random I image +%!test +%! I = rand (10,10); +%! [Y, newmap] = cmunique (I); +%! assert (I, newmap(:,1)(Y+1)); +%! assert (I, newmap(:,2)(Y+1)); +%! assert (I, newmap(:,3)(Y+1)); + +## Random uint8 I image +%!test +%! I = uint8 (rand (10,10)*256); +%! Id = double (I) / 255; +%! [Y, newmap] = cmunique (I); +%! assert (Id, newmap(:,1)(Y+1)); +%! assert (Id, newmap(:,2)(Y+1)); +%! assert (Id, newmap(:,3)(Y+1)); + +## Random uint16 I image +%!test +%! I = uint16 (rand (10,10)*65535); +%! Id = double (I) / 65535; +%! [Y,newmap] = cmunique (I); +%! assert (Id,newmap (:,1)(Y+1)); +%! assert (Id,newmap (:,2)(Y+1)); +%! assert (Id,newmap (:,3)(Y+1)); + +## Test input validation +%!error cmpermute () +%!error cmpermute (1,2,3) +%!error <X is of invalid data type> cmunique (single (magic (16))) +%!error <MAP must be a valid colormap> cmunique (1, "a") +%!error <MAP must be a valid colormap> cmunique (1, i) +%!error <MAP must be a valid colormap> cmunique (1, ones (3,3,3)) +%!error <MAP must be a valid colormap> cmunique (1, ones (3,2)) +%!error <MAP must be a valid colormap> cmunique (1, [-1 1 1]) +%!error <MAP must be a valid colormap> cmunique (1, [2 1 1]) +
--- a/scripts/image/gray2ind.m +++ b/scripts/image/gray2ind.m @@ -35,7 +35,7 @@ if (nargin < 1 || nargin > 2) print_usage (); endif - C = class(I); + C = class (I); if (! ismatrix (I) || ndims (I) != 2) error ("gray2ind: first input argument must be a gray scale image"); endif
--- a/scripts/image/image.m +++ b/scripts/image/image.m @@ -135,12 +135,12 @@ if (xdata(2) < xdata(1)) xdata = xdata(2:-1:1); elseif (xdata(2) == xdata(1)) - xdata = xdata(1) + [0, size(img,2)-1]; + xdata = xdata(1) + [0, columns(img)-1]; endif if (ydata(2) < ydata(1)) ydata = ydata(2:-1:1); elseif (ydata(2) == ydata(1)) - ydata = ydata(1) + [0, size(img,1)-1]; + ydata = ydata(1) + [0, rows(img)-1]; endif xlim = xdata + [-px(1), px(1)]; ylim = ydata + [-px(2), px(2)];
--- a/scripts/image/imshow.m +++ b/scripts/image/imshow.m @@ -25,7 +25,7 @@ ## @deftypefnx {Function File} {} imshow (@dots{}, @var{string_param1}, @var{value1}, @dots{}) ## @deftypefnx {Function File} {@var{h} =} imshow (@dots{}) ## Display the image @var{im}, where @var{im} can be a 2-dimensional -## (gray-scale image) or a 3-dimensional (RGB image) matrix. +## (grayscale image) or a 3-dimensional (RGB image) matrix. ## ## If @var{limits} is a 2-element vector @code{[@var{low}, @var{high}]}, ## the image is shown using a display range between @var{low} and
--- a/scripts/image/imwrite.m +++ b/scripts/image/imwrite.m @@ -162,7 +162,7 @@ error ("imwrite: %s: invalid class for indexed image data", img_class); endif if (isa (map, "double")) - if (ndims (map) != 2 || size (map, 2) != 3) + if (ndims (map) != 2 || columns (map) != 3) error ("imwrite: invalid size for colormap"); endif else
--- a/scripts/image/module.mk +++ b/scripts/image/module.mk @@ -4,6 +4,8 @@ image/autumn.m \ image/bone.m \ image/brighten.m \ + image/cmpermute.m \ + image/cmunique.m \ image/colorcube.m \ image/colormap.m \ image/contrast.m \
--- a/scripts/image/pink.m +++ b/scripts/image/pink.m @@ -44,7 +44,7 @@ endif if (n == 1) - map = sqrt([1/3, 1/3, 1/3]); + map = sqrt ([1/3, 1/3, 1/3]); elseif (n > 1) x = linspace (0, 1, n)'; r = (x < 3/8) .* (14/9 * x) ...
--- a/scripts/io/dlmwrite.m +++ b/scripts/io/dlmwrite.m @@ -180,7 +180,7 @@ endif if (iscomplex (M)) M = M.'; - b = zeros (2*rows(M), columns (M)); + b = zeros (2*rows (M), columns (M)); b(1: 2 : end, :) = real (M); b(2: 2 : end, :) = imag (M); fprintf (fid, template, b);
--- a/scripts/io/strread.m +++ b/scripts/io/strread.m @@ -564,7 +564,7 @@ while (ii <= num_words_per_line) ## Check if fmt_words(ii) contains a literal or fixed-width - if ((idf(ii) || idg(ii)) && (rows(words) < num_words_per_line)) + if ((idf(ii) || idg(ii)) && (rows (words) < num_words_per_line)) if (idf(ii)) s = strfind (words(icol, 1), fmt_words{ii}); if (isempty (s{:})) @@ -583,11 +583,11 @@ if (! idg(ii) && ! isempty (s) && s(1) == 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)); + 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), ... + (@(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))]; @@ -617,14 +617,14 @@ wrds(1:2:2*numel (words(icol, jptr))) = ... strrep (words(icol, jptr), fmt_words{ii}, ... [char(255) char(254)]); - wrds(2:2:2*numel (words(icol, jptr))-1) = char(255); - wrds = strsplit ([wrds{:}], char(255)); + wrds(2:2:2*numel (words(icol, jptr))-1) = char (255); + wrds = strsplit ([wrds{:}], char (255)); words(icol, jptr) = ... - wrds(find (cellfun ("isempty", strfind (wrds, char(254))))); - wrds(find (cellfun ("isempty", strfind (wrds, char(254))))) ... - = char(255); + wrds(find (cellfun ("isempty", strfind (wrds, char (254))))); + wrds(find (cellfun ("isempty", strfind (wrds, char (254))))) ... + = char (255); words(icol+1, jptr) = strsplit (strrep ([wrds{2:end}], ... - char(254), fmt_words{ii}), char(255)); + char (254), fmt_words{ii}), char (255)); ## Former trailing literal may now be leading for next specifier --ii; fwptr = [fwptr(1:ii) (++fwptr(ii+1:end))]; @@ -762,7 +762,7 @@ ## to avoid it being included in consecutive delim series enchr = ' '; ## However watch out if eol_char is also in delimiters - if (index (sep, eol_char)); enchr = char(255); endif + if (index (sep, eol_char)); enchr = char (255); endif text = strrep (text, eol_char, [enchr eol_char enchr]); else mult_dlms_s1 = false; @@ -770,7 +770,7 @@ ## Split text string along delimiters out = strsplit (text, sep, mult_dlms_s1); - if (index (sep, eol_char)); out = strrep (out, char(255), ''); endif + 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))) out(end) = [];
--- a/scripts/io/textread.m +++ b/scripts/io/textread.m @@ -150,7 +150,7 @@ str = fscanf (fid, "%c", eoi_pos); else fseek (fid, st_pos, "bof"); - str = fread(fid, "char=>char").'; + str = fread (fid, "char=>char").'; endif fclose (fid);
--- a/scripts/io/textscan.m +++ b/scripts/io/textscan.m @@ -332,7 +332,7 @@ %!test %! str = "13, 72, NA, str1, 25\r\n// Middle line\r\n36, na, 05, str3, 6"; %! a = textscan (str, "%d %n %f %s %n", "delimiter", ",","treatAsEmpty", {"NA", "na"},"commentStyle", "//"); -%! assert (a{1}, int32([13; 36])); +%! assert (a{1}, int32 ([13; 36])); %! assert (a{2}, [72; NaN]); %! assert (a{3}, [NaN; 5]); %! assert (a{4}, {"str1"; "str3"}); @@ -345,9 +345,9 @@ %! str = [str "Km:25 = hhhZ\r\n"]; %! fmt = "Km:%d = hhh%1sjjj miles%dhour"; %! a = textscan (str, fmt, "delimiter", " "); -%! assert (a{1}', int32([10 15 2 25])); +%! assert (a{1}', int32 ([10 15 2 25])); %! assert (a{2}', {'B' 'J' 'R' 'Z'}); -%! assert (a{3}', int32([16 241 3 0])); +%! assert (a{3}', int32 ([16 241 3 0])); %% Test with default endofline parameter %!test @@ -357,7 +357,7 @@ %% 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 ])); +%! assert (int8 (c{:}{:}), int8 ([ 76, 49, 10, 76, 50 ])); %!test %! # No delimiters at all besides EOL. Skip fields, even empty fields @@ -372,8 +372,8 @@ %! str = sprintf ("%g miles/hr = %g (%g) kilometers (meters)/hr\n", b); %! fmt = "%f miles%s %s %f (%f) kilometers %*s"; %! c = textscan (str, fmt, "collectoutput", 1); -%! assert (size(c{3}), [10, 2]); -%! assert (size(c{2}), [10, 2]); +%! assert (size (c{3}), [10, 2]); +%! assert (size (c{2}), [10, 2]); %!test %% CollectOutput test with uneven column length files @@ -383,9 +383,9 @@ %! str = [str "110 miles/hr"]; %! fmt = "%f miles%s %s %f (%f) kilometers %*s"; %! c = textscan (str, fmt, "collectoutput", 1); -%! assert (size(c{1}), [11, 1]); -%! assert (size(c{3}), [11, 2]); -%! assert (size(c{2}), [11, 2]); +%! assert (size (c{1}), [11, 1]); +%! assert (size (c{3}), [11, 2]); +%! assert (size (c{2}), [11, 2]); %! assert (c{3}(end), NaN); %! assert (c{2}{11, 1}, "/hr"); %! assert (isempty (c{2}{11, 2}), true); @@ -400,5 +400,5 @@ %! Test incomplete first data line %! R = textscan (['Empty1' char(10)], 'Empty%d %f'); -%! assert (R{1}, int32(1)); -%! assert (isempty(R{2}), true); +%! assert (R{1}, int32 (1)); +%! assert (isempty (R{2}), true);
--- a/scripts/linear-algebra/housh.m +++ b/scripts/linear-algebra/housh.m @@ -23,8 +23,8 @@ ## ## @example ## @group -## (I - beta*housv*housv')x = norm(x)*e(j) if x(j) < 0, -## (I - beta*housv*housv')x = -norm(x)*e(j) if x(j) >= 0 +## (I - beta*housv*housv')x = norm (x)*e(j) if x(j) < 0, +## (I - beta*housv*housv')x = -norm (x)*e(j) if x(j) >= 0 ## @end group ## @end example ## @@ -66,7 +66,7 @@ ## Check for valid inputs. if (! isvector (x) && ! isscalar (x)) error ("housh: first input must be a vector"); - elseif (! isscalar(j)) + elseif (! isscalar (j)) error ("housh: second argment must be an integer scalar"); else housv = x;
--- a/scripts/linear-algebra/ishermitian.m +++ b/scripts/linear-algebra/ishermitian.m @@ -63,7 +63,7 @@ %!test %! s.a = 1; -%! assert(! ishermitian (s)); +%! assert (! ishermitian (s)); %!error ishermitian ([1, 2; 2, 1], 0, 0) %!error ishermitian ()
--- a/scripts/linear-algebra/issymmetric.m +++ b/scripts/linear-algebra/issymmetric.m @@ -62,7 +62,7 @@ %!test %! s.a = 1; -%! assert(! issymmetric (s)); +%! assert (! issymmetric (s)); %!error issymmetric ([1, 2; 2, 1], 0, 0) %!error issymmetric ()
--- a/scripts/linear-algebra/krylov.m +++ b/scripts/linear-algebra/krylov.m @@ -34,7 +34,7 @@ ## meaningless. ## ## If @var{V} is a vector and @var{k} is greater than -## @code{length(A)-1}, then @var{h} contains the Hessenberg matrix such +## @code{length (A) - 1}, then @var{h} contains the Hessenberg matrix such ## that @code{a*u == u*h}. ## ## The value of @var{nu} is the dimension of the span of the Krylov @@ -71,7 +71,7 @@ pflg = 0; endif - if(nargin < 4) + if (nargin < 4) ## Default tolerance parameter. eps1 = defeps; endif @@ -115,14 +115,14 @@ iter = 0; alpha = []; nh = 0; - while (length(alpha) < na) && (columns(V) > 0) && (iter < k) + while (length (alpha) < na) && (columns (V) > 0) && (iter < k) iter++; ## Get orthogonal basis of V. jj = 1; while (jj <= columns (V) && length (alpha) < na) ## Index of next Householder reflection. - nu = length(alpha)+1; + nu = length (alpha)+1; short_pv = pivot_vec(nu:na); q = V(:,jj);
--- a/scripts/linear-algebra/logm.m +++ b/scripts/linear-algebra/logm.m @@ -104,7 +104,7 @@ s = 2^k * u * s * u'; ## Remove small complex values (O(eps)) which may have entered calculation - if (real_eig && isreal(A)) + if (real_eig && isreal (A)) s = real (s); endif
--- a/scripts/linear-algebra/null.m +++ b/scripts/linear-algebra/null.m @@ -67,9 +67,9 @@ if (rank < cols) retval = V (:, rank+1:cols); if (isa (A, "single")) - retval(abs (retval) < eps ("single")) = 0; + retval (abs (retval) < eps ("single")) = 0; else - retval(abs (retval) < eps) = 0; + retval (abs (retval) < eps) = 0; endif else retval = zeros (cols, 0);
--- a/scripts/linear-algebra/rref.m +++ b/scripts/linear-algebra/rref.m @@ -62,20 +62,20 @@ if (m <= tol) ## Skip column c, making sure the approximately zero terms are ## actually zero. - A (r:rows, c) = zeros (rows-r+1, 1); + A(r:rows, c) = zeros (rows-r+1, 1); else ## keep track of bound variables used (1, c) = 1; ## Swap current row and pivot row - A ([pivot, r], c:cols) = A ([r, pivot], c:cols); + A([pivot, r], c:cols) = A([r, pivot], c:cols); ## Normalize pivot row - A (r, c:cols) = A (r, c:cols) / A (r, c); + A(r, c:cols) = A(r, c:cols) / A(r, c); ## Eliminate the current column ridx = [1:r-1, r+1:rows]; - A (ridx, c:cols) = A (ridx, c:cols) - A (ridx, c) * A(r, c:cols); + A(ridx, c:cols) = A(ridx, c:cols) - A(ridx, c) * A(r, c:cols); ## Check if done if (r++ == rows)
--- a/scripts/miscellaneous/compare_versions.m +++ b/scripts/miscellaneous/compare_versions.m @@ -66,8 +66,8 @@ ## Note that version "1.1-test2" will compare as greater than ## "1.1-test10". Also, since the numeric part is compared first, "a" ## compares less than "1a" because the second string starts with a -## numeric part even though @code{double("a")} is greater than -## @code{double("1").} +## numeric part even though @code{double ("a")} is greater than +## @code{double ("1").} ## @end deftypefn ## Author: Bill Denney <denney@seas.upenn.edu> @@ -89,7 +89,7 @@ if (! ischar (operator)) error ("compare_versions: OPERATOR must be a character string"); elseif (numel (operator) > 2) - error("compare_versions: OPERATOR must be 1 or 2 characters long"); + error ("compare_versions: OPERATOR must be 1 or 2 characters long"); endif ## trim off any character data that is not part of a normal version @@ -99,14 +99,14 @@ v1firstchar = find (! ismember (v1, numbers), 1); v2firstchar = find (! ismember (v2, numbers), 1); if (! isempty (v1firstchar)) - v1c = v1(v1firstchar:length(v1)); + v1c = v1(v1firstchar:length (v1)); v1nochar = v1(1:v1firstchar-1); else v1c = ""; v1nochar = v1; endif if (! isempty (v2firstchar)) - v2c = v2(v2firstchar:length(v2)); + v2c = v2(v2firstchar:length (v2)); v2nochar = v2(1:v2firstchar-1); else v2c = ""; @@ -115,7 +115,7 @@ v1n = str2num (char (strsplit (v1nochar, "."))); v2n = str2num (char (strsplit (v2nochar, "."))); - if ((isempty (v1n) && isempty (v1c)) || (isempty (v2n) && isempty(v2c))) + if ((isempty (v1n) && isempty (v1c)) || (isempty (v2n) && isempty (v2c))) error ("compare_versions: given version strings are not valid: %s %s", v1, v2); endif
--- a/scripts/miscellaneous/copyfile.m +++ b/scripts/miscellaneous/copyfile.m @@ -72,7 +72,7 @@ ## If f1 has more than 1 element f2 must be a directory isdir = (exist (f2, "dir") != 0); - if (length(f1) > 1 && ! isdir) + if (length (f1) > 1 && ! isdir) error ("copyfile: when copying multiple files, second argument must be a directory"); endif @@ -84,12 +84,12 @@ p1 = sprintf ("\"%s\" ", f1{:}); p2 = tilde_expand (f2); - if (isdir && length(p1) > max_cmd_line) - l2 = length(p2) + length (cmd) + 6; - while (! isempty(f1)) + if (isdir && length (p1) > max_cmd_line) + l2 = length (p2) + length (cmd) + 6; + while (! isempty (f1)) p1 = sprintf ("\"%s\" ", f1{1}); f1(1) = []; - while (!isempty (f1) && (length(p1) + length(f1{1}) + l2 < + while (!isempty (f1) && (length (p1) + length (f1{1}) + l2 < max_cmd_line)) p1 = sprintf ("%s\"%s\" ", p1, f1{1}); f1(1) = [];
--- a/scripts/miscellaneous/dump_prefs.m +++ b/scripts/miscellaneous/dump_prefs.m @@ -82,7 +82,7 @@ "struct_levels_to_print"; "suppress_verbose_help_message"]; - for i = 1:rows(sym_list) + for i = 1:rows (sym_list) sym = deblank (sym_list(i,:)); try val = feval (sym);
--- a/scripts/miscellaneous/edit.m +++ b/scripts/miscellaneous/edit.m @@ -72,7 +72,7 @@ ## @item editor ## This is the editor to use to modify the functions. By default it uses ## Octave's @env{EDITOR} built-in function, which comes from -## @code{getenv("EDITOR")} and defaults to @code{emacs}. Use @code{%s} +## @code{getenv ("EDITOR")} and defaults to @code{emacs}. Use @code{%s} ## In place of the function name. For example, ## ## @table @samp @@ -179,7 +179,7 @@ if (strcmp (state, "sync") || strcmp (state, "async")) FUNCTION.MODE = state; else - error('edit: expected "edit MODE sync|async"'); + error ('edit: expected "edit MODE sync|async"'); endif case "EDITINPLACE" if (ischar (state)) @@ -193,7 +193,7 @@ endif FUNCTION.EDITINPLACE = state; case "GET" - if (isfield (FUNCTION, toupper(state))) + if (isfield (FUNCTION, toupper (state))) ret = FUNCTION.(toupper (state)); else ret = FUNCTION; @@ -260,7 +260,7 @@ ## If the file includes a path, it may be an overloaded function. if (! strcmp (file, "@") && index (file, filesep)) ## No "@" at the beginning of the file, add to the list. - numfiles = numel(filelist); + numfiles = numel (filelist); for n = 1:numfiles filelist{n+numfiles} = cat (2, "@", filelist{n}); endfor @@ -268,7 +268,7 @@ ## Search the entire path for the 1st instance of a file in the list. fileandpath = ""; - for n = 1:numel(filelist) + for n = 1:numel (filelist) filetoedit = file_in_path (path, filelist{n}); if (! isempty (filetoedit)) ## The path is explicitly included. @@ -324,7 +324,7 @@ ## Guess the email name if it was not given. if (isempty (FUNCTION.EMAIL)) - host = getenv("HOSTNAME"); + host = getenv ("HOSTNAME"); if (isempty (host) && ispc ()) host = getenv ("COMPUTERNAME"); endif @@ -443,11 +443,11 @@ endif if (isempty (head)) comment = cstrcat ("## ", name, "\n\n", - "## ", strrep (tail, "\n", "\n## "), "\n\n"); + "## ", strrep (tail, "\n", "\n## "), "\n\n"); else - comment = cstrcat ("## ", strrep(head,"\n","\n## "), "\n\n", ... - "## ", name, "\n\n", ... - "## ", strrep (tail, "\n", "\n## "), "\n\n"); + comment = cstrcat ("## ", strrep (head,"\n","\n## "), "\n\n", ... + "## ", name, "\n\n", ... + "## ", strrep (tail, "\n", "\n## "), "\n\n"); endif text = cstrcat (comment, body); endswitch
--- a/scripts/miscellaneous/fileparts.m +++ b/scripts/miscellaneous/fileparts.m @@ -34,7 +34,7 @@ es = rindex (filename, "."); ## These can be the same if they are both 0 (no dir or ext). if (es <= ds) - es = length(filename)+1; + es = length (filename)+1; endif if (ds == 0) directory = "";
--- a/scripts/miscellaneous/getappdata.m +++ b/scripts/miscellaneous/getappdata.m @@ -33,7 +33,7 @@ ## and missing fields? val = cell (numel (h), 1); appdata = struct (); - for nh = 1:numel(h) + for nh = 1:numel (h) try appdata = get (h(nh), "__appdata__"); end_try_catch
--- a/scripts/miscellaneous/isappdata.m +++ b/scripts/miscellaneous/isappdata.m @@ -30,7 +30,7 @@ error ("isappdata: invalid input"); endif - for nh = 1:numel(h) + for nh = 1:numel (h) data = get (h(nh)); if (isfield (data, "__appdata__") && isfield (data.__appdata__, name)) res(nh) = true;
--- a/scripts/miscellaneous/movefile.m +++ b/scripts/miscellaneous/movefile.m @@ -72,7 +72,7 @@ ## If f1 has more than 1 element f2 must be a directory isdir = (exist (f2, "dir") != 0); - if (length(f1) > 1 && ! isdir) + if (length (f1) > 1 && ! isdir) error ("movefile: when moving multiple files, second argument must be a directory"); endif @@ -84,12 +84,12 @@ p1 = sprintf ("\"%s\" ", f1{:}); p2 = tilde_expand (f2); - if (isdir && length(p1) > max_cmd_line) - l2 = length(p2) + length (cmd) + 6; - while (! isempty(f1)) + if (isdir && length (p1) > max_cmd_line) + l2 = length (p2) + length (cmd) + 6; + while (! isempty (f1)) p1 = sprintf ("\"%s\" ", f1{1}); f1(1) = []; - while (!isempty (f1) && (length(p1) + length(f1{1}) + l2 < + while (!isempty (f1) && (length (p1) + length (f1{1}) + l2 < max_cmd_line)) p1 = sprintf ("%s\"%s\" ", p1, f1{1}); f1(1) = [];
--- a/scripts/miscellaneous/orderfields.m +++ b/scripts/miscellaneous/orderfields.m @@ -37,7 +37,7 @@ ## ## @example ## @group -## s = struct("d", 4, "b", 2, "a", 1, "c", 3); +## s = struct ("d", 4, "b", 2, "a", 1, "c", 3); ## t1 = orderfields (s) ## @result{} t1 = ## @{ @@ -48,7 +48,7 @@ ## @} ## @end group ## @group -## t = struct("d", @{@}, "c", @{@}, "b", "a", @{@}); +## t = struct ("d", @{@}, "c", @{@}, "b", "a", @{@}); ## t2 = orderfields (s, t) ## @result{} t2 = ## @{
--- a/scripts/miscellaneous/parseparams.m +++ b/scripts/miscellaneous/parseparams.m @@ -88,7 +88,7 @@ if (! size_equal (pnames, values) || ! all (strs(i:2:end))) error_as_caller ("options must be given as name-value pairs"); endif - idx = lookup (toupper(names), toupper(pnames), "m"); + idx = lookup (toupper (names), toupper (pnames), "m"); if (! all (idx)) error_as_caller ("unrecognized option: %s", pnames{find (idx == 0, 1)}); else
--- a/scripts/miscellaneous/private/__xzip__.m +++ b/scripts/miscellaneous/private/__xzip__.m @@ -62,13 +62,13 @@ files = glob (files); ## Ignore any file with the compress extension - files(cellfun (@(x) length(x) > length(extension) - && strcmp (x((end - length(extension) + 1):end), extension), + files(cellfun (@(x) length (x) > length (extension) + && strcmp (x((end - length (extension) + 1):end), extension), files)) = []; copyfile (files, outdir); - [d, f] = myfileparts(files); + [d, f] = myfileparts (files); cd (outdir); @@ -87,12 +87,12 @@ f, "uniformoutput", false); endif else - movefile (cellfun(@(x) sprintf ("%s.%s", x, extension), f, + movefile (cellfun (@(x) sprintf ("%s.%s", x, extension), f, "uniformoutput", false), cwd); if (nargout > 0) ## FIXME this does not work when you try to compress directories - entries = cellfun(@(x) sprintf ("%s.%s", x, extension), - files, "uniformoutput", false); + entries = cellfun (@(x) sprintf ("%s.%s", x, extension), + files, "uniformoutput", false); endif endif @@ -119,20 +119,20 @@ ## functions directly. ## ## %!error <extension has to be a string with finite length> -## %! __xzip__("gzip", "", "gzip -r %s", "bla"); +## %! __xzip__ ("gzip", "", "gzip -r %s", "bla"); ## %!error <no files to move> -## %! __xzip__("gzip", ".gz", "gzip -r %s", tmpnam); +## %! __xzip__ ("gzip", ".gz", "gzip -r %s", tmpnam); ## %!error <command failed with exit status> ## %! # test __xzip__ with invalid compression command ## %! unwind_protect ## %! filename = tmpnam; ## %! dummy = 1; -## %! save(filename, "dummy"); +## %! save (filename, "dummy"); ## %! dirname = tmpnam; -## %! mkdir(dirname); -## %! entry = __xzip__("gzip", ".gz", "xxxzipxxx -r %s 2>/dev/null", +## %! mkdir (dirname); +## %! entry = __xzip__ ("gzip", ".gz", "xxxzipxxx -r %s 2>/dev/null", ## %! filename, dirname); ## %! unwind_protect_cleanup -## %! delete(filename); -## %! rmdir(dirname); +## %! delete (filename); +## %! rmdir (dirname); ## %! end_unwind_protect
--- a/scripts/miscellaneous/rmappdata.m +++ b/scripts/miscellaneous/rmappdata.m @@ -29,7 +29,7 @@ error ("rmappdata: invalid input"); endif - for nh = 1:numel(h) + for nh = 1:numel (h) appdata = get (h(nh), "__appdata__"); appdata = rmfield (appdata, varargin); set (h(nh), "__appdata__", appdata);
--- a/scripts/miscellaneous/setappdata.m +++ b/scripts/miscellaneous/setappdata.m @@ -30,12 +30,12 @@ error ("setappdata: invalid input"); endif - for nh = 1:numel(h) + for nh = 1:numel (h) if (! isfield (get (h(nh)), "__appdata__")) addproperty ("__appdata__", h(nh), "any", struct ()); endif appdata = get (h(nh), "__appdata__"); - for narg = 1:2:numel(varargin) + for narg = 1:2:numel (varargin) if (iscellstr (varargin{narg})) ## Handle cell arrays like set() does. set (h(nh), "__appdata__", appdata);
--- a/scripts/miscellaneous/swapbytes.m +++ b/scripts/miscellaneous/swapbytes.m @@ -52,7 +52,7 @@ error ("swapbytes: invalid class of object"); endif y = reshape (typecast (reshape (typecast (x(:), "uint8"), nb, numel (x)) - ([nb : -1 : 1], :) (:), clx), size(x)); + ([nb : -1 : 1], :) (:), clx), size (x)); endif endfunction
--- a/scripts/miscellaneous/unpack.m +++ b/scripts/miscellaneous/unpack.m @@ -39,7 +39,7 @@ endif if (! ischar (file) && ! iscellstr (file)) - error ("unpack: invalid input file class, %s", class(file)); + error ("unpack: invalid input file class, %s", class (file)); endif ## character arrays of more than one string must be treated as cell strings @@ -224,7 +224,7 @@ ## Skip first line which is Archive header output(1) = []; for i = 1:length (output) - files{i} = output{i}(14:length(output{i})); + files{i} = output{i}(14:length (output{i})); endfor endfunction @@ -246,7 +246,7 @@ "Unable to parse line (gzip missing colon):\n%s", output{i}); else midcolon = colons(ceil (length (colons)/2)); - thisstr = output{i}(midcolon+2:length(output{i})); + thisstr = output{i}(midcolon+2:length (output{i})); idx = index (thisstr, "with") + 5; if (isempty (idx)) warning ("unpack:parsing",
--- a/scripts/miscellaneous/ver.m +++ b/scripts/miscellaneous/ver.m @@ -94,7 +94,7 @@ else if (! isempty (package)) n = []; - for r = 1:numel(ret) + for r = 1:numel (ret) if (strcmpi (ret(r).Name, package)) n = r; break;
--- a/scripts/optimization/fminbnd.m +++ b/scripts/optimization/fminbnd.m @@ -20,14 +20,13 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {[@var{x}, @var{fval}, @var{info}, @var{output}] =} fminbnd (@var{fun}, @var{a}, @var{b}, @var{options}) -## Find a minimum point of a univariate function. @var{fun} should be a -## function -## handle or name. @var{a}, @var{b} specify a starting interval. @var{options} -## is a -## structure specifying additional options. Currently, @code{fminbnd} -## recognizes these options: @code{"FunValCheck"}, @code{"OutputFcn"}, -## @code{"TolX"}, @code{"MaxIter"}, @code{"MaxFunEvals"}. -## For description of these options, see @ref{doc-optimset,,optimset}. +## Find a minimum point of a univariate function. +## +## @var{fun} should be a function handle or name. @var{a}, @var{b} specify a +## starting interval. @var{options} is a structure specifying additional +## options. Currently, @code{fminbnd} recognizes these options: +## "FunValCheck", "OutputFcn", "TolX", "MaxIter", "MaxFunEvals". For a +## description of these options, see @ref{doc-optimset,,optimset}. ## ## On exit, the function returns @var{x}, the approximate minimum point ## and @var{fval}, the function value thereof. @@ -43,7 +42,13 @@ ## @item -1 ## The algorithm has been terminated from user output function. ## @end itemize -## @seealso{optimset, fzero, fminunc} +## +## Notes: The search for a minimum is restricted to be in the interval +## bound by @var{a} and @var{b}. If you only have an initial point +## to begin searching from you will need to use an unconstrained +## minimization algorithm such as @code{fminunc} or @code{fminsearch}. +## @code{fminbnd} internally uses a Golden Section search strategy. +## @seealso{fzero, fminunc, fminsearch, optimset} ## @end deftypefn ## This is patterned after opt/fmin.f from Netlib, which in turn is taken from @@ -88,7 +93,7 @@ nfev = 0; sqrteps = eps (class (xmin + xmax)); - c = 0.5*(3-sqrt(5)); + c = 0.5*(3 - sqrt (5)); a = xmin; b = xmax; v = a + c*(b-a); w = x = v; @@ -98,9 +103,9 @@ while (niter < maxiter && nfev < maxfev) xm = 0.5*(a+b); - ## FIXME: the golden section search can actually get closer than sqrt(eps)... - ## sometimes. Sometimes not, it depends on the function. This is the strategy - ## from the Netlib code. Something yet smarter would be good. + ## FIXME: the golden section search can actually get closer than sqrt(eps) + ## sometimes. Sometimes not, it depends on the function. This is the + ## strategy from the Netlib code. Something yet smarter would be good. tol = 2 * sqrteps * abs (x) + tolx / 3; if (abs (x - xm) <= (2*tol - 0.5*(b-a))) info = 1;
new file mode 100644 --- /dev/null +++ b/scripts/optimization/fminsearch.m @@ -0,0 +1,352 @@ +## Copyright (C) 2003,2012 Andy Adler +## Copyright (C) 2002 N.J.Higham +## +## This file is part of Octave. +## +## 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. +## +## Octave 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{x} =} fminsearch (@var{fun}, @var{x0}) +## @deftypefnx {Function File} {@var{x} =} fminsearch (@var{fun}, @var{x0}, @var{options}) +## @deftypefnx {Function File} {[@var{x}, @var{fval}] =} fminsearch (@dots{}) +## +## Find a value of @var{x} which minimizes the function @var{fun}. +## The search begins at the point @var{x0} and iterates using the +## Nelder & Mead Simplex algorithm (a derivative-free method). This algorithm +## is better-suited to functions which have discontinuities or for which +## a gradient-based search such as @code{fminunc} fails. +## +## Options for the search are provided in the parameter @var{options} using +## the function @code{optimset}. Currently, @code{fminsearch} accepts the +## options: "TolX", "MaxFunEvals", "MaxIter", "Display". For a description of +## these options, see @code{optimset}. +## +## On exit, the function returns @var{x}, the minimum point, +## and @var{fval}, the function value thereof. +## +## Example usages: +## +## @example +## @group +## fminsearch (@@(x) (x(1)-5).^2+(x(2)-8).^4, [0;0]) +## +## fminsearch (inline ("(x(1)-5).^2+(x(2)-8).^4", "x"), [0;0]) +## @end group +## @end example +## @seealso{fminbnd, fminunc, optimset} +## @end deftypefn + +## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup. +## PKG_ADD: [~] = __all_opts__ ("fminsearch"); + +## FIXME: Add support for "exitflag" output variable +## FIXME: Add support for "output" output variable +## FIXME: For Display option, add 'final' and 'notify' options. Not too hard. +## FIXME: Add support for OutputFcn. See fminunc for a template +## FIXME: Add support for exiting based on TolFun. See fminunc for an idea. + +function [x, fval] = fminsearch (fun, x0, options = struct ()) + + ## Get default options if requested. + if (nargin == 1 && ischar (fun) && strcmp (fun, "defaults")) + x = optimset ("Display", "notify", "FunValCheck", "off", + "MaxFunEvals", 400, "MaxIter", 400, + "OutputFcn", [], + "TolFun", 1e-7, "TolX", 1e-4); + return; + endif + + if (nargin < 2 || nargin > 3) + print_usage (); + endif + + x = nmsmax (fun, x0, options); + + if (isargout (2)) + fval = feval (fun, x); + endif + +endfunction + +##NMSMAX Nelder-Mead simplex method for direct search optimization. +## [x, fmax, nf] = NMSMAX(FUN, x0, STOPIT, SAVIT) attempts to +## maximize the function FUN, using the starting vector x0. +## The Nelder-Mead direct search method is used. +## Output arguments: +## x = vector yielding largest function value found, +## fmax = function value at x, +## nf = number of function evaluations. +## The iteration is terminated when either +## - the relative size of the simplex is <= STOPIT(1) +## (default 1e-3), +## - STOPIT(2) function evaluations have been performed +## (default inf, i.e., no limit), or +## - a function value equals or exceeds STOPIT(3) +## (default inf, i.e., no test on function values). +## The form of the initial simplex is determined by STOPIT(4): +## STOPIT(4) = 0: regular simplex (sides of equal length, the default) +## STOPIT(4) = 1: right-angled simplex. +## Progress of the iteration is not shown if STOPIT(5) = 0 (default 1). +## STOPIT(6) indicates the direction (ie. minimization or +## maximization.) Default is 1, maximization. +## set STOPIT(6)=-1 for minimization +## If a non-empty fourth parameter string SAVIT is present, then +## `SAVE SAVIT x fmax nf' is executed after each inner iteration. +## NB: x0 can be a matrix. In the output argument, in SAVIT saves, +## and in function calls, x has the same shape as x0. +## NMSMAX(fun, x0, STOPIT, SAVIT, P1, P2,...) allows additional +## arguments to be passed to fun, via feval(fun,x,P1,P2,...). +## References: +## N. J. Higham, Optimization by direct search in matrix computations, +## SIAM J. Matrix Anal. Appl, 14(2): 317-333, 1993. +## C. T. Kelley, Iterative Methods for Optimization, Society for Industrial +## and Applied Mathematics, Philadelphia, PA, 1999. + +## From Matrix Toolbox +## Copyright (C) 2002 N.J.Higham +## www.maths.man.ac.uk/~higham/mctoolbox +## +## Modifications for Octave by A.Adler 2003 + +function [stopit, savit, dirn, trace, tol, maxiter] = parse_options (options, x ); + + ## Tolerance for cgce test based on relative size of simplex. + stopit(1) = tol = optimget (options, "TolX", 1e-4); + + ## Max no. of f-evaluations. + stopit(2) = optimget (options, "MaxFunEvals", length (x) * 200); + + ## Max no. of iterations + maxiter = optimget (options, "MaxIter", length (x) * 200); + + ## Default target for f-values. + stopit(3) = Inf; # FIXME: expose this parameter to the outside + + ## Default initial simplex. + stopit(4) = 0; # FIXME: expose this parameter to the outside + + ## Default: show progress. + display = optimget (options, "Display", "notify"); + if (strcmp (display, "iter")) + stopit(5) = 1; + else + stopit(5) = 0; + endif + trace = stopit(5); + + ## Use function to minimize, not maximize + stopit(6) = dirn = -1; + + ## File name for snapshots. + savit = []; # FIXME: expose this parameter to the outside + +endfunction + +function [x, fmax, nf] = nmsmax (fun, x, options, savit, varargin) + + [stopit, savit, dirn, trace, tol, maxiter] = parse_options (options, x); + + if (strcmpi (optimget (options, "FunValCheck", "off"), "on")) + ## Replace fcn with a guarded version. + fun = @(x) guarded_eval (fun, x); + endif + + x0 = x(:); # Work with column vector internally. + n = length (x0); + + V = [zeros(n,1) eye(n)]; + f = zeros (n+1,1); + V(:,1) = x0; + f(1) = dirn * feval (fun,x,varargin{:}); + fmax_old = f(1); + + if (trace) + fprintf ("f(x0) = %9.4e\n", f(1)); + endif + + k = 0; m = 0; + + ## Set up initial simplex. + scale = max (norm (x0,Inf), 1); + if (stopit(4) == 0) + ## Regular simplex - all edges have same length. + ## Generated from construction given in reference [18, pp. 80-81] of [1]. + alpha = scale / (n*sqrt (2)) * [sqrt(n+1)-1+n, sqrt(n+1)-1]; + V(:,2:n+1) = (x0 + alpha(2)*ones (n,1)) * ones (1,n); + for j = 2:n+1 + V(j-1,j) = x0(j-1) + alpha(1); + x(:) = V(:,j); + f(j) = dirn * feval (fun,x,varargin{:}); + endfor + else + ## Right-angled simplex based on co-ordinate axes. + alpha = scale * ones(n+1,1); + for j=2:n+1 + V(:,j) = x0 + alpha(j)*V(:,j); + x(:) = V(:,j); + f(j) = dirn * feval (fun,x,varargin{:}); + endfor + endif + nf = n+1; + how = "initial "; + + [~,j] = sort (f); + j = j(n+1:-1:1); + f = f(j); + V = V(:,j); + + alpha = 1; beta = 1/2; gamma = 2; + + while (1) # Outer (and only) loop. + k++; + + if (k > maxiter) + msg = "Exceeded maximum iterations...quitting\n"; + break; + endif + + fmax = f(1); + if (fmax > fmax_old) + if (! isempty (savit)) + x(:) = V(:,1); + eval (["save " savit " x fmax nf"]); + endif + endif + if (trace) + fprintf ("Iter. %2.0f,", k); + fprintf ([" how = " how " "]); + fprintf ("nf = %3.0f, f = %9.4e (%2.1f%%)\n", nf, fmax, ... + 100*(fmax-fmax_old)/(abs(fmax_old)+eps)); + endif + fmax_old = fmax; + + ## Three stopping tests from MDSMAX.M + + ## Stopping Test 1 - f reached target value? + if (fmax >= stopit(3)) + msg = "Exceeded target...quitting\n"; + break; + endif + + ## Stopping Test 2 - too many f-evals? + if (nf >= stopit(2)) + msg = "Max no. of function evaluations exceeded...quitting\n"; + break; + endif + + ## Stopping Test 3 - converged? This is test (4.3) in [1]. + v1 = V(:,1); + size_simplex = norm (V(:,2:n+1)-v1(:,ones (1,n)),1) / max (1, norm (v1,1)); + if (size_simplex <= tol) + msg = sprintf ("Simplex size %9.4e <= %9.4e...quitting\n", ... + size_simplex, tol); + break; + endif + + ## One step of the Nelder-Mead simplex algorithm + ## NJH: Altered function calls and changed CNT to NF. + ## Changed each `fr < f(1)' type test to `>' for maximization + ## and re-ordered function values after sort. + + vbar = (sum (V(:,1:n)')/n)'; # Mean value + vr = (1 + alpha)*vbar - alpha*V(:,n+1); + x(:) = vr; + fr = dirn * feval (fun,x,varargin{:}); + nf = nf + 1; + vk = vr; fk = fr; how = "reflect, "; + if (fr > f(n)) + if (fr > f(1)) + ve = gamma*vr + (1-gamma)*vbar; + x(:) = ve; + fe = dirn * feval (fun,x,varargin{:}); + nf = nf + 1; + if (fe > f(1)) + vk = ve; + fk = fe; + how = "expand, "; + endif + endif + else + vt = V(:,n+1); + ft = f(n+1); + if (fr > ft) + vt = vr; + ft = fr; + endif + vc = beta*vt + (1-beta)*vbar; + x(:) = vc; + fc = dirn * feval (fun,x,varargin{:}); + nf = nf + 1; + if (fc > f(n)) + vk = vc; fk = fc; + how = "contract,"; + else + for j = 2:n + V(:,j) = (V(:,1) + V(:,j))/2; + x(:) = V(:,j); + f(j) = dirn * feval (fun,x,varargin{:}); + endfor + nf = nf + n-1; + vk = (V(:,1) + V(:,n+1))/2; + x(:) = vk; + fk = dirn * feval (fun,x,varargin{:}); + nf = nf + 1; + how = "shrink, "; + endif + endif + V(:,n+1) = vk; + f(n+1) = fk; + [~,j] = sort(f); + j = j(n+1:-1:1); + f = f(j); + V = V(:,j); + + endwhile # End of outer (and only) loop. + + ## Finished. + if (trace) + fprintf (msg); + endif + x(:) = V(:,1); + +endfunction + +## A helper function that evaluates a function and checks for bad results. +function y = guarded_eval (fun, x) + + y = fun (x); + + if (! (isreal (f))) + error ("fminsearch:notreal", "fminsearch: non-real value encountered"); + elseif (any (isnan (f(:)))) + error ("fminsearch:isnan", "fminsearch: NaN value encountered"); + elseif (any (isinf (f(:)))) + error ("fminsearch:isinf", "fminsearch: Inf value encountered"); + endif + +endfunction + + +%!demo +%! fcn = @(x) (x(1)-5).^2 + (x(2)-8).^4 +%! x0 = [0;0]; +%! [xmin, fval] = fminsearch (fcn, x0) + +%!assert (fminsearch (@sin, 3, optimset ("MaxIter", 3)), 4.8750, 1e-4) +%!assert (fminsearch (@sin, 3, optimset ("MaxIter", 30)), 4.7124, 1e-4) +%!shared c +%! c = 1.5; +%!assert (fminsearch (@(x) x(1).^2+c*x(2).^2,[1;1]), [0;0], 1e-4) +
--- a/scripts/optimization/fminunc.m +++ b/scripts/optimization/fminunc.m @@ -24,6 +24,7 @@ ## @deftypefnx {Function File} {[@var{x}, @var{fvec}, @var{info}, @var{output}, @var{grad}, @var{hess}] =} fminunc (@var{fcn}, @dots{}) ## Solve an unconstrained optimization problem defined by the function ## @var{fcn}. +## ## @var{fcn} should accepts a vector (array) defining the unknown variables, ## and return the objective function value, optionally with gradient. ## In other words, this function attempts to determine a vector @var{x} such @@ -72,9 +73,12 @@ ## (@var{output}), the output gradient (@var{grad}) and approximate Hessian ## (@var{hess}). ## -## Note: If you only have a single nonlinear equation of one variable, using -## @code{fminbnd} is usually a much better idea. -## @seealso{fminbnd, optimset} +## Notes: If you only have a single nonlinear equation of one variable then +## using @code{fminbnd} is usually a much better idea. The algorithm used is a +## gradient search which depends on the objective function being differentiable. +## If the function has discontinuities it may be better to use a derivative-free +## algorithm such as @code{fminsearch}. +## @seealso{fminbnd, fminsearch, optimset} ## @end deftypefn ## PKG_ADD: ## Discard result to avoid polluting workspace with ans at startup. @@ -260,7 +264,7 @@ endif ## Update delta. - if (ratio < min(max(0.1, 0.8*lastratio), 0.9)) + if (ratio < min (max (0.1, 0.8*lastratio), 0.9)) delta *= decfac; decfac ^= 1.4142; if (delta <= 1e1*macheps*xn)
--- a/scripts/optimization/fsolve.m +++ b/scripts/optimization/fsolve.m @@ -327,7 +327,7 @@ endif ## Update delta. - if (ratio < min(max(0.1, 0.8*lastratio), 0.9)) + if (ratio < min (max (0.1, 0.8*lastratio), 0.9)) nsuc = 0; nfail ++; delta *= decfac; @@ -446,7 +446,7 @@ if (! complexeqn && ! (isreal (fx) && isreal (jx))) error ("fsolve:notreal", "fsolve: non-real value encountered"); - elseif (complexeqn && ! (isnumeric (fx) && isnumeric(jx))) + elseif (complexeqn && ! (isnumeric (fx) && isnumeric (jx))) error ("fsolve:notnum", "fsolve: non-numeric value encountered"); elseif (any (isnan (fx(:)))) error ("fsolve:isnan", "fsolve: NaN value encountered");
--- a/scripts/optimization/glpk.m +++ b/scripts/optimization/glpk.m @@ -500,7 +500,7 @@ error ("glpk: A cannot be an empty matrix"); return; endif - [nc, nxa] = size(A); + [nc, nxa] = size (A); if (! isreal (A) || nxa != nx) error ("glpk: A must be a real valued %d by %d matrix", nc, nx); return;
--- a/scripts/optimization/lsqnonneg.m +++ b/scripts/optimization/lsqnonneg.m @@ -39,7 +39,7 @@ ## @itemize @bullet ## @item resnorm ## -## The squared 2-norm of the residual: norm(@var{c}*@var{x}-@var{d})^2 +## The squared 2-norm of the residual: norm (@var{c}*@var{x}-@var{d})^2 ## ## @item residual ##
--- a/scripts/optimization/module.mk +++ b/scripts/optimization/module.mk @@ -6,6 +6,7 @@ optimization_FCN_FILES = \ optimization/__all_opts__.m \ optimization/fminbnd.m \ + optimization/fminsearch.m \ optimization/fminunc.m \ optimization/fsolve.m \ optimization/fzero.m \
--- a/scripts/optimization/optimset.m +++ b/scripts/optimization/optimset.m @@ -26,16 +26,34 @@ ## ## Valid parameters are: ## -## @itemize @bullet +## @table @asis ## @item AutoScaling ## ## @item ComplexEqn ## +## @item Display +## Request verbose display of results from optimizations. Values are: +## +## @table @asis +## @item "off" [default] +## No display. +## +## @item "iter" +## Display intermediate results for every loop iteration. +## +## @item "final" +## Display the result of the final loop iteration. +## +## @item "notify" +## Display the result of the final loop iteration if the function has +## failed to converge. +## @end table +## ## @item FinDiffType ## ## @item FunValCheck ## When enabled, display an error if the objective function returns an invalid -## value (a complex value, NaN, or Inf). Must be set to "on" or "off" +## value (a complex number, NaN, or Inf). Must be set to "on" or "off" ## [default]. Note: the functions @code{fzero} and @code{fminbnd} correctly ## handle Inf values and only complex values or NaN will cause an error in this ## case. @@ -77,7 +95,7 @@ ## @item TypicalX ## ## @item Updating -## @end itemize +## @end table ## @end deftypefn function retval = optimset (varargin)
--- a/scripts/optimization/qp.m +++ b/scripts/optimization/qp.m @@ -228,15 +228,15 @@ if (! isempty (lb) && ! isempty (ub)) rtol = sqrt (eps); for i = 1:n - if (abs(lb (i) - ub(i)) < rtol*(1 + max (abs (lb(i) + ub(i))))) + if (abs (lb (i) - ub(i)) < rtol*(1 + max (abs (lb(i) + ub(i))))) ## These are actually an equality constraint - tmprow = zeros(1,n); + tmprow = zeros (1,n); tmprow(i) = 1; A = [A;tmprow]; b = [b; 0.5*(lb(i) + ub(i))]; n_eq = n_eq + 1; else - tmprow = zeros(1,n); + tmprow = zeros (1,n); tmprow(i) = 1; Ain = [Ain; tmprow; -tmprow]; bin = [bin; lb(i); -ub(i)];
--- a/scripts/optimization/sqp.m +++ b/scripts/optimization/sqp.m @@ -122,7 +122,7 @@ ## iterations. The default value is 100. ## ## The eighth argument @var{tol} specifies the tolerance for the -## stopping criteria. The default value is @code{sqrt(eps)}. +## stopping criteria. The default value is @code{sqrt (eps)}. ## ## The value returned in @var{info} may be one of the following: ##
--- a/scripts/pkg/private/configure_make.m +++ b/scripts/pkg/private/configure_make.m @@ -58,7 +58,7 @@ rmdir (desc.dir, "s"); error ("the configure script returned the following error: %s", output); elseif (verbose) - printf("%s", output); + printf ("%s", output); endif endif @@ -70,7 +70,7 @@ rmdir (desc.dir, "s"); error ("'make' returned the following error: %s", output); elseif (verbose) - printf("%s", output); + printf ("%s", output); endif endif
--- a/scripts/pkg/private/copy_files.m +++ b/scripts/pkg/private/copy_files.m @@ -111,7 +111,7 @@ ## Is there an INDEX file to copy or should we generate one? index_file = fullfile (packdir, "INDEX"); - if (exist(index_file, "file")) + if (exist (index_file, "file")) packinfo_copy_file ("INDEX", "required", packdir, packinfo, desc, octfiledir); else try
--- a/scripts/pkg/private/describe.m +++ b/scripts/pkg/private/describe.m @@ -45,7 +45,7 @@ if (describe_all) name_pos = i; else - name_pos = find(strcmp (curr_name, pkgnames)); + name_pos = find (strcmp (curr_name, pkgnames)); endif if (! isempty (name_pos))
--- a/scripts/pkg/private/get_description.m +++ b/scripts/pkg/private/get_description.m @@ -35,7 +35,7 @@ while (line != -1) if (line(1) == "#") ## Comments, do nothing. - elseif (isspace(line(1))) + elseif (isspace (line(1))) ## Continuation lines if (exist ("keyword", "var") && isfield (desc, keyword)) desc.(keyword) = cstrcat (desc.(keyword), " ", deblank (line));
--- a/scripts/pkg/private/get_forge_pkg.m +++ b/scripts/pkg/private/get_forge_pkg.m @@ -46,7 +46,7 @@ ## Good. Let's grep for the version. pat = "<tdclass=""package_table"">PackageVersion:</td><td>([\\d.]*)</td>"; t = regexp (html, pat, "tokens"); - if (isempty (t) || isempty(t{1})) + if (isempty (t) || isempty (t{1})) error ("get_forge_pkg: could not read version number from package's page"); else ver = t{1}{1};
--- a/scripts/pkg/private/install.m +++ b/scripts/pkg/private/install.m @@ -51,7 +51,7 @@ try ## Warn about non existent files. for i = 1:length (files) - if (isempty (glob(files{i}))) + if (isempty (glob (files{i}))) warning ("file %s does not exist", files{i}); endif endfor @@ -115,7 +115,7 @@ ## Verify that package name corresponds with filename. [dummy, nm] = fileparts (tgz); if ((length (nm) >= length (desc.name)) - && ! strcmp (desc.name, nm(1:length(desc.name)))) + && ! strcmp (desc.name, nm(1:length (desc.name)))) error ("package name '%s' doesn't correspond to its filename '%s'", desc.name, nm); endif @@ -153,15 +153,15 @@ error_text = ""; for i = 1:length (descriptions) desc = descriptions{i}; - idx2 = setdiff (1:length(descriptions), i); + idx2 = setdiff (1:length (descriptions), i); if (global_install) ## Global installation is not allowed to have dependencies on locally ## installed packages. - idx1 = setdiff (1:length(global_packages), packages_to_uninstall); + idx1 = setdiff (1:length (global_packages), packages_to_uninstall); pseudo_installed_packages = {global_packages{idx1}, ... descriptions{idx2}}; else - idx1 = setdiff (1:length(local_packages), packages_to_uninstall); + idx1 = setdiff (1:length (local_packages), packages_to_uninstall); pseudo_installed_packages = {local_packages{idx1}, ... global_packages{:}, ... descriptions{idx2}}; @@ -281,12 +281,12 @@ ## Add the packages to the package list. try if (global_install) - idx = setdiff (1:length(global_packages), packages_to_uninstall); + idx = setdiff (1:length (global_packages), packages_to_uninstall); global_packages = save_order ({global_packages{idx}, descriptions{:}}); save (global_list, "global_packages"); installed_pkgs_lst = {local_packages{:}, global_packages{:}}; else - idx = setdiff (1:length(local_packages), packages_to_uninstall); + idx = setdiff (1:length (local_packages), packages_to_uninstall); local_packages = save_order ({local_packages{idx}, descriptions{:}}); save (local_list, "local_packages"); installed_pkgs_lst = {local_packages{:}, global_packages{:}};
--- a/scripts/pkg/private/installed_packages.m +++ b/scripts/pkg/private/installed_packages.m @@ -52,7 +52,7 @@ endif endfor endfor - if (! isempty(dup)) + if (! isempty (dup)) installed_pkgs_lst(dup) = []; endif @@ -121,9 +121,9 @@ h2 = postpad (h2, max_version_length, " ");; ## Print a header. - header = sprintf("%s | %s | %s\n", h1, h2, h3); + header = sprintf ("%s | %s | %s\n", h1, h2, h3); printf (header); - tmp = sprintf (repmat ("-", 1, length(header)-1)); + tmp = sprintf (repmat ("-", 1, length (header) - 1)); tmp(length(h1)+2) = "+"; tmp(length(h1)+length(h2)+5) = "+"; printf ("%s\n", tmp);
--- a/scripts/pkg/private/is_architecture_dependent.m +++ b/scripts/pkg/private/is_architecture_dependent.m @@ -36,7 +36,7 @@ endif pos = strfind (nm, ext); if (pos) - if (! isglob && (length(nm) - pos(end) != length(ext) - 1)) + if (! isglob && (length (nm) - pos(end) != length (ext) - 1)) continue; endif dep = true;
--- a/scripts/pkg/private/load_package_dirs.m +++ b/scripts/pkg/private/load_package_dirs.m @@ -36,7 +36,7 @@ if (handle_deps) deps = installed_pkgs_lst{i}.depends; if ((length (deps) > 1) - || (length (deps) == 1 && ! strcmp(deps{1}.package, "octave"))) + || (length (deps) == 1 && ! strcmp (deps{1}.package, "octave"))) tmplidx = []; for k = 1 : length (deps) for j = 1 : length (installed_pkgs_lst)
--- a/scripts/pkg/private/print_package_description.m +++ b/scripts/pkg/private/print_package_description.m @@ -31,10 +31,10 @@ printf ("Status:\n\t%s\n", status); if (verbose) printf ("---\nProvides:\n"); - for i = 1:length(pkg_idx_struct) + for i = 1:length (pkg_idx_struct) if (! isempty (pkg_idx_struct{i}.functions)) printf ("%s\n", pkg_idx_struct{i}.category); - for j = 1:length(pkg_idx_struct{i}.functions) + for j = 1:length (pkg_idx_struct{i}.functions) printf ("\t%s\n", pkg_idx_struct{i}.functions{j}); endfor endif
--- a/scripts/pkg/private/rebuild.m +++ b/scripts/pkg/private/rebuild.m @@ -35,7 +35,7 @@ wd = pwd (); unwind_protect cd (prefix); - dirlist = glob (cellfun(@(x) cstrcat(x, '-*'), files, 'uniformoutput', 0)); + dirlist = glob (cellfun(@(x) cstrcat (x, '-*'), files, 'uniformoutput', 0)); unwind_protect_cleanup cd (wd); end_unwind_protect
--- a/scripts/pkg/private/repackage.m +++ b/scripts/pkg/private/repackage.m @@ -26,7 +26,7 @@ packages = installed_packages (buildlist, buildlist); wd = pwd (); - for i = 1 : length(packages) + for i = 1 : length (packages) pack = packages{i}; unwind_protect cd (builddir);
--- a/scripts/pkg/private/save_order.m +++ b/scripts/pkg/private/save_order.m @@ -24,10 +24,10 @@ function newdesc = save_order (desc) newdesc = {}; - for i = 1 : length(desc) + for i = 1 : length (desc) deps = desc{i}.depends; if (isempty (deps) - || (length (deps) == 1 && strcmp(deps{1}.package, "octave"))) + || (length (deps) == 1 && strcmp (deps{1}.package, "octave"))) newdesc {end + 1} = desc{i}; else tmpdesc = {};
--- a/scripts/pkg/private/shell.m +++ b/scripts/pkg/private/shell.m @@ -27,8 +27,8 @@ cmd = strrep (cmd, "\\", "/"); if (ispc () && ! isunix ()) - if (isempty(have_sh)) - if (system("sh.exe -c \"exit\"")) + if (isempty (have_sh)) + if (system ("sh.exe -c \"exit\"")) have_sh = false; else have_sh = true;
--- a/scripts/plot/allchild.m +++ b/scripts/plot/allchild.m @@ -49,7 +49,7 @@ %! hf = figure ("visible", "off"); %! unwind_protect %! l = line; -%! assert(get (allchild (hf),"type"),{"axes"; "uimenu"; "uimenu"; "uimenu"}); +%! assert (get (allchild (hf),"type"),{"axes"; "uimenu"; "uimenu"; "uimenu"}); %! unwind_protect_cleanup %! close (hf); %! graphics_toolkit (toolkit);
--- a/scripts/plot/ancestor.m +++ b/scripts/plot/ancestor.m @@ -49,7 +49,7 @@ endif endif h = num2cell (h); - for nh = 1:numel(h) + for nh = 1:numel (h) while (true) if (isempty (h{nh}) || ! ishandle (h{nh})) break;
--- a/scripts/plot/area.m +++ b/scripts/plot/area.m @@ -80,9 +80,9 @@ y = y(:); endif if (isempty (x)) - x = repmat ([1:size(y, 1)]', 1, size (y, 2)); + x = repmat ([1:rows(y)]', 1, columns (y)); elseif (isvector (x)) - x = repmat (x(:), 1, size (y, 2)); + x = repmat (x(:), 1, columns (y)); endif oldax = gca (); @@ -107,7 +107,7 @@ y0 = bv * ones (1, rows (y)); y0 = zeros (1, rows (y)); retval = []; - for i = 1: size (y, 2); + for i = 1: columns (y); hg = hggroup (); retval = [retval; hg]; args = __add_datasource__ ("area", hg, {"x", "y"}, varargin{:});
--- a/scripts/plot/axes.m +++ b/scripts/plot/axes.m @@ -43,7 +43,7 @@ else ## arg is axes handle. tmp = varargin{1}; - if (length(tmp) == 1 && ishandle (tmp) + if (length (tmp) == 1 && ishandle (tmp) && strcmp (get (tmp, "type"), "axes")) if (__is_handle_visible__ (tmp)) parent = ancestor (tmp, "figure");
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -328,7 +328,7 @@ n = cellfun (@isempty, data); data(n) = cellfun (@(x) x(x<0), tmp(n), "uniformoutput", false); endif - data = cellfun (@(x) x(isfinite(x)), data, "uniformoutput", false); + data = cellfun (@(x) x(isfinite (x)), data, "uniformoutput", false); data = data(! cellfun ("isempty", data)); if (! isempty (data)) lims_min = min (cellfun (@(x) min (x(:)), data(:)));
--- a/scripts/plot/clabel.m +++ b/scripts/plot/clabel.m @@ -67,7 +67,7 @@ hparent = gca (); else arg = varargin{1}; - if (isscalar (arg) && ishandle(arg) + if (isscalar (arg) && ishandle (arg) && strcmp (get (arg, "type"), "hggroup")) obj = get (arg); if (! isfield (obj, "contourmatrix")) @@ -81,7 +81,7 @@ endif endif - if (length(varargin) > 0 && isnumeric (varargin{1})) + if (length (varargin) > 0 && isnumeric (varargin{1})) v = varargin{1}(:); varargin(1) = []; else
--- a/scripts/plot/close.m +++ b/scripts/plot/close.m @@ -46,7 +46,7 @@ close_all_figures (false); elseif (isfigure (arg1)) figs = arg1; - elseif (isempty(arg1)) + elseif (isempty (arg1)) figs = []; else error ("close: expecting argument to be \"all\" or a figure handle");
--- a/scripts/plot/colorbar.m +++ b/scripts/plot/colorbar.m @@ -63,7 +63,7 @@ i = 1; while (i <= nargin) arg = varargin {i++}; - if (ischar(arg)) + if (ischar (arg)) if (strcmpi (arg, "peer")) if (i > nargin) error ("colorbar: missing axes handle after \"peer\"");
--- a/scripts/plot/comet.m +++ b/scripts/plot/comet.m @@ -44,7 +44,7 @@ print_usage (); elseif (nargin == 1) y = varargin{1}; - x = 1:numel(y); + x = 1:numel (y); p = 0.1; elseif (nargin == 2) x = varargin{1};
--- a/scripts/plot/comet3.m +++ b/scripts/plot/comet3.m @@ -43,7 +43,7 @@ print_usage (); elseif (nargin == 1) z = varargin{1}; - x = y = 1:numel(z); + x = y = 1:numel (z); p = 0.1; elseif (nargin == 3) x = varargin{1};
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -83,7 +83,7 @@ %! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); %! [X, Y] = pol2cart (theta, r); %! Z = sin (2*theta) .* (1-r); -%! contour (X, Y, abs(Z), 10); +%! contour (X, Y, abs (Z), 10); %!demo %! clf;
--- a/scripts/plot/contourc.m +++ b/scripts/plot/contourc.m @@ -101,8 +101,8 @@ c = __contourc__ (x(:)', y(:)', z, vv); else ## Indexes x,y for the purpose of __contourc__. - ii = 1:size (z,2); - jj = 1:size (z,1); + ii = 1:columns (z); + jj = 1:rows (z); ## Now call __contourc__ for the real work... c = __contourc__ (ii, jj, z, vv); @@ -111,7 +111,7 @@ ## to the original grid (x,y) i = 1; - while (i < size (c,2)) + while (i < columns (c)) clen = c(2, i); ind = i + [1 : clen]; @@ -123,8 +123,8 @@ ## return NA for those values. ## The permitted range is enforced here: - ci = max (ci, 1); ci = min (ci, size (z, 2)); - cj = max (cj, 1); cj = min (cj, size (z, 1)); + ci = max (ci, 1); ci = min (ci, columns (z)); + cj = max (cj, 1); cj = min (cj, rows (z)); c(1, ind) = interp2 (ii, jj, x, ci, cj); c(2, ind) = interp2 (ii, jj, y, ci, cj);
new file mode 100644 --- /dev/null +++ b/scripts/plot/copyobj.m @@ -0,0 +1,127 @@ +## Copyright (C) 2012 pdiribarne +## +## 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{hnew} =} copyobj (@var{horig}) +## @deftypefnx {Function File} {@var{hnew} =} copyobj (@var{horig}, @var{hparent}) +## Constructs a copy of the object associated with handle @var{horig} +## and returns a handle, @var{hnew}, to the new object. +## If a parent handle @var{hparent} (root, figure, axes or hggroup) is specified, +## the copied object will be created as a child to @var{hparent}. +## @seealso{findobj, get, set, struct2hdl, hdl2struct} +## @end deftypefn + +## Author: pdiribarne <pdiribarne@new-host.home> +## Created: 2012-04-01 + +function hout = copyobj (hin, hpar = 0) + + partypes = {"root", "figure", "axes", "hggroup"}; + othertypes = {"line", "patch", "surface", "image", "text"}; + alltypes = [partypes othertypes]; + + if (! ishandle (hin) || nargin > 2) + print_usage (); + elseif (! ishandle (hpar)) + hpar = figure (floor (hpar)); + elseif (! any (strcmpi (get (hpar).type, partypes))) + print_usage (); + endif + + ## compatibility of input handles + kididx = find (strcmp (alltypes, get (hin).type)); + paridx = find (strcmp (alltypes, get (hpar).type)); + + if (kididx <= paridx) + error ("copyobj: %s object can't be children to %s.", + alltypes{kididx}, alltypes{paridx}) + elseif nargin == 1 + str = hdl2struct (hin); + hout = struct2hdl (str); + else + str = hdl2struct (hin); + hout = struct2hdl (str, hpar); + endif +endfunction + +%!test +%! h1 = figure (); +%! set (h1, "visible", "off") +%! x = 0:0.1:2*pi; +%! y1 = sin (x); +%! y2 = exp (x - 1); +%! ax = plotyy (x,y1, x-1,y2, @plot, @semilogy); +%! xlabel ("X"); +%! ylabel (ax(1), "Axis 1"); +%! ylabel (ax(2), "Axis 2"); +%! axes (ax(1)); +%! text (0.5, 0.5, "Left Axis", ... +%! "color", [0 0 1], "horizontalalignment", "center"); +%! axes (ax(2)); +%! text (4.5, 80, "Right Axis", ... +%! "color", [0 0.5 0], "horizontalalignment", "center"); +%! s1 = hdl2struct (h1); +%! h2 = struct2hdl (s1); +%! s2 = hdl2struct (h2); +%! png1 = strcat (tmpnam (), ".png"); +%! png2 = strcat (tmpnam (), ".png"); +%! unwind_protect +%! print (h1, png1) +%! [img1, map1, alpha1] = imread (png1); +%! print (h2, png2) +%! [img2, map2, alpha2] = imread (png2); +%! unwind_protect_cleanup +%! unlink (png1); +%! unlink (png2); +%! end_unwind_protect +%! assert (img1, img2) +%! assert (map1, map2) +%! assert (alpha1, alpha2) + +%!demo +%! hdl = figure (1234); +%! clf () +%! hold on +%! x = 1:10; +%! y = x.^2; +%! dy = 2 * (.2 * x); +%! y2 = (x - 3).^2; +%! hg = errorbar (x, y, dy,'#~'); +%! set (hg, 'marker', '^', 'markerfacecolor', rand(1,3)) +%! plot (x, y2, 'ok-') +%! legend ('errorbar', 'line') +%! hout = copyobj (1234); + +%!demo +%! hdl = figure (1234); +%! clf () +%! subplot (2, 2, 1); +%! hold on +%! [C, H] = contourf (rand(10, 10)); +%! colorbar +%! subplot (2, 2, 2); +%! hold on +%! quiver (rand(10, 10), rand(10, 10)) +%! subplot (2, 2, 3); +%! colormap (jet (64)) +%! sombrero; +%! colorbar('peer', gca, 'NorthOutside') +%! subplot (2, 2, 4); +%! imagesc (rand (30, 30)); +%! text (15, 15, 'Rotated text', ... +%! 'HorizontAlalignment', 'Center', 'Rotation', 30); +%! hout = copyobj (1234); +
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -65,13 +65,13 @@ endif if (length (r) < 2) - error ("cylinder: length(R) must be larger than 2"); + error ("cylinder: length (R) must be larger than 2"); endif phi = linspace (0, 2*pi, n+1); - idx = 1:length(r); - [phi, idx] = meshgrid(phi, idx); - z = (idx - 1) / (length(r) - 1); + idx = 1:length (r); + [phi, idx] = meshgrid (phi, idx); + z = (idx - 1) / (length (r) - 1); r = r(idx); [x, y] = pol2cart (phi, r);
--- a/scripts/plot/ezmesh.m +++ b/scripts/plot/ezmesh.m @@ -58,9 +58,9 @@ ## ## @example ## @group -## fx = @@(s,t) cos (s) .* cos(t); -## fy = @@(s,t) sin (s) .* cos(t); -## fz = @@(s,t) sin(t); +## fx = @@(s,t) cos (s) .* cos (t); +## fy = @@(s,t) sin (s) .* cos (t); +## fz = @@(s,t) sin (t); ## ezmesh (fx, fy, fz, [-pi, pi, -pi/2, pi/2], 20); ## @end group ## @end example @@ -92,8 +92,8 @@ %!demo %! clf; %! colormap ('default'); -%! fx = @(s,t) cos (s) .* cos(t); -%! fy = @(s,t) sin (s) .* cos(t); +%! fx = @(s,t) cos (s) .* cos (t); +%! fy = @(s,t) sin (s) .* cos (t); %! fz = @(s,t) sin (t); %! ezmesh (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20);
--- a/scripts/plot/ezsurf.m +++ b/scripts/plot/ezsurf.m @@ -92,8 +92,8 @@ %!demo %! clf; %! colormap ('default'); -%! fx = @(s,t) cos (s) .* cos(t); -%! fy = @(s,t) sin (s) .* cos(t); +%! fx = @(s,t) cos (s) .* cos (t); +%! fy = @(s,t) sin (s) .* cos (t); %! fz = @(s,t) sin (t); %! ezsurf (fx, fy, fz, [-pi,pi,-pi/2,pi/2], 20);
--- a/scripts/plot/findobj.m +++ b/scripts/plot/findobj.m @@ -146,7 +146,7 @@ na = na + 1; pvalue{np} = args{na}; na = na + 1; - if (na <= numel(args)) + if (na <= numel (args)) if (ischar (args{na})) if (strcmpi (args{na}, "-and")) logicaloperator{np} = "and"; @@ -192,7 +192,7 @@ while (numel (handles) && ! (idepth >= depth)) children = []; for n = 1 : numel (handles) - children = union (children, get(handles(n), "children")); + children = union (children, get (handles(n), "children")); endfor handles = children; h = union (h, children); @@ -201,7 +201,7 @@ keepers = ones (size (h)); if (numpairs > 0) - for nh = 1 : numel(h) + for nh = 1 : numel (h) p = get (h (nh)); for np = 1 : numpairs fields = fieldnames (p);
--- a/scripts/plot/fplot.m +++ b/scripts/plot/fplot.m @@ -80,7 +80,7 @@ error ("fplot: first input argument must be a function handle, inline function or string"); endif - if (floor(n) != n) + if (floor (n) != n) tol = n; x0 = linspace (limits(1), limits(2), 5)'; y0 = feval (fn, x0);
new file mode 100644 --- /dev/null +++ b/scripts/plot/hdl2struct.m @@ -0,0 +1,166 @@ +## Copyright (C) 2012 pdiribarne +## +## 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{s} =} hdl2struct (@var{h}) +## Returns a structure, @var{s}, whose fields describe the properties +## of the object, and its children, associated with the handle, @var{h}. +## The fields of the structure, @var{s}, are "type", "handle", "properties", +## "children" and "special". +## @seealso{findobj, get, set, struct2hdl} +## @end deftypefn + +## Author: pdiribarne <pdiribarne@new-host.home> +## Created: 2012-03-04 + +function hgS = hdl2struct (h) + if (nargin != 1 || !ishandle (h)) + print_usage (); + endif + + hiddenh = get (0, "showhiddenhandles"); + if strcmp (hiddenh, "on") + set (0, "showhiddenhandles", "off"); + endif + + ## main object + main = get (h); + hgS.handle = h; + hgS.type = main.type; + hgS.properties = getprops (h); + hgS.children = []; + hgS.special = []; + + ## sweep all children but legends, colorbars, uimenu and hggroup children + ## in reverse order + kids = main.children; + lg = findobj (h, "-depth", 1, "tag", "legend"); + cb = findobj (h, "-depth", 1, "tag", "colorbar"); + ui = findobj (h, "-depth", 1, "type", "uimenu"); + nkids = length (kids); + ii = 0; + while nkids + if (! any (kids (nkids) == lg) && !any (kids (nkids) == cb) + && ! any (kids (nkids) == ui) && !strcmpi (main.type, "hggroup")) + ii++; + hgS.children(ii) = hdl2struct(kids(nkids)); + endif + nkids--; + endwhile + + ## add non "children" children objects (title, xlabel, ...) and + ## hggroup children and tag theim in "special" + special = []; + if (strcmpi (main.type, "hggroup")) + special = main.children; + endif + special = [special getspecial(h)]; + nsp = length (special); + while nsp + ii++; + hgS.children(ii) = hdl2struct (special(nsp)); + hgS.special(nsp) = ii; + nsp--; + endwhile + + ## look for legends and colorbars among "main"'s brothers and add them + ## to the children list + if (strcmpi (main.type, "axes")) + par = main.parent; + lg = findobj (par, "-depth", 1, "tag", "legend"); + if !isempty (lg) + idx = arrayfun (@(x) get(x).userdata.handle(end) == h, lg); + lg = lg(find(idx)); + endif + nlg = length (lg); + if nlg == 1 + ii++; + hgS.children(ii) = hdl2struct (lg); + elseif (nlg > 1) + error ("hdl2struct: more than one legend found") + endif + + cb = findobj (par, "-depth", 1, "tag", "colorbar"); + if (! isempty (cb)) + idx = arrayfun (@(x) get(x).axes == h, cb); + cb = cb(find(idx)); + endif + + ncb = length (cb); + if (ncb == 1) + ii++; + hgS.children(ii) = hdl2struct(cb); + elseif (nlg > 1) + error ("hdl2struct: more than one colorbar found") + endif + endif + + set (0, "showhiddenhandles", hiddenh); + +endfunction + +function hdlist = getspecial (h) + obj = get (h); + ## return handles to special children + fields = fieldnames (obj); + hdlist = []; + + regkids = get ( h, "children"); + set (0, "showhiddenhandles", "on") + allkids = get ( h, "children"); + set (0, "showhiddenhandles", "off") + speckids = arrayfun (@(x) ! any (x == regkids), allkids); + hdlist = allkids (find (speckids)); + hdlist = reshape (hdlist, 1, numel (hdlist)); + +endfunction + +function prpstr = getprops (h) + obj = get (h); + ## get usefull properties rejecting readonly, children, handles ... + fields = fieldnames (obj); + hdlist = []; + + forbid = {"beingdeleted", "busyaction", "buttondownfcn", ... + "children", "clipping", "createfcn", ... + "deletefcn", "handlevisibility", "hittest", ... + "interruptible", "parent", "selected" ,... + "selectionhighlight", "type", "__modified__", ... + "uicontextmenu", "__graphics_toolkit__", "currentaxes", ... + "currentcharacter", "currentobject","tightinset", ... + "currentpoint", "extent"}; + + nflds = length (fields); + ii = 0; + while nflds + prop = fields{nflds}; + val = obj.(fields{nflds}); + ii++; + if !any (strcmp (prop, forbid)) + prpstr.(prop) = val; + endif + nflds--; + endwhile + + ## hidden properties + hidden = {"autopos_tag", "looseinset"}; + for ii = 1:numel (hidden) + if (isprop (h, hidden{ii})) + prpstr.(hidden{ii}) = get (h, hidden{ii}); + endif + endfor +endfunction +
--- a/scripts/plot/hist.m +++ b/scripts/plot/hist.m @@ -93,7 +93,7 @@ if (nargin == 1 || ischar (varargin{iarg})) n = 10; x = [0.5:n]'/n; - x = x * (max_val - min_val) + ones(size(x)) * min_val; + x = x * (max_val - min_val) + ones (size (x)) * min_val; else ## nargin is either 2 or 3 x = varargin{iarg++}; @@ -160,7 +160,7 @@ nn = freq; xx = x; endif - elseif (size (freq, 2) != 1) + elseif (columns (freq) != 1) bar (x, freq, 0.8, varargin{iarg:end}); else bar (x, freq, 1.0, varargin{iarg:end});
--- a/scripts/plot/isocolors.m +++ b/scripts/plot/isocolors.m @@ -98,7 +98,7 @@ ## Author: Martin Helm <martin@mhelm.de> -function varargout = isocolors(varargin) +function varargout = isocolors (varargin) calc_rgb = false; switch (nargin) case 2 @@ -134,7 +134,7 @@ otherwise print_usage (); endswitch - if (ismatrix (vp) && size (vp,2) == 3) + if (ismatrix (vp) && columns (vp) == 3) pa = []; v = vp; elseif ( ishandle (vp) ) @@ -144,7 +144,7 @@ error ("isocolors: last argument is not a vertex list or patch handle"); endif if (calc_rgb) - new_col = zeros (size (v, 1), 3); + new_col = zeros (rows (v), 3); new_col(:,1) = __interp_cube__ (x, y, z, R, v, "values" ); new_col(:,2) = __interp_cube__ (x, y, z, G, v, "values" ); new_col(:,3) = __interp_cube__ (x, y, z, B, v, "values" );
--- a/scripts/plot/isonormals.m +++ b/scripts/plot/isonormals.m @@ -95,7 +95,7 @@ ## Author: Martin Helm <martin@mhelm.de> -function varargout = isonormals(varargin) +function varargout = isonormals (varargin) na = nargin; negate = false; if (ischar (varargin{nargin})) @@ -122,7 +122,7 @@ otherwise print_usage (); endswitch - if (ismatrix (vp) && size (vp,2) == 3) + if (ismatrix (vp) && columns (vp) == 3) pa = []; v = vp; elseif (ishandle (vp))
--- a/scripts/plot/isosurface.m +++ b/scripts/plot/isosurface.m @@ -118,7 +118,7 @@ ## Author: Martin Helm <martin@mhelm.de> -function varargout = isosurface(varargin) +function varargout = isosurface (varargin) if (nargin < 2 || nargin > 8 || nargout > 3) print_usage ();
--- a/scripts/plot/isprop.m +++ b/scripts/plot/isprop.m @@ -37,7 +37,7 @@ endif res = false (size (h)); - for n = 1:numel(res) + for n = 1:numel (res) res(n) = true; try v = get (h(n), prop);
--- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -145,7 +145,7 @@ kids = ca; kids (strcmp (get (ca, "tag"), "legend")) = []; if (isscalar (kids)) - kids = get(kids, "children")(:); + kids = get (kids, "children")(:); else kids = flipud ([get(kids, "children"){:}](:)); endif @@ -215,7 +215,7 @@ hlegend = []; fkids = get (fig, "children"); - for i = 1 : numel(fkids) + for i = 1 : numel (fkids) if (ishandle (fkids (i)) && strcmp (get (fkids (i), "type"), "axes") && (strcmp (get (fkids (i), "tag"), "legend"))) udata = get (fkids (i), "userdata"); @@ -498,8 +498,8 @@ ## FIXME hlegend should inherit properties from "ca" curaxes = get (fig, "currentaxes"); unwind_protect - ud = ancestor(hplots, "axes"); - if (!isscalar(ud)) + ud = ancestor (hplots, "axes"); + if (!isscalar (ud)) ud = unique ([ud{:}]); endif if (isempty (hlegend)) @@ -707,13 +707,13 @@ hobjects = [hobjects, l1]; endif - addlistener(hplots(k), "color", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "linestyle", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "marker", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "markeredgecolor", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "markerfacecolor", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "markersize", {@updateline, hlegend, linelength}); - addlistener(hplots(k), "displayname", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "color", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "linestyle", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "marker", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "markeredgecolor", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "markerfacecolor", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "markersize", {@updateline, hlegend, linelength}); + addlistener (hplots(k), "displayname", {@updateline, hlegend, linelength}); case "patch" facecolor = get (hplots(k), "facecolor"); edgecolor = get (hplots(k), "edgecolor"); @@ -959,7 +959,7 @@ ypos1 = get (ll,"ydata"); xpos1 = get (ll,"xdata"); ypos2 = ypos1(1); - xpos2 = sum(xpos1) / 2; + xpos2 = sum (xpos1) / 2; delete (ll); if (! isempty (lm)) delete (lm);
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -65,7 +65,7 @@ %!demo %! clf (); -%! x = logspace(0,1,11); +%! x = logspace (0,1,11); %! z = x'*x; %! mesh (x, x, z, z.^2); %! xlabel xlabel @@ -74,7 +74,7 @@ %!demo %! clf (); -%! x = logspace(0,1,11); +%! x = logspace (0,1,11); %! z = x'*x; %! mesh (x, x, z, z.^2); %! set (gca, "zscale", "log")
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -68,10 +68,10 @@ y(end, 1), y(end, :), y(end, end)]; endif - zref = min(z(isfinite(z))); - z = [zref .* ones(1, size(z, 2) + 2); - zref .* ones(size(z, 1), 1), z, zref .* ones(size(z, 1), 1); - zref.* ones(1, size(z, 2) + 2)]; + zref = min (z(isfinite (z))); + z = [zref .* ones(1, columns(z) + 2); + zref .* ones(rows(z), 1), z, zref .* ones(rows(z), 1); + zref.* ones(1, columns(z) + 2)]; oldh = gca (); unwind_protect
--- a/scripts/plot/module.mk +++ b/scripts/plot/module.mk @@ -80,6 +80,7 @@ plot/contour3.m \ plot/contourc.m \ plot/contourf.m \ + plot/copyobj.m \ plot/cylinder.m \ plot/daspect.m \ plot/diffuse.m \ @@ -112,6 +113,7 @@ plot/gtext.m \ plot/guidata.m \ plot/guihandles.m \ + plot/hdl2struct.m \ plot/hggroup.m \ plot/hidden.m \ plot/hist.m \ @@ -172,6 +174,7 @@ plot/stairs.m \ plot/stem.m \ plot/stem3.m \ + plot/struct2hdl.m \ plot/subplot.m \ plot/surf.m \ plot/surface.m \
--- a/scripts/plot/pareto.m +++ b/scripts/plot/pareto.m @@ -74,20 +74,20 @@ endif endif else - y = cellfun ("int2str", num2cell (1 : numel(x)), + y = cellfun ("int2str", num2cell (1 : numel (x)), "uniformoutput", false); endif [x, idx] = sort (x, "descend"); y = y (idx); cdf = cumsum (x); - maxcdf = max(cdf); + maxcdf = max (cdf); cdf = cdf ./ maxcdf; cdf95 = cdf - 0.95; - idx95 = find(sign(cdf95(1:end-1)) != sign(cdf95(2:end)))(1); + idx95 = find (sign (cdf95(1:end-1)) != sign (cdf95(2:end)))(1); [ax, hbar, hline] = plotyy (1 : idx95, x (1 : idx95), - 1 : length(cdf), 100 .* cdf, + 1 : length (cdf), 100 .* cdf, @bar, @plot); axis (ax(1), [1 - 0.6, idx95 + 0.6, 0, maxcdf]);
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -55,7 +55,7 @@ if (nargin == 1) c = x; - [nr, nc] = size(c); + [nr, nc] = size (c); z = zeros (nr, nc); [x, y] = meshgrid (1:nc, 1:nr); elseif (nargin == 3)
--- a/scripts/plot/peaks.m +++ b/scripts/plot/peaks.m @@ -69,9 +69,9 @@ Y = y; endif - Z = 3 * (1 - X) .^ 2 .* exp(- X .^ 2 - (Y + 1) .^ 2) ... - - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp(- X .^ 2 - Y .^ 2) ... - - 1 / 3 * exp(- (X + 1) .^ 2 - Y .^ 2); + Z = 3 * (1 - X) .^ 2 .* exp (- X .^ 2 - (Y + 1) .^ 2) ... + - 10 * (X / 5 - X .^ 3 - Y .^ 5) .* exp (- X .^ 2 - Y .^ 2) ... + - 1 / 3 * exp (- (X + 1) .^ 2 - Y .^ 2); if (nargout == 0) surf (x, y, Z);
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -121,10 +121,10 @@ y = real (x); y_set = 1; z_set = 1; - if (rows(x) > 1) - x = repmat ((1:rows(x))', 1, columns(x)); + if (rows (x) > 1) + x = repmat ((1:rows (x))', 1, columns (x)); else - x = 1:columns(x); + x = 1:columns (x); endif endif else @@ -164,7 +164,7 @@ elseif (length (x) == rows (z) && length (y) == columns (z)) [x, y] = meshgrid (x, y); else - error ("plot3: [length(x), length(y)] must match size(z)"); + error ("plot3: [length(x), length(y)] must match size (z)"); endif endif @@ -218,7 +218,7 @@ elseif (length (x) == rows (z) && length (y) == columns (z)) [x, y] = meshgrid (x, y); else - error ("plot3: [length(x), length(y)] must match size(z)"); + error ("plot3: [length(x), length(y)] must match size (z)"); endif endif @@ -278,9 +278,9 @@ y_set = 1; z_set = 1; if (rows (x) > 1) - x = repmat ((1:rows (x))', 1, columns(x)); + x = repmat ((1:rows (x))', 1, columns (x)); else - x = 1:columns(x); + x = 1:columns (x); endif endif @@ -292,7 +292,7 @@ elseif (length (x) == rows (z) && length (y) == columns (z)) [x, y] = meshgrid (x, y); else - error ("plot3: [length(x), length(y)] must match size(z)"); + error ("plot3: [length(x), length(y)] must match size (z)"); endif endif
--- a/scripts/plot/plotmatrix.m +++ b/scripts/plot/plotmatrix.m @@ -145,7 +145,7 @@ returm; endif - if (rows(X) != rows(Y)) + if (rows (X) != rows (Y)) error ("plotmatrix: dimension mismatch in the arguments"); endif
--- a/scripts/plot/plotyy.m +++ b/scripts/plot/plotyy.m @@ -56,8 +56,8 @@ function [Ax, H1, H2] = plotyy (varargin) ## Don't use __plt_get_axis_arg__ here as ax is a two vector for plotyy - if (nargin > 1 && length (varargin{1}) == 2 && ishandle(varargin{1}(1)) - && ishandle(varargin{1}(2)) + if (nargin > 1 && length (varargin{1}) == 2 && ishandle (varargin{1}(1)) + && ishandle (varargin{1}(2)) && all (floor (varargin{1}) != varargin{1})) obj1 = get (varargin{1}(1)); obj2 = get (varargin{1}(2)); @@ -111,7 +111,7 @@ [ax, h1, h2] = __plotyy__ (ax, varargin{:}); unwind_protect_cleanup ## Only change back to the old axis if we didn't delete it - if (ishandle(oldh) && strcmp (get (oldh, "type"), "axes")) + if (ishandle (oldh) && strcmp (get (oldh, "type"), "axes")) axes (oldh); endif end_unwind_protect @@ -138,7 +138,7 @@ xlim = [min([x1(:); x2(:)]), max([x1(:); x2(:)])]; - if (ishandle(ax(1)) && strcmp (get (ax(1), "type"), "axes")) + if (ishandle (ax(1)) && strcmp (get (ax(1), "type"), "axes")) axes (ax(1)); else ax(1) = axes (); @@ -153,7 +153,7 @@ cf = gcf (); set (cf, "nextplot", "add"); - if (ishandle(ax(2)) && strcmp (get (ax(2), "type"), "axes")) + if (ishandle (ax(2)) && strcmp (get (ax(2), "type"), "axes")) axes (ax(2)); else ax(2) = axes ();
--- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -55,8 +55,8 @@ elseif (nargs == 2) if (ischar (varargin{2})) tmp = __plr1__ (h, varargin{:}); - if (iscomplex(varargin{1})) - maxr = max (imag(varargin{1})(:)); + if (iscomplex (varargin{1})) + maxr = max (imag (varargin{1})(:)); else maxr = max (varargin{1}(:)); endif @@ -68,8 +68,8 @@ elseif (nargs == 1) fmt = ""; tmp = __plr1__ (h, varargin{:}, fmt); - if (iscomplex(varargin{1})) - maxr = max (imag(varargin{1})(:)); + if (iscomplex (varargin{1})) + maxr = max (imag (varargin{1})(:)); else maxr = max (varargin{1}(:)); endif
--- a/scripts/plot/print.m +++ b/scripts/plot/print.m @@ -333,7 +333,7 @@ if (opts.force_solid != 0) h = findall (opts.figure, "-property", "linestyle"); m = numel (props); - for n = 1:numel(h) + for n = 1:numel (h) props(m+n).h = h(n); props(m+n).name = "linestyle"; props(m+n).value = {get(h(n), "linestyle")}; @@ -349,12 +349,12 @@ if (opts.use_color < 0 && ! strcmp (get (opts.figure, "__graphics_toolkit__"), "gnuplot")) color_props = {"color", "facecolor", "edgecolor", "colormap"}; - for c = 1:numel(color_props) + for c = 1:numel (color_props) h = findall (opts.figure, "-property", color_props{c}); hnone = findall (opts.figure, color_props{c}, "none"); h = setdiff (h, hnone); m = numel (props); - for n = 1:numel(h) + for n = 1:numel (h) if (ishandle (h(n))) ## Need to verify objects exist since callbacks may delete objects ## as the colors for others are modified. @@ -364,7 +364,7 @@ props(end).value = {get(h(n), color_props{c})}; if (isnumeric (rgb)) ## convert RGB color to RGB gray scale - xfer = repmat ([0.30, 0.59, 0.11], size (rgb, 1), 1); + xfer = repmat ([0.30, 0.59, 0.11], rows (rgb), 1); ggg = repmat (sum (xfer .* rgb, 2), 1, 3); set (h(n), color_props{c}, ggg); endif @@ -376,7 +376,7 @@ if (! isempty (opts.font) || ! isempty (opts.fontsize)) h = findall (opts.figure, "-property", "fontname"); m = numel (props); - for n = 1:numel(h) + for n = 1:numel (h) if (ishandle (h(n))) if (! isempty (opts.font)) props(end+1).h = h(n); @@ -393,7 +393,7 @@ endif endfor if (! isempty (opts.font)) - set (h(ishandle(h)), "fontname", opts.font); + set (h(ishandle (h)), "fontname", opts.font); endif if (! isempty (opts.fontsize)) if (ischar (opts.fontsize)) @@ -405,7 +405,7 @@ ## This is done to work around the bbox being whole numbers. fontsize = fontsize * opts.scalefontsize; endif - set (h(ishandle(h)), "fontsize", fontsize); + set (h(ishandle (h)), "fontsize", fontsize); endif endif @@ -420,7 +420,7 @@ unwind_protect_cleanup ## restore modified properties if (isstruct (props)) - for n = numel(props):-1:1 + for n = numel (props):-1:1 if (ishandle (props(n).h)) set (props(n).h, props(n).name, props(n).value{1}); endif @@ -428,7 +428,7 @@ endif ## Unlink temporary files - for n = 1:numel(opts.unlink) + for n = 1:numel (opts.unlink) [status, output] = unlink (opts.unlink{n}); if (status != 0) warning ("print.m: %s, '%s'", output, opts.unlink{n});
--- a/scripts/plot/private/__add_datasource__.m +++ b/scripts/plot/private/__add_datasource__.m @@ -39,7 +39,7 @@ newargs = {}; while (i < numel (varargin)) arg = varargin{++i}; - if (i != numel(varargin) && ischar (arg) + if (i != numel (varargin) && ischar (arg) && length (arg) > 9 && strcmpi (arg(end-9:end), "datasource")) arg = tolower (arg); val = varargin{++i};
--- a/scripts/plot/private/__add_default_menu__.m +++ b/scripts/plot/private/__add_default_menu__.m @@ -98,12 +98,12 @@ endfunction function guimode_cb (h, e) - lbl = get(h, "label"); - if (strncmp(lbl, "Pan+Zoom", 8)) - gui_mode("2D"); - elseif (strncmp(lbl, "Rotate+Zoom", 11)) - gui_mode("3D"); - elseif (strncmp(lbl, "None", 4)) - gui_mode("None"); + lbl = get (h, "label"); + if (strncmp (lbl, "Pan+Zoom", 8)) + gui_mode ("2D"); + elseif (strncmp (lbl, "Rotate+Zoom", 11)) + gui_mode ("3D"); + elseif (strncmp (lbl, "None", 4)) + gui_mode ("None"); endif endfunction
--- a/scripts/plot/private/__axes_limits__.m +++ b/scripts/plot/private/__axes_limits__.m @@ -41,7 +41,7 @@ set (h, fcnmode, arg); endif else - if (!isnumeric (arg) && any (size(arg(:)) != [2, 1])) + if (!isnumeric (arg) && any (size (arg(:)) != [2, 1])) error ("%s: argument must be a 2 element vector", fcn); else if (arg(1) >= arg(2))
--- a/scripts/plot/private/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -45,12 +45,12 @@ if (isvector (y)) y = y(:); endif - if (size (x, 1) != size (y, 1)) + if (rows (x) != rows (y)) y = varargin{1}; if (isvector (y)) y = y(:); endif - x = [1:size(y,1)]'; + x = [1:rows(y)]'; idx = 2; else if (! isvector (x)) @@ -63,7 +63,7 @@ if (isvector (y)) y = y(:); endif - x = [1:size(y,1)]'; + x = [1:rows(y)]'; idx = 2; endif @@ -89,7 +89,7 @@ continue; endif endif - if (isscalar(varargin{idx})) + if (isscalar (varargin{idx})) width = varargin{idx++}; elseif (idx == nargin - 2) newargs = [newargs,varargin(idx++)]; @@ -105,8 +105,8 @@ endif endwhile - xlen = size (x, 1); - ylen = size (y, 1); + xlen = rows (x); + ylen = rows (y); if (xlen != ylen) error ("%s: length of x and y must be equal", func); @@ -115,9 +115,9 @@ error ("%s: x vector values must be in ascending order", func); endif - ycols = size (y, 2); + ycols = columns (y); if (numel (x) > 1) - cutoff = min (diff (double(x))) / 2; + cutoff = min (diff (double (x))) / 2; else cutoff = 1; endif @@ -139,7 +139,7 @@ y0 = zeros (size (y)) + bv; y1 = y; else - y1 = cumsum(y,2); + y1 = cumsum (y,2); y0 = [zeros(ylen,1)+bv, y1(:,1:end-1)]; endif @@ -196,10 +196,10 @@ else lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); endif - h = patch(xb(:,:,i), yb(:,:,i), "FaceColor", "flat", - "cdata", lev, "parent", hg); + h = patch (xb(:,:,i), yb(:,:,i), "FaceColor", "flat", + "cdata", lev, "parent", hg); else - h = patch(xb(:,:,i), yb(:,:,i), "parent", hg); + h = patch (xb(:,:,i), yb(:,:,i), "parent", hg); endif else if (! have_color_spec) @@ -208,10 +208,10 @@ else lev = (i - 1) * (clim(2) - clim(1)) / (ycols - 1) - clim(1); endif - h = patch(yb(:,:,i), xb(:,:,i), "FaceColor", "flat", - "cdata", lev, "parent", hg); + h = patch (yb(:,:,i), xb(:,:,i), "FaceColor", "flat", + "cdata", lev, "parent", hg); else - h = patch(yb(:,:,i), xb(:,:,i), "parent", hg); + h = patch (yb(:,:,i), xb(:,:,i), "parent", hg); endif endif @@ -403,7 +403,7 @@ unwind_protect recursion = true; hlist = get (h, "bargroup"); - barwidth = get(h, "barwidth"); + barwidth = get (h, "barwidth"); barlayout = get (h, "barlayout"); horizontal = get (h, "horizontal");
--- a/scripts/plot/private/__clabel__.m +++ b/scripts/plot/private/__clabel__.m @@ -25,10 +25,10 @@ ## FIXME ## Assume that the plot size is 4 by 3 inches. lims = axis (); - xspacing = 72 * 4 / abs(lims(1) - lims(2)); - yspacing = 72 * 3 / abs(lims(3) - lims(4)); + xspacing = 72 * 4 / abs (lims(1) - lims(2)); + yspacing = 72 * 3 / abs (lims(3) - lims(4)); - if (isscalar (hparent) && ishandle(hparent) + if (isscalar (hparent) && ishandle (hparent) && strcmp (get (hparent, "type"), "hggroup")) x = get (hparent, "xdata"); xmin = min (x(:)); @@ -67,14 +67,14 @@ p = c(:, i1+1:i1+clen) .* repmat ([xspacing; yspacing], 1, clen); d = sqrt (sumsq (diff (p, 1, 2))); cumd = cumsum (d); - td = sum(d); + td = sum (d); ntag = ceil (td / label_spacing); if (all (c(:,i1+1) == c(:,i1+clen))) Spacing = td / ntag; pos = Spacing / 2 + [0:ntag-1] * Spacing; else - pos = zeros(1, ntag); + pos = zeros (1, ntag); pos(1) = (td - label_spacing * (ntag - 1)) ./ 2; pos(2:ntag) = pos(1) + [1:ntag-1] * label_spacing; endif @@ -87,7 +87,7 @@ while (j1 < clen && cumd(j1) < tagpos) j1++; endwhile - tpos = sum(c(:,i1+j1-1:i1+j1), 2) ./ 2; + tpos = sum (c(:,i1+j1-1:i1+j1), 2) ./ 2; if (tpos(1) != xmin && tpos(1) != xmax && tpos(2) != ymin && tpos(2) != ymax) @@ -112,4 +112,4 @@ endfor i1 += clen+1; endwhile -endfunction \ No newline at end of file +endfunction
--- a/scripts/plot/private/__contour__.m +++ b/scripts/plot/private/__contour__.m @@ -79,10 +79,10 @@ endif endwhile - if (length(varargin) < 5) + if (length (varargin) < 5) z1 = varargin{3}; - x1 = 1 : columns(z1); - y1 = 1 : rows(z1); + x1 = 1 : columns (z1); + y1 = 1 : rows (z1); else x1 = varargin{3}; y1 = varargin{4}; @@ -100,7 +100,7 @@ endif if (isscalar (vn)) - lvl = linspace (min (z1(!isinf(z1))), max (z1(!isinf(z1))), + lvl = linspace (min (z1(!isinf (z1))), max (z1(!isinf (z1))), vn + 2)(1:end-1); else lvl = vn; @@ -111,13 +111,13 @@ [x1, y1] = meshgrid (x1, y1); endif [nr, nc] = size (z1); - x0 = prepad(x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2); - x0 = postpad(x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2); + x0 = prepad (x1, nc+1, 2 * x1(1, 1) - x1(1, 2), 2); + x0 = postpad (x0, nc+2, 2 * x1(1, nc) - x1(1, nc - 1), 2); x0 = [x0(1, :); x0; x0(1, :)]; - y0 = prepad(y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1); - y0 = postpad(y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1)); + y0 = prepad (y1, nr+1, 2 * y1(1, 1) - y1(2, 1), 1); + y0 = postpad (y0, nr+2, 2 * y1(nr, 1) - y1(nr - 1, 1)); y0 = [y0(:, 1), y0, y0(:, 1)]; - z0 = -Inf(nr+2, nc+2); + z0 = -Inf (nr+2, nc+2); z0(2:nr+1, 2:nc+1) = z1; [c, lev] = contourc (x0, y0, z0, lvl); else @@ -211,7 +211,7 @@ add_patch_children (hg); - axis("tight"); + axis ("tight"); if (!isempty (opts)) set (hg, opts{:}); @@ -258,7 +258,7 @@ lvl_idx = find (abs (cont_lev - lev(k)) < lvl_eps); len = numel (lvl_idx); if (len > 1) - ## mark = logical(zeros(size(lvl_idx))); + ## mark = logical (zeros (size (lvl_idx))); mark = false (size (lvl_idx)); a = 1; while (a < len) @@ -283,7 +283,7 @@ ma_idx = lvl_idx(mark); if (k > 1) ## Find color of level below. - tmp = find(abs(cont_lev - lev(k - 1)) < lvl_eps); + tmp = find (abs (cont_lev - lev(k - 1)) < lvl_eps); lvl_bel_idx = tmp(1); ## Set color of patches found. cont_lev(ma_idx) = cont_lev(lvl_bel_idx); @@ -319,7 +319,7 @@ else ## Special case unclosed contours endif - if (isnan(cont_lev(idx))) + if (isnan (cont_lev (idx))) fc = get (ca, "color"); if (strcmp (fc, "none")) fc = get (ancestor (ca, "figure"), "color"); @@ -458,13 +458,13 @@ [X, Y] = meshgrid (X, Y); endif [nr, nc] = size (Z); - X0 = prepad(X, nc+1, 2 * X(1, 1) - X(1, 2), 2); - X0 = postpad(X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2); + X0 = prepad (X, nc+1, 2 * X(1, 1) - X(1, 2), 2); + X0 = postpad (X0, nc+2, 2 * X(1, nc) - X(1, nc - 1), 2); X0 = [X0(1, :); X0; X0(1, :)]; - Y0 = prepad(Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1); - Y0 = postpad(Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1)); + Y0 = prepad (Y, nr+1, 2 * Y(1, 1) - Y(2, 1), 1); + Y0 = postpad (Y0, nr+2, 2 * Y(nr, 1) - Y(nr - 1, 1)); Y0 = [Y0(:, 1), Y0, Y0(:, 1)]; - Z0 = -Inf(nr+2, nc+2); + Z0 = -Inf (nr+2, nc+2); Z0(2:nr+1, 2:nc+1) = Z; [c, lev] = contourc (X0, Y0, Z0, lvl); else @@ -480,7 +480,7 @@ else set (h, "levellist", lev); z = get (h, "zdata"); - lvlstep = (max(z(:)) - min(z(:))) / 10; + lvlstep = (max (z(:)) - min (z(:))) / 10; set (h, "levelstep", lvlstep); endif
--- a/scripts/plot/private/__errcomm__.m +++ b/scripts/plot/private/__errcomm__.m @@ -34,7 +34,7 @@ nargs = length (varargin); retval = []; k = 1; - data = cell(6,1); + data = cell (6,1); while (k <= nargs) a = varargin{k++}; if (isvector (a))
--- a/scripts/plot/private/__errplot__.m +++ b/scripts/plot/private/__errplot__.m @@ -71,7 +71,7 @@ (__line__ (hg, "linestyle", "-", "marker", "none", "color", fmt.color))]; - switch (numel(varargin)) + switch (numel (varargin)) case 2 ydata = varargin{1}(:,i); xdata = 1:numel (ydata); @@ -232,7 +232,7 @@ xhi = xdata + dx; else n = xdata > 0; - rx = exp(0.01 * (max (log(xdata(n))) - min (log(xdata(n))))); + rx = exp (0.01 * (max (log (xdata(n))) - min (log (xdata(n))))); xlo = xdata/rx; xhi = xdata*rx; endif @@ -242,7 +242,7 @@ yhi = ydata + dy; else n = ydata > 0; - ry = exp(0.01 * (max (log(ydata(n))) - min (log(ydata(n))))); + ry = exp (0.01 * (max (log (ydata(n))) - min (log (ydata(n))))); ylo = ydata/ry; yhi = ydata*ry; endif
--- a/scripts/plot/private/__ezplot__.m +++ b/scripts/plot/private/__ezplot__.m @@ -74,9 +74,9 @@ endif fstr = formula (fun); if (isplot) - xarg = argnames(fun){1}; + xarg = (argnames (fun)){1}; if (nargs == 2) - yarg = argnames(fun){2}; + yarg = (argnames (fun)){2}; else yarg = ""; endif @@ -87,8 +87,8 @@ xarg = ""; yarg = ""; else - xarg = argnames(fun){1}; - yarg = argnames(fun){2}; + xarg = (argnames (fun)){1}; + yarg = (argnames (fun)){2}; endif elseif (strcmp (typeinfo (fun), "inline function")) if (isplot && length (argnames (fun)) == 2) @@ -99,9 +99,9 @@ fun = vectorize (fun); fstr = formula (fun); if (isplot) - xarg = argnames(fun){1}; + xarg = (argnames (fun)){1}; if (nargs == 2) - yarg = argnames(fun){2}; + yarg = (argnames (fun)){2}; else yarg = ""; endif @@ -112,8 +112,8 @@ xarg = ""; yarg = ""; else - xarg = argnames(fun)(1); - yarg = argnames(fun)(2); + xarg = (argnames (fun))(1); + yarg = (argnames (fun))(2); endif elseif (isa (fun, "function_handle")) fstr = func2str (fun); @@ -392,10 +392,10 @@ yrange = [XX(1), XX(end)]; endif - idx = 2 : length(Z); + idx = 2 : length (Z); idx = find (((Z(idx) > yrange(2) / 2) & (Z(idx-1) < yrange(1) / 2)) | ((Z(idx) < yrange(1) / 2) & (Z(idx-1) > yrange (2) / 2))); - if (any(idx)) + if (any (idx)) Z(idx) = NaN; endif else @@ -441,5 +441,5 @@ function x = __eliminate_sing__ (x) x (isinf (x)) = NaN; - x (abs (del2 (x)) > 0.2 * (max(x(:)) - min(x(:)))) = NaN; + x (abs (del2 (x)) > 0.2 * (max (x(:)) - min (x(:)))) = NaN; endfunction
--- a/scripts/plot/private/__file_filter__.m +++ b/scripts/plot/private/__file_filter__.m @@ -81,7 +81,7 @@ endswitch if (isempty (name)) - extlist = strsplit(filterext, ";"); + extlist = strsplit (filterext, ";"); extlist = strrep (extlist, "*.", ""); extlist = toupper (extlist); extlist(end+1, :) = repmat ({","}, 1, length (extlist));
--- a/scripts/plot/private/__fltk_print__.m +++ b/scripts/plot/private/__fltk_print__.m @@ -125,9 +125,9 @@ [cmd_gs, cmd_cleanup] = __ghostscript__ (opts.ghostscript); if (opts.send_to_printer || isempty (opts.name)) cmd_lpr = opts.lpr_cmd (opts); - cmd = sprintf("%s | %s", cmd_gs, cmd_lpr); + cmd = sprintf ("%s | %s", cmd_gs, cmd_lpr); else - cmd = sprintf("%s", cmd_gs); + cmd = sprintf ("%s", cmd_gs); endif if (! isempty (cmd_cleanup)) gl2ps_device = {"eps"}; @@ -159,11 +159,11 @@ gl2ps_device{end} = [gl2ps_device{end}, "is2D"]; endif - for n = 1:numel(pipeline) + for n = 1:numel (pipeline) if (opts.debug) fprintf ("fltk-pipeline: '%s'\n", pipeline{n}); endif - drawnow (gl2ps_device{n}, strcat('|',pipeline{n})); + drawnow (gl2ps_device{n}, strcat ('|',pipeline{n})); endfor if (! isempty (strfind (opts.devopt, "standalone")))
--- a/scripts/plot/private/__ghostscript__.m +++ b/scripts/plot/private/__ghostscript__.m @@ -49,12 +49,12 @@ n = find (cellfun ("isclass", args, "struct")); if (! isempty (n)) f = fieldnames (args{n}); - for m = 1:numel(f) + for m = 1:numel (f) opts.(f{m}) = args{n}.(f{m}); endfor args(n) = []; endif - for n = 1:2:numel(args) + for n = 1:2:numel (args) opts.(args{n}) = args{n+1}; endfor
--- a/scripts/plot/private/__gnuplot_print__.m +++ b/scripts/plot/private/__gnuplot_print__.m @@ -151,7 +151,7 @@ opts.pipeline = pipeline; - for n = 1:numel(pipeline) + for n = 1:numel (pipeline) if (opts.debug) fprintf ("gnuplot-pipeline: '%s'\n", pipeline{n}); endif @@ -170,12 +170,12 @@ function eps_drawnow (opts, epsfile, gp_opts) [h, fontsize] = get_figure_text_objs (opts); unwind_protect - for n = 1:numel(h) + for n = 1:numel (h) set (h(n), "fontsize", 2 * fontsize{n}); endfor local_drawnow (sprintf ("postscript eps %s", gp_opts), epsfile, opts); unwind_protect_cleanup - for n = 1:numel(h) + for n = 1:numel (h) set (h(n), "fontsize", fontsize{n}); endfor end_unwind_protect @@ -196,7 +196,7 @@ endfunction function f = font_spec (opts, varargin) - for n = 1:2:numel(varargin) + for n = 1:2:numel (varargin) opts.(varargin{n}) = varargin{n+1}; endfor f = "";
--- a/scripts/plot/private/__go_draw_axes__.m +++ b/scripts/plot/private/__go_draw_axes__.m @@ -90,7 +90,7 @@ x = [1, 1]; else ## 3D plots need to be sized down to fit in the window. - x = 1.0 ./ sqrt([2, 2.5]); + x = 1.0 ./ sqrt ([2, 2.5]); endif fprintf (plot_stream, "set tmargin screen %.15g;\n", pos(2)+pos(4)/2+x(2)*pos(4)/2); @@ -495,13 +495,13 @@ img_xdata = img_xdata(2:-1:1); img_data = img_data(:,end:-1:1,:); elseif (img_xdata(1) == img_xdata(2)) - img_xdata = img_xdata(1) + [0, size(img_data,2)-1]; + img_xdata = img_xdata(1) + [0, columns(img_data)-1]; endif if (img_ydata(2) < img_ydata(1)) img_ydata = img_ydata(2:-1:1); img_data = img_data(end:-1:1,:,:); elseif (img_ydata(1) == img_ydata(2)) - img_ydata = img_ydata(1) + [0, size(img_data,1)-1]; + img_ydata = img_ydata(1) + [0, rows(img_data)-1]; endif [y_dim, x_dim] = size (img_data(:,:,1)); @@ -574,7 +574,7 @@ ydat = obj.ydata(:); data{data_idx} = [xdat, ydat]'; usingclause{data_idx} = sprintf ("record=%d using ($1):($2) axes %s%s", - rows(xdat), xaxisloc_using, yaxisloc_using); + rows (xdat), xaxisloc_using, yaxisloc_using); endif style = do_linestyle_command (obj, obj.color, data_idx, mono, @@ -680,14 +680,14 @@ || strncmp (obj.facecolor, "interp", 6)) && isfield (obj, "cdata")) if (ndims (obj.cdata) == 2 - && (size (obj.cdata, 2) == nc - && (size (obj.cdata, 1) == 1 - || size (obj.cdata, 1) == 3))) + && (columns (obj.cdata) == nc + && (rows (obj.cdata) == 1 + || rows (obj.cdata) == 3))) ccol = cdat (:, i); elseif (ndims (obj.cdata) == 2 - && (size (obj.cdata, 1) == nc - && (size (obj.cdata, 2) == 1 - || size (obj.cdata, 2) == 3))) + && (rows (obj.cdata) == nc + && (columns (obj.cdata) == 1 + || columns (obj.cdata) == 3))) ccol = cdat (i, :); elseif (ndims (obj.cdata) == 3) ccol = permute (cdat (:, i, :), [1, 3, 2]); @@ -704,17 +704,17 @@ if (cdatadirect) r = round (ccol); else - r = 1 + round ((size (cmap, 1) - 1) + r = 1 + round ((rows (cmap) - 1) * (ccol - clim(1))/(clim(2) - clim(1))); endif - r = max (1, min (r, size (cmap, 1))); + r = max (1, min (r, rows (cmap))); color = cmap(r, :); endif elseif (strncmp (obj.facecolor, "interp", 6)) if (nd == 3 && numel (xcol) == 3) ccdat = ccol; if (! isvector (ccdat)) - tmp = rows(cmap) + rows(addedcmap) + ... + tmp = rows (cmap) + rows (addedcmap) + ... [1 : rows(ccdat)]; addedcmap = [addedcmap; ccdat]; ccdat = tmp(:); @@ -728,10 +728,10 @@ if (cdatadirect) r = round (ccol); else - r = 1 + round ((size (cmap, 1) - 1) + r = 1 + round ((rows (cmap) - 1) * (ccol - clim(1))/(clim(2) - clim(1))); endif - r = max (1, min (r, size (cmap, 1))); + r = max (1, min (r, rows (cmap))); color = cmap(r(1),:); endif endif @@ -746,7 +746,7 @@ if (nd == 3 && numel (xcol) == 3) if (isnan (ccdat)) - ccdat = (rows (cmap) + rows(addedcmap) + 1) * ones(3, 1); + ccdat = (rows (cmap) + rows (addedcmap) + 1) * ones(3, 1); addedcmap = [addedcmap; reshape(color, 1, 3)]; endif data{data_3d_idx} = [data{data_3d_idx}, ... @@ -812,14 +812,14 @@ || strncmp (ec, "interp", 6)) && isfield (obj, "cdata")) if (ndims (obj.cdata) == 2 - && (size (obj.cdata, 2) == nc - && (size (obj.cdata, 1) == 1 - || size (obj.cdata, 1) == 3))) + && (columns (obj.cdata) == nc + && (rows (obj.cdata) == 1 + || rows (obj.cdata) == 3))) ccol = cdat (:, i); elseif (ndims (obj.cdata) == 2 - && (size (obj.cdata, 1) == nc - && (size (obj.cdata, 2) == 1 - || size (obj.cdata, 2) == 3))) + && (rows (obj.cdata) == nc + && (columns (obj.cdata) == 1 + || columns (obj.cdata) == 3))) ccol = cdat (i, :); elseif (ndims (obj.cdata) == 3) ccol = permute (cdat (:, i, :), [1, 3, 2]); @@ -827,22 +827,22 @@ ccol = cdat; endif if (strncmp (ec, "flat", 4)) - if (numel(ccol) == 3) + if (numel (ccol) == 3) color = ccol; else if (isscalar (ccol)) - ccol = repmat(ccol, numel (xcol), 1); + ccol = repmat (ccol, numel (xcol), 1); endif color = "flat"; have_cdata(data_idx) = true; endif elseif (strncmp (ec, "interp", 6)) - if (numel(ccol) == 3) + if (numel (ccol) == 3) warning ("\"interp\" not supported, using 1st entry of cdata"); color = ccol(1,:); else if (isscalar (ccol)) - ccol = repmat(ccol, numel (xcol), 1); + ccol = repmat (ccol, numel (xcol), 1); endif color = "interp"; have_cdata(data_idx) = true; @@ -877,7 +877,7 @@ endif if (isfield (obj, "linewidth")) - lw = sprintf("linewidth %f", obj.linewidth); + lw = sprintf ("linewidth %f", obj.linewidth); else lw = ""; endif @@ -923,7 +923,7 @@ else m = mdat; endif - ps = sprintf("pointsize %f", m / 3); + ps = sprintf ("pointsize %f", m / 3); else ps = ""; endif @@ -950,7 +950,7 @@ else m = mdat; endif - ps = sprintf("pointsize %f", m / 3); + ps = sprintf ("pointsize %f", m / 3); else ps = ""; endif @@ -977,7 +977,7 @@ else m = mdat; endif - ps = sprintf("pointsize %f", m / 3); + ps = sprintf ("pointsize %f", m / 3); else ps = ""; endif @@ -987,7 +987,7 @@ endif else if (!isempty (style)) - if (length(tmpwith) < sidx || isempty (tmpwith{sidx})) + if (length (tmpwith) < sidx || isempty (tmpwith{sidx})) tmpwith{sidx} = sprintf ("with %s %s %s %s", style, lw, lt, colorspec); @@ -1012,7 +1012,7 @@ else m = mdat; endif - ps = sprintf("pointsize %f", m / 3); + ps = sprintf ("pointsize %f", m / 3); else ps = ""; endif @@ -1122,7 +1122,7 @@ cdat = obj.cdata; err = false; - if (! size_equal(zdat, cdat)) + if (! size_equal (zdat, cdat)) err = true; endif if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) @@ -1188,11 +1188,11 @@ if (all (obj.facecolor == 1)) hidden_removal = true; endif - fputs(plot_stream,"unset pm3d;\n"); - fputs(plot_stream,"set style increment user;\n"); + fputs (plot_stream,"unset pm3d;\n"); + fputs (plot_stream,"set style increment user;\n"); withpm3d = false; - withclause{data_idx} = sprintf("with %s linestyle %d", - style{1}, data_idx); + withclause{data_idx} = sprintf ("with %s linestyle %d", + style{1}, data_idx); fputs (plot_stream, "unset pm3d\n"); endif @@ -1267,7 +1267,7 @@ style{3}, data_idx); endif if (withpm3d && strncmp (style {1}, "linespoints", 11)) - if (isempty(zz)) + if (isempty (zz)) len = 3 * xlen; zz = zeros (ylen, len); k = 1; @@ -1315,7 +1315,7 @@ endif if (ischar (obj.string)) - num_lines = size (obj.string, 1); + num_lines = rows (obj.string); else num_lines = numel (obj.string); endif @@ -1335,7 +1335,7 @@ ## Gnuplot's Character units are different for x/y and vary with fontsize. The aspect ratio ## of 1:1.7 was determined by experiment to work for eps/ps/etc. For the MacOS aqua terminal ## a value of 2.5 is needed. However, the difference is barely noticable. - dx_and_dy = [(-dy * sind (angle)), (dy * cosd(angle))] .* [1.7 1]; + dx_and_dy = [(-dy * sind (angle)), (dy * cosd (angle))] .* [1.7 1]; ## FIXME - Multiline text produced the gnuplot "warning: ft_render: skipping glyph" if (nd == 3) @@ -1376,7 +1376,7 @@ fputs (plot_stream, "set pm3d explicit;\n"); endif - if (isnan(hidden_removal) || hidden_removal) + if (isnan (hidden_removal) || hidden_removal) fputs (plot_stream, "set hidden3d;\n"); else fputs (plot_stream, "unset hidden3d;\n"); @@ -1425,17 +1425,17 @@ endif cmap = parent_figure_obj.colormap; - cmap_sz = rows(cmap); + cmap_sz = rows (cmap); if (! any (isinf (clim))) if (truecolor || ! cdatadirect) - if (rows(addedcmap) > 0) + if (rows (addedcmap) > 0) for i = 1:data_idx if (have_3d_patch(i)) data{i}(end,:) = clim(2) * (data{i}(end, :) - 0.5) / cmap_sz; endif endfor fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim(1), clim(2) * - (cmap_sz + rows(addedcmap)) / cmap_sz); + (cmap_sz + rows (addedcmap)) / cmap_sz); else fprintf (plot_stream, "set cbrange [%.15e:%.15e];\n", clim); endif @@ -1590,8 +1590,8 @@ fputs (plot_stream, "set style data lines;\n"); cmap = [cmap; addedcmap]; - cmap_sz = cmap_sz + rows(addedcmap); - if (length(cmap) > 0) + cmap_sz = cmap_sz + rows (addedcmap); + if (length (cmap) > 0) fprintf (plot_stream, "set palette positive color model RGB maxcolors %i;\n", cmap_sz); @@ -1629,7 +1629,7 @@ if (numel (is_image_data) > 1 && is_image_data(2)) ## Remove terminating semicolon n = max (strfind (withclause{1}, ";")); - if (! isempty(n)) + if (! isempty (n)) withclause{1} = withclause{1}(1:n-1); endif endif @@ -1657,7 +1657,7 @@ if (numel (is_image_data) > i && is_image_data(i+1)) ## Remove terminating semicolon n = max (strfind (withclause{i}, ";")); - if (! isempty(n)) + if (! isempty (n)) withclause{i} = withclause{i}(1:n-1); endif endif @@ -1690,7 +1690,7 @@ ## Can't write 3d patch data as binary as can't plot more than ## a single patch at a time and have to plot all patches together ## so that the gnuplot depth ordering is done correctly - for j = 1 : 4 : columns(data{i}) + for j = 1 : 4 : columns (data{i}) if (j != 1) fputs (plot_stream, "\n\n"); endif @@ -1730,9 +1730,9 @@ endfunction function x = flip (x) - if (size (x, 1) == 1) + if (rows (x) == 1) x = fliplr (x); - elseif (size (x, 2) == 1 || ischar (x)) + elseif (columns (x) == 1 || ischar (x)) x = flipud (x); else x = flipud (fliplr (x)); @@ -2097,7 +2097,7 @@ fontname, fontspec, interpreter, scale, sgn, gnuplot_term) persistent warned_latex = false; if (strcmpi (interpreter, "tex")) - for n = 1 : numel(labels) + for n = 1 : numel (labels) labels{n} = __tex2enhanced__ (labels{n}, fontname, false, false); endfor elseif (strcmpi (interpreter, "latex")) @@ -2147,7 +2147,7 @@ tickdir, ticklength, axispos); endif - labels = regexprep(labels, '%', "%%"); + labels = regexprep (labels, '%', "%%"); for i = 1:ntics fprintf (plot_stream, " \"%s\" %.15g", labels{k++}, tics(i)); if (i < ntics) @@ -2206,7 +2206,7 @@ ticklabel = num2str (ticklabel(:), 5); endif if (ischar (ticklabel)) - if (size (ticklabel, 1) == 1 && any (ticklabel == "|")) + if (rows (ticklabel) == 1 && any (ticklabel == "|")) ticklabel = strsplit (ticklabel, "|"); else ticklabel = cellstr (ticklabel); @@ -2237,7 +2237,7 @@ it = false; bld = false; if (! isempty (t.fontweight) && strcmpi (t.fontweight, "bold")) - if (! isempty(t.fontangle) + if (! isempty (t.fontangle) && (strcmpi (t.fontangle, "italic") || strcmpi (t.fontangle, "oblique"))) f = cstrcat (f, "-bolditalic"); @@ -2247,7 +2247,7 @@ f = cstrcat (f, "-bold"); bld = true; endif - elseif (! isempty(t.fontangle) + elseif (! isempty (t.fontangle) && (strcmpi (t.fontangle, "italic") || strcmpi (t.fontangle, "oblique"))) f = cstrcat (f, "-italic"); @@ -2276,13 +2276,13 @@ ## The text object maybe multiline, and may be of any class str = getfield (obj, fld); - if (ischar (str) && size (str, 1) > 1) + if (ischar (str) && rows (str) > 1) str = cellstr (str); elseif (isnumeric (str)) str = cellstr (num2str (str(:))); endif if (iscellstr (str)) - for n = 1:numel(str) + for n = 1:numel (str) if (isnumeric (str{n})) str{n} = num2str (str{n}); endif @@ -2293,7 +2293,7 @@ if (enhanced) if (strcmpi (obj.interpreter, "tex")) if (iscellstr (str)) - for n = 1:numel(str) + for n = 1:numel (str) str{n} = __tex2enhanced__ (str{n}, fnt, it, bld); endfor else @@ -2317,14 +2317,14 @@ labels = cellstr (str); endif for marker = "_^" - for m = 1 : numel(labels) + for m = 1 : numel (labels) n1 = strfind (labels{m}, sprintf ("\\%s", marker)); n2 = strfind (labels{m}, marker); if (! isempty (n1)) n1 = n1 + 1; n2 = setdiff (n2, n1); endif - for n = numel(n2):-1:1 + for n = numel (n2):-1:1 labels{m} = [labels{m}(1:n2(n)-1), "\\", labels{m}(n2(n):end)]; endfor endfor @@ -2340,7 +2340,7 @@ persistent sym = __setup_sym_table__ (); persistent flds = fieldnames (sym); - [s, e, m] = regexp(str,'\\\\([a-zA-Z]+|0)','start','end','matches'); + [s, e, m] = regexp (str,'\\\\([a-zA-Z]+|0)','start','end','matches'); for i = length (s) : -1 : 1 ## special case for "\0" and replace with "{/Symbol \306}' @@ -2349,7 +2349,7 @@ else f = m{i}(2:end); if (isfield (sym, f)) - g = getfield(sym, f); + g = getfield (sym, f); ## FIXME The symbol font doesn't seem to support bold or italic ##if (bld) ## if (it) @@ -2369,54 +2369,54 @@ it = true; if (bld) str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', - str(s(i) + 3:end)); + str(s(i) + 3:end)); else str = cstrcat (str(1:s(i) - 1), '/', fnt, '-italic ', - str(s(i) + 3:end)); + str(s(i) + 3:end)); endif elseif (strncmp (f, "bf", 2)) bld = true; if (it) str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bolditalic ', - str(2(i) + 3:end)); + str(2(i) + 3:end)); else str = cstrcat (str(1:s(i) - 1), '/', fnt, '-bold ', - str(s(i) + 3:end)); + str(s(i) + 3:end)); endif elseif (strcmpi (f, "color")) ## FIXME Ignore \color but remove trailing {} block as well - d = strfind(str(e(i) + 1:end),'}'); + d = strfind (str(e(i) + 1:end),'}'); if (isempty (d)) warning ('syntax error in \color argument'); else str = cstrcat (str(1:s(i) - 1), str(e(i) + d + 1:end)); endif - elseif(strcmpi (f, "fontname")) - b1 = strfind(str(e(i) + 1:end),'{'); - b2 = strfind(str(e(i) + 1:end),'}'); - if (isempty(b1) || isempty(b2)) + elseif (strcmpi (f, "fontname")) + b1 = strfind (str(e(i) + 1:end),'{'); + b2 = strfind (str(e(i) + 1:end),'}'); + if (isempty (b1) || isempty (b2)) warning ('syntax error in \fontname argument'); else str = cstrcat (str(1:s(i) - 1), '/', - str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', - str(e(i) + b2(1) + 1:end)); + str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', + str(e(i) + b2(1) + 1:end)); endif - elseif(strcmpi (f, "fontsize")) - b1 = strfind(str(e(i) + 1:end),'{'); - b2 = strfind(str(e(i) + 1:end),'}'); - if (isempty(b1) || isempty(b2)) + elseif (strcmpi (f, "fontsize")) + b1 = strfind (str(e(i) + 1:end),'{'); + b2 = strfind (str(e(i) + 1:end),'}'); + if (isempty (b1) || isempty (b2)) warning ('syntax error in \fontname argument'); else str = cstrcat (str(1:s(i) - 1), '/=', - str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', - str(e(i) + b2(1) + 1:end)); + str(e(i)+b1(1) + 1:e(i)+b2(1)-1), '{}', + str(e(i) + b2(1) + 1:end)); endif else ## Last desperate attempt to treat the symbol. Look for things ## like \pix, that should be translated to the symbol Pi and x for j = 1 : length (flds) if (strncmp (flds{j}, f, length (flds{j}))) - g = getfield(sym, flds{j}); + g = getfield (sym, flds{j}); ## FIXME The symbol font doesn't seem to support bold or italic ##if (bld) ## if (it) @@ -2428,7 +2428,7 @@ ## g = regexprep (g, '/Symbol', '/Symbol-italic'); ##endif str = cstrcat (str(1:s(i) - 1), g, - str(s(i) + length (flds{j}) + 1:end)); + str(s(i) + length (flds{j}) + 1:end)); break; endif endfor @@ -2444,15 +2444,15 @@ ## FIXME -- This is a mess... Is it worth it just for a "@" character? - [s, m] = regexp(str,'[_\^]','start','matches'); + [s, m] = regexp (str,'[_\^]','start','matches'); i = 1; p = 0; while (i < length (s)) - if (i < length(s)) + if (i < length (s)) if (str(s(i) + p + 1) == "{") - s1 = strfind(str(s(i) + p + 2:end),'{'); + s1 = strfind (str(s(i) + p + 2:end),'{'); si = 1; - l1 = strfind(str(s(i) + p + 1:end),'}'); + l1 = strfind (str(s(i) + p + 1:end),'}'); li = 1; while (li <= length (l1) && si <= length (s1)) if (l1(li) < s1(si)) @@ -2464,12 +2464,12 @@ si++; endif endwhile - l1 = l1 (min (length(l1), si)); + l1 = l1 (min (length (l1), si)); if (s(i) + l1 + 1 == s(i+1)) if (str(s(i + 1) + p + 1) == "{") - s2 = strfind(str(s(i + 1) + p + 2:end),'{'); + s2 = strfind (str(s(i + 1) + p + 2:end),'{'); si = 1; - l2 = strfind(str(s(i + 1) + p + 1:end),'}'); + l2 = strfind (str(s(i + 1) + p + 1:end),'}'); li = 1; while (li <= length (l2) && si <= length (s2)) if (l2(li) < s2(si)) @@ -2481,20 +2481,20 @@ si++; endif endwhile - l2 = l2 (min (length(l2), si)); + l2 = l2 (min (length (l2), si)); if (length_string (str(s(i)+p+2:s(i)+p+l1-1)) <= - length_string(str(s(i+1)+p+2:s(i+1)+p+l2-1))) + length_string (str(s(i+1)+p+2:s(i+1)+p+l2-1))) ## Shortest already first! str = cstrcat (str(1:s(i)+p-1), "@", str(s(i)+p:end)); else ## Have to swap sub/super-script to get shortest first. str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+l2), - str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); + str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+l2+1:end)); endif else ## Have to swap sub/super-script to get shortest first. str = cstrcat (str(1:s(i)+p-1), "@", str(s(i+1)+p:s(i+1)+p+1), - str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); + str(s(i)+p:s(i)+p+l1), str(s(i+1)+p+2:end)); endif i += 2; p ++; @@ -2519,7 +2519,7 @@ endfunction function l = length_string (s) - l = length (s) - length (strfind(s,'{')) - length (strfind(s,'}')); + l = length (s) - length (strfind (s,'{')) - length (strfind (s,'}')); m = regexp (s, '/([\w-]+|[\w-]+=\d+)', 'matches'); if (!isempty (m)) l = l - sum (cellfun ("length", m));
--- a/scripts/plot/private/__go_draw_figure__.m +++ b/scripts/plot/private/__go_draw_figure__.m @@ -158,12 +158,12 @@ ## to __go_draw_axes__ hlegend = []; fkids = get (h, "children"); - for j = 1 : numel(fkids) + for j = 1 : numel (fkids) if (ishandle (fkids (j)) && strcmp (get (fkids (j), "type"), "axes") && (strcmp (get (fkids (j), "tag"), "legend"))) udata = get (fkids (j), "userdata"); - if (isscalar(udata.handle) + if (isscalar (udata.handle) && ! isempty (intersect (udata.handle, kids (i)))) hlegend = get (fkids (j)); break;
--- a/scripts/plot/private/__interp_cube__.m +++ b/scripts/plot/private/__interp_cube__.m @@ -23,7 +23,7 @@ ## Undocumented internal function. ## @end deftypefn -function [Vxyz, idx, frac] = __interp_cube__(x, y, z, val, v, req = "values" ) +function [Vxyz, idx, frac] = __interp_cube__ (x, y, z, val, v, req = "values" ) if (ismatrix (x) && ndims (x) == 3 && ismatrix (y) && ndims (y) == 3 ... && ismatrix (z) && ndims (z) == 3 && size_equal (x, y, z, val)) x = squeeze (x(1,:,1))(:); @@ -34,12 +34,12 @@ y = y(:); z = z(:); else - error("__interp_cube__: X, Y, Z have wrong dimensions"); + error ("__interp_cube__: X, Y, Z have wrong dimensions"); endif if (size (val) != [length(x), length(y), length(z)]) error ("__interp_cube__: VAL has wrong dimensions"); endif - if (size (v, 2) != 3) + if (columns (v) != 3) error ( "v has to be N*3 matrix"); endif if (!ischar (req)) @@ -101,7 +101,7 @@ endswitch endfunction -function [Vxyz, idx, frac] = interp_cube_trilin(x, y, z, val, v) +function [Vxyz, idx, frac] = interp_cube_trilin (x, y, z, val, v) [idx, frac] = cube_idx (x(:), y(:), z(:), v); sval = size (val); i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)); @@ -126,7 +126,7 @@ val( i111 ) .* Bx .* By .* Bz; endfunction -function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad(x, y, z, val, v) +function [Dx, Dy, Dz, idx, frac] = interp_cube_trilin_grad (x, y, z, val, v) [idx, frac] = cube_idx (x(:), y(:), z(:), v); sval = size (val); i000 = sub2ind (sval, idx(:, 1), idx(:, 2), idx(:, 3)); @@ -169,7 +169,7 @@ val( i111 ) .* Bx .* By; endfunction -function [idx, frac] = cube_idx(x, y, z, v) +function [idx, frac] = cube_idx (x, y, z, v) idx = zeros (size (v)); frac = zeros (size (v)); idx(:, 2) = lookup (x(2:end-1), v(:, 1)) + 1;
--- a/scripts/plot/private/__marching_cube__.m +++ b/scripts/plot/private/__marching_cube__.m @@ -169,13 +169,13 @@ if (calc_cols) pp(id__, 1:5, jj) = [vertex_interp(iso, xx(id1), yy(id1), zz(id1), ... xx(id2), yy(id2), zz(id2), c(id1), c(id2), colors(id1), colors(id2)), ... - (1:size (id_, 1))' + ix_offset ]; + (1:rows (id_))' + ix_offset ]; else pp(id__, 1:4, jj) = [vertex_interp(iso, xx(id1), yy(id1), zz(id1), ... xx(id2), yy(id2), zz(id2), c(id1), c(id2)), ... - (1:size (id_, 1))' + ix_offset ]; + (1:rows (id_))' + ix_offset ]; endif - ix_offset += size (id_, 1); + ix_offset += rows (id_); endfor ## phase III: calculate the triangulation from the point list @@ -183,7 +183,7 @@ tri = tri_table(cc(id)+1, :); for jj=1:3:15 id_ = find (tri(:, jj)>0); - p = [id_, lindex*ones(size (id_, 1), 1),tri(id_, jj:jj+2)]; + p = [id_, lindex*ones(rows (id_), 1),tri(id_, jj:jj+2)]; if (!isempty (p)) p1 = sub2ind (size (pp), p(:,1), p(:,2), p(:,3)); p2 = sub2ind (size (pp), p(:,1), p(:,2), p(:,4)); @@ -205,7 +205,7 @@ endfor endfunction -function p = vertex_interp(isolevel,p1x, p1y, p1z,... +function p = vertex_interp (isolevel,p1x, p1y, p1z,... p2x, p2y, p2z,valp1,valp2, col1, col2) if (nargin == 9)
--- a/scripts/plot/private/__patch__.m +++ b/scripts/plot/private/__patch__.m @@ -40,12 +40,12 @@ elseif (isstruct (varargin{1})) if (isfield (varargin{1}, "vertices") && isfield (varargin{1}, "faces")) args{1} = "faces"; - args{2} = getfield(varargin{1}, "faces"); + args{2} = getfield (varargin{1}, "faces"); args{3} = "vertices"; - args{4} = getfield(varargin{1}, "vertices"); + args{4} = getfield (varargin{1}, "vertices"); args{5} = "facevertexcdata"; if (isfield (varargin{1}, "facevertexcdata")) - args{6} = getfield(varargin{1}, "facevertexcdata"); + args{6} = getfield (varargin{1}, "facevertexcdata"); else args{6} = []; endif @@ -97,7 +97,7 @@ if (isnumeric (c)) if (isvector (c) && numel (c) == numel (x)) c = c(:); - elseif (size (c, 1) != numel (x) && size (c, 2) == numel (x)) + elseif (rows (c) != numel (x) && columns (c) == numel (x)) c = c.'; endif endif @@ -111,7 +111,7 @@ if (isnumeric (c)) - if (ndims (c) == 3 && size (c, 2) == 1) + if (ndims (c) == 3 && columns (c) == 1) c = permute (c, [1, 3, 2]); endif @@ -136,14 +136,14 @@ args{10} = []; elseif (ndims (c) == 3 && size (c, 3) == 3) ## CDATA is specified as RGB data - if ((size (c, 1) == 1 && size (c, 2) == 1) ... - || (size (c, 1) == 1 && size (c, 2) == columns (x))) + if ((rows (c) == 1 && columns (c) == 1) ... + || (rows (c) == 1 && columns (c) == columns (x))) ## Single patch color or per-face color args{7} = "facecolor"; args{8} = "flat"; args{9} = "cdata"; args{10} = c; - elseif (size (c, 1) == rows (x) && size (c, 2) == columns (x)) + elseif (rows (c) == rows (x) && columns (c) == columns (x)) ## Per-vertex color args{7} = "facecolor"; args{8} = "interp"; @@ -209,7 +209,7 @@ endif endfunction -function args = delfields(args, flds) +function args = delfields (args, flds) idx = cellfun (@(x) any (strcmpi (x, flds)), args); if (rows (idx) == 1) idx = idx | [false, idx(1:end-1)]; @@ -237,13 +237,13 @@ vert = args {idx}; endif idx = find (strcmpi (args, "facevertexcdata"), 1, "last") + 1; - if (isempty(idx) || idx > nargs) + if (isempty (idx) || idx > nargs) fvc = []; else fvc = args {idx}; endif idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; - if (isempty(idx) || idx > nargs) + if (isempty (idx) || idx > nargs) if (!isempty (fvc)) fc = "flat"; else @@ -252,7 +252,7 @@ args = {"facecolor", fc, args{:}}; endif - nc = size (faces, 1); + nc = rows (faces); idx = faces .'; t1 = isnan (idx); for i = find (any (t1)) @@ -261,22 +261,22 @@ endfor x = reshape (vert(:,1)(idx), size (idx)); y = reshape (vert(:,2)(idx), size (idx)); - if (size(vert,2) > 2) + if (columns (vert) > 2) z = reshape (vert(:,3)(idx), size (idx)); else z = []; endif - if (size(fvc, 1) == nc || size (fvc, 1) == 1) + if (rows (fvc) == nc || rows (fvc) == 1) c = reshape (fvc, [1, size(fvc)]); else - if (size(fvc, 2) == 3) - c = cat(3, reshape (fvc(idx, 1), size(idx)), - reshape (fvc(idx, 2), size(idx)), - reshape (fvc(idx, 3), size(idx))); + if (columns (fvc) == 3) + c = cat (3, reshape (fvc(idx, 1), size (idx)), + reshape (fvc(idx, 2), size (idx)), + reshape (fvc(idx, 3), size (idx))); elseif (isempty (fvc)) c = []; - else ## if (size (fvc, 2) == 1) + else ## if (columnns (fvc) == 1) c = permute (fvc(faces), [2, 1]); endif endif @@ -301,19 +301,19 @@ y = args {idx}; endif idx = find (strcmpi (args, "zdata"), 1, "last") + 1; - if (isempty(idx) || idx > nargs) + if (isempty (idx) || idx > nargs) z = []; else z = args {idx}; endif idx = find (strcmpi (args, "cdata"), 1, "last") + 1; - if (isempty(idx) || idx > nargs) + if (isempty (idx) || idx > nargs) c = []; else c = args {idx}; endif idx = find (strcmpi (args, "facecolor"), 1, "last") + 1; - if (isempty(idx) || idx > nargs) + if (isempty (idx) || idx > nargs) if (!isempty (c)) fc = "flat"; else @@ -332,11 +332,11 @@ else vert = [x(:), y(:)]; endif - faces = reshape (1:numel(x), nr, nc); + faces = reshape (1:numel (x), nr, nc); faces = faces'; if (ndims (c) == 3) - fvc = reshape (c, size (c, 1) * size (c, 2), size(c, 3)); + fvc = reshape (c, rows (c) * columns (c), size (c, 3)); else fvc = c(:); endif
--- a/scripts/plot/private/__pie__.m +++ b/scripts/plot/private/__pie__.m @@ -123,10 +123,10 @@ sc = i * ones (size (sz)); hlist = [hlist; - patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zeros (1, ln + 1), i); - surface(sx, sy, sz, sc); - patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zlvl * ones (1, ln + 1), i); - text(xt, yt, zlvl, labels{i})]; + patch (xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zeros (1, ln + 1), i); + surface (sx, sy, sz, sc); + patch (xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], zlvl * ones (1, ln + 1), i); + text (xt, yt, zlvl, labels{i})]; elseif (strncmp (caller, "pie", 3)) if (xt > 0) @@ -136,14 +136,14 @@ endif hlist = [hlist; patch(xoff + [0, - sind(xn)], yoff + [0, cosd(xn)], i); - text(xt, yt, labels{i}, "horizontalalignment", align)]; + text (xt, yt, labels{i}, "horizontalalignment", align)]; else error ("__pie__: unknown caller `%s'", caller); endif endfor - addlistener(gca, "view", {@update_text_pos, hlist}); + addlistener (gca, "view", {@update_text_pos, hlist}); if (strncmp (caller, "pie3", 4)) axis ([-1.25, 1.25, -1.25, 1.25, -0.05, 0.4], "equal", "off");
--- a/scripts/plot/private/__plt__.m +++ b/scripts/plot/private/__plt__.m @@ -38,7 +38,7 @@ hlegend = []; fkids = get (gcf (), "children"); - for i = 1 : numel(fkids) + for i = 1 : numel (fkids) if (ishandle (fkids (i)) && strcmp (get (fkids (i), "type"), "axes") && (strcmp (get (fkids (i), "tag"), "legend"))) udata = get (fkids (i), "userdata");
--- a/scripts/plot/private/__print_parse_opts__.m +++ b/scripts/plot/private/__print_parse_opts__.m @@ -77,7 +77,7 @@ varargin(1) = []; endif - for i = 1:numel(varargin) + for i = 1:numel (varargin) arg = strtrim (varargin{i}); if (ischar (arg)) if (strcmp (arg, "-color")) @@ -569,7 +569,7 @@ ## Papersize is tall when portrait,and wide when landscape. if ((papersize(1) > papersize(2) && strcmpi (paperorientation, "portrait")) || (papersize(1) < papersize(2) && strcmpi (paperorientation, "landscape"))) - papersize = papersize ([2,1]); + papersize = papersize([2,1]); paperposition = paperposition([2,1,4,3]); endif
--- a/scripts/plot/private/__quiver__.m +++ b/scripts/plot/private/__quiver__.m @@ -43,9 +43,9 @@ v = varargin{ioff++}; if (is3d) w = varargin{ioff++}; - [x, y, z] = meshgrid (1:size(u,2), 1:size(u,1), 1:max(size(w))); + [x, y, z] = meshgrid (1:columns (u), 1:rows (u), 1:max (size (w))); else - [x, y] = meshgrid (1:size(u,2), 1:size(u,1)); + [x, y] = meshgrid (1:columns (u), 1:rows (u)); endif if (nargin >= ioff && isnumeric (varargin{ioff}) && isscalar (varargin{ioff})) @@ -62,7 +62,7 @@ if (is3d) w = varargin{ioff++}; if (isvector (x) && isvector (y) && isvector (z) - && (! isvector (u) || ! isvector (v) || ! isvector(w))) + && (! isvector (u) || ! isvector (v) || ! isvector (w))) [x, y, z] = meshgrid (x, y, z); endif else @@ -112,10 +112,10 @@ else [nx, ny] = size (x); endif - dx = (max(x(:)) - min(x(:))) ./ nx; - dy = (max(y(:)) - min(y(:))) ./ ny; + dx = (max (x(:)) - min (x(:))) ./ nx; + dy = (max (y(:)) - min (y(:))) ./ ny; if (is3d) - dz = (max(z(:)) - min(z(:))) ./ max (size (z)); + dz = (max (z(:)) - min (z(:))) ./ max (size (z)); len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2)); else dz = 0; @@ -124,7 +124,7 @@ if (len > 0) sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len; if (sd != 0) - s = sqrt(2) * autoscale * sd; + s = sqrt (2) * autoscale * sd; else # special case of identical points with multiple vectors s = autoscale; endif @@ -349,10 +349,10 @@ else [nx, ny] = size (x); endif - dx = (max(x(:)) - min(x(:))) ./ nx; - dy = (max(y(:)) - min(y(:))) ./ ny; + dx = (max (x(:)) - min (x(:))) ./ nx; + dy = (max (y(:)) - min (y(:))) ./ ny; if (is3d) - dz = (max(z(:)) - min(z(:))) ./ max (size (z)); + dz = (max (z(:)) - min (z(:))) ./ max (size (z)); len = max (sqrt (u(:).^2 + v(:).^2 + w(:).^2)); else dz = 0; @@ -361,7 +361,7 @@ if (len > 0) sd = sqrt (dx.^2 + dy.^2 + dz.^2) / len; if (sd != 0) - s *= sqrt(2) * sd; + s *= sqrt (2) * sd; endif u = s * u; v = s * v;
--- a/scripts/plot/private/__scatter__.m +++ b/scripts/plot/private/__scatter__.m @@ -32,13 +32,13 @@ if (nd == 3) z = varargin{6}(:); - idx = isnan(x) | isnan (y) | isnan (z); + idx = isnan (x) | isnan (y) | isnan (z); x (idx) = []; y (idx) = []; z (idx) = []; istart = 7; else - idx = isnan(x) | isnan (y); + idx = isnan (x) | isnan (y); x (idx) = []; y (idx) = []; z = zeros (length (x), 0); @@ -140,7 +140,7 @@ ## For small number of points, we'll construct an object for each point. if (numel (s) == 1) - s = repmat (s, numel(x), 1); + s = repmat (s, numel (x), 1); endif if (one_explicit_color) @@ -222,11 +222,11 @@ if (! ischar (c) && rows (c) > 1) ax = get (hg, "parent"); clim = get (ax, "clim"); - if (min(c(:)) < clim(1)) - clim(1) = min(c(:)); + if (min (c(:)) < clim(1)) + clim(1) = min (c(:)); set (ax, "clim", clim); endif - if (max(c(:)) > clim(2)) + if (max (c(:)) > clim(2)) set (ax, "clim", [clim(1), max(c(:))]); endif endif @@ -259,7 +259,7 @@ endfunction -function h = render_size_color(hg, vert, s, c, marker, filled, isflat) +function h = render_size_color (hg, vert, s, c, marker, filled, isflat) if (isscalar (s)) x = vert(:,1); y = vert(:,2); @@ -273,7 +273,7 @@ if (ischar (c) || ! isflat || gnuplot_hack) if (filled) h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, - "faces", 1:numel(x), "vertices", vert, + "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markeredgecolor", "none", @@ -281,7 +281,7 @@ "markersize", s, "linestyle", "none"); else h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, - "faces", 1:numel(x), "vertices", vert, + "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markeredgecolor", c(1,:), @@ -291,7 +291,7 @@ else if (filled) h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, - "faces", 1:numel(x), "vertices", vert, + "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markersize", s, "markeredgecolor", "none", @@ -300,7 +300,7 @@ "linestyle", "none"); else h = __go_patch__ (hg, "xdata", x, "ydata", y, "zdata", z, - "faces", 1:numel(x), "vertices", vert, + "faces", 1:numel (x), "vertices", vert, "facecolor", "none", "edgecolor", "none", "marker", marker, "markersize", s, "markeredgecolor", "flat", @@ -362,14 +362,14 @@ if (isempty (z1)) for i = 1 : length (hlist) set (hlist(i), "vertices", [x1(i), y1(i)], "cdata", - reshape(c1(i,:),[1, size(c1)(2:end)]), + reshape (c1(i,:),[1, size(c1)(2:end)]), "facevertexcdata", c1(i,:), "markersize", size1(i)); endfor else for i = 1 : length (hlist) set (hlist(i), "vertices", [x1(i), y1(i), z1(i)], "cdata", - reshape(c1(i,:),[1, size(c1)(2:end)]), + reshape (c1(i,:),[1, size(c1)(2:end)]), "facevertexcdata", c1(i,:), "markersize", size1(i)); endfor
--- a/scripts/plot/private/__stem__.m +++ b/scripts/plot/private/__stem__.m @@ -147,7 +147,7 @@ if (! isempty (args)) set (hg, args{:}); endif - if (i == 1 && !isempty(h_baseline)) + if (i == 1 && ! isempty (h_baseline)) set (h_baseline, "parent", get (hg, "parent")); endif endfor @@ -296,7 +296,7 @@ error ("stem: X and Y must be matrices"); endif endif - endif # if ischar(varargin{2}) + endif # if ischar (varargin{2}) if (! have_z) ## varargin{3} must be char. ## Check for "fill. @@ -436,7 +436,7 @@ [lc, ls, mc, ms] = set_default_values (); ## Parse the line specifier string. cur_props = __pltopt__ ("stem", str, false); - for i = 1:length(cur_props) + for i = 1:length (cur_props) if (isfield (cur_props(i), "color") && ! isempty (cur_props(i).color)); # means line color mc = lc = cur_props(i).color; elseif (isfield (cur_props(i), "linestyle")) @@ -508,7 +508,7 @@ endif kids = get (h, "children"); - yt = get(h, "ydata")(:)'; + yt = get (h, "ydata")(:)'; ny = length (yt); yt = [b0 * ones(1, ny); yt; NaN(1, ny)](:); set (kids(2), "ydata", yt); @@ -532,7 +532,7 @@ if (!isempty (z) && size_equal (x, y, z)) error ("stem3: inconsistent size of x, y and z"); - elseif (numel(x) != numel (y)) + elseif (numel (x) != numel (y)) error ("stem: inconsistent size of x and y"); else bl = get (h, "basevalue");
--- a/scripts/plot/private/__tight_eps_bbox__.m +++ b/scripts/plot/private/__tight_eps_bbox__.m @@ -58,12 +58,12 @@ looking_for_bbox = true; while (looking_for_bbox) current_line = fgetl (fid); - if (strncmpi (current_line, box_string, numel(box_string))) + if (strncmpi (current_line, box_string, numel (box_string))) line_length = numel (current_line); num_spaces = line_length - numel (tight_bbox_line); if (numel (current_line) >= numel (tight_bbox_line)) new_line = tight_bbox_line; - new_line(end+1:numel(current_line)) = " "; + new_line(end+1:numel (current_line)) = " "; bbox_replaced = true; ## Back up to the beginning of the line (include EOL characters). if (ispc ()) @@ -113,12 +113,12 @@ function bbox_line = get_bbox (lines) box_string = "%%BoundingBox:"; pattern = strcat (box_string, "[^%]*"); - pattern = pattern(1:find(double(pattern)>32, 1, "last")); + pattern = pattern(1:find (double (pattern) > 32, 1, "last")); bbox_line = regexp (lines, pattern, "match"); if (iscell (bbox_line)) bbox_line = bbox_line{1}; endif ## Remove the EOL characters. - bbox_line(double(bbox_line)<32) = ""; + bbox_line(double (bbox_line) < 32) = ""; endfunction
--- a/scripts/plot/private/__uigetdir_fltk__.m +++ b/scripts/plot/private/__uigetdir_fltk__.m @@ -25,7 +25,7 @@ function dirname = __uigetdir_fltk__ (start_path, dialog_title) - if (exist("__fltk_uigetfile__") != 3) + if (exist ("__fltk_uigetfile__") != 3) error ("uigetdir: fltk graphics toolkit required"); endif
--- a/scripts/plot/private/__uigetfile_fltk__.m +++ b/scripts/plot/private/__uigetfile_fltk__.m @@ -25,7 +25,7 @@ function [retval, retpath, retindex] = __uigetfile_fltk__ (filters, title, defval, position, multiselect, defdir) - if (exist("__fltk_uigetfile__") != 3) + if (exist ("__fltk_uigetfile__") != 3) error ("uigetfile: fltk graphics toolkit required"); endif
--- a/scripts/plot/private/__uiputfile_fltk__.m +++ b/scripts/plot/private/__uiputfile_fltk__.m @@ -25,7 +25,7 @@ function [retval, retpath, retindex] = __uiputfile_fltk__ (filters, title, defval, position, tag, defdir) - if (exist("__fltk_uigetfile__") != 3) + if (exist ("__fltk_uigetfile__") != 3) error ("uiputfile: fltk graphics toolkit required"); endif
--- a/scripts/plot/quiver.m +++ b/scripts/plot/quiver.m @@ -31,7 +31,7 @@ ## ## If @var{x} and @var{y} are undefined they are assumed to be ## @code{(1:@var{m}, 1:@var{n})} where @code{[@var{m}, @var{n}] = -## size(@var{u})}. +## size (@var{u})}. ## ## The variable @var{s} is a scalar defining a scaling factor to use for ## the arrows of the field relative to the mesh spacing. A value of 0
--- a/scripts/plot/quiver3.m +++ b/scripts/plot/quiver3.m @@ -31,7 +31,7 @@ ## ## If @var{x}, @var{y} and @var{z} are undefined they are assumed to be ## @code{(1:@var{m}, 1:@var{n}, 1:@var{p})} where @code{[@var{m}, @var{n}] = -## size(@var{u})} and @code{@var{p} = max (size (@var{w}))}. +## size (@var{u})} and @code{@var{p} = max (size (@var{w}))}. ## ## The variable @var{s} is a scalar defining a scaling factor to use for ## the arrows of the field relative to the mesh spacing. A value of 0
--- a/scripts/plot/rectangle.m +++ b/scripts/plot/rectangle.m @@ -72,7 +72,7 @@ while (iarg < length (varargin)) arg = varargin{iarg}; - if (ischar(arg)) + if (ischar (arg)) if (strcmpi (arg, "position")) pos = varargin{iarg+1}; varargin(iarg:iarg+1) = [];
--- a/scripts/plot/refreshdata.m +++ b/scripts/plot/refreshdata.m @@ -82,7 +82,7 @@ for i = 1 : numel (h) obj = get (h (i)); fldnames = fieldnames (obj); - m = regexpi (fieldnames(obj), '^.+datasource$', "match"); + m = regexpi (fieldnames (obj), '^.+datasource$', "match"); idx = ! cellfun ("isempty", m); if (any (idx)) tmp = m(idx);
--- a/scripts/plot/ribbon.m +++ b/scripts/plot/ribbon.m @@ -23,7 +23,7 @@ ## Plot a ribbon plot for the columns of @var{y} vs. @var{x}. The ## optional parameter @var{width} specifies the width of a single ribbon ## (default is 0.75). If @var{x} is omitted, a vector containing the -## row numbers is assumed (1:rows(Y)). +## row numbers is assumed (1:rows (Y)). ## ## The optional return value @var{h} is a vector of graphics handles to ## the surface objects representing each ribbon.
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -80,7 +80,7 @@ x1 = xx(1:end-1) + diff (xx, 1) / 2; x1 = [x1 ; x1; x1; x1](:); th = [0; 0; x1; 2*pi ; 2*pi]; - r = zeros (4 * size (nn, 1), size (nn, 2)); + r = zeros (4 * rows (nn), columns (nn)); r(2:4:end, :) = nn; r(3:4:end, :) = nn;
--- a/scripts/plot/scatter.m +++ b/scripts/plot/scatter.m @@ -50,7 +50,7 @@ ## @group ## x = randn (100, 1); ## y = randn (100, 1); -## scatter (x, y, [], sqrt(x.^2 + y.^2)); +## scatter (x, y, [], sqrt (x.^2 + y.^2)); ## @end group ## @end example ##
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -47,7 +47,7 @@ newplot (); set (h, "yscale", "log"); - if (any( strcmp (get (gca, "nextplot"), {"new", "replace"}))) + if (any (strcmp (get (gca, "nextplot"), {"new", "replace"}))) set (h, "yminortick", "on"); endif
--- a/scripts/plot/shading.m +++ b/scripts/plot/shading.m @@ -55,7 +55,7 @@ obj = [h1(:); h2(:)]; - for n = 1:numel(obj) + for n = 1:numel (obj) h = obj(n); if (strcmpi (mode, "flat")) set (h, "facecolor", "flat");
--- a/scripts/plot/shrinkfaces.m +++ b/scripts/plot/shrinkfaces.m @@ -104,26 +104,26 @@ error ("shrinkfaces: scale factor must be a positive scalar") endif - n = size (vertices, 2); + n = columns (vertices); if (n < 2 || n > 3) error ("shrinkfaces: only 2D and 3D patches are supported") endif - m = size (faces, 2); + m = columns (faces); if (m < 3) error ("shrinkfaces: faces must consist of at least 3 vertices") endif v = vertices(faces'(:), :); - if (isempty (colors) || size (colors, 1) == size (faces, 1)) + if (isempty (colors) || rows (colors) == rows (faces)) c = colors; - elseif (size (colors, 1) == size (vertices, 1)) + elseif (rows (colors) == rows (vertices)) c = colors(faces'(:), :); else ## Discard inconsistent color data. c = []; endif - sv = size (v, 1); + sv = rows (v); ## we have to deal with a probably very large number of vertices, so ## use sparse we use as midpoint (1/m, ..., 1/m) in generalized ## barycentric coordinates.
--- a/scripts/plot/slice.m +++ b/scripts/plot/slice.m @@ -104,7 +104,7 @@ x = varargin{1}; y = varargin{2}; z = varargin{3}; - if (all ([isvector(x), isvector(y), isvector(z)])) + if (isvector (x) && isvector (y) && isvector (z)])) [x, y, z] = meshgrid (x, y, z); elseif (ndims (x) == 3 && size_equal (x, y, z)) ## Do nothing. @@ -120,7 +120,7 @@ if (any ([isvector(sx), isvector(sy), isvector(sz)])) have_sval = true; - elseif (ndims(sx) == 2 && size_equal (sx, sy, sz)) + elseif (ndims (sx) == 2 && size_equal (sx, sy, sz)) have_sval = false; else error ("slice: dimensional mismatch for (XI, YI, ZI) or (SX, SY, SZ)"); @@ -135,10 +135,10 @@ if (have_sval) ns = length (sx) + length (sy) + length (sz); - hs = zeros(ns,1); + hs = zeros (ns,1); [ny, nx, nz] = size (v); - if (length(sz) > 0) - for i = 1:length(sz) + if (length (sz) > 0) + for i = 1:length (sz) [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), squeeze (y(:,1,1)), sz(i)); vz = squeeze (interp3 (x, y, z, v, xi, yi, zi, method)); @@ -147,7 +147,7 @@ endif if (length (sy) > 0) - for i = length(sy):-1:1 + for i = length (sy):-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)); tmp(sidx++) = surface (squeeze (xi), @@ -157,7 +157,7 @@ endif if (length (sx) > 0) - for i = length(sx):-1:1 + for i = length (sx):-1:1 [xi, yi, zi] = meshgrid (sx(i), squeeze (y(:,1,1)), squeeze (z(1,1,:))); vx = squeeze (interp3 (x, y, z, v, xi, yi, zi, method)); tmp(sidx++) = surface (squeeze (sx(i) * ones (size (zi))),
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -156,7 +156,7 @@ h = []; unwind_protect hold_state = get (gca (), "nextplot"); - for i = 1 : size(y, 2) + for i = 1 : columns (y) hg = hggroup (); h = [h; hg]; args = __add_datasource__ ("stairs", hg, {"x", "y"}, varargin{:});
new file mode 100644 --- /dev/null +++ b/scripts/plot/struct2hdl.m @@ -0,0 +1,615 @@ +## Copyright (C) 2012 pdiribarne +## +## 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/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{h} =} struct2hdl (@var{s}) +## @deftypefnx {Function File} {@var{h} =} struct2hdl (@var{s}, @var{p}) +## @deftypefnx {Function File} {@var{h} =} struct2hdl (@var{s}, @var{p}, @var{hilev}) +## Constructs an object from the structure @var{s}. The structure must +## contain the fields "handle", "type", "children", "properties", and +## "special". If the handle of an existing figure or axes is specified, +## @var{p}, the new object will be created as a child to that object. +## If no object handle is provided, then a new figure and the necessary +## children will be constructed using the default object values from +## the root figure. +## +## A third boolean argument @var{hilev} can be passed to specify wether +## the function should try to preserve listeners/calbacks e.g for +## legends or hggroups. Default is false. +## @seealso{findobj, get, hdl2struct, set} +## @end deftypefn + +## Author: pdiribarne <pdiribarne@new-host.home> +## Created: 2012-03-04 + +function [ h, matchout ] = struct2hdl (hgS, matchin=[], hilev = false) + + fields = { "handle", "type", "children", "properties", "special"}; + partypes = {"root", "figure", "axes", "hggroup"}; + othertypes = {"line", "patch", "surface", "image", "text"}; + alltypes = [partypes othertypes]; + + if (nargin > 3 || ! isstruct (hgS)) + print_usage (); + elseif (! all (isfield (hgS, fields))) + print_usage (); + elseif (isscalar (matchin)) + if (! ishandle (matchin)) + error ("struct2hdl: argument #2 is not a handle to graphic object") + endif + if (any (strcmp (get (matchin).type, partypes))) + paridx = find (strcmp (get (matchin).type, alltypes)); + kididx = find (strcmp (hgS.type, alltypes)); + if (kididx <= paridx) + error ("struct2hdl: incompatible input handles") + endif + else + error ("struct2hdl: %s object can't be parent object", get (matchin).type) + endif + hpar = matchin; + matchin = [NaN; hpar]; + ## create appropriate parent if needed + if (any (strcmp (hgS.type, othertypes))) + for ii = (paridx+1) : (numel (partypes)-1) + eval (["hpar = " partypes{ii} "(\"parent\", hpar);"]); + matchin = [matchin [NaN; hpar]]; + endfor + elseif (any (strcmp (hgS.type, {"hggroup", "axes"}))) + for ii = (paridx+1) : (kididx-1) + eval (["hpar = " partypes{ii} "(\"parent\", hpar);"]); + matchin = [matchin [NaN; hpar]]; + endfor + else + par = NaN; + endif + elseif (isempty (matchin)) + if (any (strcmp (hgS.type, othertypes))) + par = axes (); + elseif (any (strcmp (hgS.type, {"hggroup", "axes"}))) + par = figure (); + else + par = NaN; + endif + matchin = [NaN; par]; + endif + ## read parent (last column) in matchin and remove it if duplicate + par = matchin (2,end); + tst = find (matchin (2,:) == par); + if (numel (tst) > 1) + matchin = matchin (1:2, 1:(tst(end)-1)); + endif + + ## create object + if (strcmpi (hgS.type, "root")) + h = 0; + hgS.properties = rmfield (hgS.properties, ... + {"callbackobject", "commandwindowsize", ... + "screendepth", "screenpixelsperinch", ... + "screensize"}); + elseif (strcmpi (hgS.type, "figure")) + h = figure (); + elseif (strcmpi (hgS.type, "axes")) + ## legends and colorbars are "transformed" in normal axes + ## if hilev is not requested + if (! hilev) + if (strcmp (hgS.properties.tag, "legend")) + hgS.properties.tag = ""; + hgS.properties.userdata = []; + par = gcf; + elseif (strcmp (hgS.properties.tag, "colorbar")) + hgS.properties.tag = ""; + hgS.properties.userdata = []; + par = gcf; + endif + endif + + [h, hgS] = createaxes (hgS, matchin, par); + elseif (strcmpi (hgS.type, "line")) + h = createline (hgS, par); + elseif (strcmpi (hgS.type, "patch")) + [h, hgS] = createpatch (hgS, par); + elseif (strcmpi (hgS.type, "text")) + h = createtext (hgS, par); + elseif (strcmpi (hgS.type, "image")) + h = createimage (hgS, par); + elseif (strcmpi (hgS.type, "surface")) + h = createsurface (hgS, par); + elseif (strcmpi (hgS.type, "hggroup")) + [h, hgS, matchin] = createhg (hgS, matchin, par, hilev); + endif + + ## children + matchin = [matchin [hgS.handle; h]]; # [original; new] + kids = hgS.children; + nkids = length (kids); + ii = 0; + while nkids + ii++; + if (! any (ii == hgS.special)) + [h2, matchin] = struct2hdl (hgS.children(ii), + [matchin [hgS.handle; h]], hilev); + endif + nkids--; + endwhile + + ## paste properties + setprops (hgS, h, matchin, hilev); + + matchout = matchin; + +endfunction + +function [h, hgSout] = createaxes (hgS, matchin, par); + ## regular axes + if (strcmpi (hgS.properties.tag, "")) + propval = {"position", hgS.properties.position}; + hid = {"autopos_tag", "looseinset"}; + for ii = 1:numel (hid) + prop = hid{ii}; + if (isfield (hgS.properties, prop)) + val = hgS.properties.(prop); + propval = [propval, prop, val]; + endif + endfor + h = axes (propval{:}, "parent", par); + + if isfield (hgS.properties, "__plotyy_axes__") + plty = hgS.properties.__plotyy_axes__; + addproperty ("__plotyy_axes__", h, "any") + tmp = [matchin [hgS.handle; h]]; + tst = arrayfun (@(x) any (plty == x), tmp (1:2:end)); + if sum (tst) == numel (plty) + for ii = 1:numel (plty) + plty(ii) = tmp (find (tmp == plty(ii)) + 1); + endfor + for ii = 1:numel (plty) + set (plty(ii), "__plotyy_axes__", plty); + endfor + endif + hgS.properties = rmfield (hgS.properties, "__plotyy_axes__"); + endif + + ## delete non-default and already set properties + fields = fieldnames (hgS.properties); + tst = cellfun (@(x) isprop (h, x), fields); + hgS.properties = rmfield (hgS.properties, fields(find (tst == 0))); + + elseif (strcmpi (hgS.properties.tag, "legend")) + ## legends + oldax = hgS.properties.userdata.handle; + idx = find (matchin == oldax); + newax = matchin(idx+1); + strings = {}; + kids = hgS.children; + kids(hgS.special) = []; + oldh = unique (arrayfun (@(x) x.properties.userdata(end), kids)); + for ii = 1:length (oldh) + idx = find (matchin(1:2:end) == oldh(ii)) * 2; + if (! isempty (idx)) + newh(ii) = matchin (idx); + if (! strcmp (get (newh(ii), "type"), "hggroup")) + str = get (newh(ii), "displayname"); + strings = [strings str]; + else + str = get (get (newh(ii), "children")(1), "displayname"); + strings = [strings str]; + endif + else + error ("struct2hdl: didn't find a legend item") + endif + endfor + location = hgS.properties.location; + orientation = hgS.properties.orientation; + textpos = hgS.properties.textposition; + box = hgS.properties.box; + + h = legend (newax, newh, strings, "location", location, ... + "orientation", orientation); + set (h, "textposition", textpos); # bug makes "textposition" + # redefine the legend + h = legend (newax, newh, strings, "location", location, ... + "orientation", orientation); + ## box + if (strcmp (box, "on")) + legend boxon + endif + + ## visibility + tst = arrayfun (@(x) strcmp (x.properties.visible, "on"), kids); + if !any (tst) + legend ("hide"); + endif + + ## remove all properties such as "textposition" that redefines + ## the entire legend. Also remove chidren + hgS.properties = rmfield (hgS.properties, ... + {"userdata", "xlabel",... + "ylabel", "zlabel", "location", ... + "title", "string","orientation", ... + "visible", "textposition"}); + + hgS.children = []; + + elseif (strcmpi (hgS.properties.tag, "colorbar")) + ## colorbar + oldax = hgS.properties.axes; + if (! isempty (idx = find (oldax == matchin))) + ax = matchin(idx+1); + location = hgS.properties.location; + h = colorbar ("peer", ax, location); + hgS.properties = rmfield (hgS.properties, ... + {"userdata", "xlabel" ... + "ylabel", "zlabel", ... + "title", "axes"}); + hgS.children= []; + else + error ("hdl2struct: didn't find an object") + endif + endif + hgSout = hgS; +endfunction + +function [h] = createline (hgS, par); + h = line ("parent", par); + addmissingprops (h, hgS.properties); +endfunction + +function [h, hgSout] = createpatch (hgS, par); + prp.faces = hgS.properties.faces; + prp.vertices = hgS.properties.vertices; + prp.facevertexcdata = hgS.properties.facevertexcdata; + h = patch (prp); + set (h, "parent", par); + hgS.properties = rmfield (hgS.properties, + {"faces", "vertices", "facevertexcdata"}); + addmissingprops (h, hgS.properties); + hgSout = hgS; +endfunction + +function [h] = createtext (hgS, par); + h = text ("parent", par); + addmissingprops (h, hgS.properties) +endfunction + +function [h] = createimage (hgS, par); + h = image ("parent", par); + addmissingprops (h, hgS.properties) +endfunction + +function [h] = createsurface (hgS, par); + h = surface ("parent", par); + addmissingprops (h, hgS.properties) +endfunction + +function [h, hgSout, matchout] = createhg (hgS, matchin, par, hilev) + ## Here we infer from properties the type of hggroup we should build + ## an call corresponding high level functions + ## We manually set "hold on" to avoid next hggroup be deleted + ## the proper value of axes "nextplot" will finally be recovered + + hold on; + if (hilev) + [h, hgS, matchin] = createhg_hilev (hgS, matchin, par); + if (numel (hgS.children) != numel (get (h).children)) + warning (["struct2hdl: couldn't infer the hggroup type. ", ... + "Will build objects but listener/callback functions ", ... + "will be lost"]); + if isfield (h, "bargroup") + delete (get (h).bargroup); + else + delete (h); + endif + h = hggroup ("parent", par); + addmissingprops (h, hgS.properties); + hgS.special = []; + else + oldkids = hgS.children; + newkids = get (h).children; + nkids = numel (oldkids); + ii = 1; + while nkids + matchin = [matchin [oldkids(ii++).handle; newkids(nkids--)]]; + endwhile + endif + else + h = hggroup ("parent", par); + addmissingprops (h, hgS.properties); + hgS.special = []; + endif + hgSout = hgS; + matchout = matchin; +endfunction + +function [h, hgSout, matchout] = createhg_hilev (hgS, matchin, par) + fields = hgS.properties; + if (isfield (fields, "contourmatrix")) + ## contours + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + zdata = hgS.properties.zdata; + levellist = hgS.properties.levellist; + textlist = hgS.properties.textlist; + + ## contour creation + if (isempty (hgS.children(1).properties.zdata)) + if (strcmpi (hgS.properties.fill, "on")) + [cm2, h] = contourf (xdata, ydata, zdata, levellist); + else + [cm2, h] = contour (xdata, ydata, zdata, levellist); + endif + + ## labels + if (strcmpi (hgS.properties.showtext, "on")) + clabel (cm2, h, textlist); + endif + else + [cm2, h] = contour3 (xdata, ydata, zdata, levellist); + endif + + ## delete already set properties and children + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", "zdata", ... + "contourmatrix", "levellist", ... + "fill", "labelspacing", ... + "levellistmode", "levelstep", ... + "levelstepmode", "textlist"... + "textlistmode" , "textstep", ... + "textstepmode", "zlevel", ... + "zlevelmode"}); + + elseif (isfield (fields, "udata") && isfield (fields, "vdata")) + ## quiver + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + + udata = hgS.properties.udata; + vdata = hgS.properties.vdata; + + h = quiver (xdata, ydata, udata, vdata); + + ## delete already set properties and children + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", "zdata", ... + "xdatasource", "ydatasource", "zdatasource", ... + "udata", "vdata", "wdata", ... + "udatasource", "vdatasource", "wdatasource"}); + + elseif (isfield (fields, "format")) + ##errorbar + form = hgS.properties.format; + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + xldata = hgS.properties.xldata; + ldata = hgS.properties.ldata; + xudata = hgS.properties.xudata; + udata = hgS.properties.udata; + + switch form + case "xerr" + h = errorbar (xdata, ydata, xldata, xudata, ">"); + case "yerr" + h = errorbar (xdata, ydata, ldata, udata, "~"); + case "xyerr" + h = errorbar (xdata, ydata, xldata, xudata, ldata, udata, "~>"); + case "box" + h = errorbar (xdata, ydata, xldata, xudata, "#"); + case "boxy" + h = errorbar (xdata, ydata, ldata, udata, "#~"); + case "boxxy" + h = errorbar (xdata, ydata, xldata, xudata, ldata, udata, "#~>"); + otherwise + error ("struct2hdl: couldn't guess the errorbar format") + endswitch + ## delete already set properties + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", ... + "xldata", "ldata", ... + "xudata", "udata", ... + "xldatasource", "ldatasource", ... + "xudatasource", "udatasource", ... + "format"}); + + elseif (isfield (fields, "bargroup")) + ## bar plot + ## FIXME - here we don't have access to brothers so we first create all + ## the barseries of the bargroup (but the last), then retrieve information, + ## and rebuild the whole bargroup. + ## The duplicate are deleted after calling "setprops" + + bargroup = hgS.properties.bargroup; + oldh = hgS.handle; + + temp = arrayfun (@(x) any(x == bargroup), [matchin(1:2:end) oldh]); + tst = sum (temp) == length (bargroup); + + if (isscalar (bargroup) || !tst) + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + + h = bar (xdata, ydata); + + ## delete already set properties, + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", ... + "xdatasource", "ydatasource", ... + "bargroup", ... + "barwidth", "baseline"}); + else + xdata = []; + ydata = []; + + ##build x/y matrix + nbar = length (bargroup); + tmp = struct ("handle", NaN,"type", "", "children", [], "special", []); + for ii = 1:(nbar - 1) + idx = find (matchin(1:2:end) == bargroup(ii)) * 2; + hdl = matchin (idx); + xdata = [xdata get(hdl).xdata]; + ydata = [ydata get(hdl).ydata]; + tmp.children(ii) = hdl2struct (hdl); + endfor + + xdata = [xdata hgS.properties.xdata]; + ydata = [ydata hgS.properties.ydata]; + width = hgS.properties.barwidth; + h = bar (ydata, width); + + ## replace previous handles in "match", copy props and delete redundant + for ii = 1:(nbar - 1) + props = tmp.children(ii).properties; + bl = props.baseline; + tmp.children(ii).properties = rmfield (props, {"baseline", "bargroup"}); + setprops (tmp.children(ii), h(ii), matchin, 1); + delete (tmp.children(ii).handle); + delete (bl); + idxpar = find (matchin == tmp.children(ii).handle); + matchin (idxpar) = h(ii); + idxkid = idxpar - 2; + matchin (idxkid) = get (h(ii), "children"); + endfor + matchin (2,((end-nbar+2):end)) = h (1:(end-1)); + h = h (end); + + ## delete already set properties , + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", "bargroup"... + "barwidth", "baseline"}); + endif + elseif (isfield (fields, "baseline")) + ## stem plot + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + + h = stem (xdata, ydata); + + ## delete already set properties, + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", ... + "xdatasource", "ydatasource", ... + "baseline"}); + elseif (isfield (fields, "basevalue")) + ## area plot + xdata = hgS.properties.xdata; + ydata = hgS.properties.ydata; + level = hgS.properties.basevalue; + + h = area (xdata, ydata, level); + + ## delete already set properties, + hgS.properties = rmfield (hgS.properties, ... + {"xdata", "ydata", ... + "xdatasource", "ydatasource"}); + else + warning ("struct2hdl: couldn't infer the hggroup type. Will build objects but listener/callback functions will be lost"); + h = hggroup ("parent", par); + addmissingprops (h, hgS.properties); + hgS.special = []; # children will be treated as normal children + endif + hgSout = hgS; + matchout = matchin; +endfunction + +function setprops (hgS, h, matchin, hilev) + more off + if (strcmpi (hgS.properties.tag, "")) + specs = hgS.children(hgS.special); + hdls = arrayfun (@(x) x.handle, specs); + nh = length(hdls); + msg = ""; + if (! nh) + set (h, hgS.properties); + else + ## Specials are objects that where automatically constructed with + ## current object. Among them are "x(yz)labels", "title", high + ## level hggroup children + fields = fieldnames (hgS.properties); + vals = struct2cell (hgS.properties); + idx = find (cellfun (@(x) valcomp(x, hdls) , vals)); + hgS.properties = rmfield (hgS.properties, fields(idx)); + + ## set all properties but special handles + set (h, hgS.properties); + + ## find props with val == (one of special handles) + nf = length (idx); + fields = fields(idx); + vals = vals(idx); + while nf + field = fields{nf}; + idx = find (hdls == vals{nf}); + spec = specs(idx); + if (isprop (h, field)) + h2 = get (h , field); + set (h2, spec.properties); + endif + nf--; + endwhile + + ## If hggroup children were created by high level functions, + ## copy only usefull properties. + if (hilev) + if (strcmpi (hgS.type, "hggroup")) + nold = numel (hgS.children); + nnew = numel (get(h).children); + + if (nold == nnew) + hnew = get(h).children; + ii = 1; + while ii <= nnew + try + set (hnew (ii), "displayname", ... + hgS.children(ii).properties.displayname); + catch + sprintf ("struct2hdl: couldn't set hggroup children #%d props.", ii) + end_try_catch + ii ++; + endwhile + + else + error ("struct2hdl: non-conformant number of children in hgggroup") + endif + endif + endif + endif + + elseif (strcmpi (hgS.properties.tag, "legend") + || strcmpi (hgS.properties.tag, "colorbar")) + set (h, hgS.properties); + endif + +endfunction + +function out = valcomp (x, hdls) + if (isfloat(x) && isscalar(x)) + out = any (x == hdls); + else + out = 0; + endif +endfunction + +function addmissingprops (h, props) + hid = {"autopos_tag", "looseinset"}; + oldfields = fieldnames (props); + curfields = fieldnames (get (h)); + missing = cellfun (@(x) !any (strcmp (x, curfields)), oldfields); + idx = find (missing); + for ii = 1:length(idx) + prop = oldfields{idx(ii)}; + if (! any (strcmp (prop, hid))) + addproperty (prop, h, "any"); + endif + endfor +endfunction
--- a/scripts/plot/subplot.m +++ b/scripts/plot/subplot.m @@ -313,7 +313,7 @@ x0 = xi .* (width + margins.column) + margins.left; y0 = yi .* (height + margins.row) + margins.bottom; - if (numel(x0) > 1) + if (numel (x0) > 1) ## subplot (row, col, m:n) x1 = max (x0(:)) + width; y1 = max (y0(:)) + height; @@ -338,14 +338,14 @@ %! xlabel (sprintf ('xlabel #%d', n)); %! ylabel (sprintf ('ylabel #%d', n)); %! title (sprintf ('title #%d', n)); -%! text (0.5, 0.5, sprintf('subplot(%d,%d,%d)', r, c, n), fmt{:}); +%! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d)', r, c, n), fmt{:}); %! axis ([0 1 0 1]); %! end %! subplot (r, c, 1:3); %! xlabel (sprintf ('xlabel #%d:%d', 1, 3)); %! ylabel (sprintf ('ylabel #%d:%d', 1, 3)); %! title (sprintf ('title #%d:%d', 1, 3)); -%! text (0.5, 0.5, sprintf('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:}); +%! text (0.5, 0.5, sprintf ('subplot(%d,%d,%d:%d)', r, c, 1, 3), fmt{:}); %! axis ([0 1 0 1]); %!demo
--- a/scripts/plot/surface.m +++ b/scripts/plot/surface.m @@ -145,7 +145,7 @@ elseif (firststring == 1) x = 1:3; y = (x).'; - c = z = eye(3); + c = z = eye (3); else bad_usage = true; endif @@ -175,8 +175,8 @@ %! assert (findobj (hf, "type", "surface"), h); %! assert (get (h, "xdata"), 1:3, eps); %! assert (get (h, "ydata"), (1:3)', eps); -%! assert (get (h, "zdata"), eye(3)); -%! assert (get (h, "cdata"), eye(3)); +%! assert (get (h, "zdata"), eye (3)); +%! assert (get (h, "cdata"), eye (3)); %! assert (get (h, "type"), "surface"); %! assert (get (h, "linestyle"), get (0, "defaultsurfacelinestyle")); %! assert (get (h, "linewidth"), get (0, "defaultsurfacelinewidth"), eps);
--- a/scripts/plot/surfl.m +++ b/scripts/plot/surfl.m @@ -151,7 +151,7 @@ ## Normalize vn. vn = vn ./ repmat (sqrt (sumsq (vn, 3)), [1, 1, 3]); - [nr, nc] = size(get(htmp, "zdata")); + [nr, nc] = size (get (htmp, "zdata")); ## Ambient, diffuse, and specular term. cdata = (r(1) * ones (nr, nc)
--- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -27,8 +27,8 @@ ## ## @example ## @group -## [@var{x}, @var{y}] = meshgrid (1:size (@var{z}, 1), -## 1:size (@var{z}, 2)); +## [@var{x}, @var{y}] = meshgrid (1:rows (@var{z}), +## 1:columns (@var{z})); ## @end group ## @end example ## @@ -62,7 +62,7 @@ if (nargin == 1) z = varargin{1}; - [x, y] = meshgrid (1:size(z,1), 1:size(z,2)); + [x, y] = meshgrid (1:rows (z), 1:columns (z)); ioff = 2; else x = varargin{1}; @@ -96,9 +96,9 @@ v.z = zz(1:end-1,2:end) - zz(2:end,1:end-1); c = cross ([u.x(:), u.y(:), u.z(:)], [v.x(:), v.y(:), v.z(:)]); - w.x = reshape (c(:,1), size(u.x)); - w.y = reshape (c(:,2), size(u.y)); - w.z = reshape (c(:,3), size(u.z)); + w.x = reshape (c(:,1), size (u.x)); + w.y = reshape (c(:,2), size (u.y)); + w.z = reshape (c(:,3), size (u.z)); ## Create normal vectors as mesh vectices from normals at mesh centers nx = (w.x(1:end-1,1:end-1) + w.x(1:end-1,2:end) +
--- a/scripts/plot/tetramesh.m +++ b/scripts/plot/tetramesh.m @@ -70,7 +70,7 @@ colmap = colormap (); if (length (reg) < 3) - size_colmap = size (colmap, 1); + size_colmap = rows (colmap); C = mod ((1:size_T)' - 1, size_colmap) + 1; if (size_T < size_colmap && size_T > 1) ## expand to the available range of colors
--- a/scripts/plot/text.m +++ b/scripts/plot/text.m @@ -57,7 +57,7 @@ ny = numel (y); nz = numel (z); if (ischar (label) || isnumeric (label)) - nt = size (label, 1); + nt = rows (label); if (nx > 1 && nt == 1) ## Mutiple text objects with same string label = repmat ({label}, [nx, 1]); @@ -134,8 +134,8 @@ %! x = [0.25 0.5 0.75]; %! y = x; %! for t = 0:30:359; -%! for nh = 1:numel(ha) -%! for nv = 1:numel(va) +%! for nh = 1:numel (ha) +%! for nv = 1:numel (va) %! text (x(nh), y(nv), 'Hello World', ... %! 'rotation', t, ... %! 'horizontalalignment', ha{nh}, ...
--- a/scripts/plot/uigetfile.m +++ b/scripts/plot/uigetfile.m @@ -81,7 +81,7 @@ error ("uigetfile: number of input arguments must be less than eight"); endif - defaultvals = {cell(0, 2), # File Filter + defaultvals = {cell (0, 2), # File Filter "Open File", # Dialog Title "", # Default file name [240, 120], # Dialog Position (pixel x/y) @@ -165,7 +165,7 @@ prop = varargin{i}; val = varargin{i + 1}; if (strncmp (tolower (prop), "position", 8)) - if (ismatrix (val) && length(val) == 2) + if (ismatrix (val) && length (val) == 2) outargs{4} = val; else error ("uigetfile: expecting 2-element vector for position argument");
--- a/scripts/plot/uiputfile.m +++ b/scripts/plot/uiputfile.m @@ -30,21 +30,21 @@ ## extracted and used as filter. ## In addition the path is selected as current path and the filename is selected ## as default file. -## Example: uiputfile("myfun.m"); +## Example: uiputfile ("myfun.m"); ## ## @item "*.ext" ## A single file extension. -## Example: uiputfile("*.ext"); +## Example: uiputfile ("*.ext"); ## ## @item @{"*.ext","My Description"@} ## A 2-column cell array containing the file extension in the 1st column and ## a brief description in the 2nd column. -## Example: uiputfile(@{"*.ext","My Description";"*.xyz","XYZ-Format"@}); +## Example: uiputfile (@{"*.ext","My Description";"*.xyz","XYZ-Format"@}); ## @end table ## ## The filter string can also contain a semicolon separated list of filter ## extensions. -## Example: uiputfile(@{"*.gif;*.png;*.jpg", "Supported Picture Formats"@}); +## Example: uiputfile (@{"*.gif;*.png;*.jpg", "Supported Picture Formats"@}); ## ## @var{dialog_name} can be used to customize the dialog title. ## If @var{default_file} is given it is preselected in the GUI dialog. @@ -72,14 +72,14 @@ print_usage (); endif - defaultvals = {cell(0, 2), # File Filter + 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); + outargs = cell (6, 1); for i = 1 : 6 outargs{i} = defaultvals{i}; endfor
--- a/scripts/plot/whitebg.m +++ b/scripts/plot/whitebg.m @@ -74,7 +74,7 @@ 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); @@ -95,21 +95,21 @@ while (numel (handles)) children = []; for n = 1 : numel (handles) - children = union (children, get(handles(n), "children")); + children = union (children, get (handles(n), "children")); endfor handles = children; h = union (h, children); endwhile - for nh = 1 : numel(h) + for nh = 1 : numel (h) p = get (h (nh)); fields = fieldnames (p); - fieldindex = find (!cellfun ("isempty", regexp(fields, 'color'))); + fieldindex = find (!cellfun ("isempty", regexp (fields, 'color'))); if (numel (fieldindex)) for nf = 1 : numel (fieldindex); field = fields {fieldindex (nf)}; c = subsref (p, struct ("type", ".", "subs", field)); - if (! ischar(c) && columns(c) == 3) + if (! ischar (c) && columns (c) == 3) set (h (nh), field, 1 - c); endif endfor @@ -121,7 +121,7 @@ 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));
--- a/scripts/polynomial/deconv.m +++ b/scripts/polynomial/deconv.m @@ -40,7 +40,7 @@ endif if (! (isvector (y) && isvector (a))) - error("deconv: both arguments must be vectors"); + error ("deconv: both arguments must be vectors"); endif la = length (a); @@ -68,7 +68,7 @@ r = y - conv (a, b); else ## Respect the orientation of Y" - if (size (y, 1) <= size (y, 2)) + if (rows (y) <= columns (y)) r = [(zeros (1, lc - ly)), y] - conv (a, b); else r = [(zeros (lc - ly, 1)); y] - conv (a, b);
--- a/scripts/polynomial/mkpp.m +++ b/scripts/polynomial/mkpp.m @@ -96,17 +96,17 @@ %!assert (pp.order, 12) %!assert (pp.dim, 1) %!assert (size (pp.coefs), [2,12]) -%! pp = mkpp(b,c,2); +%! pp = mkpp (b,c,2); %!assert (pp.pieces, 2) %!assert (pp.order, 6) %!assert (pp.dim, 2) %!assert (size (pp.coefs), [4,6]) -%! pp = mkpp(b,c,3); +%! pp = mkpp (b,c,3); %!assert (pp.pieces, 2) %!assert (pp.order, 4) %!assert (pp.dim, 3) %!assert (size (pp.coefs), [6,4]) -%! pp = mkpp(b,c,[2,3]); +%! pp = mkpp (b,c,[2,3]); %!assert (pp.pieces, 2) %!assert (pp.order, 2) %!assert (pp.dim, [2,3])
--- a/scripts/polynomial/pchip.m +++ b/scripts/polynomial/pchip.m @@ -144,8 +144,8 @@ %!assert (pchip (x,y,x'), y') %!assert (pchip (x',y',x'), y') %!assert (pchip (x',y',x), y) -%!assert (isempty (pchip(x',y',[]))) -%!assert (isempty (pchip(x,y,[]))) +%!assert (isempty (pchip (x',y',[]))) +%!assert (isempty (pchip (x,y,[]))) %!assert (pchip (x,[y;y],x), [pchip(x,y,x);pchip(x,y,x)]) %!assert (pchip (x,[y;y],x'), [pchip(x,y,x);pchip(x,y,x)]) %!assert (pchip (x',[y;y],x), [pchip(x,y,x);pchip(x,y,x)])
--- a/scripts/polynomial/polyaffine.m +++ b/scripts/polynomial/polyaffine.m @@ -73,7 +73,7 @@ %! f = [1/5 4/5 -7/5 -2]; %! g = polyaffine (f, [1, 1.2]); %! x = linspace (-4,4,100); -%! plot (x,polyval(f, x), x,polyval(g, x)); +%! plot (x,polyval (f, x), x,polyval (g, x)); %! legend ("original", "affine"); %! axis ([-4 4 -3 5]); %! grid on;
--- a/scripts/polynomial/polyder.m +++ b/scripts/polynomial/polyder.m @@ -60,7 +60,7 @@ ## remove common factors from numerator and denominator x = polygcd (q, d); - if (length(x) != 1) + if (length (x) != 1) q = deconv (q, x); d = deconv (d, x); endif
--- a/scripts/polynomial/polygcd.m +++ b/scripts/polynomial/polygcd.m @@ -23,7 +23,7 @@ ## Find the greatest common divisor of two polynomials. This is equivalent ## to the polynomial found by multiplying together all the common roots. ## Together with deconv, you can reduce a ratio of two polynomials. -## The tolerance @var{tol} defaults to @code{sqrt(eps)}. +## The tolerance @var{tol} defaults to @code{sqrt (eps)}. ## ## @strong{Caution:} This is a numerically unstable algorithm and should not ## be used on large polynomials. @@ -34,7 +34,7 @@ ## @group ## polygcd (poly (1:8), poly (3:12)) - poly (3:8) ## @result{} [ 0, 0, 0, 0, 0, 0, 0 ] -## deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))) - poly(1:2) +## deconv (poly (1:8), polygcd (poly (1:8), poly (3:12))) - poly (1:2) ## @result{} [ 0, 0, 0 ] ## @end group ## @end example
--- a/scripts/polynomial/polyout.m +++ b/scripts/polynomial/polyout.m @@ -76,7 +76,7 @@ tmp = " "; endif - if(nargout == 0) + if (nargout == 0) disp (tmp); else y = tmp;
--- a/scripts/polynomial/polyval.m +++ b/scripts/polynomial/polyval.m @@ -124,9 +124,9 @@ %! assert (x, polyval (p,x), eps); %! x = x(:); %! assert (x, polyval (p,x), eps); -%! x = reshape(x, [2, 5]); +%! x = reshape (x, [2, 5]); %! assert (x, polyval (p,x), eps); -%! x = reshape(x, [5, 2]); +%! x = reshape (x, [5, 2]); %! assert (x, polyval (p,x), eps); %! x = reshape (x, [1, 1, 5, 2]); %! assert (x, polyval (p,x), eps);
--- a/scripts/polynomial/ppint.m +++ b/scripts/polynomial/ppint.m @@ -47,7 +47,7 @@ ppi = mkpp (x, pi, d); tmp = -cumsum (ppjumps (ppi), length (d) + 1); - ppi.coefs(prod(d)+1:end, k) = tmp(:); + ppi.coefs(prod (d)+1 : end, k) = tmp(:); endfunction
--- a/scripts/polynomial/ppjumps.m +++ b/scripts/polynomial/ppjumps.m @@ -34,18 +34,18 @@ endif ## Extract info. - [x, P, n, k, d] = unmkpp(pp); + [x, P, n, k, d] = unmkpp (pp); nd = length (d) + 1; ## Offsets. - dx = diff(x(1:n)); + dx = diff (x(1:n)); dx = repmat (dx, [prod(d), 1]); dx = reshape (dx, [d, n-1]); dx = shiftdim (dx, nd - 1); ## Use Horner scheme. if (k>1) - llim = shiftdim (reshape (P(1:(n-1) * prod(d), 1), [d, n-1]), nd - 1); + llim = shiftdim (reshape (P(1:(n-1) * prod (d), 1), [d, n-1]), nd - 1); endif for i = 2 : k;
--- a/scripts/polynomial/ppval.m +++ b/scripts/polynomial/ppval.m @@ -56,7 +56,7 @@ P = reshape (P, [n, k, d]); Pidx = P(idx(:), :);#2d matrix size x: coefs*prod(d) y: prod(sxi) - if (isvector(xi)) + if (isvector (xi)) Pidx = reshape (Pidx, [xn, k, d]); Pidx = shiftdim (Pidx, 1); dimvec = [d, xn]; @@ -92,7 +92,7 @@ if (isvector (xi) && (d == 1)) yi = reshape (yi, sxi); elseif (isfield (pp, "orient") && strcmp (pp.orient, "first")) - yi = shiftdim(yi, nd); + yi = shiftdim (yi, nd); endif ##
--- a/scripts/polynomial/residue.m +++ b/scripts/polynomial/residue.m @@ -252,7 +252,7 @@ A = zeros (border+1, border+1); B = prepad (reshape (b, [numel(b), 1]), border+1, 0); - for ip = 1:numel(p) + for ip = 1:numel (p) ri = zeros (size (p)); ri(ip) = 1; A(:,ip) = prepad (rresidue (ri, p, [], toler), border+1, 0).'; @@ -286,14 +286,14 @@ endif if (numel (e)) - indx = 1:numel(p); + indx = 1:numel (p); else [e, indx] = mpoles (p, toler, 0); p = p (indx); r = r (indx); endif - indx = 1:numel(p); + indx = 1:numel (p); for n = indx pn = [1, -p(n)];
--- a/scripts/polynomial/roots.m +++ b/scripts/polynomial/roots.m @@ -81,7 +81,7 @@ if (nargin != 1 || min (size (v)) > 1) print_usage (); - elseif (any (isnan(v) | isinf(v))) + elseif (any (isnan (v) | isinf (v))) error ("roots: inputs must not contain Inf or NaN"); endif
--- a/scripts/polynomial/spline.m +++ b/scripts/polynomial/spline.m @@ -100,7 +100,7 @@ endfor complete = false; - if (size (a, 1) == n + 2) + if (rows (a) == n + 2) complete = true; dfs = a(1,:); dfe = a(end,:); @@ -108,7 +108,7 @@ endif if (! issorted (x)) - [x, idx] = sort(x); + [x, idx] = sort (x); a = a(idx,:); endif @@ -135,8 +135,8 @@ g(2:n-1,:) = (a(3:n,:) - a(2:n-1,:)) ./ h(2:n-1) - ... (a(2:n-1,:) - a(1:n-2,:)) ./ h(1:n-2); g(n,:) = dfe - (a(n,:) - a(n-1,:)) / h(n-1); - c = spdiags([[h/6;0],[h(1)/3;(h(1:n-2)+h(2:n-1))/3;h(n-1)/3],[0;h/6]],... - [-1,0,1],n,n) \ (g / 2); + c = spdiags ([[h/6;0],[h(1)/3;(h(1:n-2)+h(2:n-1))/3;h(n-1)/3],[0;h/6]],... + [-1,0,1],n,n) \ (g / 2); b(1:n-1,:) = diff (a) ./ h(1:n-1, idx) ... - h(1:n-1,idx) / 3 .* (c(2:n,:) + 2 * c(1:n-1,:)); d = diff (c) ./ (3 * h(1:n-1, idx));
--- a/scripts/polynomial/splinefit.m +++ b/scripts/polynomial/splinefit.m @@ -39,7 +39,7 @@ ## ## The optional property @var{periodic} is a logical value which specifies ## whether a periodic boundary condition is applied to the spline. The -## length of the period is @code{max(@var{breaks})-min(@var{breaks})}. +## length of the period is @code{max (@var{breaks}) - min (@var{breaks})}. ## The default value is @code{false}. ## ## The optional property @var{robust} is a logical value which specifies @@ -182,7 +182,7 @@ props = struct (); endif fields = fieldnames (props); - for f = 1:numel(fields) + for f = 1:numel (fields) if (! any (strcmp (fields{f}, {"periodic", "robust", "beta", "order", "constraints"}))) error ("splinefit:invalidproperty",
--- a/scripts/prefs/addpref.m +++ b/scripts/prefs/addpref.m @@ -45,7 +45,7 @@ endif elseif (iscellstr (pref)) if (size_equal (pref, val)) - for i = 1:numel(pref) + for i = 1:numel (pref) if (isfield (group, pref{i})) error ("preference %s already exists in group %s", pref{i}, group);
--- a/scripts/prefs/getpref.m +++ b/scripts/prefs/getpref.m @@ -69,7 +69,7 @@ endif elseif (iscellstr (pref)) if (nargin == 2 || size_equal (pref, default)) - for i = 1:numel(pref) + for i = 1:numel (pref) if (isfield (grp, pref{i})) retval.(pref) = grp.(pref{i}); elseif (nargin == 3)
--- a/scripts/prefs/setpref.m +++ b/scripts/prefs/setpref.m @@ -43,7 +43,7 @@ prefs.(group).(pref) = val; elseif (iscellstr (pref)) if (size_equal (pref, val)) - for i = 1:numel(pref) + for i = 1:numel (pref) prefs.(group).(pref{i}) = val; endfor else
--- a/scripts/set/intersect.m +++ b/scripts/set/intersect.m @@ -75,7 +75,7 @@ ib = jb(ic(ii+1) - len_a); ## b(ib) == c endif - if (nargin == 2 && (size (b, 1) == 1 || size (a, 1) == 1)) + if (nargin == 2 && (rows (b) == 1 || rows (a) == 1)) c = c.'; endif endif
--- a/scripts/set/ismember.m +++ b/scripts/set/ismember.m @@ -56,7 +56,7 @@ ## @group ## a = [1:3; 5:7; 4:6]; ## s = [0:2; 1:3; 2:4; 3:5; 4:6]; -## [tf, s_idx] = ismember(a, s, "rows") +## [tf, s_idx] = ismember (a, s, "rows") ## @result{} tf = logical ([1; 0; 1]) ## @result{} s_idx = [2; 0; 5]; ## @end group @@ -185,12 +185,12 @@ %! assert (a_idx, []); %!test -%! [result, a_idx] = ismember([1 2 3 4 5], [3]); +%! [result, a_idx] = ismember ([1 2 3 4 5], [3]); %! assert (result, logical ([0 0 1 0 0])) %! assert (a_idx , [0 0 1 0 0]); %!test -%! [result, a_idx] = ismember([1 6], [1 2 3 4 5 1 6 1]); +%! [result, a_idx] = ismember ([1 6], [1 2 3 4 5 1 6 1]); %! assert (result, [true true]); %! assert (a_idx(2), 7);
--- a/scripts/set/setdiff.m +++ b/scripts/set/setdiff.m @@ -82,7 +82,7 @@ i(idx(dups)) = []; endif ## Reshape if necessary. - if (size (c, 1) != 1 && size (b, 1) == 1) + if (rows (c) != 1 && rows (b) == 1) c = c.'; endif endif
--- a/scripts/set/setxor.m +++ b/scripts/set/setxor.m @@ -79,7 +79,7 @@ c([idx, idx+1]) = []; i([idx, idx+1]) = []; endif - if (size (a, 1) == 1 || size (b, 1) == 1) + if (rows (a) == 1 || rows (b) == 1) c = c.'; endif endif @@ -98,5 +98,5 @@ %! a = [3, 1, 4, 1, 5]; b = [1, 2, 3, 4]; %! [y, ia, ib] = setxor (a, b.'); %! assert (y, [2, 5]); -%! assert (y, sort([a(ia), b(ib)])); +%! assert (y, sort ([a(ia), b(ib)]));
--- a/scripts/set/union.m +++ b/scripts/set/union.m @@ -65,7 +65,7 @@ if (nargin == 2) y = [a(:); b(:)]; na = numel (a); nb = numel (b); - if (size (a, 1) == 1 || size (b, 1) == 1) + if (rows (a) == 1 || rows (b) == 1) y = y.'; endif else
--- a/scripts/signal/arch_fit.m +++ b/scripts/signal/arch_fit.m @@ -109,7 +109,7 @@ esq = e .^ 2; Z = autoreg_matrix (esq, p); h = Z * a; - f = esq ./ h - ones(T,1); + 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/scripts/signal/arch_rnd.m +++ b/scripts/signal/arch_rnd.m @@ -71,7 +71,7 @@ b = [b, 0]; lb = lb + 1; endif - m = max([la, lb]); + m = max ([la, lb]); e = zeros (t, 1); h = zeros (t, 1);
--- a/scripts/signal/arch_test.m +++ b/scripts/signal/arch_test.m @@ -80,9 +80,9 @@ if ((rx == 1) && (cx == 1)) x = autoreg_matrix (y, x); elseif (! (rx == T)) - error ("arch_test: either rows(X) == length(Y), or X is a scalar"); + error ("arch_test: either rows (X) == length (Y), or X is a scalar"); endif - if (! (isscalar(p) && (rem(p, 1) == 0) && (p > 0))) + if (! (isscalar (p) && (rem (p, 1) == 0) && (p > 0))) error ("arch_test: P must be a positive integer"); endif
--- a/scripts/signal/autoreg_matrix.m +++ b/scripts/signal/autoreg_matrix.m @@ -51,9 +51,9 @@ %!test %! K = 4; -%! A = zeros(1,K+1); +%! A = zeros (1,K+1); %! A(1) = 1; -%! B = eye(K+1); +%! B = eye (K+1); %! B(:,1) = 1; %! assert (autoreg_matrix (A,K), B);
--- a/scripts/signal/diffpara.m +++ b/scripts/signal/diffpara.m @@ -49,7 +49,7 @@ k = 1; x = reshape (x, n, 1); else - [n, k] = size(x); + [n, k] = size (x); endif if (nargin == 1) a = 0.5 * sqrt (n);
--- a/scripts/signal/fftconv.m +++ b/scripts/signal/fftconv.m @@ -67,8 +67,8 @@ %% FIXME: Borrow tests from conv.m. May need a tolerance on the assert comparison %!test -%! x = ones(3,1); -%! y = ones(1,3); +%! x = ones (3,1); +%! y = ones (1,3); %! b = 2; %! c = 3; %! assert (fftconv (x, x), [1; 2; 3; 2; 1], 5*eps);
--- a/scripts/signal/filter2.m +++ b/scripts/signal/filter2.m @@ -52,7 +52,7 @@ shape = "same"; endif - [nr, nc] = size(b); + [nr, nc] = size (b); y = conv2 (x, b(nr:-1:1, nc:-1:1), shape); endfunction
--- a/scripts/signal/hanning.m +++ b/scripts/signal/hanning.m @@ -59,5 +59,5 @@ %!error hanning () %!error hanning (0.5) %!error hanning (-1) -%!error hanning (ones(1,4)) +%!error hanning (ones (1,4))
--- a/scripts/signal/hurst.m +++ b/scripts/signal/hurst.m @@ -42,7 +42,7 @@ s = std (x); w = cumsum (x - mean (x)); - RS = (max(w) - min(w)) ./ s; + RS = (max (w) - min (w)) ./ s; H = log (RS) / log (xr); endfunction
--- a/scripts/signal/periodogram.m +++ b/scripts/signal/periodogram.m @@ -40,7 +40,7 @@ ## @item win: weight data with window, x.*win is used for further computation, ## if window is empty, a rectangular window is used. ## -## @item nfft: number of frequency bins, default max(256, 2.^ceil(log2(length(x)))). +## @item nfft: number of frequency bins, default max (256, 2.^ceil (log2 (length (x)))). ## ## @item Fs: sampling rate, default 1. ## @@ -108,7 +108,7 @@ if (! isempty (window)) if (all (size (x) == size (window))) x .*= window; - elseif (size (x, 1) == size (window, 1) && size (window, 2) == 1) + elseif (rows (x) == rows (window) && columns (window) == 1) x .*= window (:,ones (1,c)); endif; endif
--- a/scripts/signal/private/triangle_sw.m +++ b/scripts/signal/private/triangle_sw.m @@ -31,7 +31,7 @@ print_usage (); endif - retval = zeros(n,1); + retval = zeros (n,1); retval(1) = 1 / b; l = (2:n)' - 1;
--- a/scripts/signal/sinc.m +++ b/scripts/signal/sinc.m @@ -23,7 +23,7 @@ ## $ \sin (\pi x)/(\pi x)$. ## @end tex ## @ifnottex -## sin(pi*x)/(pi*x). +## sin (pi*x) / (pi*x). ## @end ifnottex ## @end deftypefn
--- a/scripts/signal/spectral_xdf.m +++ b/scripts/signal/spectral_xdf.m @@ -53,7 +53,7 @@ x = x - sum (x) / xr; retval = (abs (fft (x)) / xr).^2; - retval = real (ifft (fft(retval) .* fft(w))); + retval = real (ifft (fft (retval) .* fft (w))); retval = [(zeros (xr, 1)), retval]; retval(:, 1) = (0 : xr-1)' / xr;
--- a/scripts/signal/spencer.m +++ b/scripts/signal/spencer.m @@ -31,15 +31,15 @@ print_usage (); endif - [xr, xc] = size(x); + [xr, xc] = size (x); n = xr; c = xc; - if (isvector(x)) - n = length(x); + if (isvector (x)) + n = length (x); c = 1; - x = reshape(x, n, 1); + x = reshape (x, n, 1); endif w = [-3, -6, -5, 3, 21, 46, 67, 74, 67, 46, 21, 3, -5, -6, -3] / 320; @@ -47,7 +47,7 @@ retval = fftfilt (w, x); retval = [zeros(7,c); retval(15:n,:); zeros(7,c);]; - retval = reshape(retval, xr, xc); + retval = reshape (retval, xr, xc); endfunction
--- a/scripts/signal/stft.m +++ b/scripts/signal/stft.m @@ -55,7 +55,7 @@ ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> ## Description: Short-Time Fourier Transform -function [y, c] = stft(x, win_size, inc, num_coef, win_type) +function [y, c] = stft (x, win_size, inc, num_coef, win_type) ## Default values of unspecified arguments. if (nargin < 5)
--- a/scripts/signal/synthesis.m +++ b/scripts/signal/synthesis.m @@ -62,11 +62,11 @@ z = z(st:st+inc-1, :); w_coeff = w_coeff(st:st+inc-1); - nc = columns(z); + nc = columns (z); for i = 1:nc z(:, i) = z(:, i) ./ w_coeff; endfor - x = reshape(z, inc * nc, 1); + x = reshape (z, inc * nc, 1); endfunction
--- 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); @@ -90,7 +90,7 @@ endfunction -%!function t = __xassert(a,b,tol) +%!function t = __xassert (a,b,tol) %! if (nargin == 1) %! t = all (a(:)); %! else
--- a/scripts/signal/yulewalker.m +++ b/scripts/signal/yulewalker.m @@ -41,7 +41,7 @@ endif cp = c(2 : p+1); - CP = zeros(p, p); + CP = zeros (p, p); for i = 1:p for j = 1:p
--- a/scripts/sparse/bicgstab.m +++ b/scripts/sparse/bicgstab.m @@ -138,7 +138,7 @@ rr = res; ## Vector of the residual norms for each iteration. - resvec = norm(res) / norm_b; + resvec = norm (res) / norm_b; ## Default behaviour we don't reach tolerance tol within maxit iterations. flag = 1;
--- a/scripts/sparse/gmres.m +++ b/scripts/sparse/gmres.m @@ -224,7 +224,7 @@ %! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) diag (diag (A)) \ x, [], []); %! assert (x, A\b, 1e-9*norm (x, Inf)); %!test -%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x./diag(A), [], []); +%! x = gmres (@(x) A*x, b, dim, 1e-10, 1e6, @(x) x ./ diag (A), [], []); %! assert (x, A\b, 1e-7*norm (x, Inf));
--- a/scripts/sparse/pcg.m +++ b/scripts/sparse/pcg.m @@ -241,7 +241,7 @@ endif if (nargin < 4 || isempty (maxit)) - maxit = min (size (b, 1), 20); + maxit = min (rows (b), 20); endif maxit += 2; @@ -275,7 +275,7 @@ while (resvec (iter-1,1) > tol * resvec (1,1) && iter < maxit) if (exist_m1) - if(isnumeric (m1)) + if (isnumeric (m1)) y = m1 \ r; else y = feval (m1, r, varargin{:}); @@ -316,8 +316,8 @@ if (nargout > 5 && iter > 2) T(iter-1:iter, iter-1:iter) = T(iter-1:iter, iter-1:iter) + ... [1 sqrt(beta); sqrt(beta) beta]./oldalpha; - ## EVS = eig(T(2:iter-1,2:iter-1)); - ## fprintf(stderr,"PCG condest: %g (iteration: %d)\n", max(EVS)/min(EVS),iter); + ## EVS = eig (T(2:iter-1,2:iter-1)); + ## fprintf (stderr,"PCG condest: %g (iteration: %d)\n", max (EVS)/min (EVS),iter); endif resvec (iter,1) = norm (r); iter++;
--- a/scripts/sparse/pcr.m +++ b/scripts/sparse/pcr.m @@ -252,7 +252,7 @@ x += lambda*p; r -= lambda*q; - if (isnumeric(A)) # is A a matrix? + if (isnumeric (A)) # is A a matrix? t = A*s; else # then A should be a function! t = feval (A, s, varargin{:});
--- a/scripts/sparse/private/__sprand_impl__.m +++ b/scripts/sparse/private/__sprand_impl__.m @@ -39,7 +39,7 @@ return; endif - [m, n, d, funname, randfun] = deal(varargin{:}); + [m, n, d, funname, randfun] = deal (varargin{:}); if (!(isscalar (m) && m == fix (m) && m > 0)) error ("%s: M must be an integer greater than 0", funname); @@ -60,4 +60,4 @@ [i, j] = ind2sub ([m, n], idx); S = sparse (i, j, randfun (k, 1), m, n); -endfunction \ No newline at end of file +endfunction
--- a/scripts/sparse/speye.m +++ b/scripts/sparse/speye.m @@ -32,7 +32,7 @@ function s = speye (m, n) if (nargin == 1) - if (isvector (m) && length(m) == 2) + if (isvector (m) && length (m) == 2) n = m(2); m = m(1); elseif (isscalar (m))
--- a/scripts/sparse/spfun.m +++ b/scripts/sparse/spfun.m @@ -37,7 +37,7 @@ if (isa (f, "function_handle") || isa (f, "inline function")) y = sparse (i, j, f(v), m, n); else - y = sparse(i, j, feval (f, v), m, n); + y = sparse (i, j, feval (f, v), m, n); endif endfunction
--- a/scripts/sparse/sprandn.m +++ b/scripts/sparse/sprandn.m @@ -63,10 +63,10 @@ %!error sprandn () %!error sprandn (1, 2) %!error sprandn (1, 2, 3, 4) -%!error sprandn (ones(3), 3, 0.5) +%!error sprandn (ones (3), 3, 0.5) %!error sprandn (3.5, 3, 0.5) %!error sprandn (0, 3, 0.5) -%!error sprandn (3, ones(3), 0.5) +%!error sprandn (3, ones (3), 0.5) %!error sprandn (3, 3.5, 0.5) %!error sprandn (3, 0, 0.5) %!error sprandn (3, 3, -1)
--- a/scripts/sparse/spstats.m +++ b/scripts/sparse/spstats.m @@ -51,7 +51,7 @@ endif if (nargout > 2) ## FIXME Variance with count = 0 or 1? - diff = S - sparse (i, j, mean(j), n, m); + diff = S - sparse (i, j, mean (j), n, m); var = sum (diff .* diff) ./ (count - 1); endif
--- a/scripts/sparse/svds.m +++ b/scripts/sparse/svds.m @@ -85,7 +85,7 @@ ## @end example ## ## @code{svds} is best for finding only a few singular values from a large -## sparse matrix. Otherwise, @code{svd (full(@var{A}))} will likely be more +## sparse matrix. Otherwise, @code{svd (full (@var{A}))} will likely be more ## efficient. ## @end deftypefn ## @seealso{svd, eigs} @@ -98,7 +98,7 @@ print_usage (); endif - if (ndims(A) > 2) + if (ndims (A) > 2) error ("svds: A must be a 2D matrix"); endif @@ -194,7 +194,7 @@ ## norm since if we don't we might end up with too many singular ## values. tol = norma * opts.tol; - ind = find(s > tol); + ind = find (s > tol); if (length (ind) < k) ## Too few eigenvalues returned. Add in any zero eigenvalues of B, ## including the nominally negative ones. @@ -248,7 +248,7 @@ %! A = sparse ([3:n,1:n,1:(n-2)],[1:(n-2),1:n,3:n],[ones(1,n-2),0.4*n*ones(1,n),ones(1,n-2)]); %! [u,s,v] = svd (full (A)); %! s = diag (s); -%! [~, idx] = sort (abs(s)); +%! [~, idx] = sort (abs (s)); %! s = s(idx); %! u = u(:, idx); %! v = v(:, idx); @@ -272,7 +272,7 @@ %! assert (s2, s(k:-1:1), 1e-10); %! %!testif HAVE_ARPACK, HAVE_UMFPACK -%! idx = floor(n/2); +%! idx = floor (n/2); %! % Don't put sigma right on a singular value or there are convergence issues %! sigma = 0.99*s(idx) + 0.01*s(idx+1); %! [u2,s2,v2,flag] = svds (A,k,sigma,opts);
--- a/scripts/sparse/treelayout.m +++ b/scripts/sparse/treelayout.m @@ -141,7 +141,7 @@ ## We are in top level separator when we have one child and the ## flag is 1 - if (columns(idx) == 1 && top_level == 1) + if (columns (idx) == 1 && top_level == 1) s++; else # We aren't in top level separator now. @@ -152,7 +152,7 @@ left_most++; x_coordinate_r(par_number) = left_most; max_ht = min (max_ht, level); - if (length(stk) > 1 && find ((shift(stk,1)-stk) == 0) > 1 + if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1 && stk(end,2) != stk(end-1,2)) ## Return to the nearest branching the position to return ## position is the position on the stack, where should be
--- a/scripts/sparse/treeplot.m +++ b/scripts/sparse/treeplot.m @@ -116,13 +116,13 @@ left_most++; x_coordinate_r(par_number) = left_most; max_ht = min (max_ht, level); - if (length(stk) > 1 && find ((shift(stk,1)-stk) == 0) > 1 + if (length (stk) > 1 && find ((shift (stk,1) - stk) == 0) > 1 && stk(end,2) != stk(end-1,2)) ## Return to the nearest branching the position to return ## position is the position on the stack, where should be ## started further search (there are two nodes which has the ## same parent node). - position = (find ((shift(stk(:,2),1)-stk(:,2)) == 0))(end) + 1; + position = (find ((shift (stk(:,2),1) - stk(:,2)) == 0))(end) + 1; par_number_vec = stk(position:end,2); ## The vector of removed nodes (the content of stack form ## position to end). @@ -173,7 +173,7 @@ hold ("on"); ## Plot each tree component in one loop. - for i = 2:length(idx) + for i = 2:length (idx) ## Tree component start. istart = idx(i-1) + 1; ## Tree component end.
--- a/scripts/specfun/bessel.m +++ b/scripts/specfun/bessel.m @@ -27,21 +27,21 @@ ## @table @code ## @item besselj ## Bessel functions of the first kind. If the argument @var{opt} is supplied, -## the result is multiplied by @code{exp(-abs(imag(x)))}. +## the result is multiplied by @code{exp (-abs (imag (x)))}. ## ## @item bessely ## Bessel functions of the second kind. If the argument @var{opt} is supplied, -## the result is multiplied by @code{exp(-abs(imag(x)))}. +## the result is multiplied by @code{exp (-abs (imag (x)))}. ## ## @item besseli ## Modified Bessel functions of the first kind. If the argument @var{opt} is ## supplied, -## the result is multiplied by @code{exp(-abs(real(x)))}. +## the result is multiplied by @code{exp (-abs (real (x)))}. ## ## @item besselk ## Modified Bessel functions of the second kind. If the argument @var{opt} is ## supplied, -## the result is multiplied by @code{exp(x)}. +## the result is multiplied by @code{exp (x)}. ## ## @item besselh ## Compute Hankel functions of the first (@var{k} = 1) or second (@var{k}
--- a/scripts/specfun/factor.m +++ b/scripts/specfun/factor.m @@ -76,7 +76,7 @@ ## Determine muliplicity. if (nargout > 1) idx = find ([0, x] != [x, 0]); - x = x(idx(1:length(idx)-1)); + x = x(idx(1:length (idx)-1)); n = diff (idx); endif
--- a/scripts/specfun/legendre.m +++ b/scripts/specfun/legendre.m @@ -196,7 +196,7 @@ ## http://en.wikipedia.org/wiki/Associated_Legendre_function overflow = false; - retval = zeros([n+1, size(x)]); + retval = zeros ([n+1, size(x)]); for m = 1:n lpm1 = scale; lpm2 = (2*m-1) .* x .* scale; @@ -222,7 +222,7 @@ ## normalization == "sch" or normalization == "norm" scale = scale / sqrt ((n-m+1)*(n+m))*(2*m-1); endif - scale = scale .* sqrt(1-x.^2); + scale = scale .* sqrt (1-x.^2); endfor retval(n+1,:) = scale(:);
--- a/scripts/specfun/perms.m +++ b/scripts/specfun/perms.m @@ -24,7 +24,7 @@ ## result has size @code{factorial (@var{n}) * @var{n}}, where @var{n} ## is the length of @var{v}. ## -## As an example, @code{perms([1, 2, 3])} returns the matrix +## As an example, @code{perms ([1, 2, 3])} returns the matrix ## ## @example ## @group @@ -52,7 +52,7 @@ for j = 2:n B = A; A = zeros (prod (2:j), n, class (v)); - k = size (B, 1); + k = rows (B); idx = 1:k; for i = j:-1:1 A(idx,1:i-1) = B(:,1:i-1);
--- a/scripts/specfun/primes.m +++ b/scripts/specfun/primes.m @@ -31,7 +31,7 @@ ## $k \log (5 k)$. ## @end tex ## @ifnottex -## k*log(5*k). +## k*log (5*k). ## @end ifnottex ## @seealso{list_primes, isprime} ## @end deftypefn @@ -61,7 +61,7 @@ sievem = true (1, lenm); # assume every number of form 6n-1 is prime sievep = true (1, lenp); # assume every number of form 6n+1 is prime - for i = 1:(sqrt(n)+1)/6 # check up to sqrt(n) + for i = 1:(sqrt (n)+1)/6 # check up to sqrt (n) if (sievem(i)) # if i is prime, eliminate multiples of i sievem(7*i-1:6*i-1:lenm) = false; sievep(5*i-1:6*i-1:lenp) = false; @@ -71,11 +71,11 @@ sievem(5*i+1:6*i+1:lenm) = false; endif endfor - x = sort([2, 3, 6*find(sievem)-1, 6*find(sievep)+1]); + x = sort ([2, 3, 6*find(sievem)-1, 6*find(sievep)+1]); elseif (n > 352) # nothing magical about 352; must be >2 len = floor ((n-1)/2); # length of the sieve sieve = true (1, len); # assume every odd number is prime - for i = 1:(sqrt(n)-1)/2 # check up to sqrt(n) + for i = 1:(sqrt (n)-1)/2 # check up to sqrt (n) if (sieve(i)) # if i is prime, eliminate multiples of i sieve(3*i+1:2*i+1:len) = false; # do it endif
--- a/scripts/special-matrix/magic.m +++ b/scripts/special-matrix/magic.m @@ -26,7 +26,7 @@ ## Note: @var{n} must be greater than 2 for the magic square to exist. ## @end deftypefn -function A = magic(n) +function A = magic (n) if (nargin != 1) print_usage ();
--- a/scripts/special-matrix/toeplitz.m +++ b/scripts/special-matrix/toeplitz.m @@ -105,8 +105,8 @@ ridx = ridx(ridx > 1); ## Form matrix. - retval = spdiags(repmat (c(cidx),nr,1),1-cidx,nr,nc) + ... - spdiags(repmat (r(ridx),nr,1),ridx-1,nr,nc); + retval = spdiags (repmat (c(cidx),nr,1),1-cidx,nr,nc) + ... + spdiags (repmat (r(ridx),nr,1),ridx-1,nr,nc); else ## Concatenate data into a single column vector. data = [r(end:-1:2)(:); c(:)];
--- a/scripts/statistics/base/corr.m +++ b/scripts/statistics/base/corr.m @@ -101,7 +101,7 @@ %! assert (corr ([x, y]), single ([1 -1; -1 1]), 5*eps); %!assert (corr (5), 1) -%!assert (corr (single(5)), single(1)) +%!assert (corr (single (5)), single (1)) %% Test input validation %!error corr ()
--- a/scripts/statistics/base/cov.m +++ b/scripts/statistics/base/cov.m @@ -144,15 +144,15 @@ %! assert (isscalar (c)); %! assert (c, 2.5); -%!assert(cov (5), 0) -%!assert(cov (single(5)), single(0)) +%!assert (cov (5), 0) +%!assert (cov (single (5)), single (0)) %!test %! x = [1:5]; %! c = cov (x, 0); -%! assert(c, 2.5); +%! assert (c, 2.5); %! c = cov (x, 1); -%! assert(c, 2); +%! assert (c, 2); %% Test input validation %!error cov ()
--- a/scripts/statistics/base/mean.m +++ b/scripts/statistics/base/mean.m @@ -143,7 +143,7 @@ %!error mean (1, 2, 3, 4) %!error mean ({1:5}) %!error mean (1, 2, 3) -%!error mean (1, ones(2,2)) +%!error mean (1, ones (2,2)) %!error mean (1, 1.5) %!error mean (1, 0) %!error mean (1, 3)
--- a/scripts/statistics/base/median.m +++ b/scripts/statistics/base/median.m @@ -117,7 +117,7 @@ %!error median (1, 2, 3) %!error median ({1:5}) %!error median (['A'; 'B']) -%!error median (1, ones(2,2)) +%!error median (1, ones (2,2)) %!error median (1, 1.5) %!error median (1, 0)
--- a/scripts/statistics/base/mode.m +++ b/scripts/statistics/base/mode.m @@ -112,7 +112,7 @@ %! [m2, f2, c2] = mode (full (a)); %! assert (m, sparse (m2)); %! assert (f, sparse (f2)); -%! c_exp(1:length(a)) = { sparse (0) }; +%! c_exp(1:length (a)) = { sparse (0) }; %! assert (c ,c_exp); %! assert (c2,c_exp );
--- a/scripts/statistics/base/qqplot.m +++ b/scripts/statistics/base/qqplot.m @@ -58,7 +58,7 @@ print_usage (); endif - if (!(isnumeric (x) && isvector(x))) + if (!(isnumeric (x) && isvector (x))) error ("qqplot: X must be a numeric vector"); endif
--- a/scripts/statistics/base/quantile.m +++ b/scripts/statistics/base/quantile.m @@ -131,7 +131,7 @@ endif ## Set the permutation vector. - perm = 1:ndims(x); + perm = 1:ndims (x); perm(1) = dim; perm(dim) = 1;
--- a/scripts/statistics/base/ranks.m +++ b/scripts/statistics/base/ranks.m @@ -54,7 +54,7 @@ endif if (sz(dim) == 1) - y = ones(sz); + y = ones (sz); else ## The algorithm works only on dim = 1, so permute if necesary. if (dim != 1) @@ -73,7 +73,7 @@ runs = setdiff (eq_el, eq_el+1); len = diff (find (diff ([Inf; eq_el; -Inf]) != 1)) + 1; [eq_el, y] = sort (xi); - for i = 1 : length(runs) + for i = 1 : length (runs) y (xi (runs (i) + [0:(len(i)-1)]) + floor (runs (i) ./ sz(1)) * sz(1)) = eq_el(runs(i)) + (len(i) - 1) / 2; endfor
--- a/scripts/statistics/base/zscore.m +++ b/scripts/statistics/base/zscore.m @@ -52,8 +52,8 @@ if (nargin < 2) opt = 0; else - if (opt != 0 && opt != 1 || ! isscalar(opt)) - error("zscore: OPT must be empty, 0, or 1"); + if (opt != 0 && opt != 1 || ! isscalar (opt)) + error ("zscore: OPT must be empty, 0, or 1"); endif endif
--- a/scripts/statistics/models/private/logistic_regression_likelihood.m +++ b/scripts/statistics/models/private/logistic_regression_likelihood.m @@ -35,7 +35,7 @@ e = exp ([z, x] * beta); e1 = exp ([z1, x] * beta); g = e ./ (1 + e); g1 = e1 ./ (1 + e1); - g = max (y == max (y), g); g1 = min (y > min(y), g1); + g = max (y == max (y), g); g1 = min (y > min (y), g1); p = g - g1; dev = -2 * sum (log (p));
--- a/scripts/statistics/tests/bartlett_test.m +++ b/scripts/statistics/tests/bartlett_test.m @@ -61,7 +61,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - printf(" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction
--- a/scripts/statistics/tests/chisquare_test_homogeneity.m +++ b/scripts/statistics/tests/chisquare_test_homogeneity.m @@ -42,7 +42,7 @@ print_usage (); endif - if (! (isvector(x) && isvector(y) && isvector(c))) + if (! (isvector (x) && isvector (y) && isvector (c))) error ("chisquare_test_homogeneity: X, Y and C must be vectors"); endif ## Now test c for strictly increasing entries @@ -57,12 +57,12 @@ n_x = sum (x * ones (1, df+1) < ones (l_x, 1) * c); l_y = length (y); y = reshape (y, l_y, 1); - n_y = sum(y * ones (1, df+1) < ones (l_y, 1) * c); + n_y = sum (y * ones (1, df+1) < ones (l_y, 1) * c); chisq = l_x * l_y * sum ((n_x/l_x - n_y/l_y).^2 ./ (n_x + n_y)); pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - printf(" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction
--- a/scripts/statistics/tests/chisquare_test_independence.m +++ b/scripts/statistics/tests/chisquare_test_independence.m @@ -47,7 +47,7 @@ pval = 1 - chi2cdf (chisq, df); if (nargout == 0) - printf(" pval: %g\n", pval); + printf (" pval: %g\n", pval); endif endfunction
--- a/scripts/statistics/tests/kolmogorov_smirnov_test.m +++ b/scripts/statistics/tests/kolmogorov_smirnov_test.m @@ -28,7 +28,7 @@ ## a uniform distribution on [2,4], use ## ## @example -## kolmogorov_smirnov_test(x, "unif", 2, 4) +## kolmogorov_smirnov_test (x, "unif", 2, 4) ## @end example ## ## @noindent
--- a/scripts/statistics/tests/run_test.m +++ b/scripts/statistics/tests/run_test.m @@ -46,13 +46,13 @@ b = [1/6; 5/24; 11/120; 19/720; 29/5040; 1/840]; n = rows (x); - r = run_count (x, 6) - n * b * ones (1, columns(x)); + r = run_count (x, 6) - n * b * ones (1, columns (x)); chisq = diag (r' * A * r)' / n; pval = chi2cdf (chisq, 6); if (nargout == 0) - printf("pval: %g\n", pval); + printf ("pval: %g\n", pval); endif endfunction
--- a/scripts/statistics/tests/u_test.m +++ b/scripts/statistics/tests/u_test.m @@ -66,7 +66,7 @@ endif if (! ischar (alt)) - error("u_test: ALT must be a string"); + error ("u_test: ALT must be a string"); endif if (strcmp (alt, "!=") || strcmp (alt, "<>")) pval = 2 * min (cdf, 1 - cdf);
--- a/scripts/statistics/tests/wilcoxon_test.m +++ b/scripts/statistics/tests/wilcoxon_test.m @@ -73,7 +73,7 @@ endif if (! ischar (alt)) - error("wilcoxon_test: ALT must be a string"); + error ("wilcoxon_test: ALT must be a string"); elseif (strcmp (alt, "!=") || strcmp (alt, "<>")) pval = 2 * min (cdf, 1 - cdf); elseif (strcmp (alt, ">"))
--- a/scripts/statistics/tests/z_test.m +++ b/scripts/statistics/tests/z_test.m @@ -79,8 +79,8 @@ if (nargout == 0) s = cstrcat ("Z-test of mean(x) == %g against mean(x) %s %g,\n", - "with known var(x) == %g:\n", - " pval = %g\n"); + "with known var(x) == %g:\n", + " pval = %g\n"); printf (s, m, alt, m, v, pval); endif
--- a/scripts/statistics/tests/z_test_2.m +++ b/scripts/statistics/tests/z_test_2.m @@ -48,7 +48,7 @@ endif if (! (isvector (x) && isvector (y))) - error("z_test_2: both X and Y must be vectors"); + error ("z_test_2: both X and Y must be vectors"); elseif (! (isscalar (v_x) && (v_x > 0) && isscalar (v_y) && (v_y > 0))) error ("z_test_2: both V_X and V_Y must be positive scalars"); @@ -79,9 +79,9 @@ if (nargout == 0) s = cstrcat ("Two-sample Z-test of mean(x) == mean(y) against ", - "mean(x) %s mean(y),\n", - "with known var(x) == %g and var(y) == %g:\n", - " pval = %g\n"); + "mean(x) %s mean(y),\n", + "with known var(x) == %g and var(y) == %g:\n", + " pval = %g\n"); printf (s, alt, v_x, v_y, pval); endif
--- a/scripts/strings/bin2dec.m +++ b/scripts/strings/bin2dec.m @@ -60,10 +60,10 @@ endfunction -%!assert(bin2dec ("0000"), 0) -%!assert(bin2dec ("1110"), 14) -%!assert(bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) -%!assert(bin2dec ({"1110", "1111"}), [14; 15]) +%!assert (bin2dec ("0000"), 0) +%!assert (bin2dec ("1110"), 14) +%!assert (bin2dec ("11111111111111111111111111111111111111111111111111111"), 2^53-1) +%!assert (bin2dec ({"1110", "1111"}), [14; 15]) %!assert (bin2dec ("1 0 1"), 5) %!assert (bin2dec (char ("1 0 1", " 1111")), [5; 15])
--- a/scripts/strings/dec2base.m +++ b/scripts/strings/dec2base.m @@ -161,7 +161,7 @@ %!error dec2base (1.1) %!error dec2base (1, "ABA") %!error dec2base (1, "A B") -%!error dec2base (1, ones(2)) +%!error dec2base (1, ones (2)) %!error dec2base (1, 1) %!error dec2base (1, 37)
--- a/scripts/strings/mat2str.m +++ b/scripts/strings/mat2str.m @@ -41,7 +41,7 @@ ## mat2str ([ -1/3 +i/7; 1/3 -i/7 ], [4 2]) ## @result{} "[-0.3333+0i 0+0.14i;0.3333+0i -0-0.14i]" ## -## mat2str (int16([1 -1]), "class") +## mat2str (int16 ([1 -1]), "class") ## @result{} "int16([1 -1])" ## ## mat2str (logical (eye (2))) @@ -143,5 +143,5 @@ %!error mat2str () %!error mat2str (1,2,3,4) %!error mat2str (["Hello"]) -%!error <X must be two dimensional> mat2str (ones(3,3,2)) +%!error <X must be two dimensional> mat2str (ones (3,3,2))
--- a/scripts/strings/strcat.m +++ b/scripts/strings/strcat.m @@ -143,8 +143,8 @@ %!assert (all (strcmp (strcat ({"a", "bb"}, "ccc"), {"accc", "bbccc"}))) %!assert (all (strcmp (strcat ("a", {"bb", "ccc"}), {"abb", "accc"}))) -%!assert (strcat (1, 2), strcat (char(1), char(2))) -%!assert (strcat ("", 2), strcat ([], char(2))) +%!assert (strcat (1, 2), strcat (char (1), char (2))) +%!assert (strcat ("", 2), strcat ([], char (2))) %!error strcat ()
--- a/scripts/strings/strchr.m +++ b/scripts/strings/strchr.m @@ -53,7 +53,7 @@ ## Index the str into a mask of valid values. ## This is slower than it could be because of the +1 issue. f = false (256, 1); - f(uint8(chars)+1) = true; + f(uint8 (chars) + 1) = true; ## Default goes via double -- unnecessarily long. si = uint32 (str); ## in-place is faster than str+1
--- a/scripts/strings/strjust.m +++ b/scripts/strings/strjust.m @@ -87,7 +87,7 @@ endif ## Adjust the column indices. - jdx += shift(idx); + jdx += shift (idx); ## Create a blank matrix and position the nonblank characters. y = repmat (" ", nr, nc);
--- a/scripts/strings/strtok.m +++ b/scripts/strings/strtok.m @@ -75,7 +75,7 @@ ## Index the str into a mask of valid values. Faster for large N. f = false (256, 1); ## This is slower than it could be because of the +1 issue. - f(uint8(delim)+1) = true; + f(uint8 (delim)+1) = true; ## Default goes via double -- unnecessarily long. si = uint32 (str); ## in-place is faster than str+1 @@ -146,7 +146,7 @@ %! endif %! printf ("<%s>", s(1)); %! endwhile -%! printf("\n"); +%! printf ("\n"); %! % ---------------------------------------------------- %! % Demonstrates processing of an entire string split on %! % a variety of delimiters. Tokens and delimiters are
--- a/scripts/strings/substr.m +++ b/scripts/strings/substr.m @@ -103,8 +103,8 @@ %!error substr () %!error substr ("foo", 2, 3, 4) %!error substr (ones (5, 1), 1, 1) -%!error substr ("foo", ones(2,2)) -%!error substr ("foo", 1, ones(2,2)) +%!error substr ("foo", ones (2,2)) +%!error substr ("foo", 1, ones (2,2)) %!error substr ("foo", 0) %!error substr ("foo", 5) %!error substr ("foo", 1, 5)
--- a/scripts/strings/untabify.m +++ b/scripts/strings/untabify.m @@ -82,10 +82,10 @@ nr = rows (t); sc = cell (nr, 1); for j = 1:nr - n = 1:numel(t(j,:)); + n = 1:numel (t(j,:)); m = find (t(j,:) == "\t"); t(j,m) = " "; - for i = 1:numel(m) + for i = 1:numel (m) k = tw * ceil (n(m(i)) / tw); dn = k - n(m(i)); n(m(i):end) += dn;
--- a/scripts/testfun/assert.m +++ b/scripts/testfun/assert.m @@ -43,10 +43,10 @@ ## Produce an error if observed is not the same as expected but equality ## comparison for numeric data uses a tolerance @var{tol}. ## If @var{tol} is positive then it is an absolute tolerance which will produce -## an error if @code{abs(@var{observed} - @var{expected}) > abs(@var{tol})}. +## an error if @code{abs (@var{observed} - @var{expected}) > abs (@var{tol})}. ## If @var{tol} is negative then it is a relative tolerance which will produce -## an error if @code{abs(@var{observed} - @var{expected}) > -## abs(@var{tol} * @var{expected})}. If @var{expected} is zero @var{tol} will +## an error if @code{abs (@var{observed} - @var{expected}) > +## abs (@var{tol} * @var{expected})}. If @var{expected} is zero @var{tol} will ## always be interpreted as an absolute tolerance. ## @end table ## @seealso{test, fail, error} @@ -249,9 +249,9 @@ %!assert (isempty ([])) %!assert (1) %!error assert (0) -%!assert (ones(3,1)) -%!assert (ones(1,3)) -%!assert (ones(3,4)) +%!assert (ones (3,1)) +%!assert (ones (1,3)) +%!assert (ones (3,4)) %!error assert ([1,0,1]) %!error assert ([1;1;0]) %!error assert ([1,0;1,1])
--- a/scripts/testfun/demo.m +++ b/scripts/testfun/demo.m @@ -65,7 +65,7 @@ ## Also, because demo evaluates within a function context, you cannot ## define new functions inside a demo. If you must have function blocks, ## rather than just anonymous functions or inline functions, you will have to -## use @code{eval(example("function",n))} to see them. Because eval only +## use @code{eval (example ("function",n))} to see them. Because eval only ## evaluates one line, or one statement if the statement crosses ## multiple lines, you must wrap your demo in "if 1 <demo stuff> endif" ## with the 'if' on the same line as 'demo'. For example: @@ -112,7 +112,7 @@ if (n > 0) doidx = n; else - doidx = 1:length(idx)-1; + doidx = 1:(length (idx) - 1); endif for i = 1:length (doidx) ## Pause between demos
--- a/scripts/testfun/example.m +++ b/scripts/testfun/example.m @@ -65,13 +65,13 @@ if (n > 0) doidx = n; else - doidx = 1:length(idx)-1; + doidx = 1:length (idx) - 1; endif if (isempty (idx)) warning ("no example available for %s", name); return; - elseif (n >= length(idx)) - warning ("only %d examples available for %s", length(idx)-1, name); + elseif (n >= length (idx)) + warning ("only %d examples available for %s", length (idx) - 1, name); return; endif
--- a/scripts/testfun/fail.m +++ b/scripts/testfun/fail.m @@ -44,7 +44,7 @@ ## The angle brackets are not part of the output. ## ## Called with three arguments, the behavior is similar to -## @code{fail(@var{code}, @var{pattern})}, but produces an error if no +## @code{fail (@var{code}, @var{pattern})}, but produces an error if no ## warning is given during code execution or if the code fails. ## @seealso{assert} ## @end deftypefn @@ -70,7 +70,7 @@ pattern = "."; endif - ## allow assert(fail()) + ## allow assert (fail ()) if (nargout) ret = 1; endif @@ -83,9 +83,9 @@ state = warning ("query", "quiet"); warning ("on", "quiet"); try - ## printf("lastwarn before %s: %s\n",code,lastwarn); + ## printf ("lastwarn before %s: %s\n",code,lastwarn); evalin ("caller", sprintf ("%s;", code)); - ## printf("lastwarn after %s: %s\n",code,lastwarn); + ## printf ("lastwarn after %s: %s\n",code,lastwarn); ## Retrieve new warnings. err = lastwarn (); warning (state.state, "quiet"); @@ -131,15 +131,15 @@ %!fail ("[1,2]*[2,3]", "nonconformant") -%!fail ("fail('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none") -%!fail ("fail('[1,2]*[2,3]','usage:')", "expected error <usage:>\nbut got.*nonconformant") -%!fail ("warning('test warning')", "warning", "test warning"); +%!fail ("fail ('[1,2]*[2;3]', 'nonconformant')", "expected error <nonconformant> but got none") +%!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 %!error fail ("1") %!error <undefined> fail ("a*[2;3]", "nonconformant") %!error <expected error> fail ("a*[2,3]", "usage:") -%!error <warning failure> fail ("warning('warning failure')", "warning", "success") +%!error <warning failure> fail ("warning ('warning failure')", "warning", "success")
--- a/scripts/testfun/speed.m +++ b/scripts/testfun/speed.m @@ -323,13 +323,13 @@ endif v = polyval (p, log (__test_n(tailidx))); - loglog (__test_n(tailidx), exp(v)*1000, sprintf ("b;%s;", order)); + loglog (__test_n(tailidx), exp (v) * 1000, sprintf ("b;%s;", order)); title ({"Time Complexity", __f1}); xlabel ("test length"); ## Get base time to 1 digit of accuracy. dt = exp (p(2)); - dt = floor (dt/10^floor(log10(dt)))*10^floor(log10(dt)); + dt = floor (dt/10^floor (log10 (dt)))*10^floor (log10 (dt)); if (log10 (dt) >= -0.5) time = sprintf ("%g s", dt); elseif (log10 (dt) >= -3.5) @@ -379,7 +379,7 @@ %! eval (fstr_build); %! %! disp ("Preallocated vector test.\nThis takes a little while..."); -%! speed("build (n)", "", 1000, "build_orig (n)"); +%! speed ("build (n)", "", 1000, "build_orig (n)"); %! clear -f build build_orig %! disp ("-----------------------"); %! disp ("Note how much faster it is to pre-allocate a vector."); @@ -408,7 +408,7 @@ %! eval (fstr_build); %! %! disp ("Vectorized test.\nThis takes a little while..."); -%! speed("build (n)", "", 1000, "build_orig (n)"); +%! speed ("build (n)", "", 1000, "build_orig (n)"); %! clear -f build build_orig %! disp ("-----------------------"); %! disp ("This time, the for loop is done away with entirely.");
--- a/scripts/testfun/test.m +++ b/scripts/testfun/test.m @@ -145,7 +145,7 @@ fprintf (__fid, "# success (in which case no error will be reported).\n"); fflush (__fid); if (__close_fid) - fclose(__fid); + fclose (__fid); endif return; else @@ -184,7 +184,7 @@ endif endif if (__close_fid) - fclose(__fid); + fclose (__fid); endif return; endif @@ -204,12 +204,12 @@ endif endif if (__close_fid) - fclose(__fid); + fclose (__fid); endif return; else ## Add a dummy comment block to the end for ease of indexing. - if (__body (length(__body)) == "\n") + if (__body (length (__body)) == "\n") __body = sprintf ("\n%s#", __body); else __body = sprintf ("\n%s\n#", __body); @@ -233,7 +233,7 @@ __shared = " "; __shared_r = " "; __clear = ""; - for __i = 1:length(__blockidx)-1 + for __i = 1:length (__blockidx)-1 ## Extract the block. __block = __body(__blockidx(__i):__blockidx(__i+1)-2); @@ -251,7 +251,7 @@ __code = ""; else __type = __block(1:__idx(1)-1); - __code = __block(__idx(1):length(__block)); + __code = __block(__idx(1):length (__block)); endif ## Assume the block will succeed. @@ -270,11 +270,11 @@ __istest = 0; if (__grabdemo && __isdemo) - if (isempty(__demo_code)) + if (isempty (__demo_code)) __demo_code = __code; __demo_idx = [1, length(__demo_code)+1]; else - __demo_code = cstrcat(__demo_code, __code); + __demo_code = cstrcat (__demo_code, __code); __demo_idx = [__demo_idx, length(__demo_code)+1]; endif @@ -306,7 +306,7 @@ __code = ""; else __vars = __code (1:__idx(1)-1); - __code = __code (__idx(1):length(__code)); + __code = __code (__idx(1):length (__code)); endif ## Strip comments off the variables. @@ -354,7 +354,7 @@ __name = __block(__name_position(1):__name_position(2)); __code = __block; try - eval(__code); ## Define the function + eval (__code); ## Define the function __clear = sprintf ("%sclear %s;\n", __clear, __name); catch __success = 0; @@ -382,7 +382,7 @@ ### ERROR/WARNING - elseif (strcmp (__type, "error") || strcmp(__type, "warning")) + elseif (strcmp (__type, "error") || strcmp (__type, "warning")) __istest = 1; __warning = strcmp (__type, "warning"); [__pattern, __id, __code] = getpattern (__code); @@ -547,7 +547,7 @@ __ret1 = __ret2 = 0; endif if (__close_fid) - fclose(__fid); + fclose (__fid); endif return; endif @@ -644,7 +644,7 @@ ## Strip leading blanks from string. function str = trimleft (str) idx = find (isspace (str)); - leading = find (idx == 1:length(idx)); + leading = find (idx == 1:length (idx)); if (! isempty (leading)) str = str(leading(end)+1:end); endif @@ -666,7 +666,7 @@ ln = fgetl (fid); if (length (ln) >= 2 && strcmp (ln(1:2), "%!")) body = [body, "\n"]; - if (length(ln) > 2) + if (length (ln) > 2) body = cstrcat (body, ln(3:end)); endif endif @@ -683,29 +683,29 @@ ### Disable this test to avoid spurious skipped test for "make check" % !testif HAVE_FOOBAR % ! ## missing feature. Fail if this test is run -% ! error("Failed missing feature test"); +% ! error ("Failed missing feature test"); ### Test for a known failure -%!xtest error("This test is known to fail") +%!xtest error ("This test is known to fail") ### example from toeplitz %!shared msg1,msg2 %! msg1="C must be a vector"; %! msg2="C and R must be vectors"; -%!fail ('toeplitz([])', msg1); -%!fail ('toeplitz([1,2;3,4])', msg1); -%!fail ('toeplitz([1,2],[])', msg2); -%!fail ('toeplitz([1,2],[1,2;3,4])', msg2); +%!fail ('toeplitz ([])', msg1); +%!fail ('toeplitz ([1,2;3,4])', msg1); +%!fail ('toeplitz ([1,2],[])', msg2); +%!fail ('toeplitz ([1,2],[1,2;3,4])', msg2); %!fail ('toeplitz ([1,2;3,4],[1,2])', msg2); % !fail ('toeplitz','usage: toeplitz'); # usage doesn't generate an error -% !fail ('toeplitz(1, 2, 3)', 'usage: toeplitz'); +% !fail ('toeplitz (1, 2, 3)', 'usage: toeplitz'); %!test assert (toeplitz ([1,2,3], [1,4]), [1,4; 2,1; 3,2]); %!demo toeplitz ([1,2,3,4],[1,5,6]) ### example from kron %!#error kron # FIXME suppress these until we can handle output %!#error kron(1,2,3) -%!test assert (isempty (kron ([], rand(3, 4)))) +%!test assert (isempty (kron ([], rand (3, 4)))) %!test assert (isempty (kron (rand (3, 4), []))) %!test assert (isempty (kron ([], []))) %!shared A, B @@ -729,16 +729,16 @@ ### an extended demo from specgram %!#demo %! ## Speech spectrogram -%! [x, Fs] = auload(file_in_loadpath("sample.wav")); # audio file -%! step = fix(5*Fs/1000); # one spectral slice every 5 ms -%! window = fix(40*Fs/1000); # 40 ms data window -%! fftn = 2^nextpow2(window); # next highest power of 2 -%! [S, f, t] = specgram(x, fftn, Fs, window, window-step); -%! S = abs(S(2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz. -%! S = S/max(max(S)); # normalize magnitude so that max is 0 dB. -%! S = max(S, 10^(-40/10)); # clip below -40 dB. -%! S = min(S, 10^(-3/10)); # clip above -3 dB. -%! imagesc(flipud(20*log10(S)), 1); +%! [x, Fs] = auload (file_in_loadpath ("sample.wav")); # audio file +%! step = fix (5*Fs/1000); # one spectral slice every 5 ms +%! window = fix (40*Fs/1000); # 40 ms data window +%! fftn = 2^nextpow2 (window); # next highest power of 2 +%! [S, f, t] = specgram (x, fftn, Fs, window, window-step); +%! S = abs (S (2:fftn*4000/Fs,:)); # magnitude in range 0<f<=4000 Hz. +%! S = S/max(max(S)); # normalize magnitude so that max is 0 dB. +%! S = max (S, 10^(-40/10)); # clip below -40 dB. +%! S = min (S, 10^(-3/10)); # clip above -3 dB. +%! imagesc (flipud (20*log10 (S)), 1); %! % you should now see a spectrogram in the image window @@ -746,62 +746,62 @@ %!## usage and error testing % !fail ('test','usage.*test') # no args, generates usage() -% !fail ('test(1,2,3,4)','usage.*test') # too many args, generates usage() -%!fail ('test("test", "bogus")','unknown flag') # incorrect args +% !fail ('test (1,2,3,4)','usage.*test') # too many args, generates usage() +%!fail ('test ("test", "bogus")','unknown flag') # incorrect args %!fail ('garbage','garbage.*undefined') # usage on nonexistent function should be %!error test # no args, generates usage() -%!error test(1,2,3,4) # too many args, generates usage() -%!error <unknown flag> test("test", 'bogus'); # incorrect args, generates error() +%!error test (1,2,3,4) # too many args, generates usage() +%!error <unknown flag> test ("test", 'bogus'); # incorrect args, generates error() %!error <garbage' undefined> garbage # usage on nonexistent function should be -%!error test("test", 'bogus'); # test without pattern +%!error test ("test", 'bogus'); # test without pattern %!test %! lastwarn(); # clear last warning just in case -%!warning <warning message> warning('warning message'); +%!warning <warning message> warning ('warning message'); %!## test of shared variables %!shared a # create a shared variable %!test a=3; # assign to a shared variable -%!test assert(a,3) # variable should equal 3 +%!test assert (a,3) # variable should equal 3 %!shared b,c # replace shared variables -%!test assert (!exist("a")); # a no longer exists -%!test assert (isempty(b)); # variables start off empty +%!test assert (!exist ("a")); # 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 +%!test assert (isempty (a)); # value is empty even if it had a previous value %!test a=1; b=2; c=3; # give values to all variables %!test assert ([a,b,c],[1,2,3]); # test all of them together %!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")) # show that they are cleared -%!shared a,b,c # support for initializer shorthand +%!test assert ([a, b, c],[1, 2, 6]); # show that the update sticks +%!shared # clear all shared variables +%!test assert (!exist ("a")) # show that they are cleared +%!shared a,b,c # support for initializer shorthand %! a=1; b=2; c=4; -%!function x = __test_a(y) +%!function x = __test_a (y) %! x = 2*y; %!endfunction -%!assert(__test_a(2),4); # Test a test function +%!assert (__test_a (2),4); # Test a test function %!function __test_a (y) %! x = 2*y; %!endfunction %!test -%! __test_a(2); # Test a test function with no return value +%! __test_a (2); # Test a test function with no return value %!function [x,z] = __test_a (y) %! x = 2*y; %! z = 3*y; %!endfunction %!test # Test a test function with multiple returns -%! [x,z] = __test_a(3); -%! assert(x,6); -%! assert(z,9); +%! [x,z] = __test_a (3); +%! assert (x,6); +%! assert (z,9); %!## test of assert block -%!assert (isempty([])) # support for test assert shorthand +%!assert (isempty ([])) # support for test assert shorthand %!## demo blocks %!demo # multiline demo block
--- a/scripts/time/now.m +++ b/scripts/time/now.m @@ -47,7 +47,7 @@ ## divided by 86400 sec/day plus day num for 1970-1-1 ## t = (time - mktime(gmtime(0)))/86400 + 719529; ## - ## mktime(gmtime(0)) does indeed return the offset from Greenwich to the + ## mktime (gmtime (0)) does indeed return the offset from Greenwich to the ## local time zone, but we need to account for daylight savings time ## changing by an hour the offset from CUT for part of the year.
--- a/src/DLD-FUNCTIONS/eig.cc +++ b/src/DLD-FUNCTIONS/eig.cc @@ -39,12 +39,12 @@ @deftypefnx {Loadable Function} {@var{lambda} =} eig (@var{A}, @var{B})\n\ @deftypefnx {Loadable Function} {[@var{V}, @var{lambda}] =} eig (@var{A})\n\ @deftypefnx {Loadable Function} {[@var{V}, @var{lambda}] =} eig (@var{A}, @var{B})\n\ -Compute the eigenvalues and eigenvectors of a matrix.\n\ +Compute the eigenvalues (and optionally the eigenvectors) of a matrix\n\ +or a pair of matrices\n\ \n\ -Eigenvalues are computed in a several step process which begins with a\n\ -Hessenberg decomposition, followed by a Schur@tie{}decomposition, from which\n\ -the eigenvalues are apparent. The eigenvectors, when desired, are computed\n\ -by further manipulations of the Schur@tie{}decomposition.\n\ +The algorithm used depends on whether there are one or two input\n\ +matrices, if they are real or complex and if they are symmetric\n\ +(Hermitian if complex) or nonsymmetric.\n\ \n\ The eigenvalues returned by @code{eig} are not ordered.\n\ @seealso{eigs, svd}\n\
--- a/src/DLD-FUNCTIONS/qz.cc +++ b/src/DLD-FUNCTIONS/qz.cc @@ -534,7 +534,7 @@ ComplexMatrix CQ(nn,nn), CZ(nn,nn), CVR(nn,nn), CVL(nn,nn); octave_idx_type ilo, ihi, info; char compq = (nargout >= 3 ? 'V' : 'N'); - char compz = (nargout >= 4 ? 'V' : 'N'); + char compz = ((nargout >= 4 || nargin == 3)? 'V' : 'N'); // Initialize Q, Z to identity if we need either of them. if (compq == 'V' || compz == 'V') @@ -1182,7 +1182,12 @@ case 3: if (nargin == 3) - retval(2) = CZ; + { + if (complex_case) + retval(2) = CZ; + else + retval(2) = ZZ; + } else { if (complex_case) @@ -1264,5 +1269,10 @@ %! assert (q * a * z, aa, norm (aa) * 1e-14); %! assert (q * b * z, bb, norm (bb) * 1e-14); -## FIXME: Still need a test for third form of calling qz +%!test +%! A = [0, 0, -1, 0; 1, 0, 0, 0; -1, 0, -2, -1; 0, -1, 1, 0]; +%! B = [0, 0, 0, 0; 0, 1, 0, 0; 0, 0, 1, 0; 0, 0, 0, 1]; +%! [AA, BB, Q, Z1] = qz (A, B); +%! [AA, BB, Z2] = qz (A, B, '-'); +%! assert (Z1, Z2); */
--- a/src/DLD-FUNCTIONS/symrcm.cc +++ b/src/DLD-FUNCTIONS/symrcm.cc @@ -135,9 +135,7 @@ if (smallest != j) { - CMK_Node tmp = A[j]; - A[j] = A[smallest]; - A[smallest] = tmp; + std::swap (A[j], A[smallest]); j = smallest; } else @@ -161,9 +159,7 @@ octave_idx_type p = PARENT(i); if (H[i].deg < H[p].deg) { - CMK_Node tmp = H[i]; - H[i] = H[p]; - H[p] = tmp; + std::swap (H[i], H[p]); i = p; } @@ -699,11 +695,7 @@ // compute the reverse-ordering s = N / 2 - 1; for (octave_idx_type i = 0, j = N - 1; i <= s; i++, j--) - { - double tmp = P.elem (i); - P.elem (i) = P.elem (j); - P.elem (j) = tmp; - } + std::swap (P.elem (i), P.elem (j)); // increment all indices, since Octave is not C return octave_value (P+1);
--- a/src/bitfcns.cc +++ b/src/bitfcns.cc @@ -72,8 +72,8 @@ template <typename OP, typename T> octave_value -bitopxx(const OP& op, const std::string& fname, - const Array<T>& x, const Array<T>& y) +bitopxx (const OP& op, const std::string& fname, + const Array<T>& x, const Array<T>& y) { int nelx = x.numel (); int nely = y.numel (); @@ -98,9 +98,9 @@ for (int i = 0; i < nelx; i++) if (is_scalar_op) for (int k = 0; k < nely; k++) - result(i+k) = op(x(i), y(k)); + result(i+k) = op (x(i), y(k)); else - result(i) = op(x(i), y(i)); + result(i) = op (x(i), y(i)); retval = result; } @@ -117,7 +117,7 @@ // information about which integer types we need to instantiate. template<typename T> octave_value -bitopx(const std::string& fname, const Array<T>& x, const Array<T>& y) +bitopx (const std::string& fname, const Array<T>& x, const Array<T>& y) { if (fname == "bitand") return bitopxx (std::bit_and<T>(), fname, x, y); @@ -129,7 +129,7 @@ } octave_value -bitop(const std::string& fname, const octave_value_list& args) +bitop (const std::string& fname, const octave_value_list& args) { octave_value retval;
--- a/src/comment-list.cc +++ b/src/comment-list.cc @@ -88,7 +88,7 @@ octave_comment_buffer::do_append (const std::string& s, octave_comment_elt::comment_type t) { - comment_list->append(s, t); + comment_list->append (s, t); } octave_comment_list *
--- a/src/data.cc +++ b/src/data.cc @@ -1834,7 +1834,7 @@ for (int j = 0; j < n_args; j++) { // Can't fast return here to skip empty matrices as something - // like cat(1,[],single([])) must return an empty matrix of + // like cat (1,[],single ([])) must return an empty matrix of // the right type. tmp = do_cat_op (tmp, args (j), ra_idx); @@ -2340,7 +2340,7 @@ @deftypefn {Built-in Function} {} permute (@var{A}, @var{perm})\n\ Return the generalized transpose for an N-D array object @var{A}.\n\ The permutation vector @var{perm} must contain the elements\n\ -@code{1:ndims(A)} (in any order, but each element must appear only once).\n\ +@code{1:ndims (A)} (in any order, but each element must appear only once).\n\ @seealso{ipermute}\n\ @end deftypefn") { @@ -3100,10 +3100,10 @@ for (octave_idx_type j = 0; j < nc; j++) { octave_idx_type off = j * nr; - for (octave_idx_type i = im_val.cidx(j); - i < im_val.cidx(j + 1); i++) - result.data (im_val.ridx(i) + off) = - result.data (im_val.ridx(i) + off) + + for (octave_idx_type i = im_val.cidx (j); + i < im_val.cidx (j + 1); i++) + result.data (im_val.ridx (i) + off) = + result.data (im_val.ridx (i) + off) + Complex (0, im_val.data (i)); } } @@ -3123,10 +3123,10 @@ for (octave_idx_type j = 0; j < nc; j++) { octave_idx_type off = j * nr; - for (octave_idx_type i = re_val.cidx(j); - i < re_val.cidx(j + 1); i++) - result.data (re_val.ridx(i) + off) = - result.data (re_val.ridx(i) + off) + + for (octave_idx_type i = re_val.cidx (j); + i < re_val.cidx (j + 1); i++) + result.data (re_val.ridx (i) + off) = + result.data (re_val.ridx (i) + off) + re_val.data (i); } }
--- a/src/defun.cc +++ b/src/defun.cc @@ -194,7 +194,7 @@ for (int i = 0; i < nout; i++) isargout[i] = true; - for (int i = std::max(nargout, 1); i < nout; i++) + for (int i = std::max (nargout, 1); i < nout; i++) isargout[i] = false; }
--- a/src/error.cc +++ b/src/error.cc @@ -850,8 +850,8 @@ { if (err.contains ("message") && err.contains ("identifier")) { - std::string msg = err.contents("message").string_value (); - std::string id = err.contents("identifier").string_value (); + std::string msg = err.contents ("message").string_value (); + std::string id = err.contents ("identifier").string_value (); int len = msg.length (); std::string file; @@ -863,21 +863,21 @@ if (err.contains ("stack")) { - err_stack = err.contents("stack").map_value (); + err_stack = err.contents ("stack").map_value (); if (err_stack.numel () > 0) { if (err_stack.contains ("file")) - file = err_stack.contents("file")(0).string_value (); + file = err_stack.contents ("file")(0).string_value (); if (err_stack.contains ("name")) - nm = err_stack.contents("name")(0).string_value (); + nm = err_stack.contents ("name")(0).string_value (); if (err_stack.contains ("line")) - l = err_stack.contents("line")(0).nint_value (); + l = err_stack.contents ("line")(0).nint_value (); if (err_stack.contains ("column")) - c = err_stack.contents("column")(0).nint_value (); + c = err_stack.contents ("column")(0).nint_value (); } } @@ -1585,7 +1585,7 @@ Vlast_error_stack = initialize_last_error_stack (); } else - error("lasterror: unrecognized string argument"); + error ("lasterror: unrecognized string argument"); } else if (args(0).is_map ()) { @@ -1600,47 +1600,47 @@ if (! error_state && new_err.contains ("message")) { const std::string tmp = - new_err.getfield("message").string_value (); + new_err.getfield ("message").string_value (); new_error_message = tmp; } if (! error_state && new_err.contains ("identifier")) { const std::string tmp = - new_err.getfield("identifier").string_value (); + new_err.getfield ("identifier").string_value (); new_error_id = tmp; } if (! error_state && new_err.contains ("stack")) { octave_scalar_map new_err_stack = - new_err.getfield("stack").scalar_map_value (); + new_err.getfield ("stack").scalar_map_value (); if (! error_state && new_err_stack.contains ("file")) { const std::string tmp = - new_err_stack.getfield("file").string_value (); + new_err_stack.getfield ("file").string_value (); new_error_file = tmp; } if (! error_state && new_err_stack.contains ("name")) { const std::string tmp = - new_err_stack.getfield("name").string_value (); + new_err_stack.getfield ("name").string_value (); new_error_name = tmp; } if (! error_state && new_err_stack.contains ("line")) { const int tmp = - new_err_stack.getfield("line").nint_value (); + new_err_stack.getfield ("line").nint_value (); new_error_line = tmp; } if (! error_state && new_err_stack.contains ("column")) { const int tmp = - new_err_stack.getfield("column").nint_value (); + new_err_stack.getfield ("column").nint_value (); new_error_column = tmp; } }
--- a/src/gl-render.cc +++ b/src/gl-render.cc @@ -416,7 +416,7 @@ protected: void begin (GLenum type) { - //printf("patch_tesselator::begin (%d)\n", type); + //printf ("patch_tesselator::begin (%d)\n", type); first = true; if (color_mode == 2 || light_mode == 2) @@ -432,7 +432,7 @@ void end (void) { - //printf("patch_tesselator::end\n"); + //printf ("patch_tesselator::end\n"); glEnd (); renderer->set_polygon_offset (false); } @@ -441,7 +441,7 @@ { vertex_data::vertex_data_rep *v = reinterpret_cast<vertex_data::vertex_data_rep *> (data); - //printf("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2)); + //printf ("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2)); // FIXME: why did I need to keep the first vertex of the face // in JHandles? I think it's related to the fact that the @@ -481,7 +481,7 @@ void combine (GLdouble xyz[3], void *data[4], GLfloat w[4], void **out_data) { - //printf("patch_tesselator::combine\n"); + //printf ("patch_tesselator::combine\n"); vertex_data::vertex_data_rep *v[4]; int vmax = 4; @@ -508,14 +508,14 @@ cc.resize (1, 3, 0.0); for (int ic = 0; ic < 3; ic++) for (int iv = 0; iv < vmax; iv++) - cc(ic) += (w[iv] * v[iv]->color(ic)); + cc(ic) += (w[iv] * v[iv]->color (ic)); } if (v[0]->normal.numel () > 0) { for (int in = 0; in < 3; in++) for (int iv = 0; iv < vmax; iv++) - nn(in) += (w[iv] * v[iv]->normal(in)); + nn(in) += (w[iv] * v[iv]->normal (in)); } for (int iv = 0; iv < vmax; iv++) @@ -807,7 +807,7 @@ glMatrixMode (GL_MODELVIEW); glLoadIdentity (); - glScaled(1, 1, -1); + glScaled (1, 1, -1); glMultMatrixd (x_mat1.data ()); glMatrixMode (GL_PROJECTION); glLoadIdentity (); @@ -1016,14 +1016,14 @@ { render_tickmarks (xticks, x_min, x_max, ypTick, ypTick, zpTick, zpTickN, 0., 0., - signum(zpTick-zpTickN)*fz*xticklen, + signum (zpTick-zpTickN)*fz*xticklen, 0, mirror); } else { render_tickmarks (xticks, x_min, x_max, ypTick, ypTickN, zpTick, zpTick, 0., - signum(ypTick-ypTickN)*fy*xticklen, + signum (ypTick-ypTickN)*fy*xticklen, 0., 0, mirror); } @@ -1035,11 +1035,11 @@ if (tick_along_z) render_ticktexts (xticks, xticklabels, x_min, x_max, ypTick, - zpTick+signum(zpTick-zpTickN)*fz*xtickoffset, + zpTick+signum (zpTick-zpTickN)*fz*xtickoffset, 0, halign, valign, wmax, hmax); else render_ticktexts (xticks, xticklabels, x_min, x_max, - ypTick+signum(ypTick-ypTickN)*fy*xtickoffset, + ypTick+signum (ypTick-ypTickN)*fy*xtickoffset, zpTick, 0, halign, valign, wmax, hmax); } @@ -1055,12 +1055,12 @@ if (tick_along_z) render_tickmarks (xmticks, x_min, x_max, ypTick, ypTick, zpTick, zpTickN, 0., 0., - signum(zpTick-zpTickN)*fz*xticklen/2, + signum (zpTick-zpTickN)*fz*xticklen/2, 0, mirror); else render_tickmarks (xmticks, x_min, x_max, ypTick, ypTickN, zpTick, zpTick, 0., - signum(ypTick-ypTickN)*fy*xticklen/2, + signum (ypTick-ypTickN)*fy*xticklen/2, 0., 0, mirror); } @@ -1123,12 +1123,12 @@ if (tick_along_z) render_tickmarks (yticks, y_min, y_max, xpTick, xpTick, zpTick, zpTickN, 0., 0., - signum(zpTick-zpTickN)*fz*yticklen, + signum (zpTick-zpTickN)*fz*yticklen, 1, mirror); else render_tickmarks (yticks, y_min, y_max, xpTick, xpTickN, zpTick, zpTick, - signum(xPlaneN-xPlane)*fx*yticklen, + signum (xPlaneN-xPlane)*fx*yticklen, 0., 0., 1, mirror); // tick texts @@ -1140,11 +1140,11 @@ if (tick_along_z) render_ticktexts (yticks, yticklabels, y_min, y_max, xpTick, - zpTick+signum(zpTick-zpTickN)*fz*ytickoffset, + zpTick+signum (zpTick-zpTickN)*fz*ytickoffset, 1, halign, valign, wmax, hmax); else render_ticktexts (yticks, yticklabels, y_min, y_max, - xpTick+signum(xpTick-xpTickN)*fx*ytickoffset, + xpTick+signum (xpTick-xpTickN)*fx*ytickoffset, zpTick, 1, halign, valign, wmax, hmax); } @@ -1160,12 +1160,12 @@ if (tick_along_z) render_tickmarks (ymticks, y_min, y_max, xpTick, xpTick, zpTick, zpTickN, 0., 0., - signum(zpTick-zpTickN)*fz*yticklen/2, + signum (zpTick-zpTickN)*fz*yticklen/2, 1, mirror); else render_tickmarks (ymticks, y_min, y_max, xpTick, xpTickN, zpTick, zpTick, - signum(xpTick-xpTickN)*fx*yticklen/2, + signum (xpTick-xpTickN)*fx*yticklen/2, 0., 0., 1, mirror); } @@ -1220,12 +1220,12 @@ if (xisinf (fy)) render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, yPlane, yPlane, - signum(xPlaneN-xPlane)*fx*zticklen, + signum (xPlaneN-xPlane)*fx*zticklen, 0., 0., 2, mirror); else render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlaneN, yPlane, yPlane, 0., - signum(yPlane-yPlaneN)*fy*zticklen, + signum (yPlane-yPlaneN)*fy*zticklen, 0., 2, false); } else @@ -1233,12 +1233,12 @@ if (xisinf (fx)) render_tickmarks (zticks, z_min, z_max, xPlaneN, xPlane, yPlaneN, yPlane, 0., - signum(yPlaneN-yPlane)*fy*zticklen, + signum (yPlaneN-yPlane)*fy*zticklen, 0., 2, mirror); else render_tickmarks (zticks, z_min, z_max, xPlane, xPlane, yPlaneN, yPlane, - signum(xPlane-xPlaneN)*fx*zticklen, + signum (xPlane-xPlaneN)*fx*zticklen, 0., 0., 2, false); } @@ -1252,22 +1252,22 @@ { if (xisinf (fy)) render_ticktexts (zticks, zticklabels, z_min, z_max, - xPlaneN+signum(xPlaneN-xPlane)*fx*ztickoffset, + xPlaneN+signum (xPlaneN-xPlane)*fx*ztickoffset, yPlane, 2, halign, valign, wmax, hmax); else render_ticktexts (zticks, zticklabels, z_min, z_max, xPlaneN, - yPlane+signum(yPlane-yPlaneN)*fy*ztickoffset, + yPlane+signum (yPlane-yPlaneN)*fy*ztickoffset, 2, halign, valign, wmax, hmax); } else { if (xisinf (fx)) render_ticktexts (zticks, zticklabels, z_min, z_max, xPlane, - yPlaneN+signum(yPlaneN-yPlane)*fy*ztickoffset, + yPlaneN+signum (yPlaneN-yPlane)*fy*ztickoffset, 2, halign, valign, wmax, hmax); else render_ticktexts (zticks, zticklabels, z_min, z_max, - xPlane+signum(xPlane-xPlaneN)*fx*ztickoffset, + xPlane+signum (xPlane-xPlaneN)*fx*ztickoffset, yPlaneN, 2, halign, valign, wmax, hmax); } } @@ -1285,12 +1285,12 @@ if (xisinf (fy)) render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlane, yPlane, yPlane, - signum(xPlaneN-xPlane)*fx*zticklen/2, + signum (xPlaneN-xPlane)*fx*zticklen/2, 0., 0., 2, mirror); else render_tickmarks (zmticks, z_min, z_max, xPlaneN, xPlaneN, yPlane, yPlane, 0., - signum(yPlane-yPlaneN)*fy*zticklen/2, + signum (yPlane-yPlaneN)*fy*zticklen/2, 0., 2, false); } else @@ -1298,12 +1298,12 @@ if (xisinf (fx)) render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane, yPlaneN, yPlane, 0., - signum(yPlaneN-yPlane)*fy*zticklen/2, + signum (yPlaneN-yPlane)*fy*zticklen/2, 0., 2, mirror); else render_tickmarks (zmticks, z_min, z_max, xPlane, xPlane, yPlaneN, yPlaneN, - signum(xPlane-xPlaneN)*fx*zticklen/2, + signum (xPlane-xPlaneN)*fx*zticklen/2, 0., 0., 2, false); } } @@ -2104,16 +2104,16 @@ bool has_facecolor = false; bool has_facealpha = false; - int fc_mode = ((props.facecolor_is("none") + int fc_mode = ((props.facecolor_is ("none") || props.facecolor_is_rgb ()) ? 0 : - (props.facecolor_is("flat") ? 1 : 2)); + (props.facecolor_is ("flat") ? 1 : 2)); int fl_mode = (props.facelighting_is ("none") ? 0 : (props.facelighting_is ("flat") ? 1 : 2)); int fa_mode = (props.facealpha_is_double () ? 0 : (props.facealpha_is ("flat") ? 1 : 2)); - int ec_mode = ((props.edgecolor_is("none") + int ec_mode = ((props.edgecolor_is ("none") || props.edgecolor_is_rgb ()) ? 0 : - (props.edgecolor_is("flat") ? 1 : 2)); + (props.edgecolor_is ("flat") ? 1 : 2)); int el_mode = (props.edgelighting_is ("none") ? 0 : (props.edgelighting_is ("flat") ? 1 : 2)); int ea_mode = (props.edgealpha_is_double () ? 0 : @@ -2469,7 +2469,7 @@ glEnable (GL_BLEND); glEnable (GL_ALPHA_TEST); glRasterPos3d (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0); - glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0); + glBitmap (0, 0, 0, 0, bbox(0), bbox(1), 0); glDrawPixels (bbox(2), bbox(3), GL_RGBA, GL_UNSIGNED_BYTE, props.get_pixels ().data ()); glDisable (GL_ALPHA_TEST); @@ -2553,7 +2553,7 @@ else // clip to viewport { GLfloat vp[4]; - glGetFloatv(GL_VIEWPORT, vp); + glGetFloatv (GL_VIEWPORT, vp); // FIXME -- actually add the code to do it! } @@ -2862,7 +2862,7 @@ glEnd (); break; case 'x': - glBegin(GL_LINES); + glBegin (GL_LINES); glVertex2f (-sz/2, -sz/2); glVertex2f (sz/2, sz/2); glVertex2f (-sz/2, sz/2); @@ -2887,7 +2887,7 @@ glBegin (GL_POLYGON); for (double ang = 0; ang < (2*M_PI); ang += ang_step) - glVertex2d (sz*cos(ang)/3, sz*sin(ang)/3); + glVertex2d (sz*cos (ang)/3, sz*sin (ang)/3); glEnd (); } break; @@ -2905,7 +2905,7 @@ glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); for (double ang = 0; ang < (2*M_PI); ang += ang_step) - glVertex2d (sz*cos(ang)/2, sz*sin(ang)/2); + glVertex2d (sz*cos (ang)/2, sz*sin (ang)/2); glEnd (); } break; @@ -2949,14 +2949,14 @@ { double ang; double r; - double dr = 1.0 - sin(M_PI/10)/sin(3*M_PI/10)*1.02; + double dr = 1.0 - sin (M_PI/10)/sin (3*M_PI/10)*1.02; glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); for (int i = 0; i < 2*5; i++) { ang = (-0.5 + double(i+1)/5) * M_PI; - r = 1.0 - (dr * fmod(double(i+1), 2.0)); - glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2); + r = 1.0 - (dr * fmod (double(i+1), 2.0)); + glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2); } glEnd (); } @@ -2965,14 +2965,14 @@ { double ang; double r; - double dr = 1.0 - 0.5/sin(M_PI/3)*1.02; + double dr = 1.0 - 0.5/sin (M_PI/3)*1.02; glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); for (int i = 0; i < 2*6; i++) { ang = (0.5 + double(i+1)/6.0) * M_PI; - r = 1.0 - (dr * fmod(double(i+1), 2.0)); - glVertex2d (sz*r*cos(ang)/2, sz*r*sin(ang)/2); + r = 1.0 - (dr * fmod (double(i+1), 2.0)); + glVertex2d (sz*r*cos (ang)/2, sz*r*sin (ang)/2); } glEnd (); }
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -1041,23 +1041,23 @@ std::transform (str.begin (), str.end (), str.begin (), tolower); - if (str.compare(0, len, "blue", 0, len) == 0) + if (str.compare (0, len, "blue", 0, len) == 0) tmp_rgb[2] = 1; - else if (str.compare(0, len, "black", 0, len) == 0 - || str.compare(0, len, "k", 0, len) == 0) + else if (str.compare (0, len, "black", 0, len) == 0 + || str.compare (0, len, "k", 0, len) == 0) tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; - else if (str.compare(0, len, "red", 0, len) == 0) + else if (str.compare (0, len, "red", 0, len) == 0) tmp_rgb[0] = 1; - else if (str.compare(0, len, "green", 0, len) == 0) + else if (str.compare (0, len, "green", 0, len) == 0) tmp_rgb[1] = 1; - else if (str.compare(0, len, "yellow", 0, len) == 0) + else if (str.compare (0, len, "yellow", 0, len) == 0) tmp_rgb[0] = tmp_rgb[1] = 1; - else if (str.compare(0, len, "magenta", 0, len) == 0) + else if (str.compare (0, len, "magenta", 0, len) == 0) tmp_rgb[0] = tmp_rgb[2] = 1; - else if (str.compare(0, len, "cyan", 0, len) == 0) + else if (str.compare (0, len, "cyan", 0, len) == 0) tmp_rgb[1] = tmp_rgb[2] = 1; - else if (str.compare(0, len, "white", 0, len) == 0 - || str.compare(0, len, "w", 0, len) == 0) + else if (str.compare (0, len, "white", 0, len) == 0 + || str.compare (0, len, "w", 0, len) == 0) tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; else retval = false; @@ -1123,7 +1123,7 @@ if (m.numel () == 3) { - color_values col (m (0), m (1), m(2)); + color_values col (m(0), m(1), m(2)); if (! error_state) { if (current_type != color_t || col != color_val) @@ -1983,7 +1983,7 @@ { if (names.numel () != values.columns ()) { - error("set: number of names must match number of value columns (%d != %d)", + error ("set: number of names must match number of value columns (%d != %d)", names.numel (), values.columns ()); } @@ -3963,20 +3963,20 @@ { axes::properties& props = dynamic_cast<axes::properties&> (go.get_properties ()); - if (props.autopos_tag_is("subplot")) + if (props.autopos_tag_is ("subplot")) { Matrix outpos = go.get ("outerposition").matrix_value (); - bool l_align=(std::abs (outpos(0)-ref_outbox(0)) < 1e-15); - bool b_align=(std::abs (outpos(1)-ref_outbox(1)) < 1e-15); - bool r_align=(std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15); - bool t_align=(std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15); + bool l_align = (std::abs (outpos(0)-ref_outbox(0)) < 1e-15); + bool b_align = (std::abs (outpos(1)-ref_outbox(1)) < 1e-15); + bool r_align = (std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15); + bool t_align = (std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15); if (l_align || b_align || r_align || t_align) { - aligned.push_back(kids(i)); - l_aligned.push_back(l_align); - b_aligned.push_back(b_align); - r_aligned.push_back(r_align); - t_aligned.push_back(t_align); + aligned.push_back (kids(i)); + l_aligned.push_back (l_align); + b_aligned.push_back (b_align); + r_aligned.push_back (r_align); + t_aligned.push_back (t_align); // FIXME: the temporarily deleted tags should be // protected from interrupts props.set_autopos_tag ("none"); @@ -3985,7 +3985,7 @@ } } // Determine a minimum box which aligns the subplots - Matrix ref_box(1, 4, 0.); + Matrix ref_box (1, 4, 0.); ref_box(2) = 1.; ref_box(3) = 1.; for (size_t i = 0; i < aligned.size (); i++) @@ -4540,7 +4540,7 @@ inline void normalize (ColumnVector& v) { - double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); + double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); scale (v, fact, fact, fact); } @@ -4579,7 +4579,7 @@ 0,1,1,1, 1,1,1,1}; Matrix m (4, 8); - memcpy (m.fortran_vec (), data, sizeof(double)*32); + memcpy (m.fortran_vec (), data, sizeof (double)*32); return m; } @@ -4587,7 +4587,7 @@ cam2xform (const Array<double>& m) { ColumnVector retval (4, 1.0); - memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); + memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3); return retval; } @@ -4618,7 +4618,7 @@ && cameratargetmode_is ("auto") && cameraupvectormode_is ("auto") && cameraviewanglemode_is ("auto")); - bool dowarp = (autocam && dataaspectratiomode_is("auto") + bool dowarp = (autocam && dataaspectratiomode_is ("auto") && plotboxaspectratiomode_is ("auto")); ColumnVector c_eye (xform_vector ()); @@ -4640,17 +4640,17 @@ { Matrix tview = get_view ().matrix_value (); double az = tview(0), el = tview(1); - double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); + double d = 5 * sqrt (pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); if (el == 90 || el == -90) - c_eye(2) = d*signum(el); + c_eye(2) = d*signum (el); else { az *= M_PI/180.0; el *= M_PI/180.0; - c_eye(0) = d*cos(el)*sin(az); - c_eye(1) = -d*cos(el)*cos(az); - c_eye(2) = d*sin(el); + c_eye(0) = d * cos (el) * sin (az); + c_eye(1) = -d* cos (el) * cos (az); + c_eye(2) = d * sin (el); } c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0); c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1); @@ -4669,9 +4669,9 @@ if (el == 90 || el == -90) { c_upv(0) = - -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); + -signum (el) *sin (az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); c_upv(1) = - signum(el)*cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1); + signum (el) * cos (az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1); } else c_upv(2) = 1; @@ -4708,7 +4708,7 @@ if (std::abs (dot (f, UP)) > 1e-15) { - double fa = 1/sqrt(1-f(2)*f(2)); + double fa = 1 / sqrt(1-f(2)*f(2)); scale (UP, fa, fa, fa); } @@ -4866,7 +4866,7 @@ xPlane = (dir(2) < 0 ? x_min : x_max); xPlaneN = (xPlane == x_min ? x_max : x_min); - fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); + fx = (x_max-x_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1)); p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false); p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false); @@ -4894,11 +4894,11 @@ yPlane = (dir(2) < 0 ? y_min : y_max); yPlaneN = (yPlane == y_min ? y_max : y_min); - fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); - - p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); - p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); - dir(0) = xround(p2(0)-p1(0)); + fy = (y_max-y_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1)); + + p1 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); + p2 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); + dir(0) = xround (p2(0)-p1(0)); dir(1) = xround (p2(1)-p1(1)); dir(2) = (p2(2)-p1(2)); if (dir(0) == 0 && dir(1) == 0) @@ -4922,7 +4922,7 @@ zPlane = (dir(2) < 0 ? z_min : z_max); zPlaneN = (zPlane == z_min ? z_max : z_min); - fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); + fz = (z_max-z_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1)); unwind_protect frame; frame.protect_var (updating_axes_layout); @@ -4972,7 +4972,7 @@ } Matrix viewmat = get_view ().matrix_value (); - nearhoriz = std::abs(viewmat(1)) <= 5; + nearhoriz = std::abs (viewmat(1)) <= 5; update_ticklength (); } @@ -5079,9 +5079,9 @@ bool tick_along_z = nearhoriz || xisinf (fy); if (tick_along_z) - p(2) += (signum(zpTick-zpTickN)*fz*xtickoffset); + p(2) += (signum (zpTick-zpTickN)*fz*xtickoffset); else - p(1) += (signum(ypTick-ypTickN)*fy*xtickoffset); + p(1) += (signum (ypTick-ypTickN)*fy*xtickoffset); p = xform.transform (p(0), p(1), p(2), false); @@ -5170,9 +5170,9 @@ bool tick_along_z = nearhoriz || xisinf (fx); if (tick_along_z) - p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset); + p(2) += (signum (zpTick-zpTickN)*fz*ytickoffset); else - p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset); + p(0) += (signum (xpTick-xpTickN)*fx*ytickoffset); p = xform.transform (p(0), p(1), p(2), false); @@ -5264,18 +5264,18 @@ p = graphics_xform::xform_vector (xPlaneN, yPlane, (zpTickN+zpTick)/2); if (xisinf (fy)) - p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); + p(0) += (signum (xPlaneN-xPlane)*fx*ztickoffset); else - p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); + p(1) += (signum (yPlane-yPlaneN)*fy*ztickoffset); } else { p = graphics_xform::xform_vector (xPlane, yPlaneN, (zpTickN+zpTick)/2); if (xisinf (fx)) - p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); + p(1) += (signum (yPlaneN-yPlane)*fy*ztickoffset); else - p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); + p(0) += (signum (xPlane-xPlaneN)*fx*ztickoffset); } p = xform.transform (p(0), p(1), p(2), false); @@ -5359,7 +5359,7 @@ p = xform.untransform (p(0), p(1), p(2), true); - title_props.set_position (p.extract_n(0, 3).transpose ()); + title_props.set_position (p.extract_n (0, 3).transpose ()); title_props.set_positionmode ("auto"); } } @@ -5715,7 +5715,7 @@ double parent_height = box_pix_height; if (fontunits_is ("normalized") && parent_height <= 0) - parent_height = get_boundingbox (true).elem(3); + parent_height = get_boundingbox (true).elem (3); return convert_font_size (fs, get_fontunits (), "points", parent_height); } @@ -6303,7 +6303,7 @@ } \ else \ { \ - limits.resize(4, 1); \ + limits.resize (4, 1); \ limits(0) = min_val; \ limits(1) = max_val; \ limits(2) = min_pos; \ @@ -6831,16 +6831,16 @@ { Matrix v = get_view ().matrix_value (); - v (1) += delta_el; + v(1) += delta_el; if(v(1) > 90) v(1) = 90; if(v(1) < -90) v(1) = -90; - v (0) = fmod(v(0) - delta_az + 720,360); - - set_view(v); + v(0) = fmod (v(0) - delta_az + 720,360); + + set_view (v); update_transform (); } @@ -7057,7 +7057,7 @@ graphics_object go (gh_manager::get_object (get___myhandle__ ())); graphics_object ax (go.get_ancestor ("axes")); - parent_height = ax.get_properties ().get_boundingbox (true).elem(3); + parent_height = ax.get_properties ().get_boundingbox (true).elem (3); } return convert_font_size (fs, get_fontunits (), "points", parent_height); @@ -7274,7 +7274,7 @@ } else { - limits.resize(4,1); + limits.resize (4,1); limits(0) = min_val; limits(1) = max_val; limits(2) = min_pos; @@ -7543,7 +7543,7 @@ double parent_height = box_pix_height; if (fontunits_is ("normalized") && parent_height <= 0) - parent_height = get_boundingbox (false).elem(3); + parent_height = get_boundingbox (false).elem (3); return convert_font_size (fs, get_fontunits (), "points", parent_height); } @@ -7679,7 +7679,7 @@ double parent_height = box_pix_height; if (fontunits_is ("normalized") && parent_height <= 0) - parent_height = get_boundingbox (false).elem(3); + parent_height = get_boundingbox (false).elem (3); return convert_font_size (fs, get_fontunits (), "points", parent_height); } @@ -8428,7 +8428,7 @@ } else { - error("set: number of graphics handles must match number of value rows (%d != %d)", + error ("set: number of graphics handles must match number of value rows (%d != %d)", hcv.length (), args(2).cell_value ().rows ()); break; @@ -8926,7 +8926,7 @@ if (hnd.ok ()) { - const graphics_object& kid = gh_manager::get_object(hnd); + const graphics_object& kid = gh_manager::get_object (hnd); if (kid.valid_object ()) nd = calc_dimensions (kid); @@ -9947,11 +9947,11 @@ } static void -cleanup_waitfor_postset_listener(const octave_value& listener) +cleanup_waitfor_postset_listener (const octave_value& listener) { do_cleanup_waitfor_listener (listener, POSTSET); } static void -cleanup_waitfor_predelete_listener(const octave_value& listener) +cleanup_waitfor_predelete_listener (const octave_value& listener) { do_cleanup_waitfor_listener (listener, PREDELETE); } static octave_value_list
--- a/src/graphics.in.h +++ b/src/graphics.in.h @@ -465,7 +465,7 @@ if (found) { for (int j = i; j < l.length () - 1; j++) - l(j) = l (j + 1); + l(j) = l(j + 1); l.resize (l.length () - 1); }
--- a/src/input.cc +++ b/src/input.cc @@ -1379,7 +1379,7 @@ This can be useful for coloring the prompt. For example,\n\ \n\ @example\n\ -PS1 (\"\\\\[\\\\033[01;31m\\\\]\\\\s:\\\\#> \\\\[\\\\033[0m\\]\")\n\ +PS1 (\"\\\\[\\\\033[01;31m\\\\]\\\\s:\\\\#> \\\\[\\\\033[0m\\\\]\")\n\ @end example\n\ \n\ @noindent\n\
--- a/src/load-path.cc +++ b/src/load-path.cc @@ -532,19 +532,19 @@ { //Don't remove it if it's gonna be added again, but remove it from //list of items to add, to avoid duplicates later on - std::set<std::string>::iterator j = new_elts.find(i->dir_name); + std::set<std::string>::iterator j = new_elts.find (i->dir_name); if (j != new_elts.end ()) { - new_elts.erase(j); + new_elts.erase (j); i++; } else { //Warn if removing a default directory and not immediately adding //it back again - if(i->is_init) + if (i->is_init) warn_default_path_clobbered = true; - i = dir_info_list.erase(i); + i = dir_info_list.erase (i); } } @@ -1798,7 +1798,11 @@ // way we look for old.dir_name in sys_path to avoid // partial matches? - if (sys_path.find (old.dir_name) != std::string::npos + // Don't warn about Contents.m files since we expect + // more than one to exist in the load path. + + if (fname != "Contents.m" + && sys_path.find (old.dir_name) != std::string::npos && in_path_list (sys_path, old.dir_name)) { std::string fcn_path = file_ops::concat (dir_name, fname);
--- a/src/load-path.h +++ b/src/load-path.h @@ -297,13 +297,13 @@ // constructor for any other purpose. dir_info (void) : dir_name (), abs_dir_name (), is_relative (false), - is_init(false), dir_mtime (), dir_time_last_checked (), + is_init (false), dir_mtime (), dir_time_last_checked (), all_files (), fcn_files (), private_file_map (), method_file_map () { } dir_info (const std::string& d) : dir_name (d), abs_dir_name (), is_relative (false), - is_init(false), dir_mtime (), dir_time_last_checked (), + is_init (false), dir_mtime (), dir_time_last_checked (), all_files (), fcn_files (), private_file_map (), method_file_map () { initialize ();
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -91,7 +91,7 @@ #include "zfstream.h" #endif -// Write octave-core file if Octave crashes or is killed by a signal. +// Write octave-workspace file if Octave crashes or is killed by a signal. static bool Vcrash_dumps_octave_core = true; // The maximum amount of memory (in kilobytes) that we will attempt to @@ -99,7 +99,7 @@ static double Voctave_core_file_limit = -1.0; // The name of the Octave core file. -static std::string Voctave_core_file_name = "octave-core"; +static std::string Voctave_core_file_name = "octave-workspace"; // The default output format. May be one of "binary", "text", // "mat-binary", or "hdf5". @@ -649,7 +649,7 @@ std::string orig_fname = ""; // Function called with Matlab-style ["filename", options] syntax - if (argc > 1 && ! argv[1].empty () && argv[1].at(0) != '-') + if (argc > 1 && ! argv[1].empty () && argv[1].at (0) != '-') { orig_fname = argv[1]; i++; @@ -1001,7 +1001,7 @@ { std::string empty_str; - if (pat.match(m.key (p))) + if (pat.match (m.key (p))) { do_save (os, m.contents (p), m.key (p), empty_str, 0, fmt, save_as_floats); @@ -1751,7 +1751,7 @@ @deftypefnx {Built-in Function} {@var{old_val} =} crash_dumps_octave_core (@var{new_val})\n\ @deftypefnx {Built-in Function} {} crash_dumps_octave_core (@var{new_val}, \"local\")\n\ Query or set the internal variable that controls whether Octave tries\n\ -to save all current variables to the file \"octave-core\" if it\n\ +to save all current variables to the file \"octave-workspace\" if it\n\ crashes or receives a hangup, terminate or similar signal.\n\ \n\ When called from inside a function with the \"local\" option, the variable is\n\ @@ -1812,7 +1812,7 @@ @deftypefnx {Built-in Function} {} octave_core_file_name (@var{new_val}, \"local\")\n\ Query or set the internal variable that specifies the name of the file\n\ used for saving data from the top-level workspace if Octave aborts.\n\ -The default value is @code{\"octave-core\"}\n\ +The default value is @code{\"octave-workspace\"}\n\ \n\ When called from inside a function with the \"local\" option, the variable is\n\ changed locally for the function and any subroutines it calls. The original\n\
--- a/src/ls-hdf5.cc +++ b/src/ls-hdf5.cc @@ -749,7 +749,7 @@ int load_hdf5_empty (hid_t loc_id, const char *name, dim_vector &d) { - if (!hdf5_check_attr(loc_id, "OCTAVE_EMPTY_MATRIX")) + if (! hdf5_check_attr (loc_id, "OCTAVE_EMPTY_MATRIX")) return 0; hsize_t hdims, maxdims;
--- a/src/ls-mat4.cc +++ b/src/ls-mat4.cc @@ -344,18 +344,18 @@ read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt); for (octave_idx_type i = 0; i < nr - 1; i++) - r.xelem(i) = dtmp[i] - 1; + r.xelem (i) = dtmp[i] - 1; nr_new = dtmp[nr - 1]; read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt); for (octave_idx_type i = 0; i < nr - 1; i++) - c.xelem(i) = dtmp[i] - 1; + c.xelem (i) = dtmp[i] - 1; nc_new = dtmp[nr - 1]; read_mat_binary_data (is, dtmp, prec, nr - 1, swap, flt_fmt); read_mat_binary_data (is, ctmp, prec, 1, swap, flt_fmt); read_mat_binary_data (is, ctmp, prec, nr - 1, swap, flt_fmt); for (octave_idx_type i = 0; i < nr - 1; i++) - data.xelem(i) = Complex (dtmp[i], ctmp[i]); + data.xelem (i) = Complex (dtmp[i], ctmp[i]); read_mat_binary_data (is, ctmp, prec, 1, swap, flt_fmt); SparseComplexMatrix smc = SparseComplexMatrix (data, r, c, @@ -373,11 +373,11 @@ read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt); for (octave_idx_type i = 0; i < nr - 1; i++) - r.xelem(i) = dtmp[i] - 1; + r.xelem (i) = dtmp[i] - 1; nr_new = dtmp[nr - 1]; read_mat_binary_data (is, dtmp, prec, nr, swap, flt_fmt); for (octave_idx_type i = 0; i < nr - 1; i++) - c.xelem(i) = dtmp[i] - 1; + c.xelem (i) = dtmp[i] - 1; nc_new = dtmp[nr - 1]; read_mat_binary_data (is, data.fortran_vec (), prec, nr - 1, swap, flt_fmt); read_mat_binary_data (is, dtmp, prec, 1, swap, flt_fmt); @@ -509,7 +509,7 @@ for (octave_idx_type j = 0; j < ncol; j++) buf[j*nrow+i] = static_cast<double> (*s++ & 0x00FF); } - os.write (reinterpret_cast<char *> (buf), nrow*ncol*sizeof(double)); + os.write (reinterpret_cast<char *> (buf), nrow*ncol*sizeof (double)); } else if (tc.is_range ()) { @@ -537,27 +537,27 @@ SparseComplexMatrix m = tc.sparse_complex_matrix_value (); for (octave_idx_type i = 0; i < len; i++) - dtmp [i] = m.ridx(i) + 1; + dtmp[i] = m.ridx (i) + 1; os.write (reinterpret_cast<const char *> (dtmp), 8 * len); ds = nr; os.write (reinterpret_cast<const char *> (&ds), 8); octave_idx_type ii = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++) + for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++) dtmp[ii++] = j + 1; os.write (reinterpret_cast<const char *> (dtmp), 8 * len); ds = nc; os.write (reinterpret_cast<const char *> (&ds), 8); for (octave_idx_type i = 0; i < len; i++) - dtmp [i] = std::real (m.data(i)); + dtmp[i] = std::real (m.data (i)); os.write (reinterpret_cast<const char *> (dtmp), 8 * len); ds = 0.; os.write (reinterpret_cast<const char *> (&ds), 8); for (octave_idx_type i = 0; i < len; i++) - dtmp [i] = std::imag (m.data(i)); + dtmp[i] = std::imag (m.data (i)); os.write (reinterpret_cast<const char *> (dtmp), 8 * len); os.write (reinterpret_cast<const char *> (&ds), 8); } @@ -566,14 +566,14 @@ SparseMatrix m = tc.sparse_matrix_value (); for (octave_idx_type i = 0; i < len; i++) - dtmp [i] = m.ridx(i) + 1; + dtmp[i] = m.ridx (i) + 1; os.write (reinterpret_cast<const char *> (dtmp), 8 * len); ds = nr; os.write (reinterpret_cast<const char *> (&ds), 8); octave_idx_type ii = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = m.cidx(j); i < m.cidx(j+1); i++) + for (octave_idx_type i = m.cidx (j); i < m.cidx (j+1); i++) dtmp[ii++] = j + 1; os.write (reinterpret_cast<const char *> (dtmp), 8 * len); ds = nc;
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -667,7 +667,7 @@ else { // Why did mathworks decide to not have dims for a workspace!!! - dims.resize(2); + dims.resize (2); dims(0) = 1; dims(1) = 1; } @@ -864,10 +864,10 @@ // and so can ignore the seperator field of m0. I think the // sentinel field is also save to ignore. Octave_map m0 = tc2.map_value (); - Octave_map m1 = m0.contents("function_handle")(0).map_value (); - std::string ftype = m1.contents("type")(0).string_value (); - std::string fname = m1.contents("function")(0).string_value (); - std::string fpath = m1.contents("file")(0).string_value (); + Octave_map m1 = m0.contents ("function_handle")(0).map_value (); + std::string ftype = m1.contents ("type")(0).string_value (); + std::string fname = m1.contents ("function")(0).string_value (); + std::string fpath = m1.contents ("file")(0).string_value (); if (ftype == "simple" || ftype == "scopedfunction") { @@ -877,10 +877,10 @@ else { std::string mroot = - m0.contents("matlabroot")(0).string_value (); + m0.contents ("matlabroot")(0).string_value (); if ((fpath.length () >= mroot.length ()) && - fpath.substr(0, mroot.length ()) == mroot && + fpath.substr (0, mroot.length ()) == mroot && OCTAVE_EXEC_PREFIX != mroot) { // If fpath starts with matlabroot, and matlabroot @@ -979,12 +979,12 @@ } else if (ftype == "anonymous") { - Octave_map m2 = m1.contents("workspace")(0).map_value (); - uint32NDArray MCOS = m2.contents("MCOS")(0).uint32_array_value (); + Octave_map m2 = m1.contents ("workspace")(0).map_value (); + uint32NDArray MCOS = m2.contents ("MCOS")(0).uint32_array_value (); octave_idx_type off = static_cast<octave_idx_type>(MCOS(4).double_value ()); m2 = subsys_ov.map_value (); - m2 = m2.contents("MCOS")(0).map_value (); - tc2 = m2.contents("MCOS")(0).cell_value ()(1 + off).cell_value ()(1); + m2 = m2.contents ("MCOS")(0).map_value (); + tc2 = m2.contents ("MCOS")(0).cell_value ()(1 + off).cell_value ()(1); m2 = tc2.map_value (); unwind_protect_safe frame; @@ -1007,8 +1007,8 @@ for (Octave_map::iterator p0 = m2.begin () ; p0 != m2.end (); p0++) { - std::string key = m2.key(p0); - octave_value val = m2.contents(p0)(0); + std::string key = m2.key (p0); + octave_value val = m2.contents (p0)(0); symbol_table::varref (key, local_scope, 0) = val; } @@ -1219,8 +1219,8 @@ // inline is not an object in Octave but rather an // overload of a function handle. Special case. tc = - new octave_fcn_inline (m.contents("expr")(0).string_value (), - m.contents("args")(0).string_value ()); + new octave_fcn_inline (m.contents ("expr")(0).string_value (), + m.contents ("args")(0).string_value ()); } else { @@ -1277,7 +1277,7 @@ boolNDArray out (dims); for (octave_idx_type i = 0; i < nel; i++) - out (i) = in(i).bool_value (); + out(i) = in(i).bool_value (); tc = out; }
--- a/src/ls-oct-ascii.cc +++ b/src/ls-oct-ascii.cc @@ -110,7 +110,7 @@ while (is.get (c) && (c == ' ' || c == '\t' || c == ':')) ; // Skip whitespace and the colon. - is.putback(c); + is.putback (c); retval = read_until_newline (is, false); break; }
--- a/src/mappers.cc +++ b/src/mappers.cc @@ -1177,13 +1177,13 @@ %!assert (isinf (Inf)) %!assert (!isinf (NaN)) %!assert (!isinf (NA)) -%!assert (isinf (rand(1,10)), false (1,10)) +%!assert (isinf (rand (1,10)), false (1,10)) %!assert (isinf ([NaN -Inf -1 0 1 Inf NA]), [false, true, false, false, false, true, false]) %!assert (isinf (single (Inf))) %!assert (!isinf (single (NaN))) %!assert (!isinf (single (NA))) -%!assert (isinf (single (rand(1,10))), false (1,10)) +%!assert (isinf (single (rand (1,10))), false (1,10)) %!assert (isinf (single ([NaN -Inf -1 0 1 Inf NA])), [false, true, false, false, false, true, false]) %!error isinf () @@ -1276,13 +1276,13 @@ %!assert (!isna (Inf)) %!assert (!isna (NaN)) %!assert (isna (NA)) -%!assert (isna (rand(1,10)), false (1,10)) +%!assert (isna (rand (1,10)), false (1,10)) %!assert (isna ([NaN -Inf -1 0 1 Inf NA]), [false, false, false, false, false, false, true]) %!assert (!isna (single (Inf))) %!assert (!isna (single (NaN))) %!assert (isna (single (NA))) -%!assert (isna (single (rand(1,10))), false (1,10)) +%!assert (isna (single (rand (1,10))), false (1,10)) %!assert (isna (single ([NaN -Inf -1 0 1 Inf NA])), [false, false, false, false, false, false, true]) %!error isna () @@ -1318,13 +1318,13 @@ %!assert (!isnan (Inf)) %!assert (isnan (NaN)) %!assert (isnan (NA)) -%!assert (isnan (rand(1,10)), false (1,10)) +%!assert (isnan (rand (1,10)), false (1,10)) %!assert (isnan ([NaN -Inf -1 0 1 Inf NA]), [true, false, false, false, false, false, true]) %!assert (!isnan (single (Inf))) %!assert (isnan (single (NaN))) %!assert (isnan (single (NA))) -%!assert (isnan (single (rand(1,10))), false (1,10)) +%!assert (isnan (single (rand (1,10))), false (1,10)) %!assert (isnan (single ([NaN -Inf -1 0 1 Inf NA])), [true, false, false, false, false, false, true]) %!error isnan ()
--- a/src/mex.cc +++ b/src/mex.cc @@ -1576,12 +1576,12 @@ for (mwIndex i = 0; i < nzmax; i++) { - val.xdata(i) = ppr[i]; - val.xridx(i) = ir[i]; + val.xdata (i) = ppr[i]; + val.xridx (i) = ir[i]; } for (mwIndex i = 0; i < get_n () + 1; i++) - val.xcidx(i) = jc[i]; + val.xcidx (i) = jc[i]; retval = val; } @@ -1603,12 +1603,12 @@ for (mwIndex i = 0; i < nzmax; i++) { - val.xdata(i) = Complex (ppr[i], ppi[i]); - val.xridx(i) = ir[i]; + val.xdata (i) = Complex (ppr[i], ppi[i]); + val.xridx (i) = ir[i]; } for (mwIndex i = 0; i < get_n () + 1; i++) - val.xcidx(i) = jc[i]; + val.xcidx (i) = jc[i]; retval = val; } @@ -1621,12 +1621,12 @@ for (mwIndex i = 0; i < nzmax; i++) { - val.xdata(i) = ppr[i]; - val.xridx(i) = ir[i]; + val.xdata (i) = ppr[i]; + val.xridx (i) = ir[i]; } for (mwIndex i = 0; i < get_n () + 1; i++) - val.xcidx(i) = jc[i]; + val.xcidx (i) = jc[i]; retval = val; }
--- a/src/oct-map.cc +++ b/src/oct-map.cc @@ -152,7 +152,7 @@ string_vector retval(n); for (iterator p = begin (); p != end (); p++) - retval.xelem(p->second) = p->first; + retval.xelem (p->second) = p->first; return retval; } @@ -197,7 +197,7 @@ octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.xvals[i] = xvals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem (i)]; return retval; } @@ -215,7 +215,7 @@ { octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.xvals[i] = xvals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem (i)]; } else error ("orderfields: structs must have same fields up to order"); @@ -247,7 +247,7 @@ for (octave_idx_type i = 0; i < nf; i++) { xvals.push_back (Cell (dimensions)); - xvals[i].xelem(0) = m.xvals[i]; + xvals[i].xelem (0) = m.xvals[i]; } } @@ -308,7 +308,7 @@ octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.xvals[i] = xvals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem (i)]; return retval; } @@ -326,7 +326,7 @@ { octave_idx_type nf = nfields (); for (octave_idx_type i = 0; i < nf; i++) - retval.xvals[i] = xvals[perm.xelem(i)]; + retval.xvals[i] = xvals[perm.xelem (i)]; } else error ("orderfields: structs must have same fields up to order"); @@ -591,7 +591,7 @@ retval.xvals.push_back (Cell (rd)); assert (retval.xvals[j].numel () == n); for (octave_idx_type i = 0; i < n; i++) - retval.xvals[j].xelem(i) = map_list[i].xvals[j]; + retval.xvals[j].xelem (i) = map_list[i].xvals[j]; } } @@ -1278,7 +1278,7 @@ break; } - contents(pa).insert (rb.contents(pb), ra_idx); + contents(pa).insert (rb.contents (pb), ra_idx); } } else
--- a/src/oct-obj.cc +++ b/src/oct-obj.cc @@ -157,7 +157,7 @@ retval(k++) = elem (i); for (octave_idx_type i = 0; i < lst_len; i++) - retval(k++) = lst(i); + retval(k++) = lst (i); for (octave_idx_type i = offset + rep_length; i < len; i++) retval(k++) = elem (i);
--- a/src/ov-base-int.cc +++ b/src/ov-base-int.cc @@ -381,7 +381,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - this->matrix.resize(dv); + this->matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-base-mat.h +++ b/src/ov-base-mat.h @@ -53,7 +53,7 @@ octave_base_matrix (const MT& m, const MatrixType& t = MatrixType ()) : octave_base_value (), matrix (m), - typ (t.is_known () ? new MatrixType(t) : 0), idx_cache () + typ (t.is_known () ? new MatrixType (t) : 0), idx_cache () { if (matrix.ndims () == 0) matrix.resize (dim_vector (0, 0));
--- a/src/ov-base-sparse.cc +++ b/src/ov-base-sparse.cc @@ -370,13 +370,13 @@ // at all the nonzero values and display them with the same // formatting rules that apply to columns of a matrix. - for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++) + for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) { os << "\n"; - os << " (" << matrix.ridx(i)+1 << + os << " (" << matrix.ridx (i)+1 << ", " << j+1 << ") -> "; - octave_print_internal (os, matrix.data(i), pr_as_read_syntax); + octave_print_internal (os, matrix.data (i), pr_as_read_syntax); } } }
--- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -469,7 +469,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-bool-sparse.cc +++ b/src/ov-bool-sparse.cc @@ -163,7 +163,7 @@ NDArray octave_sparse_bool_matrix::array_value (bool) const { - return NDArray (Matrix(matrix.matrix_value ())); + return NDArray (Matrix (matrix.matrix_value ())); } charNDArray @@ -174,8 +174,8 @@ octave_idx_type nr = matrix.rows (); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++) - retval(matrix.ridx(i) + nr * j) = static_cast<char>(matrix.data (i)); + for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) + retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i)); return retval; } @@ -238,14 +238,14 @@ for (int i = 0; i < nc+1; i++) { octave_quit (); - itmp = matrix.cidx(i); + itmp = matrix.cidx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } for (int i = 0; i < nz; i++) { octave_quit (); - itmp = matrix.ridx(i); + itmp = matrix.ridx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } @@ -300,7 +300,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.cidx(i) = tmp; + m.cidx (i) = tmp; } for (int i = 0; i < nz; i++) @@ -310,7 +310,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.ridx(i) = tmp; + m.ridx (i) = tmp; } if (error_state || ! is) @@ -551,7 +551,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0); @@ -782,12 +782,12 @@ for (mwIndex i = 0; i < nz; i++) { - pr[i] = matrix.data(i); - ir[i] = matrix.ridx(i); + pr[i] = matrix.data (i); + ir[i] = matrix.ridx (i); } for (mwIndex i = 0; i < columns () + 1; i++) - jc[i] = matrix.cidx(i); + jc[i] = matrix.cidx (i); return retval; }
--- a/src/ov-cell.cc +++ b/src/ov-cell.cc @@ -1155,7 +1155,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-class.cc +++ b/src/ov-class.cc @@ -142,7 +142,7 @@ = parent.parent_class_name_list (); for (octave_idx_type i = 0; i < p_nel; i++) - c(i) = octave_value (pmap.index(i), pcnm, plist); + c(i) = octave_value (pmap.index (i), pcnm, plist); map.assign (pcnm, c); } @@ -187,7 +187,7 @@ = parent.parent_class_name_list (); for (octave_idx_type i = 0; i < p_nel; i++) - c(i) = octave_value (pmap.index(i), pcnm, plist); + c(i) = octave_value (pmap.index (i), pcnm, plist); map.assign (pcnm, c); }
--- a/src/ov-complex.cc +++ b/src/ov-complex.cc @@ -65,8 +65,8 @@ octave_base_value::type_conv_info octave_complex::numeric_demotion_function (void) const { - return octave_base_value::type_conv_info(default_numeric_demotion_function, - octave_float_complex::static_type_id ()); + return octave_base_value::type_conv_info (default_numeric_demotion_function, + octave_float_complex::static_type_id ()); } octave_base_value *
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -73,8 +73,8 @@ octave_base_value::type_conv_info octave_complex_matrix::numeric_demotion_function (void) const { - return octave_base_value::type_conv_info(default_numeric_demotion_function, - octave_float_complex_matrix::static_type_id ()); + return octave_base_value::type_conv_info (default_numeric_demotion_function, + octave_float_complex_matrix::static_type_id ()); } octave_base_value * @@ -644,7 +644,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-cx-sparse.cc +++ b/src/ov-cx-sparse.cc @@ -188,8 +188,8 @@ octave_idx_type nr = matrix.rows (); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++) - retval(matrix.ridx(i) + nr * j) = + for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) + retval(matrix.ridx (i) + nr * j) = static_cast<char>(std::real (matrix.data (i))); } @@ -275,14 +275,14 @@ for (int i = 0; i < nc+1; i++) { octave_quit (); - itmp = matrix.cidx(i); + itmp = matrix.cidx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } for (int i = 0; i < nz; i++) { octave_quit (); - itmp = matrix.ridx(i); + itmp = matrix.ridx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } @@ -334,7 +334,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.cidx(i) = tmp; + m.cidx (i) = tmp; } for (int i = 0; i < nz; i++) @@ -344,7 +344,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.ridx(i) = tmp; + m.ridx (i) = tmp; } if (! is.read (reinterpret_cast<char *> (&ctmp), 1)) @@ -622,7 +622,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0); @@ -862,14 +862,14 @@ for (mwIndex i = 0; i < nz; i++) { - Complex val = matrix.data(i); + Complex val = matrix.data (i); pr[i] = std::real (val); pi[i] = std::imag (val); - ir[i] = matrix.ridx(i); + ir[i] = matrix.ridx (i); } for (mwIndex i = 0; i < columns () + 1; i++) - jc[i] = matrix.cidx(i); + jc[i] = matrix.cidx (i); return retval; }
--- a/src/ov-fcn-handle.cc +++ b/src/ov-fcn-handle.cc @@ -1636,8 +1636,8 @@ { m.setfield ("type", "subfunction"); Cell parentage (dim_vector (1, 2)); - parentage.elem(0) = fh_nm; - parentage.elem(1) = fcn->parent_fcn_name (); + parentage.elem (0) = fh_nm; + parentage.elem (1) = fcn->parent_fcn_name (); m.setfield ("parentage", octave_value (parentage)); } else if (fcn->is_private_function ())
--- a/src/ov-flt-cx-mat.cc +++ b/src/ov-flt-cx-mat.cc @@ -611,7 +611,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-flt-re-mat.cc +++ b/src/ov-flt-re-mat.cc @@ -624,7 +624,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0); @@ -860,8 +860,8 @@ } /* -%!assert (class (single(1)), "single") -%!assert (class (single(1 + i)), "single") +%!assert (class (single (1)), "single") +%!assert (class (single (1 + i)), "single") %!assert (class (single (int8 (1))), "single") %!assert (class (single (uint8 (1))), "single") %!assert (class (single (int16 (1))), "single")
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -89,8 +89,8 @@ octave_base_value::type_conv_info octave_matrix::numeric_demotion_function (void) const { - return octave_base_value::type_conv_info(default_numeric_demotion_function, - octave_float_matrix::static_type_id ()); + return octave_base_value::type_conv_info (default_numeric_demotion_function, + octave_float_matrix::static_type_id ()); } octave_base_value * @@ -747,7 +747,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-re-sparse.cc +++ b/src/ov-re-sparse.cc @@ -160,8 +160,8 @@ octave_idx_type nr = matrix.rows (); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = matrix.cidx(j); i < matrix.cidx(j+1); i++) - retval(matrix.ridx(i) + nr * j) = static_cast<char>(matrix.data (i)); + for (octave_idx_type i = matrix.cidx (j); i < matrix.cidx (j+1); i++) + retval(matrix.ridx (i) + nr * j) = static_cast<char>(matrix.data (i)); return retval; } @@ -216,8 +216,8 @@ bool warned = false; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = matrix.cidx(j); - i < matrix.cidx(j+1); i++) + for (octave_idx_type i = matrix.cidx (j); + i < matrix.cidx (j+1); i++) { octave_quit (); @@ -246,7 +246,7 @@ } } - chm (matrix.ridx(i) + j * nr) = + chm (matrix.ridx (i) + j * nr) = static_cast<char> (ival); } } @@ -308,14 +308,14 @@ for (int i = 0; i < nc+1; i++) { octave_quit (); - itmp = matrix.cidx(i); + itmp = matrix.cidx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } for (int i = 0; i < nz; i++) { octave_quit (); - itmp = matrix.ridx(i); + itmp = matrix.ridx (i); os.write (reinterpret_cast<char *> (&itmp), 4); } @@ -367,7 +367,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.xcidx(i) = tmp; + m.xcidx (i) = tmp; } for (int i = 0; i < nz; i++) @@ -377,7 +377,7 @@ return false; if (swap) swap_bytes<4> (&tmp); - m.xridx(i) = tmp; + m.xridx (i) = tmp; } if (! is.read (reinterpret_cast<char *> (&ctmp), 1)) @@ -637,7 +637,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0); @@ -867,12 +867,12 @@ for (mwIndex i = 0; i < nz; i++) { - pr[i] = matrix.data(i); - ir[i] = matrix.ridx(i); + pr[i] = matrix.data (i); + ir[i] = matrix.ridx (i); } for (mwIndex i = 0; i < nc + 1; i++) - jc[i] = matrix.cidx(i); + jc[i] = matrix.cidx (i); return retval; }
--- a/src/ov-scalar.cc +++ b/src/ov-scalar.cc @@ -67,8 +67,8 @@ octave_base_value::type_conv_info octave_scalar::numeric_demotion_function (void) const { - return octave_base_value::type_conv_info(default_numeric_demotion_function, - octave_float_scalar::static_type_id ()); + return octave_base_value::type_conv_info (default_numeric_demotion_function, + octave_float_scalar::static_type_id ()); } octave_value
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -252,7 +252,7 @@ octave_idx_type nr = chm.rows (); retval.clear (nr, 1); for (octave_idx_type i = 0; i < nr; i++) - retval.xelem(i) = chm.row_as_string (i); + retval.xelem (i) = chm.row_as_string (i); } else error ("cellstr: cannot convert multidimensional arrays"); @@ -615,7 +615,7 @@ dim_vector dv; int empty = load_hdf5_empty (loc_id, name, dv); if (empty > 0) - matrix.resize(dv); + matrix.resize (dv); if (empty) return (empty > 0);
--- a/src/ov-struct.cc +++ b/src/ov-struct.cc @@ -2000,11 +2000,11 @@ %!test %! x(3).d=1; x(2).a=2; x(1).b=3; x(2).c=3; %! assert (isfield (x, "b")); -%!assert (isfield (struct("a", "1"), "a")) +%!assert (isfield (struct ("a", "1"), "a")) %!assert (isfield ({1}, "c"), false) -%!assert (isfield (struct("a", "1"), 10), false) -%!assert (isfield (struct("a", "b"), "a "), false) -%!assert (isfield (struct("a", 1, "b", 2), {"a", "c"}), [true, false]) +%!assert (isfield (struct ("a", "1"), 10), false) +%!assert (isfield (struct ("a", "b"), "a "), false) +%!assert (isfield (struct ("a", 1, "b", 2), {"a", "c"}), [true, false]) */ DEFUN (cell2struct, args, ,
--- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -188,7 +188,7 @@ system_fcn_file (false), call_depth (-1), num_named_args (param_list ? param_list->length () : 0), subfunction (false), inline_function (false), - anonymous_function (false), nested_function(false), + anonymous_function (false), nested_function (false), class_constructor (false), class_method (false), parent_scope (-1), local_scope (sid), curr_unwind_protect_frame (0) @@ -261,10 +261,10 @@ std::string ff_name = fcn_file_in_path (file_name); if (Vfcn_file_dir == ff_name.substr (0, Vfcn_file_dir.length ())) - system_fcn_file = 1; + system_fcn_file = true; } else - system_fcn_file = 0; + system_fcn_file = false; } bool @@ -871,7 +871,7 @@ the tilde (~) special output argument. Functions can use @code{isargout} to\n\ avoid performing unnecessary calculations for outputs which are unwanted.\n\ \n\ -If @var{k} is outside the range @code{1:max(nargout)}, the function returns\n\ +If @var{k} is outside the range @code{1:max (nargout)}, the function returns\n\ false. @var{k} can also be an array, in which case the function works\n\ element-by-element and a logical array is returned. At the top level,\n\ @code{isargout} returns an error.\n\
--- a/src/ov.cc +++ b/src/ov.cc @@ -2751,7 +2751,7 @@ type_string[k] = '.'; else { - error("%s: invalid indexing type `%s'", name, item.c_str ()); + error ("%s: invalid indexing type `%s'", name, item.c_str ()); return; } } @@ -2810,7 +2810,7 @@ \n\ @example\n\ @group\n\ -val = magic(3)\n\ +val = magic (3)\n\ @result{} val = [ 8 1 6\n\ 3 5 7\n\ 4 9 2 ]\n\ @@ -2957,7 +2957,7 @@ %! assert ({ subsref(c, idx1) }, {13}); %! assert ({ subsref(c, idx2p) }, {7 9 17 19}); %! assert ({ subsref(c, idx3p) }, num2cell ([1:5, 21:25])); -%! assert (subsref(c, idx4), c); +%! assert (subsref (c, idx4), c); %! c = subsasgn (c, idx1, 0); %! c = subsasgn (c, idx2, 0); %! c = subsasgn (c, idx3, 0);
--- a/src/pr-output.cc +++ b/src/pr-output.cc @@ -303,8 +303,8 @@ else os << std::setw (0) << "e+"; - os << std::setw (pef.f.ex - 2) << std::setfill('0') << ex - << std::setfill(' '); + os << std::setw (pef.f.ex - 2) << std::setfill ('0') << ex + << std::setfill (' '); os.flags (oflags); @@ -360,7 +360,7 @@ { std::ostringstream buf; buf.flags (std::ios::fixed); - buf << std::setprecision (0) << xround(val); + buf << std::setprecision (0) << xround (val); s = buf.str (); } else @@ -2004,8 +2004,8 @@ } template <typename NDA_T, typename ELT_T, typename MAT_T> -void print_nd_array(std::ostream& os, const NDA_T& nda, - bool pr_as_read_syntax) +void print_nd_array (std::ostream& os, const NDA_T& nda, + bool pr_as_read_syntax) { if (nda.is_empty ()) @@ -3554,7 +3554,7 @@ %! foo.char = repmat ("- Hello World -", [3, 20]); %! foo.cell = {foo.real, foo.complex, foo.char}; %! fields = fieldnames (foo); -%! for f = 1:numel(fields) +%! for f = 1:numel (fields) %! format loose; %! loose = disp (foo.(fields{f})); %! format compact;
--- a/src/procstream.h +++ b/src/procstream.h @@ -108,10 +108,10 @@ oprocstream (void) : std::ostream (0), procstreambase () { } oprocstream (const std::string& name, int mode = std::ios::out) - : std::ostream (0), procstreambase(name, mode) { } + : std::ostream (0), procstreambase (name, mode) { } oprocstream (const char *name, int mode = std::ios::out) - : std::ostream (0), procstreambase(name, mode) { } + : std::ostream (0), procstreambase (name, mode) { } ~oprocstream (void) { }
--- a/src/pt-id.cc +++ b/src/pt-id.cc @@ -49,10 +49,12 @@ return; if (l == -1 && c == -1) - ::error ("`%s' undefined", name ().c_str ()); + ::error_with_id ("Octave:undefined-function", + "`%s' undefined", name ().c_str ()); else - ::error ("`%s' undefined near line %d column %d", - name ().c_str (), l, c); + ::error_with_id ("Octave:undefined-function", + "`%s' undefined near line %d column %d", + name ().c_str (), l, c); } octave_value_list
--- a/src/sighandlers.cc +++ b/src/sighandlers.cc @@ -63,7 +63,7 @@ // TRUE means we should try to enter the debugger on SIGINT. static bool Vdebug_on_interrupt = false; -// Allow users to avoid writing octave-core for SIGHUP (sent by +// Allow users to avoid writing octave-workspace for SIGHUP (sent by // closing gnome-terminal, for example). Note that this variable has // no effect if Vcrash_dumps_octave_core is FALSE. static bool Vsighup_dumps_octave_core = true; @@ -147,12 +147,12 @@ #endif case SIGFPE: - std::cerr << "warning: floating point exception -- trying to return to prompt" << std::endl; + std::cerr << "warning: floating point exception" << std::endl; break; #ifdef SIGPIPE case SIGPIPE: - std::cerr << "warning: broken pipe -- some output may be lost" << std::endl; + std::cerr << "warning: broken pipe" << std::endl; break; #endif } @@ -252,7 +252,7 @@ octave_signals_caught[SIGCHLD] = true; } -#endif /* defined(SIGCHLD) */ +#endif /* defined (SIGCHLD) */ #ifdef SIGFPE #if defined (__alpha__) @@ -268,8 +268,8 @@ octave_interrupt_state++; } } -#endif /* defined(__alpha__) */ -#endif /* defined(SIGFPE) */ +#endif /* defined (__alpha__) */ +#endif /* defined (SIGFPE) */ #if defined (SIGHUP) || defined (SIGTERM) static void @@ -401,7 +401,7 @@ if (pipe_handler_error_count++ > 100 && octave_interrupt_state >= 0) octave_interrupt_state++; } -#endif /* defined(SIGPIPE) */ +#endif /* defined (SIGPIPE) */ #ifdef USE_W32_SIGINT static BOOL CALLBACK @@ -409,7 +409,7 @@ { const char *sig_name; - switch(sig) + switch (sig) { case CTRL_BREAK_EVENT: sig_name = "Ctrl-Break"; @@ -431,7 +431,7 @@ break; } - switch(sig) + switch (sig) { case CTRL_BREAK_EVENT: case CTRL_C_EVENT: @@ -447,7 +447,7 @@ // We should do the following: // clean_up_and_exit (0); // We can't because we aren't running in the normal Octave thread. - user_abort(sig_name, sig); + user_abort (sig_name, sig); break; } @@ -1001,7 +1001,7 @@ @deftypefnx {Built-in Function} {@var{old_val} =} sighup_dumps_octave_core (@var{new_val})\n\ @deftypefnx {Built-in Function} {} sighup_dumps_octave_core (@var{new_val}, \"local\")\n\ Query or set the internal variable that controls whether Octave tries\n\ -to save all current variables to the file \"octave-core\" if it receives\n\ +to save all current variables to the file \"octave-workspace\" if it receives\n\ a hangup signal.\n\ \n\ When called from inside a function with the \"local\" option, the variable is\n\ @@ -1030,7 +1030,7 @@ @deftypefnx {Built-in Function} {@var{old_val} =} sigterm_dumps_octave_core (@var{new_val})\n\ @deftypefnx {Built-in Function} {} sigterm_dumps_octave_core (@var{new_val}, \"local\")\n\ Query or set the internal variable that controls whether Octave tries\n\ -to save all current variables to the file \"octave-core\" if it receives\n\ +to save all current variables to the file \"octave-workspace\" if it receives\n\ a terminate signal.\n\ \n\ When called from inside a function with the \"local\" option, the variable is\n\
--- a/src/sparse-xdiv.cc +++ b/src/sparse-xdiv.cc @@ -117,7 +117,7 @@ INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, DiagMatrix); INSTANTIATE_MX_DIV_CONFORM (SparseComplexMatrix, ComplexDiagMatrix); -// Right division functions. X / Y = X * inv(Y) = (inv (Y') * X')' +// Right division functions. X / Y = X * inv (Y) = (inv (Y') * X')' // // Y / X: m cm sm scm // +-- +---+----+----+----+ @@ -384,10 +384,10 @@ for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) + for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) { octave_quit (); - result.elem (b.ridx(i), j) = a / b.data (i); + result.elem (b.ridx (i), j) = a / b.data (i); } return result; @@ -399,13 +399,13 @@ octave_idx_type nr = b.rows (); octave_idx_type nc = b.cols (); - ComplexMatrix result (nr, nc, Complex(octave_NaN, octave_NaN)); + ComplexMatrix result (nr, nc, Complex (octave_NaN, octave_NaN)); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) + for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) { octave_quit (); - result.elem (b.ridx(i), j) = a / b.data (i); + result.elem (b.ridx (i), j) = a / b.data (i); } return result; @@ -420,10 +420,10 @@ ComplexMatrix result (nr, nc, (a / 0.0)); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) + for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) { octave_quit (); - result.elem (b.ridx(i), j) = a / b.data (i); + result.elem (b.ridx (i), j) = a / b.data (i); } return result; @@ -438,16 +438,16 @@ ComplexMatrix result (nr, nc, (a / 0.0)); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = b.cidx(j); i < b.cidx(j+1); i++) + for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++) { octave_quit (); - result.elem (b.ridx(i), j) = a / b.data (i); + result.elem (b.ridx (i), j) = a / b.data (i); } return result; } -// Left division functions. X \ Y = inv(X) * Y +// Left division functions. X \ Y = inv (X) * Y // // Y \ X : sm scm dm dcm // +-- +---+----+
--- a/src/sparse-xpow.cc +++ b/src/sparse-xpow.cc @@ -250,7 +250,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = std::pow (atmp, b(i,j)); + result(i, j) = std::pow (atmp, b(i,j)); } } @@ -265,7 +265,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = std::pow (a, b(i,j)); + result(i, j) = std::pow (a, b(i,j)); } } @@ -290,7 +290,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = std::pow (atmp, b(i,j)); + result(i, j) = std::pow (atmp, b(i,j)); } } @@ -323,13 +323,13 @@ Complex btmp (b); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); Complex atmp (a.data (i)); - result (a.ridx(i), j) = std::pow (atmp, btmp); + result(a.ridx (i), j) = std::pow (atmp, btmp); } retval = octave_value (result); @@ -339,10 +339,10 @@ Matrix result (nr, nc, (std::pow (0.0, b))); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result (a.ridx(i), j) = std::pow (a.data (i), b); + result(a.ridx (i), j) = std::pow (a.data (i), b); } retval = octave_value (result); @@ -407,11 +407,11 @@ int convert_to_complex = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { if (a.data(i) < 0.0) { - double btmp = b (a.ridx(i), j); + double btmp = b (a.ridx (i), j); if (static_cast<int> (btmp) != btmp) { convert_to_complex = 1; @@ -429,15 +429,15 @@ if (convert_to_complex) { - SparseComplexMatrix complex_result (nr, nc, Complex(1.0, 0.0)); + SparseComplexMatrix complex_result (nr, nc, Complex (1.0, 0.0)); for (octave_idx_type j = 0; j < nc; j++) { - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - complex_result.xelem(a.ridx(i), j) = - std::pow (Complex(a.data(i)), Complex(b(a.ridx(i), j))); + complex_result.xelem (a.ridx (i), j) = + std::pow (Complex (a.data (i)), Complex (b(a.ridx (i), j))); } } complex_result.maybe_compress (true); @@ -449,11 +449,11 @@ for (octave_idx_type j = 0; j < nc; j++) { - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result.xelem(a.ridx(i), j) = std::pow (a.data(i), - b (a.ridx(i), j)); + result.xelem (a.ridx (i), j) = std::pow (a.data (i), + b(a.ridx (i), j)); } } result.maybe_compress (true); @@ -507,13 +507,13 @@ return octave_value (); } - SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); + SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); for (octave_idx_type j = 0; j < nc; j++) { - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result.xelem(a.ridx(i), j) = std::pow (a.data(i), b (a.ridx(i), j)); + result.xelem (a.ridx(i), j) = std::pow (a.data (i), b(a.ridx (i), j)); } } @@ -581,20 +581,20 @@ if (xisint (b)) { for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result (a.ridx(i), j) = + result (a.ridx (i), j) = std::pow (a.data (i), static_cast<int> (b)); } } else { for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result (a.ridx(i), j) = std::pow (a.data (i), b); + result (a.ridx (i), j) = std::pow (a.data (i), b); } } @@ -647,20 +647,20 @@ return octave_value (); } - SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); + SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); for (octave_idx_type j = 0; j < nc; j++) { - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - double btmp = b (a.ridx(i), j); + double btmp = b(a.ridx (i), j); Complex tmp; if (xisint (btmp)) - result.xelem(a.ridx(i), j) = std::pow (a.data (i), + result.xelem (a.ridx (i), j) = std::pow (a.data (i), static_cast<int> (btmp)); else - result.xelem(a.ridx(i), j) = std::pow (a.data (i), btmp); + result.xelem (a.ridx (i), j) = std::pow (a.data (i), btmp); } } @@ -715,13 +715,13 @@ return octave_value (); } - SparseComplexMatrix result (nr, nc, Complex(1.0, 0.0)); + SparseComplexMatrix result (nr, nc, Complex (1.0, 0.0)); for (octave_idx_type j = 0; j < nc; j++) { - for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++) + for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) { octave_quit (); - result.xelem(a.ridx(i), j) = std::pow (a.data (i), b (a.ridx(i), j)); + result.xelem (a.ridx (i), j) = std::pow (a.data (i), b(a.ridx (i), j)); } } result.maybe_compress (true);
--- a/src/sparse.cc +++ b/src/sparse.cc @@ -94,7 +94,7 @@ Given the option \"unique\". if more than two values are specified for the\n\ same @var{i}, @var{j} indices, the last specified value will be used.\n\ \n\ -@code{sparse(@var{m}, @var{n})} is equivalent to\n\ +@code{sparse (@var{m}, @var{n})} is equivalent to\n\ @code{sparse ([], [], [], @var{m}, @var{n}, 0)}\n\ \n\ If any of @var{sv}, @var{i} or @var{j} are scalars, they are expanded\n\ @@ -227,9 +227,9 @@ @b{and} that the following conditions are met:\n\ \n\ @itemize\n\ -@item the assignment does not decrease nnz(@var{S}).\n\ +@item the assignment does not decrease nnz (@var{S}).\n\ \n\ -@item after the assignment, nnz(@var{S}) does not exceed @var{nz}.\n\ +@item after the assignment, nnz (@var{S}) does not exceed @var{nz}.\n\ \n\ @item no index is out of bounds.\n\ @end itemize\n\
--- a/src/symtab.cc +++ b/src/symtab.cc @@ -1201,7 +1201,7 @@ std::string fcn_scope = name.substr (0, pos); scope_id stored_scope = xcurrent_scope; xcurrent_scope = xtop_scope; - octave_value parent = find_function (name.substr(0, pos), + octave_value parent = find_function (name.substr (0, pos), octave_value_list (), false); if (parent.is_defined ())
--- a/src/syscalls.cc +++ b/src/syscalls.cc @@ -403,9 +403,9 @@ %! until (done) %! fclose (out); %! if (isunix ()) -%! assert(str, {"these\n","strings\n","some\n","are\n"}); +%! assert (str, {"these\n","strings\n","some\n","are\n"}); %! else -%! assert(str, {"these\r\n","strings\r\n","some\r\n","are\r\n"}); +%! assert (str, {"these\r\n","strings\r\n","some\r\n","are\r\n"}); %! endif */
--- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -255,7 +255,7 @@ void sysdep_init (void) { -#if defined (__386BSD__) || defined (__FreeBSD__) || defined(__NetBSD__) +#if defined (__386BSD__) || defined (__FreeBSD__) || defined (__NetBSD__) BSD_init (); #elif defined (__MINGW32__) MINGW_init ();
--- a/src/txt-eng-ft.cc +++ b/src/txt-eng-ft.cc @@ -333,7 +333,7 @@ case MODE_RENDER: if (str[i] == '\n') { - glyph_index = FT_Get_Char_Index(face, ' '); + glyph_index = FT_Get_Char_Index (face, ' '); if (!glyph_index || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT)) { gripe_missing_glyph (' '); @@ -397,7 +397,7 @@ case MODE_BBOX: if (str[i] == '\n') { - glyph_index = FT_Get_Char_Index(face, ' '); + glyph_index = FT_Get_Char_Index (face, ' '); if (! glyph_index || FT_Load_Glyph (face, glyph_index, FT_LOAD_DEFAULT)) { @@ -405,7 +405,7 @@ } else { - multiline_align_xoffsets.push_back(box_line_width); + multiline_align_xoffsets.push_back (box_line_width); // Reset the pixel width for this newline, so we don't // allocate a bounding box larger than the horizontal // width of the multi-line @@ -465,7 +465,7 @@ if (mode == MODE_BBOX) { /* Push last the width associated with the last line */ - multiline_align_xoffsets.push_back(box_line_width); + multiline_align_xoffsets.push_back (box_line_width); for (unsigned int i = 0; i < multiline_align_xoffsets.size (); i++) {
--- a/src/variables.cc +++ b/src/variables.cc @@ -1336,7 +1336,7 @@ param_names(pos_t) = "Type"; for (size_t i = 0; i < param_string.length (); i++) - param_length(i) = param_names(i) . length (); + param_length(i) = param_names(i).length (); // The attribute column needs size 5. param_length(pos_a) = 5;
--- a/src/zfstream.cc +++ b/src/zfstream.cc @@ -74,16 +74,16 @@ // Set compression level and strategy int -gzfilebuf::setcompression(int comp_level, - int comp_strategy) +gzfilebuf::setcompression (int comp_level, + int comp_strategy) { - return gzsetparams(file, comp_level, comp_strategy); + return gzsetparams (file, comp_level, comp_strategy); } // Open gzipped file gzfilebuf* -gzfilebuf::open(const char *name, - std::ios_base::openmode mode) +gzfilebuf::open (const char *name, + std::ios_base::openmode mode) { // Fail if file already open if (this->is_open ()) @@ -94,11 +94,11 @@ // Build mode string for gzopen and check it [27.8.1.3.2] char char_mode[6] = "\0\0\0\0\0"; - if (!this->open_mode(mode, char_mode)) + if (! this->open_mode (mode, char_mode)) return 0; // Attempt to open file - if ((file = gzopen(name, char_mode)) == 0) + if ((file = gzopen (name, char_mode)) == 0) return 0; // On success, allocate internal buffer and set flags @@ -110,8 +110,8 @@ // Attach to gzipped file gzfilebuf* -gzfilebuf::attach(int fd, - std::ios_base::openmode mode) +gzfilebuf::attach (int fd, + std::ios_base::openmode mode) { // Fail if file already open if (this->is_open ()) @@ -122,11 +122,11 @@ // Build mode string for gzdopen and check it [27.8.1.3.2] char char_mode[6] = "\0\0\0\0\0"; - if (!this->open_mode(mode, char_mode)) + if (! this->open_mode (mode, char_mode)) return 0; // Attempt to attach to file - if ((file = gzdopen(fd, char_mode)) == 0) + if ((file = gzdopen (fd, char_mode)) == 0) return 0; // On success, allocate internal buffer and set flags @@ -141,14 +141,14 @@ gzfilebuf::close () { // Fail immediately if no file is open - if (!this->is_open ()) + if (! this->is_open ()) return 0; // Assume success gzfilebuf* retval = this; // Attempt to sync and close gzipped file if (this->sync () == -1) retval = 0; - if (gzclose(file) < 0) + if (gzclose (file) < 0) retval = 0; // File is now gone anyway (postcondition [27.8.1.3.8]) file = 0; @@ -162,8 +162,8 @@ // Convert int open mode to mode string bool -gzfilebuf::open_mode(std::ios_base::openmode mode, - char* c_mode) const +gzfilebuf::open_mode (std::ios_base::openmode mode, + char* c_mode) const { // FIXME -- do we need testb? // bool testb = mode & std::ios_base::binary; @@ -178,13 +178,13 @@ // excessive though - keeping it at the default level // To change back, just append "9" to the next three mode strings if (!testi && testo && !testt && !testa) - strcpy(c_mode, "w"); + strcpy (c_mode, "w"); if (!testi && testo && !testt && testa) - strcpy(c_mode, "a"); + strcpy (c_mode, "a"); if (!testi && testo && testt && !testa) - strcpy(c_mode, "w"); + strcpy (c_mode, "w"); if (testi && !testo && !testt && !testa) - strcpy(c_mode, "r"); + strcpy (c_mode, "r"); // No read/write mode yet // if (testi && testo && !testt && !testa) // strcpy(c_mode, "r+"); @@ -192,10 +192,10 @@ // strcpy(c_mode, "w+"); // Mode string should be empty for invalid combination of flags - if (strlen(c_mode) == 0) + if (strlen (c_mode) == 0) return false; - strcat(c_mode, "b"); + strcat (c_mode, "b"); return true; } @@ -205,11 +205,11 @@ gzfilebuf::showmanyc () { // Calls to underflow will fail if file not opened for reading - if (!this->is_open () || !(io_mode & std::ios_base::in)) + if (! this->is_open () || !(io_mode & std::ios_base::in)) return -1; // Make sure get area is in use if (this->gptr () && (this->gptr () < this->egptr ())) - return std::streamsize(this->egptr () - this->gptr ()); + return std::streamsize (this->egptr () - this->gptr ()); else return 0; } @@ -231,21 +231,21 @@ // Attempt to fill internal buffer from gzipped file // (buffer must be guaranteed to exist...) - int bytes_read = gzread(file, buffer, buffer_size); + int bytes_read = gzread (file, buffer, buffer_size); // Indicates error or EOF if (bytes_read <= 0) { // Reset get area - this->setg(buffer, buffer, buffer); + this->setg (buffer, buffer, buffer); return traits_type::eof (); } // Make all bytes read from file available as get area - this->setg(buffer, buffer, buffer + bytes_read); + this->setg (buffer, buffer, buffer + bytes_read); // If next character in get area differs from putback character // flag a failure - gzfilebuf::int_type ret = traits_type::to_int_type(*(this->gptr ())); + gzfilebuf::int_type ret = traits_type::to_int_type (*(this->gptr ())); if (ret != c) return traits_type::eof (); else @@ -263,10 +263,10 @@ // (this shouldn't normally happen, as underflow is only supposed // to be called when gptr >= egptr, but it serves as error check) if (this->gptr () && (this->gptr () < this->egptr ())) - return traits_type::to_int_type(*(this->gptr ())); + return traits_type::to_int_type (*(this->gptr ())); // If the file hasn't been opened for reading, produce error - if (!this->is_open () || !(io_mode & std::ios_base::in)) + if (! this->is_open () || !(io_mode & std::ios_base::in)) return traits_type::eof (); // Copy the final characters to the front of the buffer @@ -282,25 +282,25 @@ // Attempt to fill internal buffer from gzipped file // (buffer must be guaranteed to exist...) - int bytes_read = gzread(file, buffer + stash, buffer_size - stash); + int bytes_read = gzread (file, buffer + stash, buffer_size - stash); // Indicates error or EOF if (bytes_read <= 0) { // Reset get area - this->setg(buffer, buffer, buffer); + this->setg (buffer, buffer, buffer); return traits_type::eof (); } // Make all bytes read from file plus the stash available as get area - this->setg(buffer, buffer + stash, buffer + bytes_read + stash); + this->setg (buffer, buffer + stash, buffer + bytes_read + stash); // Return next character in get area - return traits_type::to_int_type(*(this->gptr ())); + return traits_type::to_int_type (*(this->gptr ())); } // Write put area to gzipped file gzfilebuf::int_type -gzfilebuf::overflow(int_type c) +gzfilebuf::overflow (int_type c) { // Determine whether put area is in use if (this->pbase ()) @@ -309,10 +309,10 @@ if (this->pptr () > this->epptr () || this->pptr () < this->pbase ()) return traits_type::eof (); // Add extra character to buffer if not EOF - if (!traits_type::eq_int_type(c, traits_type::eof ())) + if (! traits_type::eq_int_type (c, traits_type::eof ())) { - *(this->pptr()) = traits_type::to_char_type(c); - this->pbump(1); + *(this->pptr ()) = traits_type::to_char_type (c); + this->pbump (1); } // Number of characters to write to file int bytes_to_write = this->pptr () - this->pbase (); @@ -320,40 +320,40 @@ if (bytes_to_write > 0) { // If the file hasn't been opened for writing, produce error - if (!this->is_open () || !(io_mode & std::ios_base::out)) + if (! this->is_open () || !(io_mode & std::ios_base::out)) return traits_type::eof (); // If gzipped file won't accept all bytes written to it, fail - if (gzwrite(file, this->pbase (), bytes_to_write) != bytes_to_write) + if (gzwrite (file, this->pbase (), bytes_to_write) != bytes_to_write) return traits_type::eof (); // Reset next pointer to point to pbase on success - this->pbump(-bytes_to_write); + this->pbump (-bytes_to_write); } } // Write extra character to file if not EOF - else if (!traits_type::eq_int_type(c, traits_type::eof ())) + else if (! traits_type::eq_int_type (c, traits_type::eof ())) { // If the file hasn't been opened for writing, produce error - if (!this->is_open () || !(io_mode & std::ios_base::out)) + if (! this->is_open () || !(io_mode & std::ios_base::out)) return traits_type::eof (); // Impromptu char buffer (allows "unbuffered" output) - char_type last_char = traits_type::to_char_type(c); + char_type last_char = traits_type::to_char_type (c); // If gzipped file won't accept this character, fail - if (gzwrite(file, &last_char, 1) != 1) + if (gzwrite (file, &last_char, 1) != 1) return traits_type::eof (); } // If you got here, you have succeeded (even if c was EOF) // The return value should therefore be non-EOF - if (traits_type::eq_int_type(c, traits_type::eof ())) - return traits_type::not_eof(c); + if (traits_type::eq_int_type (c, traits_type::eof ())) + return traits_type::not_eof (c); else return c; } // Assign new buffer std::streambuf* -gzfilebuf::setbuf(char_type* p, - std::streamsize n) +gzfilebuf::setbuf (char_type* p, + std::streamsize n) { // First make sure stuff is sync'ed, for safety if (this->sync () == -1) @@ -387,7 +387,7 @@ int gzfilebuf::sync () { - return traits_type::eq_int_type(this->overflow (), traits_type::eof ()) ? -1 : 0; + return traits_type::eq_int_type (this->overflow (), traits_type::eof ()) ? -1 : 0; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -405,29 +405,29 @@ // Allocate internal buffer buffer = new char_type[buffer_size]; // Get area starts empty and will be expanded by underflow as need arises - this->setg(buffer, buffer, buffer); + this->setg (buffer, buffer, buffer); // Setup entire internal buffer as put area. // The one-past-end pointer actually points to the last element of the buffer, // so that overflow(c) can safely add the extra character c to the sequence. // These pointers remain in place for the duration of the buffer - this->setp(buffer, buffer + buffer_size - 1); + this->setp (buffer, buffer + buffer_size - 1); } else { // Even in "unbuffered" case, (small?) get buffer is still required buffer_size = SMALLBUFSIZE; buffer = new char_type[buffer_size]; - this->setg(buffer, buffer, buffer); + this->setg (buffer, buffer, buffer); // "Unbuffered" means no put buffer - this->setp(0, 0); + this->setp (0, 0); } } else { // If buffer already allocated, reset buffer pointers just to make sure no // stale chars are lying around - this->setg(buffer, buffer, buffer); - this->setp(buffer, buffer + buffer_size - 1); + this->setg (buffer, buffer, buffer); + this->setp (buffer, buffer + buffer_size - 1); } } @@ -439,21 +439,21 @@ if (own_buffer && buffer) { // Preserve unbuffered status by zeroing size - if (!this->pbase ()) + if (! this->pbase ()) buffer_size = 0; delete[] buffer; buffer = 0; - this->setg(0, 0, 0); - this->setp(0, 0); + this->setg (0, 0, 0); + this->setp (0, 0); } else { // Reset buffer pointers to initial state if external buffer exists - this->setg(buffer, buffer, buffer); + this->setg (buffer, buffer, buffer); if (buffer) - this->setp(buffer, buffer + buffer_size - 1); + this->setp (buffer, buffer + buffer_size - 1); else - this->setp(0, 0); + this->setp (0, 0); } } @@ -461,7 +461,7 @@ // Seek functions gzfilebuf::pos_type -gzfilebuf::seekoff(off_type off, std::ios_base::seekdir way, +gzfilebuf::seekoff (off_type off, std::ios_base::seekdir way, std::ios_base::openmode) { pos_type ret = pos_type (off_type (-1)); @@ -493,7 +493,7 @@ } gzfilebuf::pos_type -gzfilebuf::seekpos(pos_type sp, std::ios_base::openmode) +gzfilebuf::seekpos (pos_type sp, std::ios_base::openmode) { pos_type ret = pos_type (off_type (-1)); @@ -516,45 +516,45 @@ // Default constructor initializes stream buffer gzifstream::gzifstream () -: std::istream(0), sb () -{ this->init(&sb); } +: std::istream (0), sb () +{ this->init (&sb); } // Initialize stream buffer and open file -gzifstream::gzifstream(const char* name, - std::ios_base::openmode mode) -: std::istream(0), sb () +gzifstream::gzifstream (const char* name, + std::ios_base::openmode mode) +: std::istream (0), sb () { - this->init(&sb); - this->open(name, mode); + this->init (&sb); + this->open (name, mode); } // Initialize stream buffer and attach to file -gzifstream::gzifstream(int fd, - std::ios_base::openmode mode) -: std::istream(0), sb () +gzifstream::gzifstream (int fd, + std::ios_base::openmode mode) +: std::istream (0), sb () { - this->init(&sb); - this->attach(fd, mode); + this->init (&sb); + this->attach (fd, mode); } // Open file and go into fail() state if unsuccessful void -gzifstream::open(const char* name, - std::ios_base::openmode mode) +gzifstream::open (const char* name, + std::ios_base::openmode mode) { - if (!sb.open(name, mode | std::ios_base::in)) - this->setstate(std::ios_base::failbit); + if (! sb.open (name, mode | std::ios_base::in)) + this->setstate (std::ios_base::failbit); else this->clear (); } // Attach to file and go into fail() state if unsuccessful void -gzifstream::attach(int fd, - std::ios_base::openmode mode) +gzifstream::attach (int fd, + std::ios_base::openmode mode) { - if (!sb.attach(fd, mode | std::ios_base::in)) - this->setstate(std::ios_base::failbit); + if (! sb.attach (fd, mode | std::ios_base::in)) + this->setstate (std::ios_base::failbit); else this->clear (); } @@ -563,53 +563,53 @@ void gzifstream::close () { - if (!sb.close ()) - this->setstate(std::ios_base::failbit); + if (! sb.close ()) + this->setstate (std::ios_base::failbit); } /*****************************************************************************/ // Default constructor initializes stream buffer gzofstream::gzofstream () -: std::ostream(0), sb () -{ this->init(&sb); } +: std::ostream (0), sb () +{ this->init (&sb); } // Initialize stream buffer and open file -gzofstream::gzofstream(const char* name, - std::ios_base::openmode mode) -: std::ostream(0), sb () +gzofstream::gzofstream (const char* name, + std::ios_base::openmode mode) +: std::ostream (0), sb () { - this->init(&sb); - this->open(name, mode); + this->init (&sb); + this->open (name, mode); } // Initialize stream buffer and attach to file -gzofstream::gzofstream(int fd, - std::ios_base::openmode mode) -: std::ostream(0), sb () +gzofstream::gzofstream (int fd, + std::ios_base::openmode mode) +: std::ostream (0), sb () { - this->init(&sb); - this->attach(fd, mode); + this->init (&sb); + this->attach (fd, mode); } // Open file and go into fail() state if unsuccessful void -gzofstream::open(const char* name, - std::ios_base::openmode mode) +gzofstream::open (const char* name, + std::ios_base::openmode mode) { - if (!sb.open(name, mode | std::ios_base::out)) - this->setstate(std::ios_base::failbit); + if (! sb.open (name, mode | std::ios_base::out)) + this->setstate (std::ios_base::failbit); else this->clear (); } // Attach to file and go into fail() state if unsuccessful void -gzofstream::attach(int fd, - std::ios_base::openmode mode) +gzofstream::attach (int fd, + std::ios_base::openmode mode) { - if (!sb.attach(fd, mode | std::ios_base::out)) - this->setstate(std::ios_base::failbit); + if (! sb.attach (fd, mode | std::ios_base::out)) + this->setstate (std::ios_base::failbit); else this->clear (); } @@ -618,8 +618,8 @@ void gzofstream::close () { - if (!sb.close ()) - this->setstate(std::ios_base::failbit); + if (! sb.close ()) + this->setstate (std::ios_base::failbit); } #endif // HAVE_ZLIB
--- a/src/zfstream.h +++ b/src/zfstream.h @@ -71,8 +71,8 @@ * setcompressionlevel(level). */ int - setcompression(int comp_level, - int comp_strategy = Z_DEFAULT_STRATEGY); + setcompression (int comp_level, + int comp_strategy = Z_DEFAULT_STRATEGY); /** * @brief Check if file is open. @@ -88,8 +88,8 @@ * @return @c this on success, NULL on failure. */ gzfilebuf* - open(const char* name, - std::ios_base::openmode mode); + open (const char* name, + std::ios_base::openmode mode); /** * @brief Attach to already open gzipped file. @@ -98,8 +98,8 @@ * @return @c this on success, NULL on failure. */ gzfilebuf* - attach(int fd, - std::ios_base::openmode mode); + attach (int fd, + std::ios_base::openmode mode); /** * @brief Close gzipped file. @@ -114,8 +114,8 @@ * @return True if valid mode flag combination. */ bool - open_mode(std::ios_base::openmode mode, - char* c_mode) const; + open_mode (std::ios_base::openmode mode, + char* c_mode) const; /** * @brief Number of characters available in stream buffer. @@ -147,7 +147,7 @@ * character at a time. */ virtual int_type - overflow(int_type c = traits_type::eof ()); + overflow (int_type c = traits_type::eof ()); /** * @brief Installs external stream buffer. @@ -158,8 +158,8 @@ * Call setbuf(0,0) to enable unbuffered output. */ virtual std::streambuf* - setbuf(char_type* p, - std::streamsize n); + setbuf (char_type* p, + std::streamsize n); /** * @brief Flush stream buffer to file. @@ -176,9 +176,9 @@ * Each derived class provides its own appropriate behavior. */ virtual pos_type - seekoff(off_type off, std::ios_base::seekdir way, - std::ios_base::openmode mode = - std::ios_base::in|std::ios_base::out); + seekoff (off_type off, std::ios_base::seekdir way, + std::ios_base::openmode mode = + std::ios_base::in|std::ios_base::out); /** * @brief Alters the stream positions. @@ -186,8 +186,8 @@ * Each derived class provides its own appropriate behavior. */ virtual pos_type - seekpos(pos_type sp, std::ios_base::openmode mode = - std::ios_base::in|std::ios_base::out); + seekpos (pos_type sp, std::ios_base::openmode mode = + std::ios_base::in|std::ios_base::out); virtual int_type pbackfail (int_type c = traits_type::eof ()); @@ -290,8 +290,8 @@ * @param mode Open mode flags (forced to contain ios::in). */ explicit - gzifstream(const char* name, - std::ios_base::openmode mode = std::ios_base::in); + gzifstream (const char* name, + std::ios_base::openmode mode = std::ios_base::in); /** * @brief Construct stream on already open gzipped file. @@ -299,8 +299,8 @@ * @param mode Open mode flags (forced to contain ios::in). */ explicit - gzifstream(int fd, - std::ios_base::openmode mode = std::ios_base::in); + gzifstream (int fd, + std::ios_base::openmode mode = std::ios_base::in); /** * Obtain underlying stream buffer. @@ -329,8 +329,8 @@ * convenience. */ void - open(const char* name, - std::ios_base::openmode mode = std::ios_base::in); + open (const char* name, + std::ios_base::openmode mode = std::ios_base::in); /** * @brief Attach to already open gzipped file. @@ -341,8 +341,8 @@ * in state fail(). */ void - attach(int fd, - std::ios_base::openmode mode = std::ios_base::in); + attach (int fd, + std::ios_base::openmode mode = std::ios_base::in); /** * @brief Close gzipped file. @@ -379,8 +379,8 @@ * @param mode Open mode flags (forced to contain ios::out). */ explicit - gzofstream(const char* name, - std::ios_base::openmode mode = std::ios_base::out); + gzofstream (const char* name, + std::ios_base::openmode mode = std::ios_base::out); /** * @brief Construct stream on already open gzipped file. @@ -388,8 +388,8 @@ * @param mode Open mode flags (forced to contain ios::out). */ explicit - gzofstream(int fd, - std::ios_base::openmode mode = std::ios_base::out); + gzofstream (int fd, + std::ios_base::openmode mode = std::ios_base::out); /** * Obtain underlying stream buffer. @@ -418,8 +418,8 @@ * convenience. */ void - open(const char* name, - std::ios_base::openmode mode = std::ios_base::out); + open (const char* name, + std::ios_base::openmode mode = std::ios_base::out); /** * @brief Attach to already open gzipped file. @@ -430,8 +430,8 @@ * in state fail(). */ void - attach(int fd, - std::ios_base::openmode mode = std::ios_base::out); + attach (int fd, + std::ios_base::openmode mode = std::ios_base::out); /** * @brief Close gzipped file. @@ -467,9 +467,9 @@ const gzomanip2<Ta,Tb>&); // Constructor - gzomanip2(gzofstream& (*f)(gzofstream&, T1, T2), - T1 v1, - T2 v2); + gzomanip2 (gzofstream& (*f)(gzofstream&, T1, T2), + T1 v1, + T2 v2); private: // Underlying manipulator function gzofstream& @@ -484,18 +484,18 @@ // Manipulator function thunks through to stream buffer inline gzofstream& -setcompression(gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) +setcompression (gzofstream &gzs, int l, int s = Z_DEFAULT_STRATEGY) { - (gzs.rdbuf ())->setcompression(l, s); + (gzs.rdbuf ())->setcompression (l, s); return gzs; } // Manipulator constructor stores arguments template<typename T1, typename T2> inline - gzomanip2<T1,T2>::gzomanip2(gzofstream &(*f)(gzofstream &, T1, T2), - T1 v1, - T2 v2) + gzomanip2<T1,T2>::gzomanip2 (gzofstream &(*f)(gzofstream &, T1, T2), + T1 v1, + T2 v2) : func(f), val1(v1), val2(v2) { } @@ -507,7 +507,7 @@ // Insert this onto stream to simplify setting of compression level inline gzomanip2<int,int> -setcompression(int l, int s = Z_DEFAULT_STRATEGY) +setcompression (int l, int s = Z_DEFAULT_STRATEGY) { return gzomanip2<int,int>(&setcompression, l, s); } #endif // HAVE_ZLIB