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