Mercurial > octave-nkf
comparison 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 |
comparison
equal
deleted
inserted
replaced
11084:0f6c5efce96e | 11085:2beacd515e09 |
---|---|
16 ## You should have received a copy of the GNU General Public License | 16 ## You should have received a copy of the GNU General Public License |
17 ## along with Octave; see the file COPYING. If not, see | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | 18 ## <http://www.gnu.org/licenses/>. |
19 | 19 |
20 ## -*- texinfo -*- | 20 ## -*- texinfo -*- |
21 ## @deftypefn {Function File} {} fftconv (@var{a}, @var{b}, @var{n}) | 21 ## @deftypefn {Function File} {} fftconv (@var{a}, @var{b}) |
22 ## Return the convolution of the vectors @var{a} and @var{b}, as a vector | 22 ## @deftypefnx {Function File} {} fftconv (@var{a}, @var{b}, @var{n}) |
23 ## with length equal to the @code{length (a) + length (b) - 1}. If @var{a} | 23 ## Convolve two vectors using the FFT for computation. |
24 ## and @var{b} are the coefficient vectors of two polynomials, the returned | 24 ## |
25 ## value is the coefficient vector of the product polynomial. | 25 ## @code{c = fftconv (@var{a}, @var{b})} returns a vector of length equal to |
26 ## @code{length (@var{a}) + length (@var{b}) - 1}. | |
27 ## If @var{a} and @var{b} are the coefficient vectors of two polynomials, the | |
28 ## returned value is the coefficient vector of the product polynomial. | |
26 ## | 29 ## |
27 ## The computation uses the FFT by calling the function @code{fftfilt}. If | 30 ## The computation uses the FFT by calling the function @code{fftfilt}. If |
28 ## the optional argument @var{n} is specified, an N-point FFT is used. | 31 ## the optional argument @var{n} is specified, an N-point FFT is used. |
32 ## @seealso{deconv, conv, conv2} | |
29 ## @end deftypefn | 33 ## @end deftypefn |
30 | 34 |
31 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> | 35 ## Author: KH <Kurt.Hornik@wu-wien.ac.at> |
32 ## Created: 3 September 1994 | 36 ## Created: 3 September 1994 |
33 ## Adapted-By: jwe | 37 ## Adapted-By: jwe |
37 if (nargin < 2 || nargin > 3) | 41 if (nargin < 2 || nargin > 3) |
38 print_usage (); | 42 print_usage (); |
39 endif | 43 endif |
40 | 44 |
41 if (! (isvector (a) && isvector (b))) | 45 if (! (isvector (a) && isvector (b))) |
42 error ("fftconv: both a and b should be vectors"); | 46 error ("fftconv: both A and B must be vectors"); |
43 endif | 47 endif |
44 la = length (a); | 48 la = length (a); |
45 lb = length (b); | 49 lb = length (b); |
46 if ((la == 1) || (lb == 1)) | 50 if ((la == 1) || (lb == 1)) |
47 c = a * b; | 51 c = a * b; |
51 b(lc) = 0; | 55 b(lc) = 0; |
52 if (nargin == 2) | 56 if (nargin == 2) |
53 c = fftfilt (a, b); | 57 c = fftfilt (a, b); |
54 else | 58 else |
55 if (! (isscalar (N))) | 59 if (! (isscalar (N))) |
56 error ("fftconv: N has to be a scalar"); | 60 error ("fftconv: N must be a scalar"); |
57 endif | 61 endif |
58 c = fftfilt (a, b, N); | 62 c = fftfilt (a, b, N); |
59 endif | 63 endif |
60 endif | 64 endif |
61 | 65 |
62 endfunction | 66 endfunction |
67 | |
68 %% FIXME: Borrow tests from conv.m. May need a tolerance on the assert comparison |