Skip to main content

Poly

Struct Poly 

Source
pub struct Poly<F> {
    pub terms: Vec<Term<F>>,
    pub nvars: usize,
    pub order: Order,
}
Expand description

A sparse multivariate polynomial: nonzero terms in strictly descending order.

Fields§

§terms: Vec<Term<F>>§nvars: usize§order: Order

Implementations§

Source§

impl<F: Field> Poly<F>

Source

pub fn exact(&self, divisor: &Self) -> Option<Self>

Exact quotient, preserving this polynomial’s monomial order. None for a zero divisor, incompatible variable counts or a remainder.

Source

pub fn exact_with_budget(&self, divisor: &Self, budget: usize) -> Option<Self>

Exact quotient with a limit on term reductions. None also signals exhausted work; use Self::exact when no work limit is wanted.

Source§

impl<F: Field> Poly<F>

Source

pub fn degrees(&self) -> Vec<u32>

Degrees in every variable in a single pass through the support.

Source

pub fn eval_cached(&self, table: &PowerTable<F>) -> F

Evaluate using powers shared with other polynomials at the same point.

Source

pub fn eval_except_cached(&self, k: usize, table: &PowerTable<F>) -> Uni<F>

Leave x_k free while using cached powers in the other variables. The cache need not contain powers above zero for variable k.

Source

pub fn univariate_images(&self, point: &[F]) -> Vec<Uni<F>>

All leave-one-variable-free images in O(n T + sum(degrees)) operations. Prefix/suffix products also work when evaluation coordinates are zero.

Source§

impl<F: Field> Poly<F>

Source

pub fn new(terms: Vec<Term<F>>, nvars: usize, order: Order) -> Self

Sorts, combines like terms and drops zeros.

Source

pub const fn zero(nvars: usize, order: Order) -> Self

Source

pub fn constant(c: F, nvars: usize, order: Order) -> Self

Source

pub fn var(i: usize, nvars: usize, order: Order) -> Self

Source

pub fn monomial(m: Monomial, order: Order) -> Self

The monomial m with coefficient one.

Source

pub const fn is_zero(&self) -> bool

Source

pub fn is_constant(&self) -> bool

Source

pub fn lt(&self) -> Option<&Term<F>>

Source

pub fn lm(&self) -> Option<&Monomial>

Source

pub fn lc(&self) -> Option<&F>

Source

pub fn total_degree(&self) -> u32

Source

pub fn degree(&self, k: usize) -> u32

Source

pub fn reorder(&self, order: Order) -> Self

Source

pub fn map<G: Field>(&self, f: impl Fn(&F) -> G) -> Poly<G>

Source

pub fn try_map<G: Field>(&self, f: impl Fn(&F) -> Option<G>) -> Option<Poly<G>>

Poly::map by a partial map, such as reduction modulo a prime that may divide a denominator.

Source

pub fn support(&self) -> Vec<Monomial>

Source

pub fn min_exps(&self) -> Monomial

The largest monomial dividing every term, 1 for zero.

Source

pub fn permute(&self, perm: &[usize]) -> Self

Variable i of the result is variable perm[i] of self.

Source

pub fn scale(&self, c: &F) -> Self

Source

pub fn mul_term(&self, c: &F, m: &Monomial) -> Self

Source

pub fn monic(&self) -> Self

Source

pub fn sub_mul(&self, c: &F, m: &Monomial, g: &Self) -> Self

self - c * m * g in one merge, shifting g as it goes.

Source

pub fn pow(&self, e: u32) -> Self

Source

pub fn derivative(&self, k: usize) -> Self

The partial derivative in x_k.

Source

pub fn eval(&self, x: &[F]) -> F

Source

pub fn eval_except(&self, k: usize, x: &[F]) -> Uni<F>

Substitutes x[i] for every x_i with i != k, leaving a polynomial in x_k.

Source

pub fn on_line(&self, z: &[F], s: &[F]) -> Uni<F>

The restriction to the line x_i = z_i * t + s_i, as a polynomial in t.

Source

pub fn coeffs_in(&self, k: usize) -> Vec<(Monomial, Uni<F>)>

The coefficients in x_k: for each monomial in the other variables, descending, the polynomial in x_k multiplying it.

Source

pub fn from_coeffs_in( k: usize, nvars: usize, order: Order, groups: impl IntoIterator<Item = (Monomial, Uni<F>)>, ) -> Self

The inverse of Poly::coeffs_in.

Source

pub fn content_in(&self, k: usize) -> Uni<F>

The content in F[x_k]: the monic gcd of the coefficients in Poly::coeffs_in.

Source

pub fn primitive_in(&self, k: usize) -> (Uni<F>, Self)

The content in F[x_k] and the primitive part.

Source

pub fn eval_var(&self, k: usize, a: &F) -> Self

Substitutes a for x_k.

Source

pub fn spoly(&self, o: &Self) -> Self

The S-polynomial, zero if either is.

Source

pub fn divide(&self, divs: &[Self]) -> (Vec<Self>, Self)

Division by an ordered list: self = sum q[i] * divs[i] + r, no term of r divisible by a leading monomial, each step reducing by the first divisor that applies.

Source

pub fn reduce(&self, divs: &[Self]) -> Self

The remainder of Poly::divide.

Source§

impl Poly<BigRational>

Source

pub fn content(&self) -> BigRational

Zero for the zero polynomial.

Source

pub fn primitive(&self) -> Self

Source§

impl Poly<BigRational>

Source

pub fn modp(&self, p: u64) -> Option<Poly<Fp>>

self modulo p, or None when p divides a denominator.

Source§

impl Poly<Fp>

Source

pub fn residues(&self) -> Poly<BigRational>

The residues as the integers 0..p.

Source

pub fn symmetric(&self) -> Poly<BigRational>

The residues as the integers in (-p/2, p/2].

Trait Implementations§

Source§

impl<F: Field> Add for &Poly<F>

Source§

type Output = Poly<F>

The resulting type after applying the + operator.
Source§

fn add(self, o: Self) -> Poly<F>

Performs the + operation. Read more
Source§

impl<F: Clone> Clone for Poly<F>

Source§

fn clone(&self) -> Self

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<F: Debug> Debug for Poly<F>

Source§

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

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

impl<F: Field + Display> Display for Poly<F>

With variables named x0, x1, ....

Source§

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

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

impl<F: Eq> Eq for Poly<F>

Source§

impl<F: Field> Mul for &Poly<F>

Source§

type Output = Poly<F>

The resulting type after applying the * operator.
Source§

fn mul(self, o: Self) -> Poly<F>

Performs the * operation. Read more
Source§

impl<F: Field> Neg for &Poly<F>

Source§

type Output = Poly<F>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Poly<F>

Performs the unary - operation. Read more
Source§

impl<F: PartialEq> PartialEq for Poly<F>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<F: PartialEq> StructuralPartialEq for Poly<F>

Source§

impl<F: Field> Sub for &Poly<F>

Source§

type Output = Poly<F>

The resulting type after applying the - operator.
Source§

fn sub(self, o: Self) -> Poly<F>

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<F> Freeze for Poly<F>
where Vec<(Monomial, F)>: Freeze,

§

impl<F> RefUnwindSafe for Poly<F>
where Vec<(Monomial, F)>: RefUnwindSafe,

§

impl<F> Send for Poly<F>
where Vec<(Monomial, F)>: Send,

§

impl<F> Sync for Poly<F>
where Vec<(Monomial, F)>: Sync,

§

impl<F> Unpin for Poly<F>
where Vec<(Monomial, F)>: Unpin,

§

impl<F> UnsafeUnpin for Poly<F>
where Vec<(Monomial, F)>: UnsafeUnpin,

§

impl<F> UnwindSafe for Poly<F>
where Vec<(Monomial, F)>: UnwindSafe,

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.