pub struct FlatEx<T, OF = FloatOpsFactory<T>, LM = NumberMatcher> where
    T: Debug + Clone,
    OF: MakeOperators<T>,
    LM: MatchLiteral
{ /* private fields */ }
Expand description

This is the core data type representing a flattened expression and the result of parsing a string. We use flattened expressions to make efficient evaluation possible. Simplified, a flat expression consists of a SmallVec of nodes and a SmallVec of operators that are applied to the nodes in an order following operator priorities.

Creation of expressions is possible with the function parse which is equivalent to FlatEx::from_str.

use exmex::prelude::*;

// create an expression by parsing a string
let expr = FlatEx::<f32>::from_str("sin(1+y)*x")?;
assert!((expr.eval(&[1.5, 2.0])? - (1.0 + 2.0 as f32).sin() * 1.5).abs() < 1e-6);

The argument &[1.5, 2.0] in the call of eval specifies the variable values in the alphabetical order of the variable names. In this example, we want to evaluate the expression for the varibale values x=2.0 and y=1.5.

Implementations

Executes calculations that can trivially be executed, e.g., multiplies two numbers that need to be multiplied anyway.

Parses into an expression without compilation. Allow slightly faster direct evaluation of strings.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

feature = "partial" - Every trait implementation needs to implement the conversion to a deep expression to be able to use the default implementation of partial. Read more

feature = "partial" - Every trait implementation needs to implement the conversion from a deep expression to be able to use the default implementation of partial. Read more

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

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

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

The expression is displayed as a string created by unparse.

Formats the value using the given formatter. Read more

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

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

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

Returns the variables of the expression

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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

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

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

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

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.