@(p,q)ifft(fft([p q*0]).*fft([q p*0]))(1:end-1) ans([1 1], [1 4 6 4 1])
Standard input is empty
ans = @(p, q) ifft (fft ([p, q * 0]) .* fft ([q, p * 0])) (1:end - 1) ans = 1.00000 5.00000 10.00000 10.00000 5.00000 1.00000
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!