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