Closed
Description
The following example is taken from the readme
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.]
sitp[3.5]
This can also be called in one go by passing a vector to be evaluated
sitp[[3.0, 3.5]]
2-element Array{Float64,1}:
1.09861
1.22632
If evaluated outside the grid range (e.g. at 42), it seems to automatically extrapolate
sitp[42.0]
3.7425272463577794
However, that doesn't work for a vector
sitp[[42.0,3.5]]
BoundsError: attempt to access 20-element scale(interpolate(::Array{Float64,1}, BSpline(Linear()), OnGrid()), (1.0:2.0:39.0,)) with element type Float64 at index [[42.0,3.5]]
in throw_boundserror(::Interpolations.ScaledInterpolation{Float64,1,Interpolations.BSplineInterpolation{Float64,1,Array{Float64,1},Interpolations.BSpline{Interpolations.Linear},Interpolations.OnGrid,0},Interpolations.BSpline{Interpolations.Linear},Interpolations.OnGrid,Tuple{FloatRange{Float64}}}, ::Tuple{Array{Float64,1}}) at abstractarray.jl:363
in checkbounds at abstractarray.jl:292 [inlined]
in _getindex at multidimensional.jl:272 [inlined]
in getindex(::Interpolations.ScaledInterpolation{Float64,1,Interpolations.BSplineInterpolation{Float64,1,Array{Float64,1},Interpolations.BSpline{Interpolations.Linear},Interpolations.OnGrid,0},Interpolations.BSpline{Interpolations.Linear},Interpolations.OnGrid,Tuple{FloatRange{Float64}}}, ::Array{Float64,1}) at abstractarray.jl:760
in include_string(::String, ::String) at loading.jl:441
in include_string(::String, ::String) at sys.dylib:?
in eval(::Module, ::Any) at boot.jl:234
in eval(::Module, ::Any) at sys.dylib:?
in (::Atom.##65#68)() at eval.jl:102
in withpath(::Atom.##65#68, ::Void) at utils.jl:30
in withpath(::Function, ::Void) at eval.jl:38
in macro expansion at eval.jl:101 [inlined]
in (::Atom.##64#67{Dict{String,Any}})() at task.jl:60
What works is to set the extrapolation explicitely
esitp = extrapolate(sitp,Linear())
esitp[[42.0,3.5]]
2-element Array{Float64,1}:
3.74253
1.22632
This seems a bit inconsistent. Would it make sense to also automatically extrapolate when the input is a vector of points? Possibly related is issue #129.
General information
Pkg.status("Interpolations")
- Interpolations 0.6.1
Julia Version 0.5.3-pre+0
Commit 42f8035ccc (2017-05-06 16:34 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin16.5.0)
CPU: Intel(R) Core(TM) i7-6700K CPU @ 4.00GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT NO_AFFINITY NEHALEM)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.7.1 (ORCJIT, broadwell)
Metadata
Metadata
Assignees
Labels
No labels