Skip to main content

Module dual

Module dual 

Source
Expand description

Forward-mode automatic differentiation, for the residuals of the constraint solvers (sketches, assemblies).

Every residual is written once, generically over Number, and evaluated either with a plain Scalar value (the value only) or with Dual (the value plus its exact partial derivatives with respect to the constraint’s own variables). A constraint touches only a handful of variables, so a dual number carries a small fixed-size gradient rather than one entry per solver variable.

Building Dual over the interval Scalar rather than a bare f64 means a residual’s value is a rigorous enclosure of the true real number it stands for, not a float that silently absorbs whatever rounding sin, sqrt or PI introduced along the way — the sketch solver’s own uncertainty about an irrational quantity shows up as interval width instead of vanishing.

Structs§

Dual
A value together with its gradient with respect to up to N seeded variables — as many as the residual it is computed for depends on.