annotate constant-q-cpp/src/ext/kissfft/test/tailscrap.m @ 372:af71cbdab621 tip

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