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

Document why re-aliasing is important

Open lassepe opened this issue 5 years ago • 1 comments

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?

lassepe avatar Mar 27 '20 20:03 lassepe

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.

gdalle avatar Mar 15 '24 15:03 gdalle