You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ForwardDiff through hessian fails for ND interpolants #213
I’m getting a MethodError when differentiating through hessian with ForwardDiff.
MWE:
using FastInterpolations
using ForwardDiff
x =1.0:5.0
y =1.0:5.0
data = [sin(i) *cos(j) for i in x, j in y]
itp =linear_interp((x, y), data)
f(q) =hessian(itp, q)
ForwardDiff.jacobian(q ->vec(f(q)), [2.5, 3.5])
This errors with something like:
MethodError: no method matching Float64(::ForwardDiff.Dual{...})
It looks like the allocating hessian creates a Matrix{Float64} based on the stored data/grid types, even though the query becomes Dual under ForwardDiff.
I see the same behavior with linear, cubic, quadratic, and constant ND interpolants.
This was an unexpected regression introduced in v0.4.17, and it has now been fixed by PR #216.
I’ll release a new version with this fix shortly!
Motivated by this issue, I also realized that I had missed implementing the Jacobian operator.
(Currently, FastInterpolations supports a few common operators, gradient, Laplacian, and Hessian, but not the Jacobian.)
I’m planning to implement the Jacobian, as well as more generic versions of vector calculus derivative operators if possible.
I’ll keep you updated! Please let me know if there are any other specific vector calculus operators or features you’d like to see.
@Riarrieta
FYI, the new version (v0.4.20), which fixed this issue, has just been released.
Please give it a try and let me know if you find any issues.
Activity
fix(nd): ND `hessian` output eltype follows a Dual query (ForwardDiff) (
Riarrieta commentedon Oct 8, 2026
Thanks for looking into it!
mgyoo86 commentedon Oct 8, 2026
Hi @Riarrieta,
Thanks a lot for reporting this issue!
This was an unexpected regression introduced in v0.4.17, and it has now been fixed by PR #216.
I’ll release a new version with this fix shortly!
Motivated by this issue, I also realized that I had missed implementing the Jacobian operator.
(Currently, FastInterpolations supports a few common operators, gradient, Laplacian, and Hessian, but not the Jacobian.)
I’m planning to implement the Jacobian, as well as more generic versions of vector calculus derivative operators if possible.
I’ll keep you updated! Please let me know if there are any other specific vector calculus operators or features you’d like to see.
Thanks again! :)
chore: update version to 0.4.20 and benchmark results in README
mgyoo86 commentedon Oct 14, 2026
@Riarrieta
FYI, the new version (v0.4.20), which fixed this issue, has just been released.
Please give it a try and let me know if you find any issues.
Thank you again for raising this issue!