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} {} roots (@var{v})
19 ## For a vector @var{v} with @math{N} components, return
20 ## the roots of the polynomial over a Galois Field
24 ## v_1 z^{N-1} + \cdots + v_{N-1} z + v_N.
31 ## v(1) * z^(N-1) + ... + v(N-1) * z + v(N).
35 ## The number of roots returned and their value will be determined
36 ## by the order and primitive polynomial of the Galios Field
39 function r = roots (v)
42 error("usage: r = roots(v)");
46 error("roots: argument must be a galois variable");
49 if (min (size (v)) > 1 || nargin != 1)
50 usage ("roots (v), where v is a galois vector");
53 v = reshape (v, 1, length(v));
55 prim_poly = v.prim_poly;
62 while ((t <= n) && (length(poly) > 1))
63 [npoly, nrem] = deconv(poly,gf([1,t],m,prim_poly));
73 r = gf(r,m,prim_poly);