Hi,
while looking at the example scripts I've noticed convolve.inp, and then
also the paragraph about Convolution in the guide (cheat sheet chapter,
p. 154 for me).
I wonder if this should be wrapped in a hansl function and added to the
'extra' addon, like this:
<hansl>
function void padzeros(matrix *a, matrix *b)
a = vec(a)
b = vec(b)
outrows = rows(a) + rows(b) - 1
a |= zeros(outrows - rows(a), 1)
b |= zeros(outrows - rows(b), 1)
end function
function matrix convolve(matrix p, matrix q)
padzeros(&p, &q)
return filter(p, q)
end function
# And for comparison only:
function matrix convolve_fft(matrix p, matrix q)
padzeros(&p, &q)
f = fft(p ~ q)
return ffti(cmult(f[,1:2], f[,3:4]))
end function
<hansl>
As mentioned in the guide, the filter-based variant is indeed about 30%
faster in my examples.
BTW, I think there are some typos in the notation in the Convolution
paragraph: The sum indices i should start at 0, not 1, and the upper
bound for the R(x) index should be p + q - 1 instead of pq-1.
Any feedback welcome.
thanks,
sven