JuliaDiff / DiffResults.jl

A package which provides an API for querying differentiation results at multiple orders simultaneously
http://juliadiff.org/DiffResults.jl/
Other
35 stars 11 forks source link

Document why re-aliasing is important #17

Open lassepe opened 4 years ago

lassepe commented 4 years ago

The documentation points out, that it really important to re-alias the result, e.g. in

result = ForwardDiff.hessian!(result, f, x);

It says that more information for why this is done can be found in the documentation of ForwardDiff.hessian!. Unfortunately, the according documentation does not talk about DiffResults at all so I remain curious why re-aliasing is necessary here. Is re-aliasing no longer needed?

gdalle commented 7 months ago

Aliasing is still important, due to the updating code looking like this everywhere:

https://github.com/JuliaDiff/DiffResults.jl/blob/724a23d326353353aa78ae9b9e770685119492dc/src/DiffResults.jl#L147-L158

Basically, whenever you call res2 = do_stuff!(res1, args...), you're unsure that res1 is correct: all you know is that res2 is.