Index Mathematics Conjectures nbv lettuce Widgets

div_ceil!

Static element-wise integer division rounding up. Integer and field arithmetic

div_ceil! lhs, rhs

Divides lhs by rhs element-wise, rounding up, with each field element taken as its canonical integer in [0, p). Typically used to count the blocks needed to cover a length, e.g. div_ceil! out_len, rate.

Arguments

lhs
Static vector (or scalar) of dividends.
rhs
Static vector of divisors, the same length as lhs.

Returns

A static vector of quotients. Expression form only.

Constraints

None, both inputs must be static.

Example

(let x)
static blocks = div_ceil! 10, 4
x * blocks

Notes

Its error messages are labelled div_floor (nbv::Precompile::div_floor: inputs must be static, arguments are of mismatched dimension). A zero divisor is not checked and panics inside the compiler. See also div_floor! and div_exact!.

Used in the standard library

bdlop/bdlop_r1cs_verify, blake3/blake3_core, dilithium/lattice/lattice_permutation, keccak/keccak_sponge_shake, lattice/lattice_expand, milli/mldsa/mldsa_reduce, mldsa/mldsa_limbs, oraccle/oraccle_sample_ternary_vec, oraccle/oraccle_sample_uniform_vec, oraccle/oraccle_squeeze, slip/slip_mask_transcript, slip/slip_r1cs_arg_verify, typed/typed_bytes_lattice, typed/typed_lex_chacha