Skip to main content

Polynomial

Struct Polynomial 

Source
pub struct Polynomial { /* private fields */ }
Expand description

A polynomial in variables numbered from 0, with rational coefficients. No coefficient is zero, so equal polynomials are structurally equal.

Implementations§

Source§

impl Polynomial

Source

pub fn zero() -> Polynomial

Source

pub fn one() -> Polynomial

Source

pub fn constant(c: Rational) -> Polynomial

Source

pub fn var(i: usize) -> Polynomial

Variable i.

Source

pub fn monomial(c: Rational, exponents: Vec<u32>) -> Polynomial

c · Π x_i^e_i.

Source

pub fn from_univariate(p: &Poly, v: usize) -> Polynomial

The univariate p in variable v.

Source

pub fn is_zero(&self) -> bool

Source

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

The value of a polynomial with no variable; None for any other.

Source

pub fn terms(&self) -> impl Iterator<Item = (&[u32], &Rational)>

The terms, exponents with no trailing zero, in increasing order of exponents.

Source

pub fn add(&self, o: &Polynomial) -> Polynomial

Source

pub fn neg(&self) -> Polynomial

Source

pub fn sub(&self, o: &Polynomial) -> Polynomial

Source

pub fn scale(&self, k: &Rational) -> Polynomial

Source

pub fn mul(&self, o: &Polynomial) -> Polynomial

Source

pub fn pow(&self, k: u32) -> Polynomial

Source

pub fn degree_in(&self, v: usize) -> u32

The degree in variable v; zero for the zero polynomial.

Source

pub fn variables(&self) -> BTreeSet<usize>

The variables that occur.

Source

pub fn coefficient_in(&self, v: usize, k: u32) -> Polynomial

The coefficient of x_v^k, a polynomial in the other variables.

Source

pub fn leading_in(&self, v: usize) -> Polynomial

The coefficient of the highest power of x_v.

Source

pub fn substitute(&self, v: usize, x: &Rational) -> Polynomial

x_v set to x.

Source

pub fn compose(&self, v: usize, p: &Polynomial) -> Polynomial

x_v replaced by the polynomial p.

Source

pub fn derivative(&self, v: usize) -> Polynomial

∂/∂x_v.

Source

pub fn to_univariate(&self, v: usize) -> Option<Poly>

The polynomial as one in x_v alone; None when another variable occurs.

Source

pub fn resultant(&self, o: &Polynomial, v: usize) -> Polynomial

The resultant in x_v: lc^{deg o} · Π o(α) over the roots α in x_v of self, a polynomial in the other variables, by the univariate resultant’s convention (Poly::resultant). Zero when either is zero; self^{deg o} when self does not hold x_v.

Trait Implementations§

Source§

impl Clone for Polynomial

Source§

fn clone(&self) -> Polynomial

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Polynomial

Source§

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

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

impl Default for Polynomial

Source§

fn default() -> Polynomial

Returns the “default value” for a type. Read more
Source§

impl Display for Polynomial

Source§

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

Terms from the highest exponents down, variable i written x{i}.

Source§

impl Hash for Polynomial

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 Polynomial

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Eq for Polynomial

Source§

impl StructuralPartialEq for Polynomial

Auto Trait Implementations§

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 = 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.