annotate src/ext/kissfft/test/tailscrap.m @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 5ed6e970541b
children
rev   line source
c@174 1 function maxabsdiff=tailscrap()
c@174 2 % test code for circular convolution with the scrapped portion
c@174 3 % at the tail of the buffer, rather than the front
c@174 4 %
c@174 5 % The idea is to rotate the zero-padded h (impulse response) buffer
c@174 6 % to the left nh-1 samples, rotating the junk samples as well.
c@174 7 % This could be very handy in avoiding buffer copies during fast filtering.
c@174 8 nh=10;
c@174 9 nfft=256;
c@174 10
c@174 11 h=rand(1,nh);
c@174 12 x=rand(1,nfft);
c@174 13
c@174 14 hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ];
c@174 15
c@174 16 % baseline comparison
c@174 17 y1 = filter(h,1,x);
c@174 18 y1_notrans = y1(nh:nfft);
c@174 19
c@174 20 % fast convolution
c@174 21 y2 = ifft( fft(hpad) .* fft(x) );
c@174 22 y2_notrans=y2(1:nfft-nh+1);
c@174 23
c@174 24 maxabsdiff = max(abs(y2_notrans - y1_notrans))
c@174 25
c@174 26 end