Expression

Enum Expression 

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

Implementations§

Source§

impl Expression

Source

pub fn zero() -> Self

Source

pub fn one() -> Self

Source

pub fn from_int(n: i64) -> Self

Source

pub fn from_float(f: f64) -> Self

Source

pub fn from_float_32(f: f32) -> Self

Source

pub fn from_float_64(f: f64) -> Self

Source

pub fn to_float(&self) -> f64

Source

pub fn to_constant(&self) -> Constant

Source

pub fn gather_context(&self) -> HashSet<String>

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_zero_fast(&self) -> bool

Conservative check for zero. This is faster than the exact check.

Source

pub fn is_one(&self) -> bool

Source

pub fn is_one_fast(&self) -> bool

Source

pub fn contains_variable<T: AsRef<str>>(&self, var: T) -> bool

Source

pub fn is_parameterized(&self) -> bool

Source

pub fn eval<R: RealScalar>(&self, args: &HashMap<&str, R>) -> R

Source

pub fn hash_eval(&self) -> f64

Uses a magic value to evaluate the expression. This is useful for hashing expressions.

Source

pub fn map_var_names(&self, var_map: &HashMap<String, String>) -> Self

Source

pub fn rename_variable<S: AsRef<str>, T: AsRef<str>>( &self, original: S, new: T, ) -> Self

Source

pub fn differentiate<S: AsRef<str>>(&self, wrt: S) -> Self

Source

pub fn get_ancestors<S: AsRef<str>>(&self, variable: S) -> Vec<Expression>

Source

pub fn fast_eq(&self, other: &Expression) -> bool

Source

pub fn substitute<S: AsRef<Expression>, T: AsRef<Expression>>( &self, original: S, substitution: T, ) -> Self

Source

pub fn simplify(&self) -> Self

Source

pub fn get_unique_variables(&self) -> Vec<String>

Trait Implementations§

Source§

impl Add<&Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, other: &Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, other: &Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

fn add(self, other: Expression) -> Expression

Performs the + operation. Read more
Source§

impl Add for Expression

Source§

type Output = Expression

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AsRef<Expression> for Expression

Source§

fn as_ref(&self) -> &Expression

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Expression

Source§

fn clone(&self) -> Expression

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 Expression

Source§

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

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

impl Display for Expression

Source§

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

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

impl Div<&Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

fn div(self, other: &Expression) -> Expression

Performs the / operation. Read more
Source§

impl Div<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

fn div(self, other: &Expression) -> Expression

Performs the / operation. Read more
Source§

impl Div<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

fn div(self, other: Expression) -> Expression

Performs the / operation. Read more
Source§

impl Div for Expression

Source§

type Output = Expression

The resulting type after applying the / operator.
Source§

fn div(self, other: Self) -> Self

Performs the / operation. Read more
Source§

impl<R: RealScalar> From<R> for Expression

Source§

fn from(value: R) -> Self

Converts to this type from the input type.
Source§

impl Hash for Expression

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 Mul<&Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, other: &Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, other: Expression) -> Expression

Performs the * operation. Read more
Source§

impl Mul for Expression

Source§

type Output = Expression

The resulting type after applying the * operator.
Source§

fn mul(self, other: Self) -> Self

Performs the * operation. Read more
Source§

impl Neg for &Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expression

Performs the unary - operation. Read more
Source§

impl Neg for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Expression

Source§

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

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub<&Expression> for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, other: &Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub<Expression> for &Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

fn sub(self, other: Expression) -> Expression

Performs the - operation. Read more
Source§

impl Sub for Expression

Source§

type Output = Expression

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Eq for Expression

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Add<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output

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<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
where T: AsRef<Target> + ?Sized, Target: ?Sized,

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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

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> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Div<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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> IntoEither for T

Source§

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<Rhs, Lhs, Output> MulByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Mul<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn mul_by_ref(&self, rhs: &Rhs) -> <Lhs as MulByRef<Rhs>>::Output

Source§

impl<T, Output> NegByRef for T
where &'a T: for<'a> Neg<Output = Output>,

Source§

type Output = Output

Source§

fn neg_by_ref(&self) -> <T as NegByRef>::Output

Source§

impl<Rhs, Lhs, Output> SubByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Sub<&'a Rhs, Output = Output>,

Source§

type Output = Output

Source§

fn sub_by_ref(&self, rhs: &Rhs) -> <Lhs as SubByRef<Rhs>>::Output

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V