1 ## Copyright (C) 2002 David Bateman
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
17 ## @deftypefn {Function File} {@var{d} = } dftmtx (@var{a})
19 ## Form a matrix, that can be used to perform Fourier transforms in
22 ## Given that @var{a} is an element of the Galois Field GF(2^m), and
23 ## that the minimum value for @var{k} for which @code{@var{a} ^ @var{k}}
24 ## is equal to one is @code{2^m - 1}, then this function produces a
25 ## @var{k}-by-@var{k} matrix representing the discrete Fourier transform
26 ## over a Galois Field with respect to @var{a}. The Fourier transform of
27 ## a column vector is then given by @code{dftmtx(@var{a}) * @var{x}}.
29 ## The inverse Fourier transform is given by @code{dftmtx(1/@var{a})}
32 function d = dftmtx(a)
35 error ("usage: d = dftmtx (a)");
39 error("dftmtx: argument must be a galois variable");
46 error ([ "dftmtx: argument must be in Galois Field GF(2^m), where" ...
47 " m is not greater than 8"]);
51 error ("dftmtx: argument must be a scalar");
55 if ((mp(1) ~= 1) || !isprimitive(mp))
56 error("dftmtx: argument must be a primitive nth root of unity");
61 row = exp(gf([0:n-1], m, prim));
64 d(i,:) = row .^ mod(step*(i-1),n);