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

ForwardDiff derivative on complex interpolation #337

Closed
jtravs opened this issue Oct 23, 2019 · 1 comment
Closed

ForwardDiff derivative on complex interpolation #337

jtravs opened this issue Oct 23, 2019 · 1 comment

Comments

@jtravs
Copy link

jtravs commented Oct 23, 2019

If I make a complex interpolation:

A_x = [1.0, 1.7, 8.0, 9.7, 10.3, 12.5, 32]
A = [4.0, 2.7, 1.0, 0.7, 4.3, 17.4, 43]
intp = LinearInterpolation(A_x, A .+ im.*A./3)

I can interpolate and also take the gradient just fine:

julia> intp(3.0)
2.3492063492063493 + 0.783068783068783im

julia> Interpolations.gradient(intp, 3.0)
1-element StaticArrays.SArray{Tuple{1},Complex{Float64},1,1}:
 -0.2698412698412699 - 0.08994708994708994im

but I cannot use ForwardDiff:

julia> ForwardDiff.derivative(intp, 3.0)
ERROR: MethodError: no method matching extract_derivative(::Type{ForwardDiff.Tag{Interpolations.Extrapolation{Complex{Float64},1,Interpolations.GriddedInterpolation{Complex{Float64},1,Complex{Float64},Gridded{Linear},Tuple{Array{Float64,1}}},Gridded{Linear},Throw{Nothing}},Float64}}, ::Complex{ForwardDiff.Dual{ForwardDiff.Tag{Interpolations.Extrapolation{Complex{Float64},1,Interpolations.GriddedInterpolation{Complex{Float64},1,Complex{Float64},Gridded{Linear},Tuple{Array{Float64,1}}},Gridded{Linear},Throw{Nothing}},Float64},Float64,1}})
Closest candidates are:
  extract_derivative(::Type{T}, ::ForwardDiff.Dual) where T at C:\Users\John\.julia\packages\ForwardDiff\N0wMF\src\derivative.jl:79
  extract_derivative(::Type{T}, ::Real) where T at C:\Users\John\.julia\packages\ForwardDiff\N0wMF\src\derivative.jl:80
  extract_derivative(::Type{T}, ::AbstractArray) where T at C:\Users\John\.julia\packages\ForwardDiff\N0wMF\src\derivative.jl:81
Stacktrace:
 [1] derivative(::Interpolations.Extrapolation{Complex{Float64},1,Interpolations.GriddedInterpolation{Complex{Float64},1,Complex{Float64},Gridded{Linear},Tuple{Array{Float64,1}}},Gridded{Linear},Throw{Nothing}}, ::Float64) at C:\Users\John\.julia\packages\ForwardDiff\N0wMF\src\derivative.jl:14
 [2] top-level scope at none:0

If I use a real valued interpolation object all works fine:

julia> intp = LinearInterpolation(A_x, A);
julia> ForwardDiff.derivative(intp, 3.0)
-0.2698412698412699

Do you know why? Is this a problem with ForwardDiff?

@jtravs
Copy link
Author

jtravs commented Oct 24, 2019

I'm going to close this because I think it is actually an issue with ForwardDiff, see JuliaDiff/ForwardDiff.jl#364

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

1 participant