Skip to main content

Polynomial

Struct Polynomial 

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

Implementations§

Source§

impl Polynomial

Source

pub fn var(vindex: usize) -> Polynomial

Source

pub fn sign(&self) -> Option<bool>

Determine the sign of this polynomial (if known). Here, positive sign indicates the polynomial can never evaluate to a negative number. In constrast, a negative sign indicates it cannot evalute to a (strictly) positive number. For example, 1+2x has positive sign, whilst -2x has negative sign.

Source

pub fn constant(&self) -> isize

Determine the constant coefficient of this polynomial. For example, 1 is the constant component of 2x+1.

Source

pub fn is_zero(&self) -> Option<bool>

Determine whether or not this polynomial could be zero (or not). For example, 2x+1 cannot be zero (i.e. given that x cannot be negative). However, x - y can be zero (e.g. when x=y). Note: just because this polynomial could evaluate to zero, it does not mean that it will.

Source

pub fn above_zero(&self) -> Option<bool>

Determine whether or not this polynomial always evaluates to something above zero (or not).

Source

pub fn below_zero(&self) -> Option<bool>

Determine whether or not this polynomial always evaluates to something below zero (or not).

Source

pub fn negate(self) -> Self

Negate this polynomial. This is achieved by negating each term within the polynomial.

Source

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

Add a given Polynomial onto this polynomial. For example, adding x+2 to 2x+1 gives 3x+3.

Source

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

Subtract a given Polynomial from this polynomial.

Source

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

Source

pub fn equals(self, rhs: Polynomial) -> Constraint

Construct a constraint enforcing the equality of two polynomials.

Source

pub fn not_equals(self, rhs: Polynomial) -> Constraint

Construct a constraint enforcing the non-equality of two polynomials.

Source

pub fn less_than(self, rhs: Polynomial) -> Constraint

Construct a constraint enforcing that one polynomial is less than another.

Source

pub fn less_than_or_equals(self, rhs: Polynomial) -> Constraint

Construct a constraint enforcing that one polynomial is less than or equal to another.

Source

pub fn eval(&self, vals: &[usize]) -> isize

Evaluate this Polynomial at a given point.

Source

pub fn substitute(&self, var: usize, val: &Polynomial) -> Polynomial

Substitute all occurrenes of a given variable in self with a given Polynomial. For example, substituting x:=x+1 into 2x + xy gives 2+2x+xy+y.

Trait Implementations§

Source§

impl Add for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<usize> for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the + operator.
Source§

fn add(self, rhs: usize) -> Self

Performs the + operation. Read more
Source§

impl Clone for Polynomial

Source§

fn clone(&self) -> Polynomial

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 Polynomial

Source§

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

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

impl Display for Polynomial

Source§

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

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

impl From<i32> for Polynomial

Source§

fn from(val: i32) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Polynomial

Source§

fn from(val: usize) -> Self

Converts to this type from the input type.
Source§

impl Mul for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Polynomial) -> Self

Performs the * operation. Read more
Source§

impl Mul<usize> for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: usize) -> Self

Performs the * operation. Read more
Source§

impl PartialEq for Polynomial

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Polynomial

Source§

impl Sub for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<usize> for Polynomial

Source§

type Output = Polynomial

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: usize) -> Self

Performs the - operation. Read more

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.