I have a small problem that I can’t seem to solve regarding the use of CubicSplineInterpolation on a vector (rather than lazy array).
using Interpolations, Plots
function spline_interpolation2()
#mygrid = range(-1.0, stop=1.0, length=5) # lazy array representation
mygrid = collect(range(-1.0, stop=1.0, length=5)) # vector representation
mypoints = abs.(mygrid)
#itp = interpolate((mygrid,),mypoints, Gridded(Constant()))
#itp = interpolate((mygrid,),mypoints, Gridded(Linear()))
#itp = LinearInterpolation(mygrid, mypoints, extrapolation_bc=Flat())
#itp = LinearInterpolation(mygrid, mypoints)
#itp = Spline1D(mygrid, mypoints, k=3, bc="nearest", s=0.0)
itp = CubicSplineInterpolation(mygrid, mypoints; bc=Line(OnGrid()), extrapolation_bc=Throw())
# interpolate at any point
myfinergrid = range(-1.0, stop=1.0, length=100)
itp.(myfinergrid)
plot(myfinergrid, [abs.(myfinergrid) itp.(myfinergrid)], label=["abs" "interplotion" ])
end
spline_interpolation2()
When using Spline1D I get what I want. CubicSplineInterpolation returns a method error, though.
FYI: LinearInterpolation works, but it is not what I want to use. I am interested in Cubic Interpolation.
Thanks for the help.