Skip to main content

Cyclo

Struct Cyclo 

Source
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

Source

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.

Source

pub fn from_ints(n: usize, v: &[i64]) -> Cyclo

Convenience constructor from small integers.

Source

pub fn zero(n: usize) -> Cyclo

Source

pub fn one(n: usize) -> Cyclo

Source

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}.

Source

pub fn add(&self, o: &Cyclo) -> Cyclo

Source

pub fn sub(&self, o: &Cyclo) -> Cyclo

Source

pub fn neg(&self) -> Cyclo

Source

pub fn mul(&self, o: &Cyclo) -> Cyclo

Negacyclic product: multiply as polynomials, then reduce Xⁿ ≡ −1.

Source

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.

Source

pub fn conjugate(&self) -> Cyclo

Complex conjugation σ_{−1} : X ↦ X^{−1} = X^{2n−1} — the order-two element of the Galois group.

Source

pub fn norm(&self) -> BigInt

The field norm N(a) = ∏_{σ ∈ Gal} σ(a) ∈ ℤ — multiplicative, and ±1 exactly on the units.

Source

pub fn trace(&self) -> BigInt

The field trace Tr(a) = Σ_{σ ∈ Gal} σ(a) ∈ ℤ — additive; Tr(1) = n.

Source

pub fn is_unit(&self) -> bool

Whether a is a unit of R — equivalently N(a) = ±1.

Source

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.

Source

pub fn coeff_norm(&self) -> i64

The sum of absolute values of the coefficients — a coarse length used to recognize a short generator.

Trait Implementations§

Source§

impl Clone for Cyclo

Source§

fn clone(&self) -> Cyclo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Cyclo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Cyclo

Source§

fn eq(&self, other: &Cyclo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Cyclo

Source§

impl StructuralPartialEq for Cyclo

Auto Trait Implementations§

§

impl Freeze for Cyclo

§

impl RefUnwindSafe for Cyclo

§

impl Send for Cyclo

§

impl Sync for Cyclo

§

impl Unpin for Cyclo

§

impl UnsafeUnpin for Cyclo

§

impl UnwindSafe for Cyclo

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.