JuliaMath / JuliaMath/Interpolations.jl

StackOverflowError in gradient computation

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

Description

```
using Interpolations
xs = 0.5:0.1:5
A = [log(x) for x in xs]
interp_cubic = CubicSplineInterpolation(xs, A)
g = zeros(1)
Interpolations.gradient!(g,interp_cubic,1.0)
```

you get
```

julia> Interpolations.gradient!(g,interp_cubic,1.0)
1-element Vector{Float64}:
1.0001435205929399

julia> g
1-element Vector{Float64}:
1.0001435205929399
```

so far so good.

Then I tried

```
g = zeros(2)
Interpolations.gradient!(g,interp_cubic,[1.0,1.05])
```

and I get

```
julia> Interpolations.gradient!(g,interp_cubic,[1.0,1.05])
ERROR: StackOverflowError:
Stacktrace:
[1] gradient!(dest::Vector{Float64}, itp::Interpolations.Extrapolation{Float64, 1, ScaledInterpolation{Float64, 1, Interpolations.BSplineInterpolation{Float64, 1, OffsetArrays.OffsetVector{Float64, Vector{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}}}, BSpline{Cubic{Line{OnGrid}}}, Throw{Nothing}}, x::Vector{Float64}) (repeats 79984 times)
@ Interpolations ~/.julia/packages/Interpolations/QLbbu/src/Interpolations.jl:423
```

any chance this is a bug?

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.