Chris@366: function maxabsdiff=tailscrap() Chris@366: % test code for circular convolution with the scrapped portion Chris@366: % at the tail of the buffer, rather than the front Chris@366: % Chris@366: % The idea is to rotate the zero-padded h (impulse response) buffer Chris@366: % to the left nh-1 samples, rotating the junk samples as well. Chris@366: % This could be very handy in avoiding buffer copies during fast filtering. Chris@366: nh=10; Chris@366: nfft=256; Chris@366: Chris@366: h=rand(1,nh); Chris@366: x=rand(1,nfft); Chris@366: Chris@366: hpad=[ h(nh) zeros(1,nfft-nh) h(1:nh-1) ]; Chris@366: Chris@366: % baseline comparison Chris@366: y1 = filter(h,1,x); Chris@366: y1_notrans = y1(nh:nfft); Chris@366: Chris@366: % fast convolution Chris@366: y2 = ifft( fft(hpad) .* fft(x) ); Chris@366: y2_notrans=y2(1:nfft-nh+1); Chris@366: Chris@366: maxabsdiff = max(abs(y2_notrans - y1_notrans)) Chris@366: Chris@366: end