Skip to main content

MathExpr

Struct MathExpr 

Source
pub struct MathExpr<'a, T: Float> { /* private fields */ }

Implementations§

Source§

impl<'a, T> MathExpr<'a, T>
where T: Float + Debug + FromStr,

Source

pub fn parse(input: &'a str) -> Result<Self, ParseError>

Source§

impl<'a, T: Float + Debug> MathExpr<'a, T>

Source

pub fn variables(&self) -> HashSet<&'a str>

Returns all variable names, including those in conditional branches.

Source

pub fn substitute(&self, name: &str, replacement: &Self) -> Self

Substitutes a variable structurally, without rewriting expression text.

Source

pub fn new_var(name: &'a str) -> Self

Source

pub fn new_const(value: T) -> Self

Source

pub fn new_add(left: Self, right: Self) -> Self

Source

pub fn new_subtract(left: Self, right: Self) -> Self

Source

pub fn new_multiply(left: Self, right: Self) -> Self

Source

pub fn new_divide(numerator: Self, denominator: Self) -> Self

Source

pub fn new_power(base: Self, exponent: Self) -> Self

Source

pub fn new_negate(operand: Self) -> Self

Source

pub fn new_sin(operand: Self) -> Self

Source

pub fn new_cos(operand: Self) -> Self

Source

pub fn new_tan(operand: Self) -> Self

Source

pub fn new_asin(operand: Self) -> Self

Source

pub fn new_acos(operand: Self) -> Self

Source

pub fn new_atan(operand: Self) -> Self

Source

pub fn new_sinh(operand: Self) -> Self

Source

pub fn new_cosh(operand: Self) -> Self

Source

pub fn new_tanh(operand: Self) -> Self

Source

pub fn new_sign(operand: Self) -> Self

Source

pub fn new_abs(operand: Self) -> Self

Source

pub fn new_exp(operand: Self) -> Self

Source

pub fn new_sqrt(operand: Self) -> Self

Source

pub fn new_log(operand: Self) -> Self

Source

pub fn new_log10(operand: Self) -> Self

Source

pub fn new_iif(check: Self, if_less_than_zero: Self, otherwise: Self) -> Self

Source

pub fn derive(&self, by_var: &str) -> Self

Source

pub fn simplify(&self) -> Self

Applies real-algebra identities, not strict IEEE-754 equivalences. Reassociation may change rounding, overflow, or signed zero; eliminating expressions (including redundant iif checks) may remove evaluation errors.

Source

pub fn evaluate( &self, args: &HashMap<&str, T>, ) -> Result<T, EvaluationError<'a, T>>

Trait Implementations§

Source§

impl<'a, T: Clone + Float> Clone for MathExpr<'a, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T: Debug + Float> Debug for MathExpr<'a, T>

Source§

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

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

impl<T: Float + Display> Display for MathExpr<'_, T>

Source§

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

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

impl<'a, T: PartialEq + Float> PartialEq for MathExpr<'a, T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'a, T: PartialEq + Float> StructuralPartialEq for MathExpr<'a, T>

Auto Trait Implementations§

§

impl<'a, T> Forget for MathExpr<'a, T>

§

impl<'a, T> Freeze for MathExpr<'a, T>
where Operation<'a, T>: Freeze, Vec<MathExpr<'a, T>>: Freeze,

§

impl<'a, T> RefUnwindSafe for MathExpr<'a, T>

§

impl<'a, T> Send for MathExpr<'a, T>
where Operation<'a, T>: Send, Vec<MathExpr<'a, T>>: Send,

§

impl<'a, T> Sync for MathExpr<'a, T>
where Operation<'a, T>: Sync, Vec<MathExpr<'a, T>>: Sync,

§

impl<'a, T> Unpin for MathExpr<'a, T>
where Operation<'a, T>: Unpin, Vec<MathExpr<'a, T>>: Unpin,

§

impl<'a, T> UnsafeUnpin for MathExpr<'a, T>
where Operation<'a, T>: UnsafeUnpin, Vec<MathExpr<'a, T>>: UnsafeUnpin,

§

impl<'a, T> UnwindSafe for MathExpr<'a, T>
where Operation<'a, T>: UnwindSafe, Vec<MathExpr<'a, 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.