Struct calcu_rs::rational::Rational

source ·
pub struct Rational(pub(crate) Rational);

Tuple Fields§

§0: Rational

Implementations§

source§

impl Rational

source

pub const MINUS_TWO: Self = _

source

pub const MINUS_ONE: Self = _

source

pub const ZERO: Self = _

source

pub const ONE: Self = _

source

pub const TWO: Self = _

source

pub const fn new_int(n: i64) -> Self

source

pub fn numer(&self) -> Int

source

pub fn to_int(&self) -> Option<Int>

source

pub fn denom(&self) -> Int

source

pub fn is_zero(&self) -> bool

source

pub fn is_one(&self) -> bool

source

pub fn is_pos(&self) -> bool

source

pub fn is_neg(&self) -> bool

source

pub fn is_int(&self) -> bool

source

pub fn inverse(self) -> Option<Self>

none if self is zero

source

pub fn abs(self) -> Self

source

pub fn div_rem(&self) -> (Self, Self)

source

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

source

pub fn pow_basic(self, rhs: Self) -> Option<Self>

Trait Implementations§

source§

impl Add<&Rational> for Rational

§

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

§

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<&Rational> for Rational

source§

fn add_assign(&mut self, rhs: &Self)

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

source§

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

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

impl Default for Rational

source§

fn default() -> Rational

Returns the “default value” for a type. Read more
source§

impl Display for Rational

source§

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

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

impl Div<&Rational> for Rational

§

type Output = Option<Rational>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl Div for Rational

§

type Output = Option<Rational>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl From<(i64, i64)> for Rational

source§

fn from(value: (i64, i64)) -> Self

Converts to this type from the input type.
source§

impl From<(u64, u64)> for Rational

source§

fn from(value: (u64, u64)) -> Self

Converts to this type from the input type.
source§

impl From<Int> for Rational

source§

fn from(value: Int) -> Self

Converts to this type from the input type.
source§

impl From<Integer> for Rational

source§

fn from(value: Integer) -> Self

Converts to this type from the input type.
source§

impl From<Rational> for Real

source§

fn from(value: Rational) -> Self

Converts to this type from the input type.
source§

impl From<i32> for Rational

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl From<i64> for Rational

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl From<u128> for Rational

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl Hash for Rational

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 Mul<&Rational> for Rational

§

type Output = Rational

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl Mul for Rational

§

type Output = Rational

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl MulAssign<&Rational> for Rational

source§

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

Performs the *= operation. Read more
source§

impl MulAssign for Rational

source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
source§

impl Ord for Rational

source§

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

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Rational

source§

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

This method 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

This method 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

This method 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

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

impl Sub<&Rational> for Rational

§

type Output = Rational

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl Sub for Rational

§

type Output = Rational

The resulting type after applying the - operator.
source§

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

Performs the - operation. Read more
source§

impl SubAssign<&Rational> for Rational

source§

fn sub_assign(&mut self, rhs: &Self)

Performs the -= operation. Read more
source§

impl SubAssign for Rational

source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
source§

impl TryFrom<Rational> for Int

§

type Error = ()

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

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

Performs the conversion.
source§

impl Eq for Rational

source§

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

default 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
§

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

§

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

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

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

§

fn exact_from(value: T) -> U

§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

§

fn exact_into(self) -> U

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
§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

§

fn overflowing_into(self) -> (U, bool)

§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

§

fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)

§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

§

fn saturating_into(self) -> U

§

impl<T> ToDebugString for T
where T: Debug,

§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

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

§

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

§

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

§

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.
§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

§

fn wrapping_into(self) -> U