pub struct Poly {
pub coeffs: Vec<u64>,
}Expand description
A polynomial in Z_q[X]/(X^N + 1), stored as coefficient vector.
Fields§
§coeffs: Vec<u64>Coefficients in [0, q). Length must equal params.n.
Implementations§
Source§impl Poly
impl Poly
Sourcepub fn from_coeffs(coeffs: &[u64], n: usize) -> Self
pub fn from_coeffs(coeffs: &[u64], n: usize) -> Self
Create a polynomial from coefficients (clamped to n, zero-padded if short).
Sourcepub fn add(&self, other: &Poly, params: &Params) -> Poly
pub fn add(&self, other: &Poly, params: &Params) -> Poly
Polynomial addition: (a + b) mod q, coefficient-wise.
Sourcepub fn sub(&self, other: &Poly, params: &Params) -> Poly
pub fn sub(&self, other: &Poly, params: &Params) -> Poly
Polynomial subtraction: (a - b) mod q.
Sourcepub fn scalar_mul(&self, scalar: u64, params: &Params) -> Poly
pub fn scalar_mul(&self, scalar: u64, params: &Params) -> Poly
Scalar multiplication: (a * scalar) mod q.
Sourcepub fn mul_schoolbook(&self, other: &Poly, params: &Params) -> Poly
pub fn mul_schoolbook(&self, other: &Poly, params: &Params) -> Poly
Schoolbook polynomial multiplication in Z_q[X]/(X^N + 1). This is O(N^2) — used for correctness testing and small N.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Poly
impl RefUnwindSafe for Poly
impl Send for Poly
impl Sync for Poly
impl Unpin for Poly
impl UnsafeUnpin for Poly
impl UnwindSafe for Poly
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more