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