JuliaMath / JuliaMath/Interpolations.jl

Hessian calculations error in > 3-dimensional problems

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

Description

When the interpolated data is 4 dimensions or higher, calculating the Hessian gives an error.

Minimal working example:
```julia
using Interpolations

nsamples = 5
fn3 = interpolate(rand(nsamples, nsamples, nsamples), BSpline(Linear()))
@show Interpolations.hessian(fn3, 1, 1, 1) # Works as expected

fn4 = interpolate(rand(nsamples, nsamples, nsamples, nsamples), BSpline(Linear()))
@show Interpolations.hessian(fn4, 1, 1, 1, 1) # Error
```

Expected Results: Some 3x3 and some 4x4 matrix

Result:
```
Interpolations.hessian(fn3, 1, 1, 1) = [0.0 -0.35524799325078593 -0.08388587488866439; -0.35524799325078593 0.0 -0.2697169146789593; -0.08388587488866439 -0.2697169146789593 0.0]
ERROR: LoadError: MethodError: no method matching symmatrix(::NTuple{10,Float64})
Closest candidates are:
symmatrix(!Matched::Tuple{Any}) at C:\Users\mail\.julia\packages\Interpolations\TuOdO\src\b-splines\indexing.jl:195
symmatrix(!Matched::Tuple{L,Any}) where L at C:\Users\mail\.julia\packages\Interpolations\TuOdO\src\b-splines\indexing.jl:199
symmatrix(!Matched::Tuple{Any,Any,Any}) at C:\Users\mail\.julia\packages\Interpolations\TuOdO\src\b-splines\indexing.jl:196
...
Stacktrace:
[1] hessian(::Interpolations.BSplineInterpolation{Float64,4,Array{Float64,4},BSpline{Linear},NTuple{4,Base.OneTo{Int64}}}, ::Int64, ::Int64, ::Int64, ::Int64) at C:\Users\mail\.julia\packages\Interpolations\TuOdO\src\b-splines\indexing.jl:40
[2] top-level scope at show.jl:613
[3] include(::Module, ::String) at .\Base.jl:377
[4] exec_options(::Base.JLOptions) at .\client.jl:288
[5] _start() at .\client.jl:484
in expression starting at ...\testhessian.jl:8
```

versioninfo():
```
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
```

Package version: v0.12.9

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.