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} {} conv (@var{a}, @var{b})
18 ## Convolve two Galois vectors.
20 ## @code{y = conv (a, b)} returns a vector of length equal to
21 ## @code{length (a) + length (b) - 1}.
22 ## If @var{a} and @var{b} are polynomial coefficient vectors, @code{conv}
23 ## returns the coefficients of the product polynomial.
27 function y = conv (a, b)
33 if (!isgalois (a) && !isgalois (b))
34 error("conv: at least one argument must be a galois variable");
35 elseif (!isgalois (a))
36 a = gf(a, b.m, b.prim_poly);
37 elseif (!isgalois (b))
38 b = gf(b, a.m, a.prim_poly);
39 elseif (a.m != b.m && a.prim_poly != b.prim_poly)
40 error("conv: both vectors must be in the same galois field");
43 if (min(size(a)) > 1 || min(size(b)) > 1)
44 error("conv: both arguments must be vectors");
52 ## Ensure that both vectors are row vectors.
54 a = reshape (a, 1, la);
57 b = reshape (b, 1, lb);
60 ## Use the shortest vector as the coefficent vector to filter.
63 ## Can't concatenate galois variables like this yet
64 ## x = [b, (zeros (1, ly - lb))];
65 x = gf([b, (zeros (1, ly - lb))], b.m, b.prim_poly);
72 ## Can't concatenate galois variables like this yet
73 ## x = [a, (zeros (1, ly - la))];
74 x = gf([a, (zeros (1, ly - la))], a.m, a.prim_poly);