Hi,
I’m trying to use the function LinearInterpolation from Interpolations.jl for the first time, but I guess I’m doing many things wrong, since I get very bad performance when compared with a similar IDL routine.
The julia function I have now is:
function interp_test(size)
xs = range(0,10,length=size); ys = range(0,10,length=size); zs = range(0,10,length=size)
xsi = xs .+ 0.5 ; ysi = ys .+ 0.5 ; zsi = zs .+ 0.5
dat = randn(size,size,size)
dat_out = zeros(size,size,size)
dat_int = LinearInterpolation((xs,ys,zs),dat,extrapolation_bc = Line());
for C in CartesianIndices((length(xsi),length(ysi),length(zsi)))
dat_out[C] = dat_int(xsi[C[1]],ysi[C[2]],zsi[C[3]])
end
println(dat_out[1,1,1],dat_out[end,end,end])
end
The similar IDL that I have is:
PRO interp_test, size
xs = findgen(size)
ys = findgen(size)
zs = findgen(size)
xsi = xs + 0.5
ysi = ys + 0.5
zsi = zs + 0.5
dat = randomu(1,size,size,size)
dat_out = interpolate(dat,xsi,ysi,zsi,/grid)
print,dat_out[0,0,0],dat_out[-1,-1,-1]
end
But the times in Julia are much worse:
julia> @time interp_test(500)
1.171280353464721146.0781291105493
27.314111 seconds (125.00 M allocations: 4.657 GiB, 9.00% gc time)
IDL> interp_test, 500
interp_test, 500
0.457461 0.0822094
% Time elapsed: 1.5881102 seconds.
IDL>
Any help on getting this to work better?
Many thanks,
AdV