Add coefficient lists, treating a missing tail as zero.
Equations
- Hex.ZMod64.Ntt.addCoeffs [] x✝ = x✝
- Hex.ZMod64.Ntt.addCoeffs x✝ [] = x✝
- Hex.ZMod64.Ntt.addCoeffs (x_2 :: xs) (y :: ys) = (x_2 + y) :: Hex.ZMod64.Ntt.addCoeffs xs ys
Instances For
Ordinary low-to-high schoolbook coefficient convolution.
Equations
Instances For
A list of zero coefficients evaluates to zero.
A fixed-length coefficient vector containing one nonzero monomial.
Equations
- Hex.ZMod64.Ntt.monomial n degree coefficient = if _hn : n = 0 then [] else List.replicate (degree % n) 0 ++ coefficient :: List.replicate (n - (degree % n + 1)) 0
Instances For
Fold coefficients into a fixed cyclic vector, starting at a supplied absolute degree.
Equations
- Hex.ZMod64.Ntt.foldCyclicFrom n x✝ [] = List.replicate n 0
- Hex.ZMod64.Ntt.foldCyclicFrom n x✝ (coefficient :: coefficients) = Hex.ZMod64.Ntt.addCoeffs (Hex.ZMod64.Ntt.monomial n x✝ coefficient) (Hex.ZMod64.Ntt.foldCyclicFrom n (x✝ + 1) coefficients)
Instances For
At an nth root of unity, cyclic folding preserves evaluation, including
the absolute-degree shift used by the recursive worker.
Fold an ordinary coefficient list modulo x^n - 1.
Equations
- Hex.ZMod64.Ntt.foldCyclic n coefficients = Hex.ZMod64.Ntt.foldCyclicFrom n 0 coefficients
Instances For
Independent coefficient-level cyclic convolution reference.
Equations
- Hex.ZMod64.Ntt.cyclicConvolution n left right = Hex.ZMod64.Ntt.foldCyclic n (Hex.ZMod64.Ntt.linearConvolution left right)
Instances For
Every DFT coefficient of a cyclic convolution is the pointwise product of the corresponding input coefficients.
Pointwise multiplication of equal-order transform values.
Equations
- Hex.ZMod64.Ntt.pointwiseMul left right = List.zipWith (fun (x1 x2 : Hex.ZMod64 p) => x1 * x2) left right
Instances For
The DFT of cyclic convolution is pointwise multiplication.
Array wrapper for pointwise multiplication.
Equations
- Hex.ZMod64.Ntt.pointwiseMulArray left right = (Hex.ZMod64.Ntt.pointwiseMul left.toList right.toList).toArray
Instances For
Pointwise multiplication of the two executable forward results is the forward result of the independent cyclic-convolution reference.
Checked cyclic NTT convolution. Length mismatch is normal failure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Append enough zero coefficients to reach a requested capacity. Callers use it only when the input already fits.
Equations
- Hex.ZMod64.Ntt.padTo n coefficients = coefficients ++ List.replicate (n - coefficients.length) 0
Instances For
The exact-order DFT is injective on arrays of its plan length.
When no coefficient reaches degree n, cyclic folding is just zero
padding.
A plan whose length covers the ordinary product turns cyclic convolution into the zero-padded schoolbook result.
Padding either cyclic-convolution input with zeros does not alter the fixed-length cyclic result.
Checked ordinary convolution. The plan length must be the least power of two covering the product, and each input must fit that padded length.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Padding to nextPowerOfTwo (left.size + right.size - 1) and running the
NTT returns the zero-padded ordinary schoolbook convolution.
A successful checked ordinary convolution has the independent
coefficient-level reference value. This packages the length checks performed
inside ordinary?, so coefficient-owner adapters need no duplicate unchecked
hypotheses.
Fold coefficients into a fixed negacyclic vector, starting at a supplied
absolute degree. The quotient by n records the alternating sign.
Equations
- One or more equations did not get rendered due to their size.
- Hex.ZMod64.Ntt.foldNegacyclicFrom n x✝ [] = List.replicate n 0
Instances For
At a root of x^n = -1, negacyclic folding preserves evaluation,
including the absolute-degree shift used by the recursive worker.
Fold an ordinary coefficient list modulo x^n + 1.
Equations
- Hex.ZMod64.Ntt.foldNegacyclic n coefficients = Hex.ZMod64.Ntt.foldNegacyclicFrom n 0 coefficients
Instances For
Independent coefficient-level negacyclic convolution reference.
Equations
- Hex.ZMod64.Ntt.negacyclicConvolution n left right = Hex.ZMod64.Ntt.foldNegacyclic n (Hex.ZMod64.Ntt.linearConvolution left right)
Instances For
Negacyclic convolution evaluates to the pointwise product at every root
of x^n = -1.
A primitive root of exact order 2n has nth power -1.
Data required by the standard twist adapter from negacyclic convolution
of length n to an ordinary cyclic NTT of length n.
- transform : NttPlan p n
The reusable length-
ntransform. - twist : ZMod64 p
A primitive
2nth root used to twist coefficients. - twist_order : self.twist.ExactOrder (2 * n)
The twist has exact order
2n. Squaring the twist gives the transform root.
Instances For
A negacyclic plan's transform length is positive.
The primitive twist satisfies the defining negacyclic equation.
The primitive twist is nonzero.
Multiply coefficient i by root^(degree + i).
Equations
- Hex.ZMod64.Ntt.scalePowersFrom root x✝ [] = []
- Hex.ZMod64.Ntt.scalePowersFrom root x✝ (coefficient :: coefficients) = root ^ x✝ * coefficient :: Hex.ZMod64.Ntt.scalePowersFrom root (x✝ + 1) coefficients
Instances For
Evaluation after power scaling is evaluation at the correspondingly scaled point, with the worker's absolute-degree factor.
Multiply coefficient i by root^i.
Equations
- Hex.ZMod64.Ntt.scalePowers root coefficients = Hex.ZMod64.Ntt.scalePowersFrom root 0 coefficients
Instances For
Scaling by inverse powers cancels scaling by forward powers.
Inverse coefficient twisting cancels forward twisting.
Twisting a transform point selects the corresponding odd power of the
primitive 2nth root.
Every twisted transform point is a root of x^n = -1.
At each transform frequency, cyclic convolution of twisted inputs agrees with twisting the independent negacyclic reference.
The DFT of cyclic convolution on twisted inputs is the DFT of the twisted negacyclic reference.
Zero padding before coefficient twisting does not change the transformed values.
Cyclic convolution of twisted inputs is exactly the twisted negacyclic coefficient reference.
Padding either negacyclic-convolution input with zeros does not alter the fixed-length result.
Checked negacyclic NTT convolution via coefficient twisting. Length mismatch is normal failure.
Equations
- One or more equations did not get rendered due to their size.
Instances For
A primitive 2nth twist makes the checked adapter return exactly
schoolbook convolution folded modulo x^n + 1.