Struct cycle::Rational[][src]

pub struct Rational { /* fields omitted */ }

Implementations

impl Rational[src]

pub const fn new(num: Integer, den: Integer) -> Rational[src]

pub fn zero() -> Rational[src]

pub fn one() -> Rational[src]

pub fn trunc(&self) -> Rational[src]

pub fn fract(&self) -> Rational[src]

pub fn is_positive(&self) -> bool[src]

pub fn is_negative(&self) -> bool[src]

Trait Implementations

impl Add<Rational> for Rational[src]

type Output = Rational

The resulting type after applying the + operator.

fn add(self, o: Self) -> Self::Output[src]

a/b + c/d = (a*lcm/b + c*lcm/d)/lcm where lcm = lcm(b,d)

impl Clone for Rational[src]

impl Copy for Rational[src]

impl Debug for Rational[src]

impl Div<Rational> for Rational[src]

type Output = Rational

The resulting type after applying the / operator.

fn div(self, o: Self) -> Self::Output[src]

a/b / c/d = (a/gcd_ac)*(d/gcd_bd) / ((c/gcd_ac)*(b/gcd_bd))

impl Domain for Rational[src]

fn gcd(u: &Self, v: &Self) -> Self[src]

gcd(a/b, c/d) = gcd(a*d, c*b)/(b*d)

fn lcm(u: &Self, v: &Self) -> Self[src]

lcm(a/b, c/d) = lcm(a, c)/gcd(b, d)

impl Eq for Rational[src]

impl Field for Rational[src]

impl From<i128> for Rational[src]

impl Hash for Rational[src]

impl Mul<Rational> for Rational[src]

type Output = Rational

The resulting type after applying the * operator.

fn mul(self, o: Self) -> Self::Output[src]

a/b * c/d = (a/gcd_ad)*(c/gcd_bc) / ((d/gcd_ad)*(b/gcd_bc))

impl Neg for Rational[src]

type Output = Rational

The resulting type after applying the - operator.

impl Ord for Rational[src]

impl PartialEq<Rational> for Rational[src]

impl PartialOrd<Rational> for Rational[src]

impl Ring for Rational[src]

impl Sub<Rational> for Rational[src]

type Output = Rational

The resulting type after applying the - operator.

fn sub(self, o: Self) -> Self::Output[src]

a/b - c/d = (lcm/b*a - lcm/d*c)/lcm, where lcm = lcm(b,d)

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.