Fold every coefficient into its exponent class modulo n, using one
preallocated n-slot accumulator.
Equations
- Hex.DensePoly.cyclicCoeffs n p = List.foldl (Hex.DensePoly.addCyclicCoeff✝ n p) (Array.replicate n 0) (List.range p.size)
Instances For
Fold every coefficient modulo x^n + 1, alternating the sign after each
block of n exponents.
Equations
- Hex.DensePoly.negacyclicCoeffs n p = List.foldl (Hex.DensePoly.addNegacyclicCoeff✝ n p) (Array.replicate n 0) (List.range p.size)
Instances For
Sum coefficients of p whose exponents are congruent to k modulo n.
Equations
- Hex.DensePoly.cyclicCoeff n k p = (Hex.DensePoly.cyclicCoeffs n p).getD k 0
Instances For
Alternating sum of coefficients in one congruence class, implementing
reduction by x^n = -1.
Equations
- Hex.DensePoly.negacyclicCoeff n k p = (Hex.DensePoly.negacyclicCoeffs n p).getD k 0
Instances For
The cyclic coefficient array has exactly the requested length.
The negacyclic coefficient array has exactly the requested length.
Cyclic convolution of positive length n.
Equations
- Hex.DensePoly.mulCyclic plan n _hn a b = Hex.DensePoly.ofCoeffs (Hex.DensePoly.cyclicCoeffs n (Hex.DensePoly.mulWith plan a b))
Instances For
Negacyclic convolution of positive length n.
Equations
- Hex.DensePoly.mulNegacyclic plan n _hn a b = Hex.DensePoly.ofCoeffs (Hex.DensePoly.negacyclicCoeffs n (Hex.DensePoly.mulWith plan a b))
Instances For
Checked cyclic convolution; length zero has no quotient-ring meaning.
Equations
- Hex.DensePoly.mulCyclic? plan n a b = if hn : 0 < n then some (Hex.DensePoly.mulCyclic plan n hn a b) else none
Instances For
Checked negacyclic convolution; length zero has no quotient-ring meaning.
Equations
- Hex.DensePoly.mulNegacyclic? plan n a b = if hn : 0 < n then some (Hex.DensePoly.mulNegacyclic plan n hn a b) else none
Instances For
Cyclic products contain at most n stored coefficients.
Negacyclic products contain at most n stored coefficients.
Coefficient description of cyclic folding.
Coefficient description of negacyclic folding.
Cyclic folding sums monomials with degrees reduced modulo the length.
The signed residue of c * x^i modulo x^n + 1.
Equations
- Hex.DensePoly.negacyclicResidue n i c = if i / n % 2 = 0 then Hex.DensePoly.monomial (i % n) c else Hex.DensePoly.monomial (i % n) (0 - c)
Instances For
The signed monomial contributed by coefficient i when reducing modulo
x^n + 1.
Equations
- Hex.DensePoly.negacyclicTerm n p i = Hex.DensePoly.negacyclicResidue n i (p.coeff i)
Instances For
Negacyclic folding sums degree-reduced monomials with alternating signs.