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

Support derivatives of functions with units via Unitful extension

Open gerlero opened this issue 6 months ago • 7 comments

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.Quantitys 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.

gerlero avatar Dec 21 '23 00:12 gerlero