Mercurial > octave
changeset 30326:cd7c824f3f22
eliminate use of .+ and .- operators in Octave sources
* bsxfun.cc, graphics.cc, annotation.m, __interp_cube__.m,
__marching_cube__.m, subplot.m, spline.m, betainc.m, gallery.m: Use +
and - instead of .+ and .- in Octave sources and tests.
* pt-eval.cc (get_operator_function_name): Note that .+ and .- are
deprecated.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 23 Nov 2021 12:36:01 -0500 |
parents | f18f5cae2b06 |
children | 256fad4ac653 |
files | libinterp/corefcn/bsxfun.cc libinterp/corefcn/graphics.cc libinterp/parse-tree/pt-eval.cc scripts/plot/appearance/annotation.m scripts/plot/draw/private/__interp_cube__.m scripts/plot/draw/private/__marching_cube__.m scripts/plot/util/subplot.m scripts/polynomial/spline.m scripts/specfun/betainc.m scripts/special-matrix/gallery.m |
diffstat | 10 files changed, 51 insertions(+), 49 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/bsxfun.cc Tue Nov 23 12:28:40 2021 -0500 +++ b/libinterp/corefcn/bsxfun.cc Tue Nov 23 12:36:01 2021 -0500 @@ -797,13 +797,13 @@ %! endfor ## Automatic broadcasting with zero length dimensions -%!assert <*47085> ([1 2 3] .+ zeros (0, 3), zeros (0, 3)) -%!assert <*47085> (rand (3, 3, 1) .+ rand (3, 3, 0), zeros (3, 3, 0)) +%!assert <*47085> ([1 2 3] + zeros (0, 3), zeros (0, 3)) +%!assert <*47085> (rand (3, 3, 1) + rand (3, 3, 0), zeros (3, 3, 0)) ## In-place broadcasting with zero length dimensions %!test <*47085> %! a = zeros (0, 3); -%! a .+= [1 2 3]; +%! a += [1 2 3]; %! assert (a, zeros (0, 3)); %!test <*53179>
--- a/libinterp/corefcn/graphics.cc Tue Nov 23 12:28:40 2021 -0500 +++ b/libinterp/corefcn/graphics.cc Tue Nov 23 12:36:01 2021 -0500 @@ -4653,7 +4653,7 @@ %! set (hf, "paperunits", "centimeters"); %! psz = get (hf, "papersize"); %! fsz = in_pos(3:4) * 2.54; -%! pos = [(psz/2 .- fsz/2) fsz]; +%! pos = [(psz/2 - fsz/2) fsz]; %! set (hf, "paperpositionmode", "auto"); %! assert (get (hf, "paperposition"), pos, tol); %! unwind_protect_cleanup @@ -4671,7 +4671,7 @@ %! psz = get (hf, "papersize"); %! set (hf, "paperunits", "normalized"); %! fsz = in_pos(3:4) ./ psz; -%! pos = [([0.5 0.5] .- fsz/2) fsz]; +%! pos = [([0.5 0.5] - fsz/2) fsz]; %! assert (get (hf, "paperposition"), pos, tol); %! unwind_protect_cleanup %! close (hf); @@ -4688,7 +4688,7 @@ %! set (hf, "papertype", "a4"); %! psz = get (hf, "papersize"); %! fsz = in_pos(3:4); -%! pos = [(psz/2 .- fsz/2) fsz]; +%! pos = [(psz/2 - fsz/2) fsz]; %! assert (get (hf, "paperposition"), pos, tol); %! unwind_protect_cleanup %! close (hf); @@ -4705,7 +4705,7 @@ %! set (hf, "paperorientation", "landscape"); %! psz = get (hf, "papersize"); %! fsz = in_pos(3:4); -%! pos = [(psz/2 .- fsz/2) fsz]; +%! pos = [(psz/2 - fsz/2) fsz]; %! assert (get (hf, "paperposition"), pos, tol); %! unwind_protect_cleanup %! close (hf);
--- a/libinterp/parse-tree/pt-eval.cc Tue Nov 23 12:28:40 2021 -0500 +++ b/libinterp/parse-tree/pt-eval.cc Tue Nov 23 12:36:01 2021 -0500 @@ -1478,8 +1478,8 @@ // the corresponding function name. At least try to do it without N // string compares. - // FIXME: ** and .** are deprecated but still need to be handled - // here until they are removed. + // FIXME: .+, .-, **, and .** are deprecated but still need to be + // handled here until they are removed. std::size_t len = name.length (); @@ -1496,9 +1496,11 @@ return "transpose"; case '+': + // deprecated return "plus"; case '-': + // deprecated return "minus"; case '*':
--- a/scripts/plot/appearance/annotation.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/plot/appearance/annotation.m Tue Nov 23 12:36:01 2021 -0500 @@ -965,7 +965,7 @@ ln = get (h, "headlength"); # in points wd = get (h, "headwidth"); headstyle = get (h, "headstyle"); - pos = pos(1:2) .+ pos(3:4); + pos = pos(1:2) + pos(3:4); elseif (nar == 1) ln = get (h, "head1length"); # in points wd = get (h, "head1width"); @@ -976,7 +976,7 @@ ln = get (h, "head2length"); # in points wd = get (h, "head2width"); headstyle = get (h, "head2style"); - pos = pos(1:2) .+ pos(3:4); + pos = pos(1:2) + pos(3:4); else error ("annotation: %d, no such arrow number"); endif @@ -1024,7 +1024,7 @@ sin(ang), cos(ang)]; XY = R * [x; y]; XY = pts2norm (h, XY); - XY = pos(1:2).' .+ XY; + XY = pos(1:2).' + XY; x = XY(1,:).'; y = XY(2,:).'; @@ -1188,7 +1188,7 @@ sin(rot), cos(rot)]; XY = R * XY; XY = pts2norm (get (hte, "parent"), XY); - XY = pos(1:2) .- XY(:,pt).'; + XY = pos(1:2) - XY(:,pt).'; endfunction
--- a/scripts/plot/draw/private/__interp_cube__.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/plot/draw/private/__interp_cube__.m Tue Nov 23 12:36:01 2021 -0500 @@ -85,9 +85,9 @@ v110 = interp_cube_trilin (x, y, z, val, p110); v111 = interp_cube_trilin (x, y, z, val, p111); - Dx = -v000 .+ v100 .- v010 .- v001 .- v011 .+ v101 .+ v110 .+ v111; - Dy = -v000 .- v100 .+ v010 .- v001 .+ v011 .- v101 .+ v110 .+ v111; - Dz = -v000 .- v100 .- v010 .+ v001 .+ v011 .+ v101 .- v110 .+ v111; + Dx = -v000 + v100 - v010 - v001 - v011 + v101 + v110 + v111; + Dy = -v000 - v100 + v010 - v001 + v011 - v101 + v110 + v111; + Dz = -v000 - v100 - v010 + v001 + v011 + v101 - v110 + v111; Vxyz = 0.5 .* [Dx./dx, Dy./dy, Dz./dz]; case "normals8" @@ -128,13 +128,13 @@ By = frac(:, 2); Bz = frac(:, 3); Vxyz = ... - val( i000 ) .* (1 .- Bx) .* (1 .- By) .* (1 .- Bz) .+ ... - val( i100 ) .* Bx .* (1 .- By) .* (1 .- Bz) .+ ... - val( i010 ) .* (1 .- Bx) .* By .* (1 .- Bz) .+ ... - val( i001 ) .* (1 .- Bx) .* (1 .- By) .* Bz .+ ... - val( i011 ) .* (1 .- Bx) .* By .* Bz .+ ... - val( i101 ) .* Bx .* (1 .- By) .* Bz .+ ... - val( i110 ) .* Bx .* By .* (1 .- Bz) .+ ... + val( i000 ) .* (1 - Bx) .* (1 - By) .* (1 - Bz) + ... + val( i100 ) .* Bx .* (1 - By) .* (1 - Bz) + ... + val( i010 ) .* (1 - Bx) .* By .* (1 - Bz) + ... + val( i001 ) .* (1 - Bx) .* (1 - By) .* Bz + ... + val( i011 ) .* (1 - Bx) .* By .* Bz + ... + val( i101 ) .* Bx .* (1 - By) .* Bz + ... + val( i110 ) .* Bx .* By .* (1 - Bz) + ... val( i111 ) .* Bx .* By .* Bz; endfunction @@ -155,31 +155,31 @@ By = frac(:, 2); Bz = frac(:, 3); Dx = ... - val( i000 ) .* -1 .* (1 .- By) .* (1 .- Bz) .+ ... - val( i100 ) .* (1 .- By) .* (1 .- Bz) .+ ... - val( i010 ) .* -1 .* By .* (1 .- Bz) .+ ... - val( i001 ) .* -1 .* (1 .- By) .* Bz .+ ... - val( i011 ) .* -1 .* By .* Bz .+ ... - val( i101 ) .* (1 .- By) .* Bz .+ ... - val( i110 ) .* By .* (1 .- Bz) .+ ... + val( i000 ) .* -1 .* (1 - By) .* (1 - Bz) + ... + val( i100 ) .* (1 - By) .* (1 - Bz) + ... + val( i010 ) .* -1 .* By .* (1 - Bz) + ... + val( i001 ) .* -1 .* (1 - By) .* Bz + ... + val( i011 ) .* -1 .* By .* Bz + ... + val( i101 ) .* (1 - By) .* Bz + ... + val( i110 ) .* By .* (1 - Bz) + ... val( i111 ) .* By .* Bz; Dy = ... - val( i000 ) .* (1 .- Bx) .* -1 .* (1 .- Bz) .+ ... - val( i100 ) .* Bx .* -1 .* (1 .- Bz) .+ ... - val( i010 ) .* (1 .- Bx) .* (1 .- Bz) .+ ... - val( i001 ) .* (1 .- Bx) .* -1 .* Bz .+ ... - val( i011 ) .* (1 .- Bx) .* Bz .+ ... - val( i101 ) .* Bx .* -1 .* Bz .+ ... - val( i110 ) .* Bx .* (1 .- Bz) .+ ... + val( i000 ) .* (1 - Bx) .* -1 .* (1 - Bz) + ... + val( i100 ) .* Bx .* -1 .* (1 - Bz) + ... + val( i010 ) .* (1 - Bx) .* (1 - Bz) + ... + val( i001 ) .* (1 - Bx) .* -1 .* Bz + ... + val( i011 ) .* (1 - Bx) .* Bz + ... + val( i101 ) .* Bx .* -1 .* Bz + ... + val( i110 ) .* Bx .* (1 - Bz) + ... val( i111 ) .* Bx .* Bz; Dz = ... - val( i000 ) .* (1 .- Bx) .* (1 .- By) .* -1 .+ ... - val( i100 ) .* Bx .* (1 .- By) .* -1 .+ ... - val( i010 ) .* (1 .- Bx) .* By .* -1 .+ ... - val( i001 ) .* (1 .- Bx) .* (1 .- By) .+ ... - val( i011 ) .* (1 .- Bx) .* By + ... - val( i101 ) .* Bx .* (1 .- By) .+ ... - val( i110 ) .* Bx .* By .* -1 .+ ... + val( i000 ) .* (1 - Bx) .* (1 - By) .* -1 + ... + val( i100 ) .* Bx .* (1 - By) .* -1 + ... + val( i010 ) .* (1 - Bx) .* By .* -1 + ... + val( i001 ) .* (1 - Bx) .* (1 - By) + ... + val( i011 ) .* (1 - Bx) .* By + ... + val( i101 ) .* Bx .* (1 - By) + ... + val( i110 ) .* Bx .* By .* -1 + ... val( i111 ) .* Bx .* By; endfunction
--- a/scripts/plot/draw/private/__marching_cube__.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/plot/draw/private/__marching_cube__.m Tue Nov 23 12:36:01 2021 -0500 @@ -215,7 +215,7 @@ error ("__marching_cube__: wrong number of arguments"); endif - id = abs (valp1-valp2) < (10*eps) .* (abs (valp1) .+ abs (valp2)); + id = abs (valp1-valp2) < (10*eps) .* (abs (valp1) + abs (valp2)); if (any (id)) p(id, 1:3) = [ p1x(id), p1y(id), p1z(id) ]; if (nargin == 11)
--- a/scripts/plot/util/subplot.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/plot/util/subplot.m Tue Nov 23 12:36:01 2021 -0500 @@ -374,7 +374,7 @@ ## Row/Column inside the axes array row = ceil (idx / ncols); - col = idx .- (row - 1) * ncols; + col = idx - (row - 1) * ncols; row = [min(row) max(row)]; col = [min(col) max(col)];
--- a/scripts/polynomial/spline.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/polynomial/spline.m Tue Nov 23 12:36:01 2021 -0500 @@ -182,7 +182,7 @@ g(2:n - 3,:) = 3 * diff (a(3:n-1,:)) ./ h(3:n-2,idx) ... - 3 * diff (a(2:n-2,:)) ./ h(2:n - 3,idx); - dg = 2 * (h(1:n-2) .+ h(2:n-1)); + dg = 2 * (h(1:n-2) + h(2:n-1)); dg(1) = dg(1) - h(1); dg(n-2) = dg(n-2) - h(n-1);
--- a/scripts/specfun/betainc.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/specfun/betainc.m Tue Nov 23 12:36:01 2021 -0500 @@ -223,7 +223,7 @@ %! v2 = single ([1,1,1,1]); %! x = [.2, .4, .6, .8]; %! v3 = betainc (x, a, b); -%! v4 = 1-betainc (1.-x, b, a); +%! v4 = 1 - betainc (1. - x, b, a); %! assert (v1, v2, sqrt (eps ("single"))); %! assert (v3, v4, sqrt (eps ("single")));
--- a/scripts/special-matrix/gallery.m Tue Nov 23 12:28:40 2021 -0500 +++ b/scripts/special-matrix/gallery.m Tue Nov 23 12:36:01 2021 -0500 @@ -562,7 +562,7 @@ error ("gallery: X and Y must be vectors of same length for cauchy matrix"); endif - C = 1 ./ (x .+ y.'); + C = 1 ./ (x + y.'); endfunction function C = chebspec (n, k = 0)