Mercurial > hg > octave-nkf
changeset 14856:c3fd61c59e9c
maint: Use Octave coding conventions for cuddling parentheses in doc directory
* OctaveFAQ.texi, basics.txi, container.txi, contrib.txi, diagperm.txi,
diffeq.txi, dynamic.txi, errors.txi, eval.txi, expr.txi, func.txi,
geometry.txi, interp.txi, intro.txi, numbers.txi, oop.txi, plot.txi, poly.txi,
quad.txi, set.txi, sparse.txi, stmt.txi, testfun.txi, vectorize.txi,
refcard.tex: Use Octave coding conventions for cuddling parentheses.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 09 Jul 2012 17:00:46 -0700 |
parents | 1b48b209a8d6 |
children | 7371e127c351 |
files | doc/faq/OctaveFAQ.texi doc/interpreter/basics.txi doc/interpreter/container.txi doc/interpreter/contrib.txi doc/interpreter/diagperm.txi doc/interpreter/diffeq.txi doc/interpreter/dynamic.txi doc/interpreter/errors.txi doc/interpreter/eval.txi doc/interpreter/expr.txi doc/interpreter/func.txi doc/interpreter/geometry.txi doc/interpreter/interp.txi doc/interpreter/intro.txi doc/interpreter/numbers.txi doc/interpreter/oop.txi doc/interpreter/plot.txi doc/interpreter/poly.txi doc/interpreter/quad.txi doc/interpreter/set.txi doc/interpreter/sparse.txi doc/interpreter/stmt.txi doc/interpreter/testfun.txi doc/interpreter/vectorize.txi doc/refcard/refcard.tex |
diffstat | 25 files changed, 197 insertions(+), 198 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/faq/OctaveFAQ.texi +++ b/doc/faq/OctaveFAQ.texi @@ -454,7 +454,7 @@ @group octave:1> [3 1 4 1 5 9](3) ans = 4 -octave:2> cos([0 pi pi/4 7])(3) +octave:2> cos ([0 pi pi/4 7])(3) ans = 0.70711 @end group @end example @@ -871,7 +871,7 @@ @example @group function y = foo (x) - y = bar(x) + y = bar (x) function y = bar (x) y = @dots{}; end @@ -884,7 +884,7 @@ @example @group function y = foo (x) - y = bar(x) + y = bar (x) end function y = bar (x) y = @dots{}; @@ -1065,7 +1065,7 @@ @example @group - do_braindead_shortcircuit_evaluation(1) + do_braindead_shortcircuit_evaluation (1) @end group @end example @@ -1102,7 +1102,7 @@ logically true). Finally, note the inconsistence of thinking of the condition of an if -statement as being equivalent to @code{all(X(:))} when @var{X} is a +statement as being equivalent to @code{all (X(:))} when @var{X} is a matrix. This is true for all cases EXCEPT empty matrices: @example @@ -1147,7 +1147,7 @@ @example @group function x = mldivide (A, b) - [Q, R, E] = qr(A); + [Q, R, E] = qr (A); x = [A \ b, E(:, 1:m) * (R(:, 1:m) \ (Q' * b))] end @end group @@ -1161,14 +1161,14 @@ A numerical question arises: how big can the null space component become, relative to the minimum-norm solution? Can it be nicely bounded, or can it be arbitrarily big? Consider this example: - +OctaveFAQ.texi @example @group m = 10; n = 10000; -A = ones(m, n) + 1e-6 * randn(m,n); -b = ones(m, 1) + 1e-6 * randn(m,1); -norm(A \ b) +A = ones (m, n) + 1e-6 * randn (m,n); +b = ones (m, 1) + 1e-6 * randn (m,1); +norm (A \ b) @end group @end example @@ -1180,14 +1180,14 @@ @group m = 5; n = 100; -j = floor(m * rand(1, n)) + 1; -b = ones(m, 1); -A = zeros(m, n); -A(sub2ind(size(A),j,1:n)) = 1; +j = floor (m * rand (1, n)) + 1; +b = ones (m, 1); +A = zeros (m, n); +A(sub2ind (size (A),j,1:n)) = 1; x = A \ b; -[dummy,p] = sort(rand(1,n)); -y = A(:,p)\b; -norm(x(p)-y) +[dummy,p] = sort (rand (1,n)); +y = A(:,p) \ b; +norm (x(p)-y) @end group @end example @@ -1282,10 +1282,10 @@ gives no safe way of temporarily changing global variables. @item -Indexing can be applied to all objects in Octave and not just +Indexing can be applied to all objects in Octave and not just a variable. Therefore @code{sin(x)(1:10);} for example is perfectly valid in Octave but not @sc{Matlab}. To do the same in @sc{Matlab} you must do -@code{y = sin(x); y = y([1:10]);} +@code{y = sin (x); y = y([1:10]);} @item Octave has the operators "++", "--", "-=", "+=", "*=", etc. As
--- a/doc/interpreter/basics.txi +++ b/doc/interpreter/basics.txi @@ -1023,10 +1023,10 @@ @group function countdown # Count down for main rocket engines - disp(3); - disp(2); - disp(1); - disp("Blast Off!"); # Rocket leaves pad + disp (3); + disp (2); + disp (1); + disp ("Blast Off!"); # Rocket leaves pad endfunction @end group @end example @@ -1046,19 +1046,19 @@ @group function quick_countdown # Count down for main rocket engines - disp(3); + disp (3); #@{ - disp(2); - disp(1); + disp (2); + disp (1); #@} - disp("Blast Off!"); # Rocket leaves pad + disp ("Blast Off!"); # Rocket leaves pad endfunction @end group @end example @noindent will produce a very quick countdown from '3' to 'Blast Off' as the -lines "@code{disp(2);}" and "@code{disp(1);}" won't be executed. +lines "@code{disp (2);}" and "@code{disp (1);}" won't be executed. The block comment markers must appear alone as the only characters on a line (excepting whitespace) in order to be parsed correctly.
--- a/doc/interpreter/container.txi +++ b/doc/interpreter/container.txi @@ -308,7 +308,7 @@ @example @group -[x.a] = deal("new string1", "new string2"); +[x.a] = deal ("new string1", "new string2"); x(1).a @result{} ans = new string1 x(2).a @@ -322,7 +322,7 @@ @example @group x(3:4) = x(1:2); -[x([1,3]).a] = deal("other string1", "other string2"); +[x([1,3]).a] = deal ("other string1", "other string2"); x.a @result{} ans = other string1 @@ -337,7 +337,7 @@ @example @group -size(x) +size (x) @result{} ans = 1 4 @@ -605,10 +605,10 @@ @example @group -iscell(c) +iscell (c) @result{} ans = 1 -iscell(3) +iscell (3) @result{} ans = 0 @end group @@ -631,7 +631,7 @@ @example @group -c = cell(2,2) +c = cell (2,2) @result{} c = @{ @@ -652,9 +652,9 @@ @example @group -c1 = cell(3, 4, 5); -c2 = cell( [3, 4, 5] ); -size(c1) +c1 = cell (3, 4, 5); +c2 = cell ( [3, 4, 5] ); +size (c1) @result{} ans = 3 4 5 @end group @@ -766,7 +766,7 @@ @example @group -[c@{[1,2], :@}] = deal(c@{[2, 1], :@}) +[c@{[1,2], :@}] = deal (c@{[2, 1], :@}) @result{} = @{ [1,1] = 1
--- a/doc/interpreter/contrib.txi +++ b/doc/interpreter/contrib.txi @@ -331,7 +331,7 @@ @example @group if (isvector (a)) - s = sum(a); + s = sum (a); endif @end group @end example
--- a/doc/interpreter/diagperm.txi +++ b/doc/interpreter/diagperm.txi @@ -93,7 +93,7 @@ 0 0 3 0 0 0 0 4 - diag(1:3,5,3) + diag (1:3,5,3) @result{} Diagonal Matrix @@ -554,13 +554,13 @@ @example @group -diag(1:3) * [NaN; 1; 1] +diag (1:3) * [NaN; 1; 1] @result{} NaN 2 3 -sparse(1:3,1:3,1:3) * [NaN; 1; 1] +sparse (1:3,1:3,1:3) * [NaN; 1; 1] @result{} NaN 2
--- a/doc/interpreter/diffeq.txi +++ b/doc/interpreter/diffeq.txi @@ -100,8 +100,8 @@ @example @group -t = [0, logspace (-1, log10(303), 150), \ - logspace (log10(304), log10(500), 150)]; +t = [0, logspace(-1, log10(303), 150), \ + logspace(log10(304), log10(500), 150)]; @end group @end example
--- a/doc/interpreter/dynamic.txi +++ b/doc/interpreter/dynamic.txi @@ -551,7 +551,7 @@ should use @code{numel} rather than @code{nelem}. Note that for very large matrices, where the product of the two dimensions is larger than the representation of an unsigned int, then @code{numel} can overflow. -An example is @code{speye(1e6)} which will create a matrix with a million +An example is @code{speye (1e6)} which will create a matrix with a million rows and columns, but only a million non-zero elements. Therefore the number of rows by the number of columns in this case is more than two hundred times the maximum value that can be represented by an unsigned int. @@ -901,9 +901,9 @@ @group funcdemo (@@sin,1) @result{} 0.84147 -funcdemo (@@(x) sin(x), 1) +funcdemo (@@(x) sin (x), 1) @result{} 0.84147 -funcdemo (inline ("sin(x)"), 1) +funcdemo (inline ("sin (x)"), 1) @result{} 0.84147 funcdemo ("sin",1) @result{} 0.84147 @@ -1008,7 +1008,7 @@ @result{} b = 1.00000 0.50000 0.33333 s = There are 3 values in the input vector -[b, s] = fortdemo(0:3) +[b, s] = fortdemo (0:3) error: fortsub:divide by zero error: exception encountered in Fortran subroutine fortsub_ error: fortdemo: error in Fortran @@ -1086,7 +1086,7 @@ for (octave_idx_type i = 0; i < a.nelem (); i++) @{ OCTAVE_QUIT; - b.elem(i) = 2. * a.elem(i); + b.elem (i) = 2. * a.elem (i); @} @end group @end example @@ -1195,9 +1195,9 @@ @group /* -%!error (sin()) -%!error (sin(1,1)) -%!assert (sin([1,2]),[sin(1),sin(2)]) +%!error (sin ()) +%!error (sin (1,1)) +%!assert (sin ([1,2]),[sin(1),sin(2)]) */ @end group @@ -1371,7 +1371,7 @@ mwSize *dims; UINT32_T *pr; -dims = (mwSize *) mxMalloc (2 * sizeof(mwSize)); +dims = (mwSize *) mxMalloc (2 * sizeof (mwSize)); dims[0] = 2; dims[1] = 2; m = mxCreateNumericArray (2, dims, mxUINT32_CLASS, mxREAL); @@ -1403,8 +1403,8 @@ @example @group -b = randn(4,1) + 1i * randn(4,1); -all(b.^2 == mypow2(b)) +b = randn (4,1) + 1i * randn (4,1); +all (b.^2 == mypow2 (b)) @result{} 1 @end group @end example @@ -1434,7 +1434,7 @@ @example @group -mystring(["First String"; "Second String"]) +mystring (["First String"; "Second String"]) @result{} s1 = Second String First String @end group @@ -1549,7 +1549,7 @@ @example a(1).f1 = "f11"; a(1).f2 = "f12"; a(2).f1 = "f21"; a(2).f2 = "f22"; -b = mystruct(a) +b = mystruct (a) @result{} field f1(0) = f11 field f1(1) = f21 field f2(0) = f12 @@ -1651,8 +1651,8 @@ @example @group -myfeval("sin", 1) -a = myfeval("sin", 1) +myfeval ("sin", 1) +a = myfeval ("sin", 1) @result{} Hello, World! I have 2 inputs and 1 outputs I'm going to call the interpreter function sin
--- a/doc/interpreter/errors.txi +++ b/doc/interpreter/errors.txi @@ -63,7 +63,7 @@ @group function f (arg1) if (nargin == 0) - error("not enough input arguments"); + error ("not enough input arguments"); endif endfunction @end group
--- a/doc/interpreter/eval.txi +++ b/doc/interpreter/eval.txi @@ -127,8 +127,8 @@ @group function save (file, name1, name2) f = open_save_file (file); - save_var(f, name1, evalin ("caller", name1)); - save_var(f, name2, evalin ("caller", name2)); + save_var (f, name1, evalin ("caller", name1)); + save_var (f, name2, evalin ("caller", name2)); endfunction @end group @end example
--- a/doc/interpreter/expr.txi +++ b/doc/interpreter/expr.txi @@ -258,7 +258,7 @@ $a_i = \sqrt{i}$. @end tex @ifnottex -a(i) = sqrt(i). +a(i) = sqrt (i). @end ifnottex @example @@ -772,8 +772,8 @@ @example @group - abs(@var{z1}) < abs(@var{z2}) - || (abs(@var{z1}) == abs(@var{z2}) && arg(@var{z1}) < arg(@var{z2})) + abs (@var{z1}) < abs (@var{z2}) + || (abs (@var{z1}) == abs (@var{z2}) && arg (@var{z1}) < arg (@var{z2})) @end group @end example
--- a/doc/interpreter/func.txi +++ b/doc/interpreter/func.txi @@ -772,7 +772,7 @@ code adds @samp{~/Octave} to the load path. @example -addpath("~/Octave") +addpath ("~/Octave") @end example @noindent @@ -1400,7 +1400,7 @@ function @math{f(x) = x^2 + 2}. @example -f = inline("x^2 + 2"); +f = inline ("x^2 + 2"); @end example @noindent @@ -1430,7 +1430,7 @@ is equivalent to @example -my_command("hello", "world") +my_command ("hello", "world") @end example @noindent
--- a/doc/interpreter/geometry.txi +++ b/doc/interpreter/geometry.txi @@ -72,7 +72,7 @@ X = [ x(T(:,1)); x(T(:,2)); x(T(:,3)); x(T(:,1)) ]; Y = [ y(T(:,1)); y(T(:,2)); y(T(:,3)); y(T(:,1)) ]; axis ([0, 1, 0, 1]); -plot(X, Y, "b", x, y, "r*"); +plot (X, Y, "b", x, y, "r*"); @end group @end example @@ -172,7 +172,7 @@ @example @group @var{p} - @var{t}(end, :) = @var{beta}(1:end-1) * (@var{t}(1:end-1, :) - - ones(@var{N}, 1) * @var{t}(end, :) + - ones (@var{N}, 1) * @var{t}(end, :) @end group @end example @@ -182,8 +182,8 @@ @example @group @var{beta}(1:end-1) = (@var{p} - @var{t}(end, :)) / (@var{t}(1:end-1, :) - - ones(@var{N}, 1) * @var{t}(end, :)) -@var{beta}(end) = sum(@var{beta}(1:end-1)) + - ones (@var{N}, 1) * @var{t}(end, :)) +@var{beta}(end) = sum (@var{beta}(1:end-1)) @end group @end example @@ -298,9 +298,9 @@ @example @group -rand("state",9); -x = rand(10,1); -y = rand(10,1); +rand ("state",9); +x = rand (10,1); +y = rand (10,1); tri = delaunay (x, y); [vx, vy] = voronoi (x, y, tri); triplot (tri, x, y, "b"); @@ -336,7 +336,7 @@ x = rand (10, 1); y = rand (10, 1); [c, f] = voronoin ([x, y]); -af = zeros (size(f)); +af = zeros (size (f)); for i = 1 : length (f) af(i) = polyarea (c (f @{i, :@}, 1), c (f @{i, :@}, 2)); endfor @@ -361,7 +361,7 @@ vx = cos (pi * [-1 : 0.1: 1]); vy = sin (pi * [-1 : 0.1 : 1]); in = inpolygon (x, y, vx, vy); -plot(vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); +plot (vx, vy, x(in), y(in), "r+", x(!in), y(!in), "bo"); axis ([-2, 2, -2, 2]); @end group @end example @@ -434,12 +434,12 @@ @example @group -rand("state",1); -x=2*rand(1000,1)-1; -y=2*rand(size(x))-1; -z=sin(2*(x.^2+y.^2)); -[xx,yy]=meshgrid(linspace(-1,1,32)); -griddata(x,y,z,xx,yy); +rand ("state", 1); +x = 2*rand (1000,1) - 1; +y = 2*rand (size (x)) - 1; +z = sin (2*(x.^2+y.^2)); +[xx,yy] = meshgrid (linspace (-1,1,32)); +griddata (x,y,z,xx,yy); @end group @end example
--- a/doc/interpreter/interp.txi +++ b/doc/interpreter/interp.txi @@ -50,17 +50,17 @@ dt = 1; ti =-2:0.025:2; dti = 0.025; -y = sign(t); -ys = interp1(t,y,ti,'spline'); -yp = interp1(t,y,ti,'pchip'); -ddys = diff(diff(ys)./dti)./dti; -ddyp = diff(diff(yp)./dti)./dti; -figure(1); -plot (ti, ys,'r-', ti, yp,'g-'); -legend('spline','pchip',4); -figure(2); -plot (ti, ddys,'r+', ti, ddyp,'g*'); -legend('spline','pchip'); +y = sign (t); +ys = interp1 (t,y,ti,'spline'); +yp = interp1 (t,y,ti,'pchip'); +ddys = diff (diff (ys)./dti) ./ dti; +ddyp = diff (diff (yp)./dti) ./ dti; +figure (1); +plot (ti,ys,'r-', ti,yp,'g-'); +legend ('spline', 'pchip', 4); +figure (2); +plot (ti,ddys,'r+', ti,ddyp,'g*'); +legend ('spline', 'pchip'); @end group @end example @@ -107,9 +107,9 @@ ti = t(1) + [0 : k-1]*dt*n/k; y = sin (4*t + 0.3) .* cos (3*t - 0.1); yp = sin (4*ti + 0.3) .* cos (3*ti - 0.1); -plot (ti, yp, 'g', ti, interp1(t, y, ti, 'spline'), 'b', ... +plot (ti, yp, 'g', ti, interp1 (t, y, ti, 'spline'), 'b', ... ti, interpft (y, k), 'c', t, y, 'r+'); -legend ('sin(4t+0.3)cos(3t-0.1','spline','interpft','data'); +legend ('sin(4t+0.3)cos(3t-0.1', 'spline', 'interpft', 'data'); @end group @end example @@ -164,9 +164,9 @@ v = f (xx,yy,zz); xi = yi = zi = -1:0.1:1; [xxi, yyi, zzi] = meshgrid (xi, yi, zi); -vi = interp3(x, y, z, v, xxi, yyi, zzi, 'spline'); +vi = interp3 (x, y, z, v, xxi, yyi, zzi, 'spline'); [xxi, yyi, zzi] = ndgrid (xi, yi, zi); -vi2 = interpn(x, y, z, v, xxi, yyi, zzi, 'spline'); +vi2 = interpn (x, y, z, v, xxi, yyi, zzi, 'spline'); mesh (zi, yi, squeeze (vi2(1,:,:))); @end group @end example
--- a/doc/interpreter/intro.txi +++ b/doc/interpreter/intro.txi @@ -104,7 +104,7 @@ tolerance of the calculation. @example -octave:1> exp(i*pi) +octave:1> exp (i*pi) @end example @subsection Creating a Matrix
--- a/doc/interpreter/numbers.txi +++ b/doc/interpreter/numbers.txi @@ -570,7 +570,7 @@ When doing integer division Octave will round the result to the nearest integer. This is different from most programming languages, where the result is often floored to the nearest integer. So, the result of -@code{int32(5) ./ int32(8)} is @code{1}. +@code{int32 (5) ./ int32 (8)} is @code{1}. @DOCSTRING(idivide)
--- a/doc/interpreter/oop.txi +++ b/doc/interpreter/oop.txi @@ -184,7 +184,7 @@ @noindent Note that in the display method, it makes sense to start the method -with the line @code{fprintf("%s =", inputname(1))} to be consistent +with the line @code{fprintf ("%s =", inputname (1))} to be consistent with the rest of Octave and print the variable name to be displayed when displaying the class. @@ -317,7 +317,7 @@ @example @group -p = polynomial([1,2,3,4]); +p = polynomial ([1,2,3,4]); p(end-1) @result{} 3 @end group @@ -354,7 +354,7 @@ @group function x = subsasgn (x, ss, val) @dots{} - x.myfield(ss.subs@{1@}) = val; + x.myfield (ss.subs@{1@}) = val; endfunction @end group @end example @@ -726,15 +726,15 @@ @example @group -octave:1> f=FIRfilter(polynomial([1 1 1]/3)) +octave:1> f = FIRfilter (polynomial ([1 1 1]/3)) f.polynomial = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2 -octave:2> class(f) +octave:2> class (f) ans = FIRfilter -octave:3> isa(f,"FIRfilter") +octave:3> isa (f,"FIRfilter") ans = 1 -octave:4> isa(f,"polynomial") +octave:4> isa (f,"polynomial") ans = 1 -octave:5> struct(f) +octave:5> struct (f) ans = @{ polynomial = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2 @@ -759,9 +759,9 @@ @example @group -octave:2> f=FIRfilter(polynomial([1 1 1]/3)); -octave:3> x=ones(5,1); -octave:4> y=f(x) +octave:2> f = FIRfilter (polynomial ([1 1 1]/3)); +octave:3> x = ones (5,1); +octave:4> y = f(x) y = 0.33333 @@ -776,7 +776,7 @@ @example @group -octave:1> f=FIRfilter(polynomial([1 1 1]/3)); +octave:1> f = FIRfilter (polynomial ([1 1 1]/3)); octave:2> f.polynomial ans = 0.333333 + 0.333333 * X + 0.333333 * X ^ 2 @end group @@ -796,13 +796,12 @@ @example @group -octave:6> f=FIRfilter (); -octave:7> f.polynomial = polynomial([1 2 3]); +octave:6> f = FIRfilter (); +octave:7> f.polynomial = polynomial ([1 2 3]); f.polynomial = 1 + 2 * X + 3 * X ^ 2 @end group @end example - Defining the FIRfilter class as a child of the polynomial class implies that and FIRfilter object may be used any place that a polynomial may be used. This is not a normal use of a filter, so that
--- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -811,11 +811,11 @@ @example @group x = 0:0.01:3; -plot(x,erf(x)); +plot (x, erf (x)); hold on; -plot(x,x,"r"); -axis([0, 3, 0, 1]); -text(0.65, 0.6175, strcat('\leftarrow x = @{2/\surd\pi', +plot (x,x,"r"); +axis ([0, 3, 0, 1]); +text (0.65, 0.6175, strcat ('\leftarrow x = @{2/\surd\pi', ' @{\fontsize@{16@}\int_@{\fontsize@{8@}0@}^@{\fontsize@{8@}x@}@}', ' e^@{-t^2@} dt@} = 0.6175')) @end group @@ -2610,7 +2610,7 @@ @code{set} function. For example, @example -plot (x, "DeleteFcn", @@(s, e) disp("Window Deleted")) +plot (x, "DeleteFcn", @@(s, e) disp ("Window Deleted")) @end example @noindent
--- a/doc/interpreter/poly.txi +++ b/doc/interpreter/poly.txi @@ -54,8 +54,8 @@ @example @group -N = length(c)-1; -val = dot( x.^(N:-1:0), c ); +N = length (c) - 1; +val = dot (x.^(N:-1:0), c); @end group @end example @@ -114,8 +114,8 @@ @example @group c = [1, 0, 1]; -integral = polyint(c); -area = polyval(integral, 3) - polyval(integral, 0) +integral = polyint (c); +area = polyval (integral, 3) - polyval (integral, 0) @result{} 12 @end group @end example @@ -361,10 +361,10 @@ p = [ 0, 1, 0; 1, -2, 1; 0, -1, 1 ]; -pp = mkpp(x, p); -xi = linspace(-2, 2, 50); -yi = ppval(pp, xi); -plot(xi, yi); +pp = mkpp (x, p); +xi = linspace (-2, 2, 50); +yi = ppval (pp, xi); +plot (xi, yi); @end group @end example
--- a/doc/interpreter/quad.txi +++ b/doc/interpreter/quad.txi @@ -338,7 +338,7 @@ @ifnottex the sum over @code{i=1:n} and @code{j=1:n} of @code{q(i)*q(j)*f(r(i),r(j))}, @end ifnottex -where @math{q} and @math{r} is as returned by @code{colloc(n)}. The +where @math{q} and @math{r} is as returned by @code{colloc (n)}. The generalization to more than two variables is straight forward. The following code computes the studied integral using @math{n=8} points.
--- a/doc/interpreter/set.txi +++ b/doc/interpreter/set.txi @@ -40,7 +40,7 @@ @code{y} contains two sets, then @example -union(x, y) +union (x, y) @end example @noindent
--- a/doc/interpreter/sparse.txi +++ b/doc/interpreter/sparse.txi @@ -106,7 +106,7 @@ @example @group for (j = 0; j < nc; j++) - for (i = cidx (j); i < cidx(j+1); i++) + for (i = cidx(j); i < cidx(j+1); i++) printf ("non-zero element (%i,%i) is %d\n", ridx(i), j, data(i)); @end group @@ -212,7 +212,7 @@ that corresponds to this. For example, @example -s = diag (sparse(randn(1,n)), -1); +s = diag (sparse (randn (1,n)), -1); @end example @noindent @@ -348,8 +348,8 @@ @example @group -a = tril (sprandn(1024, 1024, 0.02), -1) ... - + speye(1024); +a = tril (sprandn (1024, 1024, 0.02), -1) ... + + speye (1024); matrix_type (a); ans = Lower @end group @@ -363,7 +363,7 @@ @example @group a = matrix_type (tril (sprandn (1024, ... - 1024, 0.02), -1) + speye(1024), 'Lower'); + 1024, 0.02), -1) + speye (1024), "Lower"); @end group @end example @@ -398,10 +398,10 @@ @example @group -A = sparse([2,6,1,3,2,4,3,5,4,6,1,5], +A = sparse ([2,6,1,3,2,4,3,5,4,6,1,5], [1,1,2,2,3,3,4,4,5,5,6,6],1,6,6); xy = [0,4,8,6,4,2;5,0,5,7,5,7]'; -gplot(A,xy) +gplot (A,xy) @end group @end example @@ -422,8 +422,8 @@ calculated in linear time without explicitly needing to calculate the Cholesky@tie{}factorization by the @code{etree} command. This command returns the elimination tree of the matrix and can be displayed -graphically by the command @code{treeplot(etree(A))} if @code{A} is -symmetric or @code{treeplot(etree(A+A'))} otherwise. +graphically by the command @code{treeplot (etree (A))} if @code{A} is +symmetric or @code{treeplot (etree (A+A'))} otherwise. @DOCSTRING(spy) @@ -519,7 +519,7 @@ @example @group -speye(3) + 0 +speye (3) + 0 @result{} 1 0 0 0 1 0 0 0 1 @@ -541,7 +541,7 @@ one area where it does cause a problem is where a sparse matrix is promoted to a full matrix, where subsequent operations would resparsify the matrix. Such cases are rare, but can be artificially created, for -example @code{(fliplr(speye(3)) + speye(3)) - speye(3)} gives a full +example @code{(fliplr (speye (3)) + speye (3)) - speye (3)} gives a full matrix when it should give a sparse one. In general, where such cases occur, they impose only a small memory penalty. @@ -551,7 +551,7 @@ depending on the type of its input arguments. So @example - a = diag (sparse([1,2,3]), -1); + a = diag (sparse ([1,2,3]), -1); @end example @noindent @@ -655,7 +655,7 @@ The standard Cholesky@tie{}factorization of this matrix can be obtained by the same command that would be used for a full matrix. This can be visualized with the command -@code{r = chol(A); spy(r);}. +@code{r = chol (A); spy (r);}. @xref{fig:simplechol}. The original matrix had @ifinfo @@ -682,8 +682,8 @@ The appropriate sparsity preserving permutation of the original matrix is given by @dfn{symamd} and the factorization using this -reordering can be visualized using the command @code{q = symamd(A); -r = chol(A(q,q)); spy(r)}. This gives +reordering can be visualized using the command @code{q = symamd (A); +r = chol (A(q,q)); spy (r)}. This gives @ifinfo @ifnothtml 29 @@ -697,7 +697,7 @@ The Cholesky@tie{}factorization itself can be used to determine the appropriate sparsity preserving reordering of the matrix during the factorization, In that case this might be obtained with three return -arguments as r@code{[r, p, q] = chol(A); spy(r)}. +arguments as @code{[r, p, q] = chol (A); spy (r)}. @float Figure,fig:simplechol @center @image{spchol,4in} @@ -712,7 +712,7 @@ In the case of an asymmetric matrix, the appropriate sparsity preserving permutation is @dfn{colamd} and the factorization using this reordering can be visualized using the command -@code{q = colamd(A); [l, u, p] = lu(A(:,q)); spy(l+u)}. +@code{q = colamd (A); [l, u, p] = lu (A(:,q)); spy (l+u)}. Finally, Octave implicitly reorders the matrix when using the div (/) and ldiv (\) operators, and so no the user does not need to explicitly @@ -948,23 +948,23 @@ @example @group - node_y= [1;1.2;1.5;1.8;2]*ones(1,11); - node_x= ones(5,1)*[1,1.05,1.1,1.2, ... + node_y = [1;1.2;1.5;1.8;2]*ones(1,11); + node_x = ones(5,1)*[1,1.05,1.1,1.2, ... 1.3,1.5,1.7,1.8,1.9,1.95,2]; - nodes= [node_x(:), node_y(:)]; + nodes = [node_x(:), node_y(:)]; - [h,w]= size(node_x); - elems= []; - for idx= 1:w-1 - widx= (idx-1)*h; - elems= [elems; ... + [h,w] = size (node_x); + elems = []; + for idx = 1:w-1 + widx = (idx-1)*h; + elems = [elems; ... widx+[(1:h-1);(2:h);h+(1:h-1)]'; ... widx+[(2:h);h+(2:h);h+(1:h-1)]' ]; endfor - E= size(elems,1); # No. of simplices - N= size(nodes,1); # No. of vertices - D= size(elems,2); # dimensions+1 + E = size (elems,1); # No. of simplices + N = size (nodes,1); # No. of vertices + D = size (elems,2); # dimensions+1 @end group @end example @@ -1001,32 +1001,32 @@ calculated. @example - # Element conductivity - conductivity= [1*ones(1,16), ... + ## Element conductivity + conductivity = [1*ones(1,16), ... 2*ones(1,48), 1*ones(1,16)]; - # Connectivity matrix + ## Connectivity matrix C = sparse ((1:D*E), reshape (elems', ... D*E, 1), 1, D*E, N); - # Calculate system matrix + ## Calculate system matrix Siidx = floor ([0:D*E-1]'/D) * D * ... ones(1,D) + ones(D*E,1)*(1:D) ; - Sjidx = [1:D*E]'*ones(1,D); - Sdata = zeros(D*E,D); - dfact = factorial(D-1); - for j=1:E - a = inv([ones(D,1), ... + Sjidx = [1:D*E]'*ones (1,D); + Sdata = zeros (D*E,D); + dfact = factorial (D-1); + for j = 1:E + a = inv ([ones(D,1), ... nodes(elems(j,:), :)]); const = conductivity(j) * 2 / ... - dfact / abs(det(a)); + dfact / abs (det (a)); Sdata(D*(j-1)+(1:D),:) = const * ... a(2:D,:)' * a(2:D,:); endfor - # Element-wise system matrix - SE= sparse(Siidx,Sjidx,Sdata); - # Global system matrix - S= C'* SE *C; + ## Element-wise system matrix + SE = sparse(Siidx,Sjidx,Sdata); + ## Global system matrix + S = C'* SE *C; @end example The system matrix acts like the conductivity @@ -1047,23 +1047,23 @@ solve for the voltages at each vertex @code{V}. @example - # Dirichlet boundary conditions - D_nodes=[1:5, 51:55]; - D_value=[10*ones(1,5), 20*ones(1,5)]; + ## Dirichlet boundary conditions + D_nodes = [1:5, 51:55]; + D_value = [10*ones(1,5), 20*ones(1,5)]; - V= zeros(N,1); + V = zeros (N,1); V(D_nodes) = D_value; idx = 1:N; # vertices without Dirichlet # boundary condns idx(D_nodes) = []; - # Neumann boundary conditions. Note that - # N_value must be normalized by the - # boundary length and element conductivity - N_nodes=[]; - N_value=[]; + ## Neumann boundary conditions. Note that + ## N_value must be normalized by the + ## boundary length and element conductivity + N_nodes = []; + N_value = []; - Q = zeros(N,1); + Q = zeros (N,1); Q(N_nodes) = N_value; V(idx) = S(idx,idx) \ ( Q(idx) - ... @@ -1082,8 +1082,8 @@ xelems = reshape (nodes(elemx, 1), 4, E); yelems = reshape (nodes(elemx, 2), 4, E); velems = reshape (V(elemx), 4, E); - plot3 (xelems,yelems,velems,'k'); - print ('grid.eps'); + plot3 (xelems,yelems,velems,"k"); + print "grid.eps"; @end group @end example
--- a/doc/interpreter/stmt.txi +++ b/doc/interpreter/stmt.txi @@ -560,11 +560,11 @@ @example @group -disp("Loop over a matrix") +disp ("Loop over a matrix") for i = [1,3;2,4] i endfor -disp("Loop over a cell array") +disp ("Loop over a cell array") for i = @{1,"two";"three",4@} i endfor @@ -580,7 +580,7 @@ @example @group -a = [1,3;2,4]; c = cat(3, a, 2*a); +a = [1,3;2,4]; c = cat (3, a, 2*a); for i = c i endfor @@ -589,8 +589,8 @@ @noindent In the above case, the multi-dimensional matrix @var{c} is reshaped to a -two-dimensional matrix as @code{reshape (c, rows(c), -prod(size(c)(2:end)))} and then the same behavior as a loop over a two +two-dimensional matrix as @code{reshape (c, rows (c), +prod (size (c)(2:end)))} and then the same behavior as a loop over a two dimensional matrix is produced. Although it is possible to rewrite all @code{for} loops as @code{while}
--- a/doc/interpreter/testfun.txi +++ b/doc/interpreter/testfun.txi @@ -72,7 +72,7 @@ %! get = kron (@var{b}, @var{a}); %! if (any (size (expect) != size (get))) %! error ("wrong size: expected %d,%d but got %d,%d", -%! size(expect), size(get)); +%! size (expect), size (get)); %! elseif (any (any (expect != get))) %! error ("didn't get what was expected."); %! endif
--- a/doc/interpreter/vectorize.txi +++ b/doc/interpreter/vectorize.txi @@ -660,7 +660,7 @@ @group n = length (A); B = zeros (n, 2); -for i = 1:length(A) +for i = 1:length (A) ## this will be two columns, the first is the difference and ## the second the mean of the two elements used for the diff. B(i,:) = [A(i+1)-A(i), (A(i+1) + A(i))/2)];
--- a/doc/refcard/refcard.tex +++ b/doc/refcard/refcard.tex @@ -679,7 +679,7 @@ \sec Paths and Packages; path&display the current Octave function path.\cr pathdef&display the default path.\cr -addpath({\it dir})&add a directory to the path.\cr +addpath ({\it dir})&add a directory to the path.\cr EXEC\_PATH&manipulate the Octave executable path.\cr pkg list&display installed packages.\cr pkg load {\it pack}&Load an installed package.\cr @@ -688,8 +688,8 @@ \sec Cells and Structures; {\it{var}}.{\it{field}} = ...&set a field of a structure.\cr {\it{var}}$\{${\it{idx}}$\}$ = ...&set an element of a cell array.\cr -cellfun({\it f}, {\it c})&apply a function to elements of cell array.\cr -fieldnames({\it s})&returns the fields of a structure.\cr +cellfun ({\it f}, {\it c})&apply a function to elements of cell array.\cr +fieldnames ({\it s})&returns the fields of a structure.\cr \endsec \widesec Statements; @@ -803,10 +803,10 @@ values\cr \endsec -% sin({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr -% asin({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr -% sinh({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr -% asinh({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig +% sin ({\it a}) cos({\it a}) tan({\it a})&trigonometric functions\cr +% asin ({\it a}) acos({\it a}) atan({\it a})&inverse trigonometric functions\cr +% sinh ({\it a}) cosh({\it a}) tanh({\it a})&hyperbolic trig functions\cr +% asinh ({\it a}) acosh({\it a}) atanh({\it a})&inverse hyperbolic trig % functions\cr\cr \sec Linear Algebra;