pub struct Poly { /* private fields */ }Expand description
A multivariable polynomial with integer coefficients in canonical form, $\mathbb{Z}[x_1,x_2 \dots x_i]$.
For example, $4x^2y^5 - 7xz + 3y + 1$.
use sirius::solver::poly::poly;
assert_eq!(poly!(a^2 - b^2).try_divide(&poly!(a - b)), Some(poly!(a + b)));
assert_eq!(poly!(2*x + 5).substitute('x', &poly!(z^2 + 1)), poly!(2*z^2 + 7));Implementations§
Source§impl Poly
impl Poly
pub fn add(&self, rhs: &Self) -> Self
pub fn mul(&self, rhs: &Self) -> Self
pub fn mul_scalar<T: Into<Coef>>(&self, c: T) -> Self
pub fn pow(&self, e: u32) -> Self
pub fn neg(&self) -> Self
pub fn sub(&self, rhs: &Self) -> Self
Sourcepub fn compound_divide(&self, divisors: &[Self]) -> (Vec<Self>, Self)
pub fn compound_divide(&self, divisors: &[Self]) -> (Vec<Self>, Self)
pub fn try_divide(&self, divisor: &Self) -> Option<Self>
Source§impl Poly
impl Poly
pub fn zero() -> Self
pub fn is_zero(&self) -> bool
pub fn constant<T: Into<Coef>>(c: T) -> Self
pub fn var<T: Into<Var>>(v: T, p: Pow) -> Self
pub fn term<T: Into<Coef>>(c: T, m: Mono) -> Self
pub fn terms(&self) -> Vec<(Coef, Mono)>
pub fn from_terms(terms: impl IntoIterator<Item = (Coef, Mono)>) -> Self
pub fn total_degree(&self) -> Pow
pub fn degree_in<T: Into<Var>>(&self, v: T) -> Pow
pub fn leading_term(&self) -> (Coef, Mono)
pub fn eval(&self, point: impl FnMut(Var) -> i128) -> Coef
pub fn map_vars(&self, f: impl FnMut(Var) -> Self) -> Self
pub fn substitute<T: Into<Var>>(&self, v: T, q: &Self) -> Self
pub fn coef_gcd(&self) -> Coef
pub fn coef_lcm(&self) -> Coef
pub fn divide_coefs<T: Into<Coef>>(&self, d: T) -> Option<Self>
pub fn as_constant(&self) -> Option<Coef>
pub fn vars(&self) -> Vec<Var> ⓘ
pub fn always_nonneg(&self, nonneg: &dyn Fn(Var) -> bool) -> bool
pub fn assert_canonical(&self)
Trait Implementations§
impl Eq for Poly
impl StructuralPartialEq for Poly
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