pub struct MultiPoly {
pub vars: Vec<ExprId>,
pub terms: BTreeMap<Vec<u32>, Integer>,
}Expand description
Sparse multivariate polynomial over ℤ.
vars fixes the variable ordering; the exponent key [e0, e1, …] means
vars[0]^e0 * vars[1]^e1 * …. Trailing zeros in the exponent vector are
always stripped so structural equality reduces to map equality.
Fields§
§vars: Vec<ExprId>§terms: BTreeMap<Vec<u32>, Integer>Implementations§
Source§impl MultiPoly
impl MultiPoly
Sourcepub fn factor_z(&self) -> Result<MultiPolyFactorization, FactorError>
pub fn factor_z(&self) -> Result<MultiPolyFactorization, FactorError>
Factor over ℤ[𝑥₁,…] using FLINT fmpz_mpoly_factor.
Source§impl MultiPoly
impl MultiPoly
pub fn zero(vars: Vec<ExprId>) -> Self
pub fn constant(vars: Vec<ExprId>, c: i64) -> Self
pub fn from_symbolic( expr: ExprId, vars: Vec<ExprId>, pool: &ExprPool, ) -> Result<Self, ConversionError>
pub fn is_zero(&self) -> bool
pub fn total_degree(&self) -> u32
Sourcepub fn integer_content(&self) -> Integer
pub fn integer_content(&self) -> Integer
GCD of all integer coefficients (content). Returns 0 for the zero polynomial.
Sourcepub fn primitive_part(&self) -> Self
pub fn primitive_part(&self) -> Self
Primitive part: divide all coefficients by the integer content.
Sourcepub fn compatible_with(&self, other: &Self) -> bool
pub fn compatible_with(&self, other: &Self) -> bool
Returns true if both polynomials have the same variable list and can be combined.
Sourcepub fn gcd(&self, other: &Self) -> Option<Self>
pub fn gcd(&self, other: &Self) -> Option<Self>
Compute the GCD of two compatible multivariate polynomials using FLINT.
Returns None if the polynomials have different variable lists, if either
is zero, or if FLINT’s GCD algorithm fails (which is exceedingly rare).
The returned GCD is normalised so that its leading coefficient is positive.
Sourcepub fn to_expr(&self, pool: &ExprPool) -> ExprId
pub fn to_expr(&self, pool: &ExprPool) -> ExprId
Convert back to a symbolic expression in the given pool.
Produces a canonical sum-of-products: each term is coeff * var[0]^e0 * var[1]^e1 * ….
The zero polynomial maps to Integer(0).
Sourcepub fn div_integer(&self, d: &Integer) -> Self
pub fn div_integer(&self, d: &Integer) -> Self
Divide all coefficients by d (exact division — caller ensures divisibility).
Trait Implementations§
impl Eq for MultiPoly
impl StructuralPartialEq for MultiPoly
Auto Trait Implementations§
impl Freeze for MultiPoly
impl RefUnwindSafe for MultiPoly
impl Send for MultiPoly
impl Sync for MultiPoly
impl Unpin for MultiPoly
impl UnsafeUnpin for MultiPoly
impl UnwindSafe for MultiPoly
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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more