Rational

Struct Rational 

Source
pub struct Rational {
    pub num: isize,
    pub denom: isize,
}

Fields§

§num: isize§denom: isize

Implementations§

Source§

impl Rational

Source

pub fn new(num: isize, denom: isize) -> Self

Source

pub fn new_box(num: isize, denom: isize) -> Box<dyn Expr>

Source

pub fn one() -> Self

Source

pub fn zero() -> Self

Source

pub fn invert(&mut self)

Source§

impl Rational

Source

pub fn from_float<N: Float + ToString>(value: N) -> Rational

Trait Implementations§

Source§

impl Add<&Integer> for &Rational

Source§

type Output = Box<dyn Expr>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<&Rational> for &Integer

Source§

type Output = Box<dyn Expr>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for &Rational

Source§

type Output = Rational

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for Rational

Source§

type Output = Rational

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl AddAssign for Rational

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl Clone for Rational

Source§

fn clone(&self) -> Rational

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 Rational

Source§

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

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

impl Div for Rational

Source§

type Output = Rational

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl DivAssign<&Rational> for Rational

Source§

fn div_assign(&mut self, rhs: &Rational)

Performs the /= operation. Read more
Source§

impl DivAssign for Rational

Source§

fn div_assign(&mut self, rhs: Rational)

Performs the /= operation. Read more
Source§

impl Expr for Rational

Source§

fn known_expr(&self) -> KnownExpr<'_>

Source§

fn for_each_arg(&self, f: &mut dyn FnMut(&dyn Arg))

Source§

fn from_args(&self, args: Vec<Box<dyn Arg>>) -> Box<dyn Expr>

Source§

fn clone_box(&self) -> Box<dyn Expr>

Source§

fn str(&self) -> String

Source§

fn to_cpp(&self) -> String

Source§

fn get_ref<'a>(&'a self) -> &'a dyn Expr

Source§

fn is_one(&self) -> bool

Source§

fn is_zero(&self) -> bool

Source§

fn is_neg_one(&self) -> bool

Source§

fn is_number(&self) -> bool

Source§

fn is_negative_number(&self) -> bool

Source§

fn as_f64(&self) -> Option<f64>

Source§

fn simplify(&self) -> Box<dyn Expr>

Source§

fn as_expr(&self) -> Option<Box<dyn Expr>>

Source§

fn args(&self) -> Vec<Box<dyn Arg>>

Source§

fn args_map_exprs( &self, _f: &dyn Fn(&dyn Expr) -> Box<dyn Arg>, ) -> Vec<Box<dyn Arg>>

Source§

fn as_arg(&self) -> Box<dyn Arg>

Source§

fn as_function(&self) -> Option<&Func>

Source§

fn equals(&self, other: &dyn Expr) -> bool

Source§

fn as_symbol(&self) -> Option<Symbol>

Source§

fn as_eq(&self) -> Option<Equation>

Source§

fn as_mul(&self) -> Option<&Mul>

Source§

fn as_pow(&self) -> Option<&Pow>

Source§

fn simplify_with_dimension(&self, dim: usize) -> Box<dyn Expr>

Source§

fn as_int(&self) -> Option<Integer>

Source§

fn pow(&self, exponent: &Box<dyn Expr>) -> Box<dyn Expr>

Source§

fn ipow(&self, exponent: isize) -> Box<dyn Expr>

Source§

fn sqrt(&self) -> Box<dyn Expr>

Source§

fn get_exponent(&self) -> (Box<dyn Expr>, Box<dyn Expr>)

Source§

fn diff(&self, var: &str, order: usize) -> Box<dyn Expr>

Source§

fn name(&self) -> String

Source§

fn subs(&self, substitutions: &[[Box<dyn Expr>; 2]]) -> Box<dyn Expr>

Source§

fn has(&self, expr: &dyn Expr) -> bool

Source§

fn has_box(&self, expr: Box<dyn Expr>) -> bool

Source§

fn expand(&self) -> Box<dyn Expr>

Expands an expression. For example: (x + y) * z -> xz + yz
Source§

fn factor(&self, factors: &[&dyn Expr]) -> Box<dyn Expr>

Factorizes an expression For example: factor(ax + cx + zy, [x]) -> (a + c)x + zy
Source§

fn terms<'a>(&'a self) -> Box<dyn Iterator<Item = &'a dyn Expr> + 'a>

Source§

fn get_coeff(&self) -> (Rational, Box<dyn Expr>)

Source§

fn compare(&self, other: &dyn Expr) -> Option<Ordering>

Source§

fn evaluate(&self, vars: Option<HashMap<Symbol, BoxExpr>>) -> BoxExpr

Source§

impl From<&Rational> for (Rational, Box<dyn Expr>)

Source§

fn from(r: &Rational) -> Self

Converts to this type from the input type.
Source§

impl From<&Rational> for f64

Source§

fn from(_: &Rational) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Rational

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl<N: ToInteger> From<N> for Rational

Source§

fn from(value: N) -> Self

Converts to this type from the input type.
Source§

impl From<Rational> for f64

Source§

fn from(_: Rational) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Rational

Source§

type Err = ParseRationalError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

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

impl<I: ToPrimitive> Mul<I> for Rational

Source§

type Output = Rational

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for Rational

Source§

type Output = Rational

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<I: ToPrimitive> MulAssign<&I> for Rational

Source§

fn mul_assign(&mut self, rhs: &I)

Performs the *= operation. Read more
Source§

impl MulAssign<&Rational> for Rational

Source§

fn mul_assign(&mut self, rhs: &Rational)

Performs the *= operation. Read more
Source§

impl Neg for &Rational

Source§

type Output = Rational

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Ord for Rational

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,

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

impl<T: Copy + Into<Rational>> PartialEq<T> for Rational

Source§

fn eq(&self, other: &T) -> 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<T: Copy + Into<Rational>> PartialOrd<T> for Rational

Source§

fn partial_cmp(&self, other: &T) -> 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<N: NumCast> Sub<N> for Rational

Source§

type Output = Box<dyn Expr>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for Rational

Source§

type Output = Rational

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Copy for Rational

Source§

impl Eq for Rational

Auto Trait Implementations§

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> Arg for T
where T: Expr,

Source§

fn srepr(&self) -> String

Source§

fn clone_arg(&self) -> Box<dyn Arg>

Source§

fn as_expr(&self) -> Option<Box<dyn Expr>>

Source§

fn map_expr(&self, f: &dyn Fn(&dyn Expr) -> Box<dyn Expr>) -> Box<dyn Arg>

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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ExprOperations for T
where T: Expr,

Source§

fn subs_refs<'a, Iter: IntoIterator<Item = [&'a dyn Expr; 2]>>( &self, substitutions: Iter, ) -> Box<dyn Expr>
where Self: Expr,

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, 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<A> ArgOperations for A
where A: Arg,