pub enum Expression {
Pi,
Variable(String),
Constant(Constant),
Neg(Box<Expression>),
Add(Box<Expression>, Box<Expression>),
Sub(Box<Expression>, Box<Expression>),
Mul(Box<Expression>, Box<Expression>),
Div(Box<Expression>, Box<Expression>),
Pow(Box<Expression>, Box<Expression>),
Sqrt(Box<Expression>),
Sin(Box<Expression>),
Cos(Box<Expression>),
}Variants§
Pi
Variable(String)
Constant(Constant)
Neg(Box<Expression>)
Add(Box<Expression>, Box<Expression>)
Sub(Box<Expression>, Box<Expression>)
Mul(Box<Expression>, Box<Expression>)
Div(Box<Expression>, Box<Expression>)
Pow(Box<Expression>, Box<Expression>)
Sqrt(Box<Expression>)
Sin(Box<Expression>)
Cos(Box<Expression>)
Implementations§
Source§impl Expression
impl Expression
pub fn zero() -> Self
pub fn one() -> Self
pub fn from_int(n: i64) -> Self
pub fn from_float(f: f64) -> Self
pub fn from_float_32(f: f32) -> Self
pub fn from_float_64(f: f64) -> Self
pub fn to_float(&self) -> f64
pub fn to_constant(&self) -> Constant
pub fn gather_context(&self) -> HashSet<String>
pub fn is_zero(&self) -> bool
Sourcepub fn is_zero_fast(&self) -> bool
pub fn is_zero_fast(&self) -> bool
Conservative check for zero. This is faster than the exact check.
pub fn is_one(&self) -> bool
pub fn is_one_fast(&self) -> bool
pub fn contains_variable<T: AsRef<str>>(&self, var: T) -> bool
pub fn is_parameterized(&self) -> bool
pub fn eval<R: RealScalar>(&self, args: &HashMap<&str, R>) -> R
Sourcepub fn hash_eval(&self) -> f64
pub fn hash_eval(&self) -> f64
Uses a magic value to evaluate the expression. This is useful for hashing expressions.
pub fn map_var_names(&self, var_map: &HashMap<String, String>) -> Self
pub fn rename_variable<S: AsRef<str>, T: AsRef<str>>( &self, original: S, new: T, ) -> Self
pub fn differentiate<S: AsRef<str>>(&self, wrt: S) -> Self
pub fn get_ancestors<S: AsRef<str>>(&self, variable: S) -> Vec<Expression>
pub fn fast_eq(&self, other: &Expression) -> bool
pub fn substitute<S: AsRef<Expression>, T: AsRef<Expression>>( &self, original: S, substitution: T, ) -> Self
pub fn simplify(&self) -> Self
pub fn get_unique_variables(&self) -> Vec<String>
Trait Implementations§
Source§impl Add<&Expression> for &Expression
impl Add<&Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, other: &Expression) -> Expression
fn add(self, other: &Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add<&Expression> for Expression
impl Add<&Expression> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, other: &Expression) -> Expression
fn add(self, other: &Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add<Expression> for &Expression
impl Add<Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
+ operator.Source§fn add(self, other: Expression) -> Expression
fn add(self, other: Expression) -> Expression
Performs the
+ operation. Read moreSource§impl Add for Expression
impl Add for Expression
Source§impl AsRef<Expression> for Expression
impl AsRef<Expression> for Expression
Source§fn as_ref(&self) -> &Expression
fn as_ref(&self) -> &Expression
Converts this type into a shared reference of the (usually inferred) input type.
Source§impl Clone for Expression
impl Clone for Expression
Source§fn clone(&self) -> Expression
fn clone(&self) -> Expression
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Expression
impl Debug for Expression
Source§impl Display for Expression
impl Display for Expression
Source§impl Div<&Expression> for &Expression
impl Div<&Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
/ operator.Source§fn div(self, other: &Expression) -> Expression
fn div(self, other: &Expression) -> Expression
Performs the
/ operation. Read moreSource§impl Div<&Expression> for Expression
impl Div<&Expression> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
/ operator.Source§fn div(self, other: &Expression) -> Expression
fn div(self, other: &Expression) -> Expression
Performs the
/ operation. Read moreSource§impl Div<Expression> for &Expression
impl Div<Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
/ operator.Source§fn div(self, other: Expression) -> Expression
fn div(self, other: Expression) -> Expression
Performs the
/ operation. Read moreSource§impl Div for Expression
impl Div for Expression
Source§impl<R: RealScalar> From<R> for Expression
impl<R: RealScalar> From<R> for Expression
Source§impl Hash for Expression
impl Hash for Expression
Source§impl Mul<&Expression> for &Expression
impl Mul<&Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§fn mul(self, other: &Expression) -> Expression
fn mul(self, other: &Expression) -> Expression
Performs the
* operation. Read moreSource§impl Mul<&Expression> for Expression
impl Mul<&Expression> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§fn mul(self, other: &Expression) -> Expression
fn mul(self, other: &Expression) -> Expression
Performs the
* operation. Read moreSource§impl Mul<Expression> for &Expression
impl Mul<Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
* operator.Source§fn mul(self, other: Expression) -> Expression
fn mul(self, other: Expression) -> Expression
Performs the
* operation. Read moreSource§impl Mul for Expression
impl Mul for Expression
Source§impl Neg for &Expression
impl Neg for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn neg(self) -> Expression
fn neg(self) -> Expression
Performs the unary
- operation. Read moreSource§impl Neg for Expression
impl Neg for Expression
Source§impl PartialEq for Expression
impl PartialEq for Expression
Source§impl Sub<&Expression> for &Expression
impl Sub<&Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, other: &Expression) -> Expression
fn sub(self, other: &Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub<&Expression> for Expression
impl Sub<&Expression> for Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, other: &Expression) -> Expression
fn sub(self, other: &Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub<Expression> for &Expression
impl Sub<Expression> for &Expression
Source§type Output = Expression
type Output = Expression
The resulting type after applying the
- operator.Source§fn sub(self, other: Expression) -> Expression
fn sub(self, other: Expression) -> Expression
Performs the
- operation. Read moreSource§impl Sub for Expression
impl Sub for Expression
impl Eq for Expression
Auto Trait Implementations§
impl Freeze for Expression
impl RefUnwindSafe for Expression
impl Send for Expression
impl Sync for Expression
impl Unpin for Expression
impl UnwindSafe for Expression
Blanket Implementations§
Source§impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
fn as_generalized_ref(&'short self) -> &'short Target
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more