HI, i’m looking to implement an implace hessian of a vector-valued function, for example:
f(x) = [x,x,sin(x),sum(x)]
The ForwardDiff Documentation gives an out of place example (slightly wrong, as
size(f(x)) !=size(x) in the general case:
julia> function vector_hessian(f, x) n = length(x) out = ForwardDiff.jacobian(x -> ForwardDiff.jacobian(f, x), x) return reshape(out, n, n, n) end
the problem arrives when you use a inplace version of the same function:
function f!(res,x) res .= [x,x,sin(x),sum(x)] end
the problem with nested inplace jacobians is that the result of the intermediate jacobian is a dual, and its very difficult to create a cache storage.
Anybody has encountered something like that? how can i create an efficient cache for this type of function?