Mercurial > hg > octave-lyh
annotate scripts/signal/fftconv.m @ 11085:2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 07 Oct 2010 11:27:03 -0700 |
parents | a1dbe9d80eee |
children | e79f59d31a74 |
rev | line source |
---|---|
7017 | 1 ## Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2005, 2006, |
2 ## 2007 John W. Eaton | |
2313 | 3 ## |
4 ## This file is part of Octave. | |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7 ## under the terms of the GNU General Public License as published by | |
7016 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
2313 | 10 ## |
11 ## Octave is distributed in the hope that it will be useful, but | |
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7016 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
1026 | 19 |
3367 | 20 ## -*- texinfo -*- |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
21 ## @deftypefn {Function File} {} fftconv (@var{a}, @var{b}) |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
22 ## @deftypefnx {Function File} {} fftconv (@var{a}, @var{b}, @var{n}) |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
23 ## Convolve two vectors using the FFT for computation. |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
24 ## |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
25 ## @code{c = fftconv (@var{a}, @var{b})} returns a vector of length equal to |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
26 ## @code{length (@var{a}) + length (@var{b}) - 1}. |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
27 ## If @var{a} and @var{b} are the coefficient vectors of two polynomials, the |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
28 ## returned value is the coefficient vector of the product polynomial. |
3426 | 29 ## |
3367 | 30 ## The computation uses the FFT by calling the function @code{fftfilt}. If |
31 ## the optional argument @var{n} is specified, an N-point FFT is used. | |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
32 ## @seealso{deconv, conv, conv2} |
3367 | 33 ## @end deftypefn |
787 | 34 |
5428 | 35 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
2312 | 36 ## Created: 3 September 1994 |
37 ## Adapted-By: jwe | |
38 | |
2311 | 39 function c = fftconv (a, b, N) |
787 | 40 |
41 if (nargin < 2 || nargin > 3) | |
6046 | 42 print_usage (); |
787 | 43 endif |
2325 | 44 |
4030 | 45 if (! (isvector (a) && isvector (b))) |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
46 error ("fftconv: both A and B must be vectors"); |
787 | 47 endif |
48 la = length (a); | |
49 lb = length (b); | |
50 if ((la == 1) || (lb == 1)) | |
51 c = a * b; | |
52 else | |
53 lc = la + lb - 1; | |
54 a(lc) = 0; | |
55 b(lc) = 0; | |
56 if (nargin == 2) | |
57 c = fftfilt (a, b); | |
58 else | |
4030 | 59 if (! (isscalar (N))) |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
60 error ("fftconv: N must be a scalar"); |
787 | 61 endif |
62 c = fftfilt (a, b, N); | |
63 endif | |
64 endif | |
65 | |
66 endfunction | |
11085
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
67 |
2beacd515e09
Update docstrings for convolution family of functions (conv, conv2, fftconv)
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
68 %% FIXME: Borrow tests from conv.m. May need a tolerance on the assert comparison |