Skip to main content

Operators

The scalar operators work on arrays, element by element, with NumPy’s broadcasting rules.
Shapes that cannot broadcast raise SFShapeError before anything is computed.

Events are counted

An event in any element is one event for the operation, reported with a count, and handled by the policy in catalogue order:
Under a non-raising policy every element gets its hardware value:

Masked division

sf.div(a, b, where=mask) divides only where the mask is true. Other elements are 0 and raise nothing, which is the usual way to handle a divisor that may be zero:
where only guards the zeros. An element where |a| >= |b| still overflows and is still reported.

Functions

sf.fma, sf.sqrt, sf.maximum, sf.minimum, sf.clip, sf.where and sf.cast all accept arrays and broadcast.

Comparisons give NumPy booleans

Casting

Narrowing re-quantizes through the policy with counts; widening is exact.