Skip to main content

Poly

Struct Poly 

Source
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

Source

pub fn add(&self, rhs: &Self) -> Self

Source

pub fn mul(&self, rhs: &Self) -> Self

Source

pub fn mul_scalar<T: Into<Coef>>(&self, c: T) -> Self

Source

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

Source

pub fn neg(&self) -> Self

Source

pub fn sub(&self, rhs: &Self) -> Self

Source

pub fn compound_divide(&self, divisors: &[Self]) -> (Vec<Self>, Self)

Source

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

Source§

impl Poly

Source

pub fn display_with(&self, var_names: Option<&[&str]>) -> String

Source§

impl Poly

Source

pub fn zero() -> Self

Source

pub fn is_zero(&self) -> bool

Source

pub fn constant<T: Into<Coef>>(c: T) -> Self

Source

pub fn var<T: Into<Var>>(v: T, p: Pow) -> Self

Source

pub fn term<T: Into<Coef>>(c: T, m: Mono) -> Self

Source

pub fn terms(&self) -> Vec<(Coef, Mono)>

Source

pub fn from_terms(terms: impl IntoIterator<Item = (Coef, Mono)>) -> Self

Source

pub fn total_degree(&self) -> Pow

Source

pub fn degree_in<T: Into<Var>>(&self, v: T) -> Pow

Source

pub fn leading_term(&self) -> (Coef, Mono)

Source

pub fn eval(&self, point: impl FnMut(Var) -> i128) -> Coef

Source

pub fn map_vars(&self, f: impl FnMut(Var) -> Self) -> Self

Source

pub fn substitute<T: Into<Var>>(&self, v: T, q: &Self) -> Self

Source

pub fn coef_gcd(&self) -> Coef

Source

pub fn coef_lcm(&self) -> Coef

Source

pub fn divide_coefs<T: Into<Coef>>(&self, d: T) -> Option<Self>

Source

pub fn as_constant(&self) -> Option<Coef>

Source

pub fn vars(&self) -> Vec<Var>

Source

pub fn always_nonneg(&self, nonneg: &dyn Fn(Var) -> bool) -> bool

Source

pub fn assert_canonical(&self)

Trait Implementations§

Source§

impl Clone for Poly

Source§

fn clone(&self) -> Poly

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

Source§

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

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

impl Eq for Poly

Source§

impl Hash for Poly

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Poly

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more