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: OrderImplementations§
Source§impl<F: Field> Poly<F>
impl<F: Field> Poly<F>
Sourcepub fn exact(&self, divisor: &Self) -> Option<Self>
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.
Sourcepub fn exact_with_budget(&self, divisor: &Self, budget: usize) -> Option<Self>
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>
impl<F: Field> Poly<F>
Sourcepub fn degrees(&self) -> Vec<u32>
pub fn degrees(&self) -> Vec<u32>
Degrees in every variable in a single pass through the support.
Sourcepub fn eval_cached(&self, table: &PowerTable<F>) -> F
pub fn eval_cached(&self, table: &PowerTable<F>) -> F
Evaluate using powers shared with other polynomials at the same point.
Sourcepub fn eval_except_cached(&self, k: usize, table: &PowerTable<F>) -> Uni<F>
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.
Sourcepub fn univariate_images(&self, point: &[F]) -> Vec<Uni<F>>
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>
impl<F: Field> Poly<F>
Sourcepub fn new(terms: Vec<Term<F>>, nvars: usize, order: Order) -> Self
pub fn new(terms: Vec<Term<F>>, nvars: usize, order: Order) -> Self
Sorts, combines like terms and drops zeros.
pub const fn zero(nvars: usize, order: Order) -> Self
pub fn constant(c: F, nvars: usize, order: Order) -> Self
pub fn var(i: usize, nvars: usize, order: Order) -> Self
pub const fn is_zero(&self) -> bool
pub fn is_constant(&self) -> bool
pub fn lt(&self) -> Option<&Term<F>>
pub fn lm(&self) -> Option<&Monomial>
pub fn lc(&self) -> Option<&F>
pub fn total_degree(&self) -> u32
pub fn degree(&self, k: usize) -> u32
pub fn reorder(&self, order: Order) -> Self
pub fn map<G: Field>(&self, f: impl Fn(&F) -> G) -> Poly<G>
Sourcepub fn try_map<G: Field>(&self, f: impl Fn(&F) -> Option<G>) -> Option<Poly<G>>
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.
pub fn support(&self) -> Vec<Monomial>
Sourcepub fn permute(&self, perm: &[usize]) -> Self
pub fn permute(&self, perm: &[usize]) -> Self
Variable i of the result is variable perm[i] of self.
pub fn scale(&self, c: &F) -> Self
pub fn mul_term(&self, c: &F, m: &Monomial) -> Self
pub fn monic(&self) -> Self
Sourcepub fn sub_mul(&self, c: &F, m: &Monomial, g: &Self) -> Self
pub fn sub_mul(&self, c: &F, m: &Monomial, g: &Self) -> Self
self - c * m * g in one merge, shifting g as it goes.
pub fn pow(&self, e: u32) -> Self
Sourcepub fn derivative(&self, k: usize) -> Self
pub fn derivative(&self, k: usize) -> Self
The partial derivative in x_k.
pub fn eval(&self, x: &[F]) -> F
Sourcepub fn eval_except(&self, k: usize, x: &[F]) -> Uni<F>
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.
Sourcepub fn on_line(&self, z: &[F], s: &[F]) -> Uni<F>
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.
Sourcepub fn coeffs_in(&self, k: usize) -> Vec<(Monomial, Uni<F>)>
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.
Sourcepub fn from_coeffs_in(
k: usize,
nvars: usize,
order: Order,
groups: impl IntoIterator<Item = (Monomial, Uni<F>)>,
) -> Self
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.
Sourcepub fn content_in(&self, k: usize) -> Uni<F>
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.
Sourcepub fn primitive_in(&self, k: usize) -> (Uni<F>, Self)
pub fn primitive_in(&self, k: usize) -> (Uni<F>, Self)
The content in F[x_k] and the primitive part.
Sourcepub fn divide(&self, divs: &[Self]) -> (Vec<Self>, Self)
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.
Sourcepub fn reduce(&self, divs: &[Self]) -> Self
pub fn reduce(&self, divs: &[Self]) -> Self
The remainder of Poly::divide.
Source§impl Poly<BigRational>
impl Poly<BigRational>
Sourcepub fn content(&self) -> BigRational
pub fn content(&self) -> BigRational
Zero for the zero polynomial.