]> Creatis software - CreaPhase.git/blob - octave_packages/communications-1.1.1/@galois/filter.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / communications-1.1.1 / @galois / filter.m
1 ## Copyright (C) 2011 David Bateman
2 ##
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
6 ## version.
7 ##
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
11 ## details.
12 ##
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/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn {Loadable Function} {y =} filter (@var{b}, @var{a}, @var{x})
18 ## @deftypefnx {Loadable Function} {[@var{y}, @var{sf}] =} filter (@var{b}, @var{a}, @var{x}, @var{si})
19 ## 
20 ## Digital filtering of vectors in a Galois Field. Returns the solution to
21 ## the following linear, time-invariant difference equation over a Galois
22 ## Field:
23 ## @iftex
24 ## @tex
25 ## $$
26 ## \\sum_{k=0}^N a_{k+1} y_{n-k} = \\sum_{k=0}^M b_{k+1} x_{n-k}, \\qquad
27 ##  1 \\le n \\le P
28 ## $$
29 ## @end tex
30 ## @end iftex
31 ## @ifinfo
32 ## 
33 ## @smallexample
34 ##    N                   M
35 ##   SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)      for 1<=n<=length(x)
36 ##   k=0                 k=0
37 ## @end smallexample
38 ## @end ifinfo
39 ## 
40 ## @noindent
41 ## where
42 ## @ifinfo
43 ##  N=length(a)-1 and M=length(b)-1.
44 ## @end ifinfo
45 ## @iftex
46 ## @tex
47 ##  $a \\in \\Re^{N-1}$, $b \\in \\Re^{M-1}$, and $x \\in \\Re^P$.
48 ## @end tex
49 ## @end iftex
50 ## An equivalent form of this equation is:
51 ## @iftex
52 ## @tex
53 ## $$
54 ## y_n = -\\sum_{k=1}^N c_{k+1} y_{n-k} + \\sum_{k=0}^M d_{k+1} x_{n-k}, \\qquad
55 ##  1 \\le n \\le P
56 ## $$
57 ## @end tex
58 ## @end iftex
59 ## @ifinfo
60 ## 
61 ## @smallexample
62 ##             N                   M
63 ##   y(n) = - SUM c(k+1) y(n-k) + SUM d(k+1) x(n-k)  for 1<=n<=length(x)
64 ##            k=1                 k=0
65 ## @end smallexample
66 ## @end ifinfo
67 ## 
68 ## @noindent
69 ## where
70 ## @ifinfo
71 ##  c = a/a(1) and d = b/a(1).
72 ## @end ifinfo
73 ## @iftex
74 ## @tex
75 ## $c = a/a_1$ and $d = b/a_1$.
76 ## @end tex
77 ## @end iftex
78 ## 
79 ## If the fourth argument @var{si} is provided, it is taken as the
80 ## initial state of the system and the final state is returned as
81 ## @var{sf}.  The state vector is a column vector whose length is
82 ## equal to the length of the longest coefficient vector minus one.
83 ## If @var{si} is not supplied, the initial state vector is set to all
84 ## zeros.
85 ## @end deftypefn
86
87 function varargout = filter (varargin)
88   varargout = cell (1, max(1, nargout));
89   [varargout{:}] = gfilter (varargin{:});
90 endfunction