annotate ext/kissfft/test/tailscrap.m @ 409:1f1999b0f577
Bring in kissfft into this repo (formerly a subrepo, but the remote is not responding)
author |
Chris Cannam <c.cannam@qmul.ac.uk> |
date |
Tue, 21 Jul 2015 07:34:15 +0100 |
parents |
|
children |
|
rev |
line source |
c@409
|
1 function maxabsdiff=tailscrap()
|
c@409
|
2 % test code for circular convolution with the scrapped portion
|
c@409
|
3 % at the tail of the buffer, rather than the front
|
c@409
|
4 %
|
c@409
|
5 % The idea is to rotate the zero-padded h (impulse response) buffer
|
c@409
|
6 % to the left nh-1 samples, rotating the junk samples as well.
|
c@409
|
7 % This could be very handy in avoiding buffer copies during fast filtering.
|
c@409
|
8 nh=10;
|
c@409
|
9 nfft=256;
|
c@409
|
10
|
c@409
|
11 h=rand(1,nh);
|
c@409
|
12 x=rand(1,nfft);
|
c@409
|
13
|
c@409
|
14 hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ];
|
c@409
|
15
|
c@409
|
16 % baseline comparison
|
c@409
|
17 y1 = filter(h,1,x);
|
c@409
|
18 y1_notrans = y1(nh:nfft);
|
c@409
|
19
|
c@409
|
20 % fast convolution
|
c@409
|
21 y2 = ifft( fft(hpad) .* fft(x) );
|
c@409
|
22 y2_notrans=y2(1:nfft-nh+1);
|
c@409
|
23
|
c@409
|
24 maxabsdiff = max(abs(y2_notrans - y1_notrans))
|
c@409
|
25
|
c@409
|
26 end
|