JuliaMath / JuliaMath/Interpolations.jl

Cubic interpolation of a vector of matrices with grid/range doesn't work

Open
#481 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
575
Forks
117
PR merge metrics
No merged PRs in 30d

Description

I just started using Interpolations, being interested to interpolate time values stored in a vector of array.
While linear interpolation works
```
julia> itp = LinearInterpolation([1,2,3],[rand(2,2),rand(2,2),rand(2,2)])
3-element extrapolate(interpolate((::Vector{Int64},), ::Vector{Matrix{Float64}}, Gridded(Linear())), Throw()) with element type Matrix{Float64}:
[0.45075441351126755 0.6948520432892077; 0.9632771824389577 0.13939170840849813]
[0.7724086132599711 0.4960608819423973; 0.8859328713683932 0.44873824726319933]
[0.11167858142523124 0.7060973358621785; 0.4175384295030793 0.9972636473469578]
```
I encountered the following error when trying to use cubic splines with the gridding option
```
julia> itp = interpolate([rand(2,2),rand(2,2),rand(2,2)], BSpline(Cubic(Line(OnGrid()))))
ERROR: MethodError: no method matching zero(::Type{Matrix{Float64}})
Closest candidates are:
zero(::Union{Type{P}, P}) where P<:Dates.Period at C:\Users\Andreas\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Dates\src\periods.jl:53
zero(::SA) where SA<:StaticArrays.StaticArray at C:\Users\Andreas\.julia\packages\StaticArrays\A0XaR\src\linalg.jl:92
zero(::OffsetArrays.OffsetArray) at C:\Users\Andreas\.julia\packages\OffsetArrays\I5Pfg\src\OffsetArrays.jl:395 ...
Stacktrace:
[1] copy_with_padding(#unused#::Type{Matrix{Float64}}, A::Vector{Matrix{Float64}}, it::BSpline{Cubic{Line{OnGrid}}})
@ Interpolations C:\Users\Andreas\.julia\packages\Interpolations\Glp9h\src\b-splines\prefiltering.jl:27
[2] prefilter(#unused#::Type{Float64}, #unused#::Type{Matrix{Float64}}, A::Vector{Matrix{Float64}}, it::BSpline{Cubic{Line{OnGrid}}})
@ Interpolations C:\Users\Andreas\.julia\packages\Interpolations\Glp9h\src\b-splines\prefiltering.jl:39
[3] interpolate(#unused#::Type{Float64}, #unused#::Type{Matrix{Float64}}, A::Vector{Matrix{Float64}}, it::BSpline{Cubic{Line{OnGrid}}})
@ Interpolations C:\Users\Andreas\.julia\packages\Interpolations\Glp9h\src\b-splines\b-splines.jl:160
[4] interpolate(A::Vector{Matrix{Float64}}, it::BSpline{Cubic{Line{OnGrid}}})
@ Interpolations C:\Users\Andreas\.julia\packages\Interpolations\Glp9h\src\b-splines\b-splines.jl:184
[5] top-level scope
@ REPL[26]:1

```
I hope it is my fault (using the wrong options) and I would be very grateful for any hint to overcome this error. I am using Julia 1.7.1 and Interpolations v0.13.5.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.