function y = wv_fftconv(a, b) % WV_FFTCONV Linear convolution of two real vectors, by FFT. % % The direct sum costs the product of the two lengths, which for a two-second % sound and a one-second impulse response is about 4e9 operations; the FFT % costs a few times n log n. The result is the full convolution, of length % numel(a) + numel(b) - 1, as a column. a = a(:); b = b(:); n = numel(a) + numel(b) - 1; nfft = 2 ^ nextpow2(n); y = real(ifft(fft(a, nfft) .* fft(b, nfft))); y = y(1:n); end