Expr

Enum Expr 

Source
pub enum Expr {
    Val(Rc<F>),
    Const(Rc<Const>),
    Sum(Rc<Sum>),
    Prod(Rc<Prod>),
    Sqrt(Rc<Sqrt>),
}
Expand description

Expression using Rc This type does not know if there are duplicates use like: let half = F::new(1u8,2u8); // <- for convenience let val_1 = Expr::from(1u32); let val_5 = Expr::from(5u32); let sqrt_5 = Expr::sqrt(val_5); let phi = Expr::from( vec![(half,val_1),(half,sqrt_5)] ) let phi_sq = Expr::from( vec![(F::new(3u8,2u8),val_1),(half,sqrt_5)] ) to be sure that sqrt_5 is shared among phi and phi_sq

Variants§

§

Val(Rc<F>)

Just a number Needs to be there, since sqrt(2)*sqrt(2) = 2

§

Const(Rc<Const>)

Constant like pi

§

Sum(Rc<Sum>)

Sum of terms Note that

§

Prod(Rc<Prod>)

Product of factors Notice that e.g. 2pi is already a product

§

Sqrt(Rc<Sqrt>)

Implementations§

Source§

impl Expr

Source

pub fn nan() -> Expr

Source

pub fn infinity() -> Expr

Source

pub fn neg_infinity() -> Expr

Source

pub fn val_i<T>(i: T) -> Expr
where F: From<T>,

Source

pub fn val_frac(f: F) -> Expr

Source

pub fn c_pi() -> Expr

Source

pub fn c_e() -> Expr

Source

pub fn sqrt_i(i: u32) -> Expr

Source

pub fn sqrt_frac(f: F) -> Expr

Source

pub fn sqrt_expr(expr: Expr) -> Expr

Source

pub fn sum_i_pi(i: u32) -> Expr

Source

pub fn sum_i_expr(i: u32, e: Expr) -> Expr

Source

pub fn sum_i_plus_pi(i: u32) -> Expr

Source

pub fn sum_phi() -> Expr

the golden ratio: (1+sqrt(5))/2 = 1/2+1/2sqrt(5)

Source

pub fn prod_pi_i(i: u32) -> Expr

Source

pub fn prod_pi_times_sqrt_i(i: u32) -> Expr

Trait Implementations§

Source§

impl Add for Expr

Source§

type Output = Expr

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Char for Expr

Const -> Name of an Expr variant. Should return char Val -> ξ Const -> Sum -> Σ Prod -> Π Sqrt -> √ For sin, cos, tan, they are a clock based on this triangle: Cos Sin Tan


| / /| /| |-/ / | / | |/ /_| /_| Cos Sin Tan |/ /| _| 🕑 🕢 🕘 Sin -> 🕢 Cos -> 🕑 Tan -> 🕘

Source§

fn ch(&self) -> char

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Expr

Source§

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

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

impl Display for Expr

Representation. Should return a string that results in the same value e.g. assert_eq!(exact::from(format!(“{}”,some_exact), some_exact) For example: 1/2+1/2√(5/2) -> Σ((1/2,ξ1),(1/2,√5/2)) Note that currently constants loose precision e.g. Const{ch: ‘π’, f64: std::consts::f64::PI} -> π Except that bla

Source§

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

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

impl From<(char, f64)> for Expr

from const tuple

Source§

fn from(value: (char, f64)) -> Self

Converts to this type from the input type.
Source§

impl From<GenericFraction<u32>> for Expr

Source§

fn from(value: F) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<(Expr, GenericFraction<u32>)>> for Expr

From a prod-type vector: PVec Also simplifies Contained products should already be simplified

Source§

fn from(v: PVec) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<(GenericFraction<u32>, Expr)>> for Expr

From a sum-type vector: Vec<(F, Expr)>

Source§

fn from(value: Vec<(F, Expr)>) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Expr

If we can convert to fraction, it’s a numeral

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl FromRaw<Vec<(Expr, GenericFraction<u32>)>> for Expr

Source§

fn from_raw(v: PVec) -> Self

Converts to this type from the input type.
Source§

impl FromRaw<Vec<(GenericFraction<u32>, Expr)>> for Expr

Source§

fn from_raw(terms: SVec) -> Self

Converts to this type from the input type.
Source§

impl GetExpr for Expr

Get the expression of a functional expression, such as Sqrt, Sin, Cos, Tan Currently only sqrt. √5/2 -> ξ5/2 Expr::Sqrt(Rc<Sqrt(expr)>) -> expr

Source§

impl Inv for Expr

Source§

type Output = Expr

The result after applying the operator.
Source§

fn inv(self) -> Self::Output

Returns the multiplicative inverse of self. Read more
Source§

impl Mul for Expr

Source§

type Output = Expr

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl MulAssign for Expr

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl One for Expr

Source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

impl ParseDisplay for Expr

Source§

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> 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 TryFrom<&str> for Expr

Source§

type Error = Error

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

fn try_from(value: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<String> for Expr

Source§

type Error = Error

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

fn try_from(value: String) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Zero for Expr

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

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