ForwardDiff.jl
ForwardDiff.jl copied to clipboard
Support derivatives of functions with units via Unitful extension
Adds support for taking derivatives of functions with Unitful
units on their input and/or output by means of an extension (weakdep). The extension works by ensuring that Dual
always wraps a Real
number—as ForwardDiff
expects—even when Unitful.Quantity
s are involved, stripping and adding back the units as appropriate.
Relevant issue is https://github.com/JuliaDiff/ForwardDiff.jl/issues/328.
With this PR only derivative
has support for units, yet the same behavior could be later applied to the other functions as well.