pub struct Cyclo {
pub n: usize,
pub coeffs: Vec<BigInt>,
}Expand description
An element of R = ℤ[X]/(Xⁿ + 1): the coefficient vector [a₀, …, a_{n−1}] of Σ aᵢ Xⁱ, with n a
power of two.
Fields§
§n: usize§coeffs: Vec<BigInt>Implementations§
Source§impl Cyclo
impl Cyclo
Sourcepub fn new(n: usize, coeffs: Vec<BigInt>) -> Cyclo
pub fn new(n: usize, coeffs: Vec<BigInt>) -> Cyclo
An element from a coefficient vector (padded/verified to length n). n must be a power of two.
pub fn zero(n: usize) -> Cyclo
pub fn one(n: usize) -> Cyclo
Sourcepub fn monomial(n: usize, i: usize, coeff: BigInt) -> Cyclo
pub fn monomial(n: usize, i: usize, coeff: BigInt) -> Cyclo
coeff · Xⁱ reduced into R (any i ≥ 0): Xⁱ = (−1)^{⌊i/n⌋} · X^{i mod n}.
pub fn add(&self, o: &Cyclo) -> Cyclo
pub fn sub(&self, o: &Cyclo) -> Cyclo
pub fn neg(&self) -> Cyclo
Sourcepub fn mul(&self, o: &Cyclo) -> Cyclo
pub fn mul(&self, o: &Cyclo) -> Cyclo
Negacyclic product: multiply as polynomials, then reduce Xⁿ ≡ −1.
Sourcepub fn galois(&self, t: u64) -> Cyclo
pub fn galois(&self, t: u64) -> Cyclo
The Galois automorphism σ_t : X ↦ X^t (t odd, i.e. a unit of ℤ/2n). On monomials
σ_t(Xⁱ) = X^{it}, reduced by Xⁿ ≡ −1. A ring automorphism of R.
Sourcepub fn conjugate(&self) -> Cyclo
pub fn conjugate(&self) -> Cyclo
Complex conjugation σ_{−1} : X ↦ X^{−1} = X^{2n−1} — the order-two element of the Galois group.
Sourcepub fn norm(&self) -> BigInt
pub fn norm(&self) -> BigInt
The field norm N(a) = ∏_{σ ∈ Gal} σ(a) ∈ ℤ — multiplicative, and ±1 exactly on the units.
Sourcepub fn trace(&self) -> BigInt
pub fn trace(&self) -> BigInt
The field trace Tr(a) = Σ_{σ ∈ Gal} σ(a) ∈ ℤ — additive; Tr(1) = n.
Sourcepub fn unit_inverse(&self) -> Option<Cyclo>
pub fn unit_inverse(&self) -> Option<Cyclo>
The exact ring inverse of a unit, with no field division: since N(u) = u·∏_{t≠1}σ_t(u) = ±1, we
have u⁻¹ = N(u)·∏_{t≠1}σ_t(u). None for a non-unit.
Sourcepub fn coeff_norm(&self) -> i64
pub fn coeff_norm(&self) -> i64
The sum of absolute values of the coefficients — a coarse length used to recognize a short generator.