Hi everyone,
I would like to initialize an array that is later filled with interpolation objects. To be specific, it should store output from interpolate() from Interpolations.jl later on.
Normally, I can initialize any array of arrays like this:
A = fill([], 1, 20)
or if I want to have the inner arrays to be Float64
, I can write
A = fill(Float64[], 1, 20)
Julia tells me that an interpolation object is of type Interpolations.BSplineInterpolation{Float64, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}
Therefore, I try to initialize my array like this
A = fill(Interpolations.BSplineInterpolation{Float64, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, 1, 20)
That looks fine, but when I try to store an interpolation afterwards in one of the arrays like this.
B = rand(10,10)
A[1] = interpolate( B, BSpline(Cubic(Line(OnGrid()))))
I get this error
ERROR: MethodError: Cannot `convert` an object of type Interpolations.BSplineInterpolation{Float64, 2, OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}} to an object of type DataType
What am I doing wrong?
Thanks a lot!
Here is the complete MWE:
using Interpolations
# Initialize array of interpolation objects
A = fill(Interpolations.BSplineInterpolation{Float64, 2, OffsetArrays.OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, 1, 20)
# Set up some "data" for interpolations
B = rand(10,10)
# Try to store an interpolation in one of the elements of A
A[1] = interpolate( B, BSpline(Cubic(Line(OnGrid()))))