Skip to main content
Every function here takes SF scalars, SF arrays, or host numbers where a literal is allowed, and returns the wider operand type. Host numbers are quantized like literals (through the policy); comparisons inside where masks are whatever you computed them with.

sf.fma(a, b, c)

a * b + c: the product truncated toward zero once, then one saturating add. Identical bits to writing a * b + c. Events: overflow on the add; underflow on the product.

sf.div(a, b, where=None)

a / b, truncated toward zero.
bool array | None
default:"None"
Arrays only. Divide where the mask is true; other elements are 0 and raise nothing.
Events: overflow when |a| >= |b|; divide when b == 0 (unless masked out).

sf.sqrt(a)

isqrt(k × 2^(N-1)), truncated toward zero. Events: invalid for a negative input (device value 0).

sf.maximum(a, b) and sf.minimum(a, b)

Elementwise selection on codes. Exact, no events. Run on the host even for device arrays.

sf.clip(x, lo, hi)

Clamp to [lo, hi]. lo and hi are quantized like literals (so a bound of 1 raises); the clamp itself is exact.

sf.where(cond, x, y)

x where cond is true, else y, elementwise. At least one branch must be an SF value; the other may be a literal. Exact, no events beyond quantizing a literal branch.

Placement

fma, div and sqrt are heavy when an operand is on a device (they run there and return a status). maximum, minimum, clip and where are selection: they run on the host and carry no status.