Mercurial > hg > qm-dsp
annotate ext/kissfft/test/tailscrap.m @ 206:335be766a54d
Fix erroneous header guard
author | Chris Cannam |
---|---|
date | Fri, 30 Sep 2016 19:04:06 +0100 |
parents | 76ec2365b250 |
children |
rev | line source |
---|---|
Chris@184 | 1 function maxabsdiff=tailscrap() |
Chris@184 | 2 % test code for circular convolution with the scrapped portion |
Chris@184 | 3 % at the tail of the buffer, rather than the front |
Chris@184 | 4 % |
Chris@184 | 5 % The idea is to rotate the zero-padded h (impulse response) buffer |
Chris@184 | 6 % to the left nh-1 samples, rotating the junk samples as well. |
Chris@184 | 7 % This could be very handy in avoiding buffer copies during fast filtering. |
Chris@184 | 8 nh=10; |
Chris@184 | 9 nfft=256; |
Chris@184 | 10 |
Chris@184 | 11 h=rand(1,nh); |
Chris@184 | 12 x=rand(1,nfft); |
Chris@184 | 13 |
Chris@184 | 14 hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ]; |
Chris@184 | 15 |
Chris@184 | 16 % baseline comparison |
Chris@184 | 17 y1 = filter(h,1,x); |
Chris@184 | 18 y1_notrans = y1(nh:nfft); |
Chris@184 | 19 |
Chris@184 | 20 % fast convolution |
Chris@184 | 21 y2 = ifft( fft(hpad) .* fft(x) ); |
Chris@184 | 22 y2_notrans=y2(1:nfft-nh+1); |
Chris@184 | 23 |
Chris@184 | 24 maxabsdiff = max(abs(y2_notrans - y1_notrans)) |
Chris@184 | 25 |
Chris@184 | 26 end |