Overflow-safe modular product of two raw words, reconstructing residues and
delegating to the (extern-backed) ZMod64.mul. Defined so that
mulWord p x.val y.val = (x * y).val.
Equations
- Hex.ZMod64.mulWord p a b = ((Hex.ZMod64.ofNat p a.toNat).mul (Hex.ZMod64.ofNat p b.toNat)).val
Instances For
Overflow-safe modular difference of two raw words, reconstructing residues
and delegating to ZMod64.sub. Defined so that
subWord p x.val y.val = (x - y).val.
Equations
- Hex.ZMod64.subWord p a b = ((Hex.ZMod64.ofNat p a.toNat).sub (Hex.ZMod64.ofNat p b.toNat)).val
Instances For
Pack a residue coefficient array into its backing words.
Equations
- Hex.FpPoly.toWords a = Array.map (fun (x : Hex.ZMod64 p) => x.val) a
Instances For
Reconstruct a residue coefficient array from raw words.
Equations
- Hex.FpPoly.ofWords p a = Array.map (fun (w : UInt64) => Hex.ZMod64.ofNat p w.toNat) a
Instances For
Packing a zero-filled array gives a zero-word-filled array.
Reconstructing the words of a residue array recovers the original array.
Packed downward degree scan: the highest index below fuel with a nonzero
word, mirroring DensePoly.arrayDegreeAux.
Equations
- Hex.FpPoly.arrayDegreeAuxPacked coeffs 0 = none
- Hex.FpPoly.arrayDegreeAuxPacked coeffs fuel.succ = if coeffs.getD fuel 0 = 0 then Hex.FpPoly.arrayDegreeAuxPacked coeffs fuel else some fuel
Instances For
Packed degree: the highest index of a nonzero word, mirroring
DensePoly.arrayDegree?.
Equations
- Hex.FpPoly.arrayDegreePacked? coeffs = Hex.FpPoly.arrayDegreeAuxPacked coeffs coeffs.size
Instances For
One packed elimination coefficient write, mirroring
DensePoly.subtractScaledShiftStep with overflow-safe word arithmetic.
Equations
- Hex.FpPoly.subtractScaledShiftStepPacked p q shift coeff next j = next.set! (shift + j) (Hex.ZMod64.subWord p (next.getD (shift + j) 0) (Hex.ZMod64.mulWord p coeff (q.getD j 0)))
Instances For
One full packed elimination step rem - coeff * xˢʰⁱᶠᵗ * q, mirroring
DensePoly.subtractScaledShift.
Equations
- Hex.FpPoly.subtractScaledShiftPacked p rem q shift coeff = List.foldl (Hex.FpPoly.subtractScaledShiftStepPacked p q shift coeff) rem (List.range q.size)
Instances For
The packed fuel-bounded long-division loop, mirroring
DensePoly.divModArrayAux.
Equations
- One or more equations did not get rendered due to their size.
- Hex.FpPoly.divModArrayAuxPacked p q qDegree scaleLead 0 quot rem = (quot, rem)
Instances For
Packed monic division remainder, sharing the signature of FpPoly.modByMonic
(so a @[csimp] swap would be well-typed, though it is intentionally not
registered; see the module docstring). Packs both operand arrays, runs the
packed loop with scaleLead = id (the divisor is monic), and reconstructs the
remainder.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Packed degree scan agrees with the reference scan on packed input.
Packed degree agrees with the reference degree on packed input.
One packed elimination coefficient write corresponds to the reference write.
Folding the packed step over any index list corresponds to folding the reference step.
A full packed elimination step corresponds to the reference step.
The packed long-division loop corresponds, coordinatewise, to the reference
loop with scaleLead = id.
Value correspondence. The packed monic-division remainder equals the
reference FpPoly.modByMonic for every modulus p (every Bounds p).