Skip to main content

Module build

Module build 

Source
Expand description

Smart constructors for building derivative expressions — useful when writing a custom Rule, which returns f'(u) as an sqlparser::ast::Expr.

Functions§

add
a + b, dropping a structurally-zero operand.
cast_double
Wrap e in a CAST(... AS DOUBLE). Self-delimiting, so it never needs precedence parentheses as an operand.
div
a / b, folding 0 / _ = 0 and a / 1 = a.
finite_num
A numeric literal for a value that might not be finite — the checked counterpart of num. Emits the literal if v is finite, else a typed DiffError::NotImplemented: a non-finite value has no valid SQL literal (inf/NaN are not numbers), so a derivative that would carry one must fail loud, never emit invalid SQL (#33). Use this for every value derived from user input or an arithmetic that can overflow (e.g. ln(base), an out-of-range exponent). This is the single seam through which computed constants become literals.
func
Build an unqualified scalar function call name(args...).
func1
f(x) — a unary call, the common case for chain-rule outer derivatives.
mul
a * b, folding 0 * _ = 0 and 1 * b = b (and the mirror cases).
neg
-a, folding -0 = 0 and -(-e) = e, and parenthesizing a binary operand (-(a + b), -(a / b)), since unary minus binds tighter than either.
one
The constant 1.0 — the derivative of wrt itself.
sign
The mathematical sign of u, as a CASE that behaves identically on every engine:
square
e * e.
sub
a - b, dropping a zero right operand and turning 0 - b into -b.
zero
The constant 0.0 — the derivative of anything independent of wrt.