Expression

Struct Expression 

Source
pub struct Expression<T> {
    pub terms: Vec<Term<T>>,
    pub constant: OrderedFloat<f64>,
}
Expand description

An expression that can be the left hand or right hand side of a constraint equation. It is a linear combination of variables, i.e. a sum of variables weighted by coefficients, plus an optional constant.

Fields§

§terms: Vec<Term<T>>§constant: OrderedFloat<f64>

Implementations§

Source§

impl<T: Clone> Expression<T>

Source

pub fn from_constant(v: f64) -> Expression<T>

Constructs an expression of the form n, where n is a constant real number, not a variable.

Source

pub fn from_term(term: Term<T>) -> Expression<T>

Constructs an expression from a single term. Forms an expression of the form n x where n is the coefficient, and x is the variable.

Source

pub fn new(terms: Vec<Term<T>>, constant: f64) -> Expression<T>

General constructor. Each Term in terms is part of the sum forming the expression, as well as constant.

Source

pub fn negate(&mut self)

Mutates this expression by multiplying it by minus one.

Trait Implementations§

Source§

impl<T> Add<Expression<T>> for Term<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<Expression<T>> for f32

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<Expression<T>> for f64

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<Expression<T>> for i32

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<Expression<T>> for u32

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl Add<Expression<Variable>> for Variable

Source§

type Output = Expression<Variable>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<Variable>) -> Expression<Variable>

Performs the + operation. Read more
Source§

impl<T> Add<Term<T>> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, t: Term<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl Add<Variable> for Expression<Variable>

Source§

type Output = Expression<Variable>

The resulting type after applying the + operator.
Source§

fn add(self, v: Variable) -> Expression<Variable>

Performs the + operation. Read more
Source§

impl<T> Add<f32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, v: f32) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<f64> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, v: f64) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<i32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, v: i32) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add<u32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, v: u32) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> Add for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the + operator.
Source§

fn add(self, e: Expression<T>) -> Expression<T>

Performs the + operation. Read more
Source§

impl<T> AddAssign<Term<T>> for Expression<T>

Source§

fn add_assign(&mut self, t: Term<T>)

Performs the += operation. Read more
Source§

impl AddAssign<Variable> for Expression<Variable>

Source§

fn add_assign(&mut self, v: Variable)

Performs the += operation. Read more
Source§

impl<T> AddAssign<f32> for Expression<T>

Source§

fn add_assign(&mut self, v: f32)

Performs the += operation. Read more
Source§

impl<T> AddAssign<f64> for Expression<T>

Source§

fn add_assign(&mut self, v: f64)

Performs the += operation. Read more
Source§

impl<T> AddAssign<i32> for Expression<T>

Source§

fn add_assign(&mut self, v: i32)

Performs the += operation. Read more
Source§

impl<T> AddAssign<u32> for Expression<T>

Source§

fn add_assign(&mut self, v: u32)

Performs the += operation. Read more
Source§

impl<T> AddAssign for Expression<T>

Source§

fn add_assign(&mut self, e: Expression<T>)

Performs the += operation. Read more
Source§

impl<T: Clone> Clone for Expression<T>

Source§

fn clone(&self) -> Expression<T>

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<Var: Clone> Constrainable<Var> for Expression<Var>

Source§

fn equal_to<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

fn greater_than_or_equal_to<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

fn less_than_or_equal_to<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

fn is<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

fn is_ge<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

fn is_le<X>(self, x: X) -> Constraint<Var>
where X: Into<Expression<Var>> + Clone,

Source§

impl<T: Debug> Debug for Expression<T>

Source§

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

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

impl<T: Clone> Div<f32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the / operator.
Source§

fn div(self, v: f32) -> Expression<T>

Performs the / operation. Read more
Source§

impl<T: Clone> Div<f64> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the / operator.
Source§

fn div(self, v: f64) -> Expression<T>

Performs the / operation. Read more
Source§

impl<T: Clone> Div<i32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the / operator.
Source§

fn div(self, v: i32) -> Expression<T>

Performs the / operation. Read more
Source§

impl<T: Clone> Div<u32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the / operator.
Source§

fn div(self, v: u32) -> Expression<T>

Performs the / operation. Read more
Source§

impl<T: Clone> DivAssign<f32> for Expression<T>

Source§

fn div_assign(&mut self, v: f32)

Performs the /= operation. Read more
Source§

impl<T: Clone> DivAssign<f64> for Expression<T>

Source§

fn div_assign(&mut self, v: f64)

Performs the /= operation. Read more
Source§

impl<T: Clone> DivAssign<i32> for Expression<T>

Source§

fn div_assign(&mut self, v: i32)

Performs the /= operation. Read more
Source§

impl<T: Clone> DivAssign<u32> for Expression<T>

Source§

fn div_assign(&mut self, v: u32)

Performs the /= operation. Read more
Source§

impl<T: Clone> From<Term<T>> for Expression<T>

Source§

fn from(t: Term<T>) -> Expression<T>

Converts to this type from the input type.
Source§

impl From<Variable> for Expression<Variable>

Source§

fn from(v: Variable) -> Expression<Variable>

Converts to this type from the input type.
Source§

impl<T: Clone> From<f64> for Expression<T>

Source§

fn from(v: f64) -> Expression<T>

Converts to this type from the input type.
Source§

impl<T: Clone> From<i32> for Expression<T>

Source§

fn from(v: i32) -> Expression<T>

Converts to this type from the input type.
Source§

impl<T: Clone> From<u32> for Expression<T>

Source§

fn from(v: u32) -> Expression<T>

Converts to this type from the input type.
Source§

impl<T: Hash> Hash for Expression<T>

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<T: Clone> Mul<Expression<T>> for f32

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, e: Expression<T>) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<Expression<T>> for f64

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, e: Expression<T>) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<Expression<T>> for i32

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, e: Expression<T>) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<Expression<T>> for u32

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, e: Expression<T>) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<f32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, v: f32) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<f64> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, v: f64) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<i32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, v: i32) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> Mul<u32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the * operator.
Source§

fn mul(self, v: u32) -> Expression<T>

Performs the * operation. Read more
Source§

impl<T: Clone> MulAssign<f32> for Expression<T>

Source§

fn mul_assign(&mut self, v: f32)

Performs the *= operation. Read more
Source§

impl<T: Clone> MulAssign<f64> for Expression<T>

Source§

fn mul_assign(&mut self, v: f64)

Performs the *= operation. Read more
Source§

impl<T: Clone> MulAssign<i32> for Expression<T>

Source§

fn mul_assign(&mut self, v: i32)

Performs the *= operation. Read more
Source§

impl<T: Clone> MulAssign<u32> for Expression<T>

Source§

fn mul_assign(&mut self, v: u32)

Performs the *= operation. Read more
Source§

impl<T: Clone> Neg for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expression<T>

Performs the unary - operation. Read more
Source§

impl<T: PartialEq> PartialEq for Expression<T>

Source§

fn eq(&self, other: &Expression<T>) -> 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<T: Clone> Sub<Expression<T>> for Term<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T: Clone> Sub<Expression<T>> for f32

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T: Clone> Sub<Expression<T>> for f64

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T: Clone> Sub<Expression<T>> for i32

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T: Clone> Sub<Expression<T>> for u32

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl Sub<Expression<Variable>> for Variable

Source§

type Output = Expression<Variable>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<Variable>) -> Expression<Variable>

Performs the - operation. Read more
Source§

impl<T> Sub<Term<T>> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, t: Term<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl Sub<Variable> for Expression<Variable>

Source§

type Output = Expression<Variable>

The resulting type after applying the - operator.
Source§

fn sub(self, v: Variable) -> Expression<Variable>

Performs the - operation. Read more
Source§

impl<T> Sub<f32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, v: f32) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T> Sub<f64> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, v: f64) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T> Sub<i32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, v: i32) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T> Sub<u32> for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, v: u32) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T: Clone> Sub for Expression<T>

Source§

type Output = Expression<T>

The resulting type after applying the - operator.
Source§

fn sub(self, e: Expression<T>) -> Expression<T>

Performs the - operation. Read more
Source§

impl<T> SubAssign<Term<T>> for Expression<T>

Source§

fn sub_assign(&mut self, t: Term<T>)

Performs the -= operation. Read more
Source§

impl SubAssign<Variable> for Expression<Variable>

Source§

fn sub_assign(&mut self, v: Variable)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<f32> for Expression<T>

Source§

fn sub_assign(&mut self, v: f32)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<f64> for Expression<T>

Source§

fn sub_assign(&mut self, v: f64)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<i32> for Expression<T>

Source§

fn sub_assign(&mut self, v: i32)

Performs the -= operation. Read more
Source§

impl<T> SubAssign<u32> for Expression<T>

Source§

fn sub_assign(&mut self, v: u32)

Performs the -= operation. Read more
Source§

impl<T: Clone> SubAssign for Expression<T>

Source§

fn sub_assign(&mut self, e: Expression<T>)

Performs the -= operation. Read more
Source§

impl<T: Eq> Eq for Expression<T>

Source§

impl<T> StructuralPartialEq for Expression<T>

Auto Trait Implementations§

§

impl<T> Freeze for Expression<T>

§

impl<T> RefUnwindSafe for Expression<T>
where T: RefUnwindSafe,

§

impl<T> Send for Expression<T>
where T: Send,

§

impl<T> Sync for Expression<T>
where T: Sync,

§

impl<T> Unpin for Expression<T>
where T: Unpin,

§

impl<T> UnwindSafe for Expression<T>
where T: UnwindSafe,

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.