JuliaMath / JuliaMath/Interpolations.jl

`gradient` does not support vector args which is inconsistent with interpolation evaluation

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

Description

perhaps this is an understanding problem, but it seems from the documentation that there is a disanalogy between of interpolant evaluation and the interpolant gradient evaluation which is not reflected in the documentation regarding vector arguments. Specifically, if I evaluate an interpolant at a vector of locations, it returns a vector of values, no problems. If I ask for the gradient at a vector of locations, it throws an error. Is this behaviour expected?

```julia
julia> itp = interpolate([1.,1.,2], (BSpline(Cubic(Line(OnGrid())))))
julia> itp( [1.0, 2.0],)
[1.0, 1.0]
julia> Interpolations.gradient(itp, [1.0, 2.0],)
gradient of [1.0, 1.0, 2.0] not supported for position ([1.0, 2.0],)

Stacktrace:
[1] error(::String) at ./error.jl:33
[2] gradient(::Interpolations.BSplineInterpolation{Float64,1,OffsetArrays.OffsetArray{Float64,1,Array{Float64,1}},BSpline{Cubic{Line{OnGrid}}},Tuple{Base.OneTo{Int64}}}, ::Array{Float64,1}) at /home/me/.julia/packages/Interpolations/AiRSM/src/Interpolations.jl:369
[3] top-level scope at In[84]:4
```

Of course I can call the gradient function multiple times to get multiple cvalues, but this seems to my limited understanding to construct the gradient weights and such multiple times, and so likely to be inefficient, as well as unnecessarily different to the normal interpolation evaluation. Am I missing something?

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.