--- a/doc/comms.txi
+++ b/doc/comms.txi
@@ -84,7 +84,7 @@
random matrix of equi-probable integers in a desired range. For example

@example
-octave:1> a = randint(3,3,[-1,1])
+octave:1> a = randint (3, 3, [-1, 1])
a =

0   1   0
@@ -97,7 +97,7 @@
allows the seed-value of the random number generator to be set. For instance

@example
-octave:1> a = randint(3,3,[-1,1],1)
+octave:1> a = randint (3, 3, [-1, 1], 1)
a =

0   1   1
@@ -123,14 +123,14 @@
can not be mixed. For example

@example
-octave:1> a = randsrc(2,2,"ab");
-octave:2> b = randsrc(4,4,[1, 1i, -1, -1i,]);
+octave:1> a = randsrc (2, 2, "ab");
+octave:2> b = randsrc (4, 4, [1, 1i, -1, -1i]);
@end example

are both legal, while

@example
-octave:1> a = randsrc(2,2,[1,"a"]);
+octave:1> a = randsrc (2, 2, [1, "a"]);
@end example

is not legal. The alphabet from which the symbols are chosen can be either
@@ -140,7 +140,7 @@
that each of the symbols are chosen. For example

@example
-octave:1> a = randsrc(5,5,[1, 1i, -1, -1i; 0.6 0.2 0.1 0.1])
+octave:1> a = randsrc (5, 5, [1, 1i, -1, -1i; 0.6 0.2 0.1 0.1])
a =

1 + 0i   0 + 1i   0 + 1i   0 + 1i   1 + 0i
@@ -162,14 +162,14 @@
matrix. That is

@example
-octave:1> a = randerr(5,10)
+octave:1> a = randerr (5, 10)
a =

-  0  1  0  0  0  0  0  0  0  0
-  0  0  1  0  0  0  0  0  0  0
-  0  0  1  0  0  0  0  0  0  0
-  0  0  0  0  0  0  0  0  0  1
-  0  0  0  0  0  0  0  0  0  1
+   0   1   0   0   0   0   0   0   0   0
+   0   0   1   0   0   0   0   0   0   0
+   0   0   1   0   0   0   0   0   0   0
+   0   0   0   0   0   0   0   0   0   1
+   0   0   0   0   0   0   0   0   0   1
@end example

The number of errors per row can be specified as the third argument to
@@ -182,10 +182,10 @@

@example
octave:1> n = 15; k = 11; nsym = 100;
-octave:2> msg = randint(nsym,k);       ## Binary vector of message
-octave:3> code = encode(msg,n,k,"bch");
-octave:4> berrs = randerr(nsym,n,[0, 1; 0.7, 0.3]);
-octave:5> noisy = mod(code + berrs, 2) ## Add errors to coded message
+octave:2> msg = randint (nsym, k);       ## Binary vector of message
+octave:3> code = encode (msg, n, k, "bch");
+octave:4> berrs = randerr (nsym, n, [0, 1; 0.7, 0.3]);
+octave:5> noisy = mod (code + berrs, 2)  ## Add errors to coded message
@end example

creates a vector @var{msg}, encodes it with a [15,11] BCH code, and then
@@ -200,7 +200,7 @@
of a certain power. A typical call to @code{wgn} is then

@example
-octave:1> nse = wgn(10,10,0);
+octave:1> nse = wgn (10, 10, 0);
@end example

Which creates a 10-by-10 matrix of noise with a root mean squared power
@@ -216,20 +216,20 @@
obtained with

@example
-octave:1> nse = randn(10,10);
+octave:1> nse = randn (10, 10);
@end example

The reference impedance and units of power to the function @code{wgn}
can however be modified, for example

@example
-octave:1> nse_30dBm_50Ohm = wgn(10000,1,30,50,"dBm");
-octave:2> nse_0dBW_50Ohm = wgn(10000,1,0,50,"dBW");
-octave:3> nse_1W_50Ohm = wgn(10000,1,1,50,"linear");
+octave:1> nse_30dBm_50Ohm = wgn (10000, 1, 30, 50, "dBm");
+octave:2> nse_0dBW_50Ohm = wgn (10000, 1, 0, 50, "dBW");
+octave:3> nse_1W_50Ohm = wgn (10000, 1, 1, 50, "linear");
octave:4> [std(nse_30dBm_50Ohm), std(nse_0dBW_50Ohm), std(nse_1W_50Ohm)]
ans =

-  7.0805  7.1061  7.0730
+   7.0805   7.1061   7.0730
@end example

All produce a 1W signal referenced to a
@@ -249,19 +249,19 @@
$$p = {\\sum_i \\sum_j v(i,j)^2 \\over Z} Watts$$
@end tex
@ifnottex
-@var{p} = sum(@var{v}(:) .^ 2 ) / @var{imp} Watts
+@var{p} = sum (@var{v}(:) .^ 2 ) / @var{imp} Watts
@end ifnottex

By default @code{wgn} produces real vectors of white noise. However, it can
produce both real and complex vectors like

@example
-octave:1> rnse = wgn(10000,1,0,"dBm","real");
-octave:2> cnse = wgn(10000,1,0,"dBm","complex");
-octave:3> [std(rnse), std(real(cnse)), std(imag(cnse)), std(cnse)]
+octave:1> rnse = wgn (10000, 1, 0, "dBm", "real");
+octave:2> cnse = wgn (10000, 1, 0, "dBm", "complex");
+octave:3> [std(rnse), std(real (cnse)), std(imag (cnse)), std(cnse)]
ans =

-  0.031615  0.022042  0.022241  0.031313
+   0.031615   0.022042   0.022241   0.031313
@end example

which shows that with a complex return value that the total power is the
@@ -271,7 +271,7 @@
data to be reproduced. That is

@example
-octave:1> nse = wgn(10,10,0,0);
+octave:1> nse = wgn (10, 10, 0, 0);
@end example

will always produce the same set of data.
@@ -283,8 +283,8 @@

@example
octave:1> x = [0:0.1:2*pi];
-octave:2> y = sin(x);
-octave:3> noisy = awgn(y, 10, "measured")
+octave:2> y = sin (x);
+octave:3> noisy = awgn (y, 10, "measured")
@end example

@ifnotinfo
@@ -301,12 +301,12 @@
power. This behavior can be modified by the third argument to @code{awgn}.
If the third argument is a numerical value, it is assumed to define the
power in the input signal, otherwise if the third argument is the string
-'measured', as above, the power in the signal is measured prior to the
+"measured", as above, the power in the signal is measured prior to the

The final argument to @code{awgn} defines the definition of the power and
signal-to-noise ratio in a similar manner to @code{wgn}. This final
-argument can be either 'dB' or 'linear'. In the first case the numerical
+argument can be either "dB" or "linear". In the first case the numerical
value of the input power is assumed to be in dBW and the signal-to-noise
ratio in dB.  In the second case, the power is assumed to be in Watts
and the signal-to-noise ratio is expressed as a ratio.
@@ -322,8 +322,8 @@

@example
octave:1> x = [0:0.1:2*pi];
-octave:2> y = sin(x);
-octave:3> noisy = awgn(y, 10, "dB", 0, "measured")
+octave:2> y = sin (x);
+octave:3> noisy = awgn (y, 10, "dB", 0, "measured")
@end example

which uses the seed-value of 0 for the random number generator.
@@ -363,12 +363,12 @@

@example
octave:1> m = 8;
-octave:2> msg = randint(10,10,2^m);
-octave:3> noisy = mod(msg + diag(1:10),2^m);
-octave:4> [berr, brate] = biterr(msg, noisy, m)
+octave:2> msg = randint (10, 10, 2^m);
+octave:3> noisy = mod (msg + diag (1:10), 2^m);
+octave:4> [berr, brate] = biterr (msg, noisy, m)
berr = 32
brate = 0.040000
-octave:5> [serr, srate] = symerr(msg, noisy)
+octave:5> [serr, srate] = symerr (msg, noisy)
serr = 10
srate = 0.10000
@end example
@@ -405,13 +405,13 @@

@example
octave:1> n = 50;
-octave:2> ovsp=50;
+octave:2> ovsp = 50;
octave:3> x = 1:n;
-octave:4> xi = [1:1/ovsp:n-0.1];
-octave:5> y = randsrc(1,n,[1 + 1i, 1 - 1i, -1 - 1i, -1 + 1i]) ;
-octave:6> yi = interp1(x,y,xi);
-octave:7> noisy = awgn(yi,15,"measured");
-octave:8> eyediagram(noisy,ovsp);
+octave:4> xi = 1:1/ovsp:n-0.1;
+octave:5> y = randsrc (1, n, [1 + 1i, 1 - 1i, -1 - 1i, -1 + 1i]);
+octave:6> yi = interp1 (x, y, xi);
+octave:7> noisy = awgn (yi, 15, "measured");
+octave:8> eyediagram (noisy, ovsp);
@end example

@ifnotinfo
@@ -428,16 +428,15 @@

@example
octave:1> n = 200;
-octave:2> ovsp=5;
+octave:2> ovsp = 5;
octave:3> x = 1:n;
-octave:4> xi = [1:1/ovsp:n-0.1];
-octave:5> y = randsrc(1,n,[1 + 1i, 1 - 1i, -1 - 1i, -1 + 1i]) ;
-octave:6> yi = interp1(x,y,xi);
-octave:7> noisy = awgn(yi,15,"measured");
-octave:8> hold off;
-octave:9> scatterplot(noisy,1,0,"b");
-octave:10> hold on;
-octave:11> scatterplot(noisy,ovsp,0,"r+");
+octave:4> xi = 1:1/ovsp:n-0.1;
+octave:5> y = randsrc (1, n, [1 + 1i, 1 - 1i, -1 - 1i, -1 + 1i]);
+octave:6> yi = interp1 (x, y, xi);
+octave:7> noisy = awgn (yi, 15, "measured");
+octave:8> f = scatterplot (noisy, 1, 0, "b");
+octave:9> hold on;
+octave:10> scatterplot (noisy, ovsp, 0, "r+", f);
@end example

@ifnotinfo
@@ -495,8 +494,8 @@
octave:3> table = 2*[0:m-1]/m - 1 + 1/m;
octave:4> codes = 2*[0:m]/m - 1;
octave:5> x = 4*pi*[0:(n-1)]/(n-1);
-octave:6> y = cos(x);
-octave:7> [i,z] = quantiz(y, table, codes);
+octave:6> y = cos (x);
+octave:7> [i, z] = quantiz (y, table, codes);
@end example

If a training signal is known that well represents the expected signals,
@@ -504,8 +503,8 @@
For example the above example can be continued

@example
-octave:8> [table2, codes2] = lloyds(y, table, codes);
-octave:9> [i,z2] = quantiz(y, table2, codes2);
+octave:8> [table2, codes2] = lloyds (y, table, codes);
+octave:9> [i, z2] = quantiz (y, table2, codes2);
@end example

Which the mapping suggested by the function @code{lloyds}. It should be
@@ -541,17 +540,17 @@
@example
octave:1> mu = 1.95;
octave:2> x = [0.01:0.01:2];
-octave:3> y = log(x);
-octave:4> V = max(abs(y));
-octave:5> [i,z,d] = quantiz(y,[-4.875:0.25:0.875],[-5:0.25:1]);
-octave:6> c = compand(y,minmu,V,'mu/compressor');
-octave:7> [i2,c2] = quantiz(c,[-4.875:0.25:0.875],[-5:0.25:1]);
-octave:8> z2 = compand(c2,minmu,max(abs(c2)),'mu/expander');
-octave:9> d2 = sumsq(y-z2) / length(y);
+octave:3> y = log (x);
+octave:4> V = max (abs (y));
+octave:5> [i, z, d] = quantiz (y, [-4.875:0.25:0.875], [-5:0.25:1]);
+octave:6> c = compand (y, minmu, V, "mu/compressor");
+octave:7> [i2, c2] = quantiz (c, [-4.875:0.25:0.875], [-5:0.25:1]);
+octave:8> z2 = compand (c2, minmu, max (abs (c2)), "mu/expander");
+octave:9> d2 = sumsq (y - z2) / length (y);
octave:10> [d, d2]
ans =

-  0.0053885  0.0029935
+   0.0053885   0.0029935
@end example

which demonstrates that the use of @code{compand} can significantly
@@ -612,9 +611,9 @@

@example
octave:1> k = 4;
-octave:2> bin_vec = randint(k*10,1);        # Binary vector format
-octave:3> bin_mat = reshape(bin_vec,k,10)'; # Binary matrix format
-octave:4> dec_vec = bi2de(bin_mat);         # Decimal vector format
+octave:2> bin_vec = randint (k*10, 1);         # Binary vector format
+octave:3> bin_mat = reshape (bin_vec, k, 10)'; # Binary matrix format
+octave:4> dec_vec = bi2de (bin_mat);           # Decimal vector format
@end example

The functions within this toolbox will return data in the same format
@@ -657,7 +656,7 @@
${\bf R} = ( {\bf T} + {\bf E} )\ mod\ 2$,
@end tex
@ifnottex
-@var{R} = mod(@var{T} + @var{E}, 2),
+@var{R} = mod (@var{T} + @var{E}, 2),
@end ifnottex
then the error vector @var{E} is
@tex
@@ -736,10 +735,10 @@

@example
octave:1> m = 3;
-octave:2> n = 2^m -1;
+octave:2> n = 2^m - 1;
octave:2> k = 4;
-octave:3> [par, gen] = hammgen(m);
-octave:4> [par2, gen2] = cyclgen(n,cyclpoly(n,k));
+octave:3> [par, gen] = hammgen (m);
+octave:4> [par2, gen2] = cyclgen (n, cyclpoly (n, k));
@end example

which create identical parity check and generator matrices for the
@@ -749,8 +748,8 @@
@code{syndtable}, in the following manner

@example
-octave:1> [par, gen] = hammgen(3);
-octave:2> st = syndtable(par);
+octave:1> [par, gen] = hammgen (3);
+octave:2> st = syndtable (par);
@end example

There exists two auxiliary functions @code{gen2par} and @code{gfweight},
@@ -758,9 +757,9 @@
the Hamming distance of the codes. For instance

@example
-octave:1> par = hammgen(3);
-octave:2> gen = gen2par(par);
-octave:3> gfweight(gen)
+octave:1> par = hammgen (3);
+octave:2> gen = gen2par (par);
+octave:3> gfweight (gen)
ans = 3
@end example

@@ -780,13 +779,13 @@
these functions

@table @asis
-@item 'linear'
+@item "linear"
Generic linear block codes
-@item 'cyclic'
+@item "cyclic"
Cyclic linear block codes
-@item 'hamming'
+@item "hamming"
Hamming codes
-@item 'bch'
+@item "bch"
Bose Chaudhuri Hocquenghem (BCH) block codes
@end table

@@ -799,15 +798,15 @@
octave:1> m = 3;
octave:2> n = 7;
octave:3> k = 4;
-octave:4> msg_bin = randint(10,k);
-octave:5> cbin = encode(msg_bin, n, k, "hamming/binary");
-octave:5> cdec = encode(bi2de(msg), n, k, "hamming/decimal");
+octave:4> msg_bin = randint (10, k);
+octave:5> cbin = encode (msg_bin, n, k, "hamming/binary");
+octave:5> cdec = encode (bi2de (msg), n, k, "hamming/decimal");
@end example

which codes a binary matrix and a non-binary vector representation of a
message, returning the coded message in the same format. The functions
@code{encode} and @code{decode} by default accept binary coded
-messages. Therefore 'hamming' is equivalent to 'hamming/binary'.
+messages. Therefore "hamming" is equivalent to "hamming/binary".

Except for the BCH codes, the function @code{encode} and @code{decode}
internally create the generator, parity check and syndrome table
@@ -818,13 +817,13 @@
@example
n = 15;
k = 11;
-[par, gen] = hammgen(4);
-code1 = code2 = zeros(100,15)
-for i=1:100
-  msg = get_msg(i);
-  code1(i,:) = encode(msg, n, k, 'linear', gen);  # This is faster
-  code2(i,:) = encode(msg, n, k, 'hamming');      # than this !!!
-end
+[par, gen] = hammgen (4);
+code1 = code2 = zeros (100, 15)
+for i = 1:100
+  msg = get_msg (i);
+  code1(i,:) = encode (msg, n, k, "linear", gen);  # This is faster
+  code2(i,:) = encode (msg, n, k, "hamming");      # than this !!!
+endfor
@end example

In the case of the BCH codes the low-level functions described in the
@@ -893,7 +892,7 @@
output, but only for the specified codeword length. In this manner codes
with codeword length greater than 511 can be found.

-In general the codeword length is of the form @code{2^@var{m}-1}, where
+In general the codeword length is of the form @code{2^@var{m} - 1}, where
@var{m} is an integer. However if [@var{n},@var{k}] is a valid BCH
code, then it is also possible to use a shortened BCH form of the form
@code{[@var{n}-@var{x},@var{k}-@var{x}]}.
@@ -902,15 +901,15 @@
polynomial of a valid BCH code. For instance

@example
-octave:1> bchpoly(15,7)
+octave:1> bchpoly (15, 7)
ans =

-  1  0  0  0  1  0  1  1  1
-
-octave:2> bchpoly(14,6)
+   1   0   0   0   1   0   1   1   1
+
+octave:2> bchpoly (14, 6)
ans =

-  1  0  0  0  1  0  1  1  1
+   1   0   0   0   1   0   1   1   1
@end example

show that the generator polynomial of a [15,7] BCH code with the default
@@ -928,15 +927,15 @@
as can be seen in the example.

@example
-octave:1> bchpoly([1 1 0 0 1], 7)
+octave:1> bchpoly ([1 1 0 0 1], 7)
ans =

-  1  0  0  0  1  0  1  1  1
-
-octave:2> bchpoly([1 0 0 1 1], 7)
+   1   0   0   0   1   0   1   1   1
+
+octave:2> bchpoly ([1 0 0 1 1], 7)
ans =

-  1  1  1  0  1  0  0  0  1
+   1   1   1   0   1   0   0   0   1
@end example

It is recommend not to convert the generator polynomials created by
@@ -951,14 +950,14 @@

@example
octave:1> n = 31;
-octave:2> pgs = bchpoly(n);
-octave:3> pg = pgs(floor(rand(1,1)*(size(pgs,1) + 1)),:); # Pick a poly
+octave:2> pgs = bchpoly (n);
+octave:3> pg = pgs(floor (rand () * (rows (pgs) + 1)),:);  # Pick a poly
octave:4> k = pg(2);
octave:5> t = pg(3);
-octave:6> msg = randint(10,k);
-octave:7> code = bchenco(msg,n,k);
-octave:8> noisy = code + [ones(10,1), zeros(10,n-1)];
-octave:9> dec = bchdeco(code,k,t);
+octave:6> msg = randint (10, k);
+octave:7> code = bchenco (msg, n, k);
+octave:8> noisy = code + [ones(10, 1), zeros(10, n-1)];
+octave:9> dec = bchdeco (code, k, t);
@end example

@node Reed-Solomon Codes, , BCH Codes, Block Coding
@@ -992,30 +991,30 @@
octave:1> m = 3;
octave:2> n = 7;
octave:3> k = 5;
-octave:4> msg = gf(floor(2^m*rand(2,k)),m)
+octave:4> msg = gf (floor (2^m * rand (2, k)), m)
msg =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  5  0  6  3  2
-  4  1  3  1  2
-
-octave:5> code = rsenc(msg,n,k)
+   5   0   6   3   2
+   4   1   3   1   2
+
+octave:5> code = rsenc (msg, n, k)
code =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  5  0  6  3  2  3  5
-  4  1  3  1  2  6  3
+   5   0   6   3   2   3   5
+   4   1   3   1   2   6   3
@end example

The variable @var{n} is the codeword length of the Reed-Solomon coder,
while @var{k} is the message length. It should be noted that @var{k}
should be less than @var{n} and that @code{@var{n} - @var{k}} should be
even. The error correcting capability of the Reed-Solomon code is then
-@code{(@var{n}-@var{k})/2} symbols. @var{m} is the number of bits per
+@code{(@var{n} - @var{k})/2} symbols. @var{m} is the number of bits per
symbol, and is related to @var{n} by @code{@var{n} = 2^@var{m} - 1}.
For a valid Reed-Solomon coder, @var{m} should be between 3 and 16.

@@ -1035,8 +1034,8 @@
the messages

@example
-octave:1> msg0 = gf([0, 1, 2, 3],3);
-octave:2> msg1 = gf([0, 1, 2, 3],3,13);
+octave:1> msg0 = gf ([0, 1, 2, 3], 3);
+octave:2> msg1 = gf ([0, 1, 2, 3], 3, 13);
@end example

will not result in the same Reed-Solomon coding. Finally, the parity of
@@ -1049,7 +1048,7 @@
determine which end of the message is the most-significant term of the
polynomial representing the message. The parity symbols are therefore
different in these two cases. The position of the parity symbols can be
-chosen by specifying 'beginning' or 'end' to @code{rsenc} and @code{rsdec}.
+chosen by specifying "beginning" or "end" to @code{rsenc} and @code{rsdec}.
By default the parity symbols are placed after the message.

Valid generator polynomials can be constructed with the @code{rsgenpoly}
@@ -1067,7 +1066,7 @@
@end example
@end ifnottex

-where @var{t} is @code{(@var{n}-@var{k})/2}, A is the primitive element
+where @var{t} is @code{(@var{n} - @var{k})/2}, A is the primitive element
of the Galois Field, @var{b} is the first consecutive root, and @var{s}
is the step between roots. Generator polynomial of this form are constructed
by @code{rsgenpoly} and can be passed to both @code{rsenc} and @code{rsdec}.
@@ -1084,21 +1083,20 @@
octave:4> prim = 391;
octave:5> b = 112;
octave:6> s = 11;
-octave:7> gg = rsgenpoly(n, k, prim, b, s);
-octave:8> msg = gf(floor(2^m*rand(17,k)), m, prim);
-octave:9> code = rsenc(msg, n, k, gg);
-octave:10> noisy = code + [toeplitz([ones(1,17)], ...
-@			zeros(1,17)), zeros(17,238)];
-octave:11> [dec, nerr] = rsdec(msg, n, k, b, s);
-octave:13> nerr'
+octave:7> gg = rsgenpoly (n, k, prim, b, s);
+octave:8> msg = gf (floor (2^m * rand (17, k)), m, prim);
+octave:9> code = rsenc (msg, n, k, gg);
+octave:10> noisy = code + [toeplitz([ones(1,17)], zeros(1,17)), zeros(17,238)];
+octave:11> [dec, nerr] = rsdec (msg, n, k, b, s);
+octave:12> nerr'
ans =

-   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  -1
-
-octave:12> any(msg' != dec')
+    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   -1
+
+octave:13> any (msg' != dec')
ans =

-  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
+   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   1
@end example

This is an interesting example in that it demonstrates many of the
@@ -1122,7 +1120,7 @@

In general the codeword length of the Reed-Solomon coder is chosen so
that it is related directly to the order of the Galois Field by the
-formula @code{@var{n} = 2^@var{m} = 1}. Although, the underlying
+formula @code{@var{n} = 2^@var{m} - 1}. Although, the underlying
Reed-Solomon coding must operate over valid codeword length, there
are sometimes reasons to assume that the codeword length will be shorter.
In this case the message is padded with zeros before coding, and the
@@ -1133,23 +1131,23 @@
octave:1> m = 3;
octave:2> n = 6;
octave:3> k = 4;
-octave:4> msg = gf(floor(2^m*rand(2,k)),m)
+octave:4> msg = gf (floor (2^m * rand (2, k)), m)
msg =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  7  0  2  5
-  1  5  7  1
-
-octave:5> code = rsenc(msg,n,k)
+   7   0   2   5
+   1   5   7   1
+
+octave:5> code = rsenc (msg, n, k)
code =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  7  0  2  5  2  3
-  1  5  7  1  0  2
+   7   0   2   5   2   3
+   1   5   7   1   0   2
@end example

@@ -1240,17 +1238,17 @@

To work with a Galois Field GF(2^M) in Octave, you must first create a variable
that Octave recognizes as a Galois Field. This is done with the function
-@code{gf(@var{a},@var{m})} as follows.
+@code{gf (@var{a}, @var{m})} as follows.

@example
octave:1> a = [0:7];
-octave:2> b = gf(a,4)
+octave:2> b = gf (a, 4)
b =
GF(2^4) array. Primitive Polynomial = D^4+D+1 (decimal 19)

Array elements =

-  0  1  2  3  4  5  6  7
+   0   1   2   3   4   5   6   7
@end example

This creates an array @var{b} with 8 elements that Octave recognizes as a
@@ -1259,18 +1257,19 @@
Field with the functions @code{isgalois} or @code{whos}.

@example
-octave:3> isgalois(a)
+octave:3> isgalois (a)
ans = 0
-octave:4> isgalois(b)
+octave:4> isgalois (b)
ans = 1
octave:5> whos
-
-*** local user variables:
-
-prot  type                       rows   cols  name
-====  ====                       ====   ====  ====
- rwd  matrix                        1      8  a
- rwd  galois                        1      8  b
+Variables in the current scope:
+
+   Attr Name        Size                     Bytes  Class
+   ==== ====        ====                     =====  =====
+        a           1x8                         24  double
+        b           1x8                         32  galois
+
+Total is 16 elements using 56 bytes
@end example

It is also possible to create a Galois Field with an arbitrary primitive
@@ -1279,18 +1278,16 @@

@example
octave:1> a = [0:7];
-octave:2> b = gf(a,4,25)
+octave:2> b = gf (a, 4, 25)
b =
GF(2^4) array. Primitive Polynomial = D^4+D^3+1 (decimal 25)

Array elements =

-  0  1  2  3  4  5  6  7
-
-octave:3> c = gf(a,4,21)
-error: primitive polynomial (21) of Galois Field must be irreducible
-error: unable to initialize Galois Field
-error: evaluating assignment expression near line 3, column 3
+   0   1   2   3   4   5   6   7
+
+octave:3> c = gf (a, 4, 21)
+error: gf: primitive polynomial (21) of Galois Field must be irreducible
@end example

The function @code{gftable} is included for compatibility with Matlab. In
@@ -1302,14 +1299,14 @@
@node Primitive Polynomials, Accessing Internal Fields, Creating Galois Fields, Galois Field Basics
@subsection Primitive Polynomials

-The function @code{gf(@var{a},@var{m})} creates a Galois Field using the default primitive
+The function @code{gf (@var{a}, @var{m})} creates a Galois Field using the default primitive
polynomial. However there exists many possible primitive polynomials for most
Galois Fields. Two functions exist for identifying primitive polynomials,
-@code{isprimitive} and @code{primpoly}. @code{primpoly(@var{m},@var{opt})} is
+@code{isprimitive} and @code{primpoly}. @code{primpoly (@var{m}, @var{opt})} is
used to identify the primitive polynomials of the fields GF(2^M). For example

@example
-octave:1> primpoly(4)
+octave:1> primpoly (4)

Primitive polynomial(s) =

@@ -1319,12 +1316,12 @@
@end example

identifies the default primitive polynomials of the field GF(2^M), which
-is the same as @code{primpoly(4,"min")}. All of the primitive polynomials
-of a field can be identified with the function @code{primpoly(@var{m},"all")}.
+is the same as @code{primpoly (4, "min")}. All of the primitive polynomials
+of a field can be identified with the function @code{primpoly (@var{m}, "all")}.
For example

@example
-octave:1> primpoly(4, "all")
+octave:1> primpoly (4, "all")

Primitive polynomial(s) =

@@ -1333,16 +1330,16 @@

ans =

-  19  25
-@end example
-
-while @code{primpoly(@var{m},"max")} returns the maximum primitive polynomial
+   19   25
+@end example
+
+while @code{primpoly (@var{m}, "max")} returns the maximum primitive polynomial
of the field, which for the case above is 25. The function @code{primpoly}
can also be used to identify the primitive polynomials having only a
certain number of non-zero terms. For instance

@example
-octave:1> primpoly(5, 3)
+octave:1> primpoly (5, 3)

Primitive polynomial(s) =

@@ -1351,7 +1348,7 @@

ans =

-  37  41
+   37   41
@end example

identifies the polynomials with only three terms that can be used as
@@ -1360,24 +1357,24 @@
empty vector. That is

@example
-octave:1> primpoly(5,2)
-primpoly: No primitive polynomial satisfies the given constraints
+octave:1> primpoly (5, 2)
+warning: primpoly: No primitive polynomial satisfies the given constraints

ans = [](1x0)
@end example

As can be seen above, @code{primpoly} displays the polynomial forms the
the polynomials that it finds. This output can be suppressed with the
-'nodisplay' option, while the returned value is left unchanged.
-
-@example
-octave:1> primpoly(4,"all","nodisplay")
+"nodisplay" option, while the returned value is left unchanged.
+
+@example
+octave:1> primpoly (4, "all", "nodisplay")
ans =

-  19  25
-@end example
-
-@code{isprimitive(@var{a})} identifies whether the elements of @var{a} can
+   19   25
+@end example
+
+@code{isprimitive (@var{a})} identifies whether the elements of @var{a} can
be used as primitive polynomials of the Galois Fields GF(2^M). Consider
as an example the fields GF(2^4). The primitive polynomials of these fields
must have an order m and so their integer representation must be between
@@ -1385,10 +1382,10 @@
@code{primpoly} as follows

@example
-octave:1> find(isprimitive(16:31)) + 15
+octave:1> find (isprimitive (16:31)) + 15
ans =

-  19  25
+   19   25
@end example

which finds all of the primitive polynomials of GF(2^4).
@@ -1404,21 +1401,22 @@

@example
octave:1> a = [0:7];
-octave:2> b = gf(a,4);
+octave:2> b = gf (a, 4);
octave:3> b.m
ans = 4
octave:4> b.prim_poly
ans = 19
octave:5> c = b.x;
octave:6> whos
-
-*** local user variables:
-
-prot  type                       rows   cols  name
-====  ====                       ====   ====  ====
- rwd  matrix                        1      8  a
- rwd  galois                        1      8  b
- rwd  matrix                        1      8  c
+Variables in the current scope:
+
+   Attr Name        Size                     Bytes  Class
+   ==== ====        ====                     =====  =====
+        a           1x8                         24  double
+        b           1x8                         32  galois
+        c           1x8                         64  double
+
+Total is 24 elements using 120 bytes
@end example

@c Note that if code compiled with GALOIS_DISP_PRIVATES then '.n', '.alpha_to'
@@ -1429,7 +1427,7 @@
accessing these variables. For instance

@example
-octave:1> a = gf([0:7],3);
+octave:1> a = gf ([0:7], 3);
octave:2> a.prim_poly = 13;
@end example

@@ -1439,8 +1437,8 @@
field, a new field must be created and the data copied. That is

@example
-octave:1> a = gf([0:7],3);
-octave:2> a = gf(a.x,a.m,13);
+octave:1> a = gf ([0:7], 3);
+octave:2> a = gf (a.x, a.m, 13);
@end example

@@ -1471,8 +1469,8 @@
example is

@example
-octave:1> a = minpol(gf(14,5));
-octave:2> b = de2bi(a.x,[],"left-msb");
+octave:1> a = minpol (gf (14, 5));
+octave:2> b = de2bi (a.x, [], "left-msb");
@end example

converts the polynomial form of the minimum polynomial of 14 in GF(2^5) into
@@ -1514,7 +1512,7 @@

@example
-octave:1> dummy = gf(1);
+octave:1> dummy = gf (1);
@end example

@@ -1533,20 +1531,20 @@
@item Logarithm of zero does not return NaN
The logarithm of zero in a Galois field is not defined. However, to avoid
segmentation faults in later calculations the logarithm of zero is defined
-as @code{2^@var{m}-1}, whose value is not the logarithm of any other value
+as @code{2^@var{m} - 1}, whose value is not the logarithm of any other value
in the Galois field. A warning is however printed to tell the user about
the problem. For example

@example
octave:1> m = 3;
-octave:2> a = log(gf([0:2^m-1],m))
+octave:2> a = log (gf ([0:2^m-1], m))
warning: log of zero undefined in Galois field
a =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  7  0  1  3  2  6  4  5
+   7   0   1   3   2   6   4   5
@end example

To fix this problem would require a major rewrite of all code, adding
@@ -1581,14 +1579,14 @@
in a similar manner to all other Octave matrices. For example

@example
-octave:1> a = gf([[0:7];[7:-1:0]],3)
+octave:1> a = gf ([[0:7]; [7:-1:0]], 3)
a =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  0  1  2  3  4  5  6  7
-  7  6  5  4  3  2  1  0
+   0   1   2   3   4   5   6   7
+   7   6   5   4   3   2   1   0

octave:2> b = a(1,:)
b =
@@ -1596,7 +1594,7 @@

Array elements =

-  0  1  2  3  4  5  6  7
+   0   1   2   3   4   5   6   7
@end example

Galois arrays can equally use indexed assignments. That is, the data
@@ -1604,16 +1602,16 @@
fields are identical. An example is

@example
-octave:1> a = gf(ones(2,8),3);
-octave:2> b = gf(zeros(1,8),3);
+octave:1> a = gf (ones (2, 8), 3);
+octave:2> b = gf (zeros (1, 8), 3);
octave:3> a(1,:) = b
a =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  0  0  0  0  0  0  0  0
-  1  1  1  1  1  1  1  1
+   0   0   0   0   0   0   0   0
+   1   1   1   1   1   1   1   1
@end example

Implicit conversions between normal matrices and Galois arrays are possible.
@@ -1621,27 +1619,27 @@
as follows.

@example
-octave:1> a = gf(ones(2,8),3);
-octave:2> b = zeros(2,8);
+octave:1> a = gf (ones (2, 8), 3);
+octave:2> b = zeros (2, 8);
octave:3> b(2,:) = a(2,:)
b =

-  0  0  0  0  0  0  0  0
-  1  1  1  1  1  1  1  1
+   0   0   0   0   0   0   0   0
+   1   1   1   1   1   1   1   1
@end example

The inverse is equally possible, with the proviso that the data in the matrix
is valid in the Galois field. For instance

@example
-octave:1> a = gf([0:7],3);
+octave:1> a = gf ([0:7], 3);
octave:2> a(1) = 1;
@end example

is valid, while

@example
-octave:1> a = gf([0:7],3);
+octave:1> a = gf ([0:7], 3);
octave:2> a(1) = 8;
@end example

@@ -1657,24 +1655,23 @@
and later.

@example
-octave:1> a = [gf([0:7],3); gf([7:-1:0],3)];
+octave:1> a = [gf([0:7], 3); gf([7:-1:0], 3)];
octave:2> b = [a, a];
octave:3> whos
-
-*** local user variables:
-
-  Prot Name       Size  Bytes  Class
-  ==== ====       ====  =====  =====
-   rwd a          2x8      64  galois
-   rwd b          2x16    128  galois
-
-Total is 49 elements using 192 bytes
+Variables in the current scope:
+
+   Attr Name        Size                     Bytes  Class
+   ==== ====        ====                     =====  =====
+        a           2x8                         64  galois
+        b           2x16                       128  galois
+
+Total is 48 elements using 192 bytes
@end example

and for previous versions of Octave

@example
-octave:1> a = [gf([0:7],3); gf([7:-1:0],3)];
+octave:1> a = [gf([0:7], 3); gf([7:-1:0], 3)];
octave:2> b = [a, a];
octave:3> whos

@@ -1692,8 +1689,8 @@
versions, use the syntax

@example
-octave:1> a = gf([0:7],3);
-octave:2> b = gf([a, a], a.m, a.prim_poly);
+octave:1> a = gf ([0:7], 3);
+octave:2> b = gf ([a, a], a.m, a.prim_poly);
@end example

which explicitly reconverts @var{b} to the correct Galois Field. Other
@@ -1758,14 +1755,14 @@
be valid members of the Galois field. Thus

@example
-octave:1> a = gf([0:7],3);
+octave:1> a = gf ([0:7], 3);
octave:2> b = a + [0:7];
@end example

is valid, while

@example
-octave:1> a = gf([0:7],3);
+octave:1> a = gf ([0:7], 3);
octave:2> b = a + [1:8];
@end example

@@ -1855,16 +1852,16 @@
Galois variables can be tested for equality in the usual manner. That is

@example
-octave:1> a = gf([0:7],3);
-octave:2> a == ones(1,8)
+octave:1> a = gf ([0:7], 3);
+octave:2> a == ones (1, 8)
ans =

-  0  1  0  0  0  0  0  0
-
-octave:3> a ~= zeros(1,8)
+   0   1   0   0   0   0   0   0
+
+octave:3> a != zeros (1, 8)
ans =

-  0  1  1  1  1  1  1  1
+   0   1   1   1   1   1   1   1
@end example

Likewise, Galois vectors can be tested against scalar values (whether they are
@@ -1874,7 +1871,7 @@
octave:4> a == 1
ans =

-  0  1  0  0  0  0  0  0
+   0   1   0   0   0   0   0   0
@end example

To test if any or all of the values in a Galois array are non-zero, the
@@ -1894,7 +1891,7 @@
if @var{a} is the @emph{primitive element}, then the example

@example
-octave:1> poly = gf([2, 4, 5, 1],3);
+octave:1> poly = gf ([2, 4, 5, 1], 3);
@end example

represents the polynomial
@@ -1914,15 +1911,15 @@
to polynomials an example is

@example
-octave:1> poly1 = gf([2, 4, 5, 1],3);
-octave:2> poly2 = gf([1, 2],3);
+octave:1> poly1 = gf ([2, 4, 5, 1], 3);
+octave:2> poly2 = gf ([1, 2], 3);
octave:3> sumpoly = poly1 + [0, 0, poly2]
sumpoly =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  2  4  4  3
+   2   4   4   3
@end example

Note that @var{poly2} must be zero padded to the same length as poly1 to
@@ -1933,33 +1930,33 @@
polynomials in GF(2^3).

@example
-octave:4> mulpoly = conv(poly1, poly2)
+octave:4> mulpoly = conv (poly1, poly2)
mulpoly =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  2  0  6  0  2
+   2   0   6   0   2
@end example

Likewise the division of two polynomials uses the de-convolution function
as follows

@example
-octave:5> [poly, remd] = deconv(mulpoly,poly2)
+octave:5> [poly, remd] = deconv (mulpoly, poly2)
poly =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  2  4  5  1
+   2   4   5   1

remd =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  0  0  0  0  0
+   0   0   0   0   0
@end example

Note that the remainder of this division is zero, as we performed the inverse
@@ -1969,24 +1966,24 @@
function @code{polyval}.

@example
-octave:1> poly1 = gf([2, 4, 5, 1],3);  ## a*x^3+a^2*x^2+(a^2+1)*x+1
-octave:2> x0 = gf([0, 1, 2],3);
-octave:3> y0 = polyval(poly1, x0);
+octave:1> poly1 = gf ([2, 4, 5, 1], 3);  ## a*x^3+a^2*x^2+(a^2+1)*x+1
+octave:2> x0 = gf ([0, 1, 2], 3);
+octave:3> y0 = polyval (poly1, x0);
y0 =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  1  2  0
-
-octave:4> a = gf(2,3);               ## The primitive element
+   1   2   0
+
+octave:4> a = gf (2, 3);               ## The primitive element
octave:5> y1 = a .* x0.^3 + a.^2 .* x0.^2 + (a.^2 + 1) .* x0 + 1
y1 =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  1  2  0
+   1   2   0
@end example

It is equally possible to find the roots of Galois polynomials with the
@@ -1994,16 +1991,16 @@
find its roots in the following manner

@example
-octave:1> poly1 = gf([2, 4, 5, 1], 3);
-octave:2> root1 = roots(poly1)
+octave:1> poly1 = gf ([2, 4, 5, 1], 3);
+octave:2> root1 = roots (poly1)
root1 =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  2
-  5
-  5
+   2
+   5
+   5
@end example

Thus the example polynomial has 3 roots in GF(2^3) with one root of
@@ -2011,15 +2008,15 @@
as follows

@example
-octave:3> check1 = polyval(poly1, root1)
+octave:3> check1 = polyval (poly1, root1)
check1 =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-  0
-  0
-  0
+   0
+   0
+   0
@end example

which as expected gives a zero vector. It should be noted that both the
@@ -2027,14 +2024,14 @@
for instance

@example
-octave:1> poly3 = gf([2, 4, 5, 1],3, 13);
-octave:2> root3 = roots(poly3)
+octave:1> poly3 = gf ([2, 4, 5, 1], 3, 13);
+octave:2> root3 = roots (poly3)
root3 =
GF(2^3) array. Primitive Polynomial = D^3+D^2+1 (decimal 13)

Array elements =

-  5
+   5
@end example

shows that in the field GF(2^3) with a different primitive polynomial,
@@ -2047,14 +2044,14 @@
function can be used to find the minimum polynomial as follows

@example
-octave:1> a = gf(2,3);               ## The primitive element
-octave:2> b = minpol(a)
+octave:1> a = gf (2, 3);               ## The primitive element
+octave:2> b = minpol (a)
b =
GF(2) array.

Array elements =

-  1  0  1  1
+   1   0   1   1
@end example

Note that the minimum polynomial of the primitive element is the primitive
@@ -2063,7 +2060,7 @@
@code{cosets} function as follows

@example
-octave:1> c = cosets(3)
+octave:1> c = cosets (3)
c =
@{
[1,1] =
@@ -2071,21 +2068,21 @@

Array elements =

-    1
-
-  [2,1] =
+     1
+
+  [1,2] =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-    2  4  6
-
-  [3,1] =
+     2   4   6
+
+  [1,3] =
GF(2^3) array. Primitive Polynomial = D^3+D+1 (decimal 11)

Array elements =

-    3  5  7
+     3   5   7

@}
@end example
@@ -2093,7 +2090,7 @@
which returns a cell array containing all of the elements of the GF(2^3),
partitioned into groups sharing the same minimum polynomial. The function
@code{cosets} can equally accept a second argument defining the primitive
-polynomial to use in its calculations (i.e. @code{cosets(@var{a},@var{p})}).
+polynomial to use in its calculations (i.e. @code{cosets (@var{a}, @var{p})}).

@node Linear Algebra, Signal Processing, Polynomial manipulations, Manipulating Galois Fields
@subsection Linear Algebra
@@ -2103,7 +2100,7 @@
following way

@example
-octave:2> [l, u, p] = lu(a)
+octave:2> [l, u, p] = lu (a)
@end example

such that @code{@var{p} * @var{a} = @var{l} * @var{u}}. The matrix @var{p}
@@ -2121,7 +2118,7 @@
For instance consider the under-determined linear equation

@example
-octave:1> A = gf([2, 0, 3, 3; 3, 1, 3, 1; 3, 1, 1, 0], 2);
+octave:1> A = gf ([2, 0, 3, 3; 3, 1, 3, 1; 3, 1, 1, 0], 2);
octave:2> b = [0:2]';
octave:3> x = A \ b;
@end example
@@ -2137,10 +2134,10 @@
matrix prior to solving the linear system. For instance

@example
-octave:1> A = gf(floor(2^m * rand(3)), 2);
+octave:1> A = gf (floor (2^m * rand (3)), 2);
octave:2> b = [0:2]';
-octave:3> if (det(A) ~= 0); x = A \ b; y = b' / A; end;
-octave:4> r = rank(A);
+octave:3> if (det (A) != 0); x = A \ b; y = b' / A; endif;
+octave:4> r = rank (A);
@end example

solves the linear systems @code{@var{A} * @var{x} = @var{b}} and
@@ -2158,16 +2155,16 @@
manner as usual. For instance

@example
-octave:1> b = gf([2, 0, 0, 1, 0, 2, 0, 1],2);
-octave:2> a = gf([2, 0, 1, 1],2);
-octave:3> x = gf([1, zeros(1,20)],2);
-octave:4> y = filter(b, a, x)
+octave:1> b = gf ([2, 0, 0, 1, 0, 2, 0, 1], 2);
+octave:2> a = gf ([2, 0, 1, 1], 2);
+octave:3> x = gf ([1, zeros(1, 20)], 2);
+octave:4> y = filter (b, a, x)
y =
GF(2^2) array. Primitive Polynomial = D^2+D+1 (decimal 7)

Array elements =

-  1  0  3  0  2  3  1  0  1  3  3  1  0  1  3  3  1  0  1  3  3
+   1   0   3   0   2   3   1   0   1   3   3   1   0   1   3   3   1   0   1   3   3
@end example

gives the impulse response of the filter defined by @var{a} and @var{b}.
@@ -2185,11 +2182,11 @@

@example
octave:1> m = 3;
-octave:2> a = gf(floor(2^m*rand(4,1)),m);
-octave:3> b = gf(floor(2^m*rand(4,1)),m);
-octave:4> c0 = conv(a,b)';
-octave:5> c1 = convmtx(a,length(b)) * b;
-octave:6> check = all(c0 == c1)
+octave:2> a = gf (floor (2^m * rand (4, 1)), m);
+octave:3> b = gf (floor (2^m * rand (4, 1)), m);
+octave:4> c0 = conv (a, b)';
+octave:5> c1 = convmtx (a, length (b)) * b;
+octave:6> check = all (c0 == c1)
check = 1
@end example

@@ -2208,14 +2205,14 @@

@example
octave:1> m = 4;
-octave:2> n = 2^m -1;
-octave:2> alph = gf(2, m);
-octave:3> x = gf(floor(2^m*rand(n,1)), m);
-octave:4> y0 = fft(x);
-octave:5> y1 = dftmtx(alph) * x;
-octave:6> z0 = ifft(y0);
-octave:7> z1 = dftmtx(1/alph) * y1;
-octave:8> check = all(y0 == y1) & all(z0 == x) & all(z1 == x)
+octave:2> n = 2^m - 1;
+octave:2> alph = gf (2, m);
+octave:3> x = gf (floor (2^m * rand (n, 1)), m);
+octave:4> y0 = fft (x);
+octave:5> y1 = dftmtx (alph) * x;
+octave:6> z0 = ifft (y0);
+octave:7> z1 = dftmtx (1/alph) * y1;
+octave:8> check = all (y0 == y1) & all (z0 == x) & all (z1 == x)
check = 1
@end example