fhelium.backend.triton._arithmetic
Integer modular arithmetic shared by generated Triton kernels.
montgomery_mul
function View source
python
def montgomery_mul(a, b, q, k, radix_bits: tl.constexpr): ...1
Return native-compatible REDC: canonical for R32, lazy for R62.
montgomery_reduce
function View source
python
def montgomery_reduce(a, q, k, radix_bits: tl.constexpr): ...1
add_lazy
function View source
python
def add_lazy(a, b, q): ...1
subtract_lazy
function View source
python
def subtract_lazy(a, b, q): ...1
canonicalize
function View source
python
def canonicalize(a, q): ...1
shoup32_mul
function View source
python
def shoup32_mul(value, root, quotient, q): ...1
Return value*root modulo q in [0,2q) for value<2q and q<2^30.
quotient carries floor(root*2^32/q) as an unsigned word. The low-word difference equals the nonnegative remainder because its value is below 2q. A standard root preserves the input's Montgomery representation.