Modular Lagrange basis evaluation #
A Lagrange basis weight for the alphabet 0, …, s-1 is evaluated by a counter and a single
modular accumulator. Inverses use the existing Fermat power routine. This executable procedure
does not materialize a list of alphabet symbols or polynomial coefficients.
Main definitions #
Cslib.TreeEval.Ary.Packed.basisFactor: one factor, omitting the diagonal symbol.Cslib.TreeEval.Ary.Packed.basisStep: one counter step.Cslib.TreeEval.Ary.Packed.basisWeight: the complete basis weight.
Main results #
Cslib.TreeEval.Ary.Packed.cast_basisWeight: correctness over a prime field.Cslib.TreeEval.Ary.Packed.basisWeight_lt: the result remains a reduced residue.
References #
- R. Williams, Simulating Time With Square-Root Space, Appendix A, equation (6). The executable prime-field realization is an original implementation of the finite-grid Lagrange factors used by that extension.
One factor of a Lagrange basis weight, with the diagonal factor replaced by one.
unitInv p (v-1) inverts the nonzero residue v when p is prime.
Evaluate the basis weight by exactly s counter steps.
Every intermediate accumulator fits within the modulus plus one, including malformed zero-modulus inputs and the initial accumulator.
A positive modulus keeps the initial and every subsequent accumulator reduced.
The counter procedure evaluates the finite-grid Lagrange basis polynomial for any alphabet size
s: when another symbol in 0, …, s - 1 collides with a modulo p, both the basis polynomial
and the product of modular factors vanish.