pub struct Rational(pub(crate) Ratio<Int>);
Tuple Fields§
§0: Ratio<Int>
Implementations§
source§impl Rational
impl Rational
pub const MINUS_TWO: Self = _
pub const MINUS_ONE: Self = _
pub const ZERO: Self = _
pub const ONE: Self = _
pub const TWO: Self = _
const fn new_raw(n: Int, d: Int) -> Self
pub fn new(n: impl Into<Int>, d: impl Into<Int>) -> Self
pub const fn new_int(n: Int) -> Self
pub const fn numer(&self) -> Int
pub fn to_int(&self) -> Option<Int>
pub fn f64_approx(&self) -> f64
pub const fn denom(&self) -> Int
pub fn is_min_two(&self) -> bool
pub fn is_min_one(&self) -> bool
pub fn is_zero(&self) -> bool
pub fn is_one(&self) -> bool
pub fn is_two(&self) -> bool
pub fn is_pos(&self) -> bool
pub fn is_neg(&self) -> bool
pub fn is_int(&self) -> bool
pub fn is_fraction(&self) -> bool
pub fn is_even(&self) -> bool
pub fn is_odd(&self) -> bool
pub fn abs(self) -> Self
pub fn floor(self) -> Int
pub fn div_rem(&self) -> (Self, Self)
sourcepub fn pow(self, rhs: Self) -> (Self, Self)
pub fn pow(self, rhs: Self) -> (Self, Self)
will calculate self to the power of an integer number.
if the exponent is (a/b) non-int: we calculate the power to the int quotient of a/b and return the remainder: (self^quot, rem).
n^(a/b) = n^(quot + rem) = n^(quot) * n^(rem) -> (n^quot, rem)
quot: Int, rest: Fraction, n^(quot): Rational
returns the input if calculation was not possible
pub fn pow_basic(self, rhs: Self) -> Option<Self>
pub fn int_gcd(&self, rhs: &Self) -> Option<Rational>
Trait Implementations§
source§impl AddAssign<&Rational> for Rational
impl AddAssign<&Rational> for Rational
source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Performs the
+=
operation. Read moresource§impl AddAssign for Rational
impl AddAssign for Rational
source§fn add_assign(&mut self, rhs: Rational)
fn add_assign(&mut self, rhs: Rational)
Performs the
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Rational
impl<'de> Deserialize<'de> for Rational
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 DivAssign<&Rational> for Rational
impl DivAssign<&Rational> for Rational
source§fn div_assign(&mut self, rhs: &Self)
fn div_assign(&mut self, rhs: &Self)
Performs the
/=
operation. Read moresource§impl DivAssign for Rational
impl DivAssign for Rational
source§fn div_assign(&mut self, rhs: Rational)
fn div_assign(&mut self, rhs: Rational)
Performs the
/=
operation. Read moresource§impl MulAssign<&Rational> for Rational
impl MulAssign<&Rational> for Rational
source§fn mul_assign(&mut self, rhs: &Self)
fn mul_assign(&mut self, rhs: &Self)
Performs the
*=
operation. Read moresource§impl MulAssign for Rational
impl MulAssign for Rational
source§fn mul_assign(&mut self, rhs: Rational)
fn mul_assign(&mut self, rhs: Rational)
Performs the
*=
operation. Read moresource§impl Ord for Rational
impl Ord for Rational
source§impl PartialOrd for Rational
impl PartialOrd for Rational
source§impl SubAssign<&Rational> for Rational
impl SubAssign<&Rational> for Rational
source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
Performs the
-=
operation. Read moresource§impl SubAssign for Rational
impl SubAssign for Rational
source§fn sub_assign(&mut self, rhs: Rational)
fn sub_assign(&mut self, rhs: Rational)
Performs the
-=
operation. Read moresource§impl SymbolicExpr for Rational
impl SymbolicExpr for Rational
source§fn reduce(&self) -> Expr
fn reduce(&self) -> Expr
basic simplification that can be applied regardless of context Read more
fn is_atom(&self) -> bool
fn n_args(&self) -> usize
fn args(&self) -> &[Expr]
fn args_mut(&mut self) -> &mut [Expr]
fn iter_args(&self) -> impl Iterator<Item = &Expr>
fn map_args(self, map_fn: impl Fn(&mut Expr)) -> Self
impl Copy for Rational
impl Eq for Rational
impl StructuralPartialEq for Rational
Auto Trait Implementations§
impl Freeze for Rational
impl RefUnwindSafe for Rational
impl Send for Rational
impl Sync for Rational
impl Unpin for Rational
impl UnwindSafe for Rational
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)