Struct exmex::DeepEx

source ·
pub struct DeepEx<'a, T, OF = FloatOpsFactory<T>, LM = NumberMatcher>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,
{ /* private fields */ }
Expand description

A deep expression evaluates co-recursively since its nodes can contain other deep expressions. Compared to FlatEx, this is slower to evaluate but easier to calculate with.

Implementations§

source§

impl<'a, T, OF, LM> DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

source

pub fn one() -> Self
where T: NeutralElts,

source

pub fn zero() -> Self
where T: NeutralElts,

source

pub fn ops(&self) -> &Vec<Operator<'a, T>>

source

pub fn pow( self, exponent: DeepEx<'a, T, OF, LM> ) -> ExResult<DeepEx<'a, T, OF, LM>>
where OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, T: NeutralElts,

source

pub fn abs(self) -> ExResult<Self>

source

pub fn sin(self) -> ExResult<Self>

source

pub fn cos(self) -> ExResult<Self>

source

pub fn tan(self) -> ExResult<Self>

source

pub fn sinh(self) -> ExResult<Self>

source

pub fn cosh(self) -> ExResult<Self>

source

pub fn tanh(self) -> ExResult<Self>

source

pub fn asin(self) -> ExResult<Self>

source

pub fn acos(self) -> ExResult<Self>

source

pub fn atan(self) -> ExResult<Self>

source

pub fn signum(self) -> ExResult<Self>

source

pub fn log(self) -> ExResult<Self>

source

pub fn log2(self) -> ExResult<Self>

source

pub fn log10(self) -> ExResult<Self>

source

pub fn ln(self) -> ExResult<Self>

source

pub fn round(self) -> ExResult<Self>

source

pub fn floor(self) -> ExResult<Self>

source

pub fn ceil(self) -> ExResult<Self>

source

pub fn exp(self) -> ExResult<Self>

source

pub fn sqrt(self) -> ExResult<Self>

source

pub fn cbrt(self) -> ExResult<Self>

source

pub fn fract(self) -> ExResult<Self>

source

pub fn trunc(self) -> ExResult<Self>

source

pub fn pi() -> Self
where T: From<f64>,

source

pub fn e() -> Self
where T: From<f64>,

source

pub fn tau() -> Self
where T: From<f64>,

Trait Implementations§

source§

impl<'a, T, OF, LM> Add for DeepEx<'a, T, OF, LM>
where T: DataType + NeutralElts, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<'a, T, OF, LM> BitAnd for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl<'a, T, OF, LM> BitOr for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<'a, T, OF, LM> BitXor for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, rhs: Self) -> Self::Output

Performs the ^ operation. Read more
source§

impl<'a, T, OF, LM> Calculate<'a, T> for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

source§

fn operate_unary(self, repr: &'a str) -> ExResult<Self>

Applies a unary operator. Read more
source§

fn operate_binary(self, other: Self, repr: &'a str) -> ExResult<Self>

Applies a binary operator. Read more
source§

fn subs<F>(self, sub: &mut F) -> ExResult<Self>
where F: FnMut(&str) -> Option<Self>,

Substitutes a variable with another expression. Read more
source§

fn from_num(x: T) -> Self

Create an expression that contains exactly one number. Read more
source§

impl<'a, T, OF, LM> Clone for DeepEx<'a, T, OF, LM>
where T: DataType + Clone, OF: MakeOperators<T> + Clone, LM: MatchLiteral + Clone, <T as FromStr>::Err: Debug,

source§

fn clone(&self) -> DeepEx<'a, T, OF, LM>

Returns a copy 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<'a, T, OF, LM> Debug for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

source§

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

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

impl<'a, T, OF, LM> Default for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

source§

fn default() -> Self

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

impl<'a, T, OF, LM> Differentiate<'a, T> for DeepEx<'a, T, OF, LM>
where T: DiffDataType, OF: MakeOperators<T> + Debug, LM: MatchLiteral + Debug, <T as FromStr>::Err: Debug,

source§

fn partial(self, var_idx: usize) -> ExResult<Self>

feature = "partial" - This method computes a new expression that is the partial derivative of self with default operators. Read more
source§

fn partial_relaxed( self, var_idx: usize, missing_op_mode: MissingOpMode ) -> ExResult<Self>

Like Differentiate::partial. The only difference is that in case there is no differentation defined for a binary operator this will not necessarily throw an error depending on missing_op_mode, see MissingOpMode.
source§

fn partial_nth(self, var_idx: usize, n: usize) -> ExResult<Self>

feature = "partial" - Computes the nth partial derivative with respect to one variable Read more
source§

fn partial_nth_relaxed( self, var_idx: usize, n: usize, missing_op_mode: MissingOpMode ) -> ExResult<Self>

Like Differentiate::partial_nth. The only difference is that in case there is no differentation defined for a binary operator this will not necessarily throw an error depending on missing_op_mode, see MissingOpMode.
source§

fn partial_iter<I>(self, var_idxs: I) -> ExResult<Self>
where I: Iterator<Item = usize> + Clone,

feature = "partial" - Computes a chain of partial derivatives with respect to the variables passed as iterator Read more
source§

fn partial_iter_relaxed<I>( self, var_idxs: I, missing_op_mode: MissingOpMode ) -> ExResult<Self>
where I: Iterator<Item = usize> + Clone,

Like Differentiate::partial_iter. The only difference is that in case there is no differentation defined for a binary this will not necessarily throw an error depending on missing_op_mode, see MissingOpMode.
source§

impl<'a, T, OF, LM> Display for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

source§

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

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

impl<'a, T, OF, LM> Div for DeepEx<'a, T, OF, LM>
where T: DataType + NeutralElts, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T, OF, LM> Express<'a, T> for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

§

type LiteralMatcher = LM

§

type OperatorFactory = OF

source§

fn eval_relaxed(&self, vars: &[T]) -> ExResult<T>

Evaluates an expression with the given variable values and returns the computed result. If more variables are passed than necessary the unnecessary ones are ignored. Read more
source§

fn eval(&self, vars: &[T]) -> ExResult<T>

Evaluates an expression with the given variable values and returns the computed result. Read more
source§

fn from_deepex(deepex: DeepEx<'a, T, OF, LM>) -> ExResult<DeepEx<'a, T, OF, LM>>
where Self: Sized, T: DataType, <T as FromStr>::Err: Debug,

source§

fn to_deepex(self) -> ExResult<DeepEx<'a, T, OF, LM>>
where Self: Sized, T: DataType, <T as FromStr>::Err: Debug,

Conversion to a deep expression necessary for computations with expressions
source§

fn unparse(&self) -> &str

Creates an expression string that corresponds to the FlatEx instance. Read more
source§

fn var_names(&self) -> &[String]

Returns the variables of the expression
source§

fn parse(text: &'a str) -> ExResult<Self>
where Self: Sized,

source§

impl<'a, T, OF, LM> Mul for DeepEx<'a, T, OF, LM>
where T: DataType + NeutralElts, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, T, OF, LM> Neg for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<'a, T, OF, LM> Ord for DeepEx<'a, T, OF, LM>
where T: DataType + Ord, OF: MakeOperators<T> + Ord, LM: MatchLiteral + Ord, <T as FromStr>::Err: Debug,

source§

fn cmp(&self, other: &DeepEx<'a, T, OF, LM>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a, T, OF, LM> PartialEq for DeepEx<'a, T, OF, LM>

source§

fn eq(&self, other: &DeepEx<'a, T, OF, LM>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, T, OF, LM> PartialOrd for DeepEx<'a, T, OF, LM>

source§

fn partial_cmp(&self, other: &DeepEx<'a, T, OF, LM>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, T, OF, LM> Rem for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Self) -> Self::Output

Performs the % operation. Read more
source§

impl<'a, T, OF, LM> Sub for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug, Self: Sized,

§

type Output = Result<DeepEx<'a, T, OF, LM>, ExError>

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<'a, T, OF, LM> Eq for DeepEx<'a, T, OF, LM>
where T: DataType + Eq, OF: MakeOperators<T> + Eq, LM: MatchLiteral + Eq, <T as FromStr>::Err: Debug,

source§

impl<'a, T, OF, LM> StructuralEq for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

source§

impl<'a, T, OF, LM> StructuralPartialEq for DeepEx<'a, T, OF, LM>
where T: DataType, OF: MakeOperators<T>, LM: MatchLiteral, <T as FromStr>::Err: Debug,

Auto Trait Implementations§

§

impl<'a, T, OF, LM> RefUnwindSafe for DeepEx<'a, T, OF, LM>

§

impl<'a, T, OF, LM> Send for DeepEx<'a, T, OF, LM>
where LM: Send, OF: Send, T: Send,

§

impl<'a, T, OF, LM> Sync for DeepEx<'a, T, OF, LM>
where LM: Sync, OF: Sync, T: Sync,

§

impl<'a, T, OF, LM> Unpin for DeepEx<'a, T, OF, LM>
where LM: Unpin, OF: Unpin, T: Unpin,

§

impl<'a, T, OF, LM> UnwindSafe for DeepEx<'a, T, OF, LM>
where LM: UnwindSafe, OF: UnwindSafe, 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> 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,

§

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§

default 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>,

§

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>,

§

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<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,