This is because a function conv
in julia uses FFT.
What does "not manual" mean? Writing your own convolution function in julia should be fast.
eg.
function native_conv{T,V}(u::Array{T,1}, v::Array{V,1})
m = length(u)
n = length(v)
w = zeros(promote_type(T,V), m+n-1)
@inbounds begin
for j in 1:m, k in 1:n
w[j+k-1] += u[j]*v[k]
end;end
return w
end
Or it can be faster (make conv with FFT with NaNs set to zero and then normalize).
Edit: this is faster if the v
(filter) is large .
function nanconv{T}(u::Array{T,1},v)
nans = find(isnan, u)
u = copy(u)
u[nans] .= zero(T)
pass1 = conv(u,v)
u[u.>0] .= one(T)
norm = conv(u,v)
u[:] .= one(T)
norm .= norm./(conv(u,v))
w = pass1 ./ norm
reshaped_nans = reshape_nans(nans,length(v))
w[reshaped_nans] .= NaN
return w
end
function reshape_nans(nans,lv)
out = zeros(Int, length(nans)*lv)
j = 1;
inc = lv - 1
for i in nans
inds = i:(i+inc)
out[j:j+inc] = inds
j += inc + 1
end
out
end
source
share