## [f62e8c]: inst / @galois / dftmtx.m  Maximize  Restore  History

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71``` ```## Copyright (C) 2002 David Bateman ## ## 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 ## this program; if not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{d} =} dftmtx (@var{a}) ## ## Form a matrix, that can be used to perform Fourier transforms in ## a Galois Field. ## ## Given that @var{a} is an element of the Galois Field GF(2^m), and ## that the minimum value for @var{k} for which @code{@var{a} ^ @var{k}} ## is equal to one is @code{2^m - 1}, then this function produces a ## @var{k}-by-@var{k} matrix representing the discrete Fourier transform ## over a Galois Field with respect to @var{a}. The Fourier transform of ## a column vector is then given by @code{dftmtx (@var{a}) * @var{x}}. ## ## The inverse Fourier transform is given by @code{dftmtx (1 / @var{a})} ## @end deftypefn function d = dftmtx (a) if (nargin != 1) print_usage (); endif if (!isgalois (a)) error ("dftmtx: argument must be a galois variable"); endif m = a.m; prim = a.prim_poly; n = 2^a.m - 1; if (n > 255) error (["dftmtx: argument must be in Galois Field GF(2^M)" ... ", where M is in the range [1,8]"]); endif if (length (a) != 1) error ("dftmtx: argument must be a scalar"); endif mp = minpol (a); if (mp(1) != 1 || !isprimitive (mp)) error ("dftmtx: argument must be a primitive nth root of unity"); endif step = log (a); step = step.x; row = exp (gf ([0:n-1], m, prim)); d = zeros (n); for i = 1:n; d(i,:) = row .^ mod (step*(i-1), n); endfor endfunction %%Test input validation %!error dftmtx (gf (1, 12)) %!error dftmtx (gf (eye (3), 4)) ```