Skip to main content

negate

Function negate 

Source
fn negate(context: &Context<'_>, operand: &Expr) -> Result<NativeNode>
Expand description

Compiles a negation as the multiplication it is: -x is -1 * x.

The tree has no negate node and needs none: broadcasting a constant over the expression’s value is the same arithmetic, and the multiplication kernel is the one that already computes it. A dedicated negate kernel would be an optimization of this node’s work rather than a different meaning, so binding the multiplication does not bind anything the query did not ask for.