Mercurial > hg > silvet
comparison constant-q-cpp/src/ext/kissfft/test/tailscrap.m @ 366:5d0a2ebb4d17
Bring dependent libraries in to repo
author | Chris Cannam |
---|---|
date | Fri, 24 Jun 2016 14:47:45 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
365:112766f4c34b | 366:5d0a2ebb4d17 |
---|---|
1 function maxabsdiff=tailscrap() | |
2 % test code for circular convolution with the scrapped portion | |
3 % at the tail of the buffer, rather than the front | |
4 % | |
5 % The idea is to rotate the zero-padded h (impulse response) buffer | |
6 % to the left nh-1 samples, rotating the junk samples as well. | |
7 % This could be very handy in avoiding buffer copies during fast filtering. | |
8 nh=10; | |
9 nfft=256; | |
10 | |
11 h=rand(1,nh); | |
12 x=rand(1,nfft); | |
13 | |
14 hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ]; | |
15 | |
16 % baseline comparison | |
17 y1 = filter(h,1,x); | |
18 y1_notrans = y1(nh:nfft); | |
19 | |
20 % fast convolution | |
21 y2 = ifft( fft(hpad) .* fft(x) ); | |
22 y2_notrans=y2(1:nfft-nh+1); | |
23 | |
24 maxabsdiff = max(abs(y2_notrans - y1_notrans)) | |
25 | |
26 end |