ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

Jacobian of in-place functions in presence of undefined references

Open lcontento opened this issue 6 years ago • 0 comments

The method

ForwardDiff.jacobian(f!, y::AbstractArray, x::AbstractArray)

throws UndefRefError when y contains undefined references. For example,

using ForwardDiff
f!(y, x) = copy!(y, x)
x0 = BigFloat[1.0, 1.0]
ForwardDiff.jacobian(f!, similar(x0), x0)

In particular, this affects the NLsolve package, e.g.,

using NLsolve
nlsolve(f!, x0, autodiff=:forward)

Since I think the reasonable expectation is that only the type and shape of the y array are going to be used in ForwardDiff.jacobian, I am reporting this here. If you do not think that the undefined case should be taken in account, I will post an issue for NLsolve instead.

lcontento avatar Jan 17 '20 07:01 lcontento