Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hessian calculations error in > 3-dimensional problems #364

Open
jurreht opened this issue Apr 12, 2020 · 1 comment
Open

Hessian calculations error in > 3-dimensional problems #364

jurreht opened this issue Apr 12, 2020 · 1 comment

Comments

@jurreht
Copy link

jurreht commented Apr 12, 2020

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

Minimal working example:

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

@timholy
Copy link
Member

timholy commented Apr 12, 2020

symmatrix makes a packed symmetric matrix. Might be enough info for you to help fix this? See #365.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants