Struct calcu_rs::atom::Expr

source ·
pub struct Expr {
    pub(crate) atom: Rc<Atom>,
}

Fields§

§atom: Rc<Atom>

Implementations§

source§

impl Expr

source

pub fn add(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn sub(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn mul(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn div(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn add_raw(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn mul_raw(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn div_raw(lhs: impl Borrow<Expr>, rhs: impl Borrow<Expr>) -> Expr

source

pub fn pow_raw(base: impl Borrow<Expr>, exponent: impl Borrow<Expr>) -> Expr

source

pub fn pow(base: impl Borrow<Expr>, exponent: impl Borrow<Expr>) -> Expr

source

pub fn derivative<T: Borrow<Self>>(&self, x: T) -> Self

source§

impl Expr

source

pub fn simplify(&self) -> Vec<Self>

source

pub fn expand(&self) -> Self

source

pub fn expand_main_op(&self) -> Self

source

pub fn expand_exponential(&self) -> Self

exponential expansion

exp(u+v) = exp(u) * exp(v) exp(w*u) = exp(u)^w

source

pub fn simplify_trig(&self) -> Self

source

pub fn substitute_trig(&self) -> Self

source

pub fn expand_trig(&self) -> Self

source

pub fn contract_trig(&self) -> Self

source

pub fn expand_ln(&self) -> Self

source

pub fn distribute(&self) -> Self

source

pub fn rationalize(&self) -> Expr

source

fn rationalize_add(lhs: &Self, rhs: &Self) -> Expr

a/b + c/d -> (ad + cb) / (bd)

source

pub fn factorize_common_terms(lhs: &Expr, rhs: &Self) -> (Expr, (Expr, Expr))

divide lhs and rhs by their common factor and return them in the form (fac, (lhs/fac, rhs/fac)

source

pub fn common_factors(lhs: &Self, rhs: &Self) -> Expr

source

pub fn factor_out(&self) -> Expr

source

pub fn separate_factors(&self, x: &Self) -> (Expr, Expr)

source

pub fn cancel(&self) -> Expr

source

pub fn substitude(&self, from: &Expr, to: &Expr) -> Self

source

pub fn seq_substitude<'a, T>(&self, subs: T) -> Self
where T: IntoIterator<Item = (&'a Expr, &'a Expr)>,

source

pub fn concurr_substitude<'a, T>(&self, subs: T) -> Self
where T: IntoIterator<Item = (&'a Expr, &'a Expr)> + Copy,

source

pub fn sort_args(&self) -> Self

source

pub fn try_for_each_compl_sub_expr<F>(&mut self, func: F)
where F: Fn(&mut Expr) -> ControlFlow<()> + Copy,

source

pub fn for_each_compl_sub_expr<F>(&mut self, func: F)
where F: Fn(&mut Expr) + Copy,

source§

impl Expr

source

const _UNDEF: LocalKey<Expr> = _

source

const _MINUS_TWO: LocalKey<Expr> = _

source

const _MINUS_ONE: LocalKey<Expr> = _

source

const _ZERO: LocalKey<Expr> = _

source

const _ONE: LocalKey<Expr> = _

source

const _TWO: LocalKey<Expr> = _

source

const _PI: LocalKey<Expr> = _

source

const _E: LocalKey<Expr> = _

source

fn from_atom(a: Atom) -> Expr

source

pub fn undef() -> Expr

source

pub fn min_two() -> Expr

source

pub fn min_one() -> Expr

source

pub fn zero() -> Expr

source

pub fn one() -> Expr

source

pub fn two() -> Expr

source

pub fn pi() -> Expr

source

pub fn e() -> Expr

source

pub fn var(str: &str) -> Expr

source

pub fn atom(&self) -> &Atom

source

pub fn atom_mut(&mut self) -> &mut Atom

source

pub fn rational<T: Into<Rational>>(r: T) -> Expr

source

pub fn cos(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_cos(e: impl Borrow<Expr>) -> Expr

source

pub fn sin(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_sin(e: impl Borrow<Expr>) -> Expr

source

pub fn tan(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_tan(e: impl Borrow<Expr>) -> Expr

source

pub fn sec(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_sec(e: impl Borrow<Expr>) -> Expr

source

pub fn cot(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_cot(e: impl Borrow<Expr>) -> Expr

source

pub fn csc(e: impl Borrow<Expr>) -> Expr

source

pub fn arc_csc(e: impl Borrow<Expr>) -> Expr

source

pub fn exp(e: impl Borrow<Expr>) -> Expr

source

pub fn log(base: impl Into<Real>, e: impl Borrow<Expr>) -> Expr

source

pub fn ln(e: impl Borrow<Expr>) -> Expr

source

pub fn log10(e: impl Borrow<Expr>) -> Expr

source

pub fn sqrt(v: impl Borrow<Expr>) -> Expr

source

pub fn as_monomial_view<'a>(&'a self, vars: &'a VarSet) -> MonomialView<'a>

source

pub fn as_polynomial_view<'a>(&'a self, vars: &'a VarSet) -> PolynomialView<'a>

source

pub fn numerator(&self) -> Expr

source

pub fn denominator(&self) -> Expr

source

pub fn base(&self) -> Expr

source

pub fn exponent(&self) -> Expr

source

pub fn is_exponential(&self) -> bool

source

pub fn is_trig(&self) -> bool

source

pub fn try_as_div(&self) -> Option<(Expr, Expr)>

source

pub fn rational_coeff(&self) -> Option<Rational>

source

pub fn non_rational_term(&self) -> Option<Expr>

source

pub fn variables(&self) -> HashSet<Expr, FxBuildHasher>

source

fn variables_impl(&self, vars: &mut HashSet<Expr, FxBuildHasher>)

source

pub fn free_of(&self, expr: &Expr) -> bool

source

pub fn free_of_set<'a, I: IntoIterator<Item = &'a Self>>( &'a self, exprs: I, ) -> bool

source

pub fn iter_compl_sub_exprs(&self) -> ExprIterator<'_>

source

pub fn flatten(&self) -> &Expr

source

fn cmp_slices(lhs: &[Self], rhs: &[Self]) -> Ordering

source

fn cost(&self) -> usize

Methods from Deref<Target = Atom>§

source

pub fn is_undef(&self) -> bool

Returns true if this value is of type Undef. Returns false otherwise

source

pub fn is_rational(&self) -> bool

Returns true if this value is of type Rational. Returns false otherwise

source

pub fn is_irrational(&self) -> bool

Returns true if this value is of type Irrational. Returns false otherwise

source

pub fn is_var(&self) -> bool

Returns true if this value is of type Var. Returns false otherwise

source

pub fn is_sum(&self) -> bool

Returns true if this value is of type Sum. Returns false otherwise

source

pub fn is_prod(&self) -> bool

Returns true if this value is of type Prod. Returns false otherwise

source

pub fn is_pow(&self) -> bool

Returns true if this value is of type Pow. Returns false otherwise

source

pub fn is_func(&self) -> bool

Returns true if this value is of type Func. Returns false otherwise

source

pub fn unwrap_undef_ref(&self)

Unwraps this reference to the Atom::Undef variant. Panics if this value is of any other type.

source

pub fn unwrap_rational_ref(&self) -> &Rational

Unwraps this reference to the Atom::Rational variant. Panics if this value is of any other type.

source

pub fn unwrap_irrational_ref(&self) -> &Irrational

Unwraps this reference to the Atom::Irrational variant. Panics if this value is of any other type.

source

pub fn unwrap_var_ref(&self) -> &Var

Unwraps this reference to the Atom::Var variant. Panics if this value is of any other type.

source

pub fn unwrap_sum_ref(&self) -> &Sum

Unwraps this reference to the Atom::Sum variant. Panics if this value is of any other type.

source

pub fn unwrap_prod_ref(&self) -> &Prod

Unwraps this reference to the Atom::Prod variant. Panics if this value is of any other type.

source

pub fn unwrap_pow_ref(&self) -> &Pow

Unwraps this reference to the Atom::Pow variant. Panics if this value is of any other type.

source

pub fn unwrap_func_ref(&self) -> &Func

Unwraps this reference to the Atom::Func variant. Panics if this value is of any other type.

source

pub fn try_unwrap_undef_ref(&self) -> Result<(), TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Undef variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_rational_ref( &self, ) -> Result<&Rational, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Rational variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_irrational_ref( &self, ) -> Result<&Irrational, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Irrational variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_var_ref(&self) -> Result<&Var, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Var variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_sum_ref(&self) -> Result<&Sum, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Sum variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_prod_ref(&self) -> Result<&Prod, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Prod variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_pow_ref(&self) -> Result<&Pow, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Pow variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub fn try_unwrap_func_ref(&self) -> Result<&Func, TryUnwrapError<&Self>>

Attempts to unwrap this reference to the Atom::Func variant. Returns a [TryUnwrapError] with the original value if this value is of any other type.

source

pub const UNDEF: Atom = Atom::Undef

source

pub const MINUS_TWO: Atom = _

source

pub const MINUS_ONE: Atom = _

source

pub const ZERO: Atom = _

source

pub const ONE: Atom = _

source

pub const TWO: Atom = _

source

pub const PI: Atom = _

source

pub const E: Atom = _

source

pub fn is_zero(&self) -> bool

source

pub fn is_one(&self) -> bool

source

pub fn is_min_one(&self) -> bool

source

pub fn is_pi(&self) -> bool

source

pub fn is_e(&self) -> bool

source

pub fn is_neg(&self) -> bool

source

pub fn is_pos(&self) -> bool

source

pub fn is_int(&self) -> bool

source

pub fn is_even(&self) -> bool

source

pub fn is_odd(&self) -> bool

source

pub fn is_number(&self) -> bool

source

pub fn is_real(&self) -> bool

source

pub fn is_irreducible(&self) -> bool

source

pub fn is_rational_and(&self, cond: impl Fn(&Rational) -> bool) -> bool

source

pub fn is_const(&self) -> bool

source

pub fn is_sin(&self) -> bool

source

pub fn is_cos(&self) -> bool

source

pub fn try_unwrap_int(&self) -> Option<i128>

source

pub fn unwrap_int(&self) -> i128

source

pub fn try_as_real(&self) -> Option<Real>

source

pub fn for_each_arg<'a>(&'a self, func: impl FnMut(&'a Expr))

source

pub fn fmt_ast(&self) -> FmtAtom

Trait Implementations§

source§

impl<T: Borrow<Expr>> Add<T> for &Expr

source§

type Output = Expr

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Borrow<Expr>> Add<T> for Expr

source§

type Output = Expr

The resulting type after applying the + operator.
source§

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

Performs the + operation. Read more
source§

impl<T: Borrow<Expr>> AddAssign<T> for Expr

source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
source§

impl Clone for Expr

source§

fn clone(&self) -> Expr

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 Debug for Expr

source§

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

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

impl Deref for Expr

source§

type Target = Atom

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'de> Deserialize<'de> for Expr

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Expr

source§

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

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

impl<T: Borrow<Expr>> Div<T> for &Expr

source§

type Output = Expr

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Borrow<Expr>> Div<T> for Expr

source§

type Output = Expr

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<T: Borrow<Expr>> DivAssign<T> for Expr

source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
source§

impl From<Expr> for VarSet

source§

fn from(value: Expr) -> Self

Converts to this type from the input type.
source§

impl From<Expr> for WlfrmAtom

source§

fn from(value: Expr) -> Self

Converts to this type from the input type.
source§

impl<T: Into<Atom>> From<T> for Expr

source§

fn from(atom: T) -> Self

Converts to this type from the input type.
source§

impl Hash for Expr

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<T: Borrow<Expr>> Mul<T> for &Expr

source§

type Output = Expr

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Borrow<Expr>> Mul<T> for Expr

source§

type Output = Expr

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<T: Borrow<Expr>> MulAssign<T> for Expr

source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
source§

impl Ord for Expr

source§

fn cmp(&self, other: &Self) -> 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 PartialEq for Expr

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 PartialOrd for Expr

source§

fn partial_cmp(&self, other: &Self) -> 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

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

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

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

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

impl Serialize for Expr

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<T: Borrow<Expr>> Sub<T> for &Expr

source§

type Output = Expr

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Borrow<Expr>> Sub<T> for Expr

source§

type Output = Expr

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl<T: Borrow<Expr>> SubAssign<T> for Expr

source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
source§

impl SymbolicExpr for Expr

source§

fn reduce(&self) -> Self

basic simplification that can be applied regardless of context Read more
source§

fn args(&self) -> &[Expr]

source§

fn args_mut(&mut self) -> &mut [Expr]

source§

fn is_atom(&self) -> bool

source§

fn n_args(&self) -> usize

source§

fn iter_args(&self) -> impl Iterator<Item = &Expr>

source§

fn map_args(self, map_fn: impl Fn(&mut Expr)) -> Self

source§

impl Eq for Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl !Send for Expr

§

impl !Sync for Expr

§

impl Unpin for Expr

§

impl UnwindSafe for Expr

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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§

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

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,