BSpline error in docs
macmyn opened this issue · comments
Douglas Brown commented
[```][https://juliamath.github.io/Interpolations.jl/stable/control/#Scaled-BSplines]
A_x = 1.:2.:40.
A = [log(x) for x in A_x]
itp = interpolate(A, BSpline(Cubic(Line(OnGrid()))))
sitp = scale(itp, A_x)
sitp(3.) # exactly log(3.)
sitp(3.5) # approximately log(3.5)
returns
20-element interpolate(OffsetArray(::Vector{Float64}, 0:21), BSpline(Cubic(Line(OnGrid())))) with element type Float64:
Error showing value of type Interpolations.BSplineInterpolation{Float64, 1, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}}}:
ERROR: BoundsError: attempt to access Tuple{} at index [1]
Mark Kittisopikul commented
This seems to work fine for me. What versions of Interpolations.jl are you using?
julia> using Interpolations
julia> A_x = 1.:2.:40.
1.0:2.0:39.0
julia> A = [log(x) for x in A_x]
20-element Vector{Float64}:
0.0
1.0986122886681098
1.6094379124341003
1.9459101490553132
2.1972245773362196
2.3978952727983707
2.5649493574615367
2.70805020110221
2.833213344056216
2.9444389791664403
3.044522437723423
3.1354942159291497
3.2188758248682006
3.295836866004329
3.367295829986474
3.4339872044851463
3.4965075614664802
3.5553480614894135
3.6109179126442243
3.6635616461296463
julia> itp = interpolate(A, BSpline(Cubic(Line(OnGrid()))))
20-element interpolate(OffsetArray(::Vector{Float64}, 0:21), BSpline(Cubic(Line(OnGrid())))) with element type Float64:
0.0
1.0986122886681098
1.6094379124341
1.9459101490553135
2.19722457733622
2.3978952727983707
2.564949357461537
2.7080502011022105
2.8332133440562166
2.9444389791664407
3.0445224377234226
3.1354942159291492
3.218875824868201
3.295836866004329
3.367295829986474
3.4339872044851467
3.4965075614664802
3.5553480614894135
3.6109179126442243
3.6635616461296463
julia> sitp = scale(itp, A_x)
20-element scale(interpolate(OffsetArray(::Vector{Float64}, 0:21), BSpline(Cubic(Line(OnGrid())))), (1.0:2.0:39.0,)) with element type Float64:
-5.551115123125783e-17
1.0986122886681098
1.6094379124341
1.9459101490553135
2.1972245773362196
2.3978952727983707
2.5649493574615367
2.70805020110221
2.8332133440562166
2.9444389791664407
3.0445224377234226
3.1354942159291492
3.218875824868201
3.295836866004329
3.3672958299864737
3.4339872044851463
3.4965075614664802
3.5553480614894135
3.610917912644224
3.6635616461296463
julia> sitp(3.) # exactly log(3.)
1.0986122886681098
julia> sitp(3.5) # approximately log(3.5)
1.2748716241925298
What is the output of the following in your environment?
using Pkg
Pkg.status("Interpolations")