[][src]Trait typenum::type_operators::Gcd

pub trait Gcd<Rhs> {
    type Output;
}

A type operator that computes the greatest common divisor of Self and Rhs.

Example

use typenum::{Gcd, U12, U8, Unsigned};

assert_eq!(<U12 as Gcd<U8>>::Output::to_i32(), 4);

Associated Types

type Output

The greatest common divisor.

Loading content...

Implementors

impl Gcd<Z0> for Z0[src]

type Output = Z0

impl Gcd<UTerm> for U0[src]

gcd(0, 0) = 0

type Output = U0

impl<U> Gcd<NInt<U>> for Z0 where
    U: Unsigned + NonZero
[src]

type Output = PInt<U>

impl<U> Gcd<PInt<U>> for Z0 where
    U: Unsigned + NonZero
[src]

type Output = PInt<U>

impl<U> Gcd<Z0> for PInt<U> where
    U: Unsigned + NonZero
[src]

type Output = PInt<U>

impl<U> Gcd<Z0> for NInt<U> where
    U: Unsigned + NonZero
[src]

type Output = PInt<U>

impl<U1, U2> Gcd<NInt<U2>> for NInt<U1> where
    U1: Unsigned + NonZero + Gcd<U2>,
    U2: Unsigned + NonZero,
    Gcf<U1, U2>: Unsigned + NonZero
[src]

type Output = PInt<Gcf<U1, U2>>

impl<U1, U2> Gcd<NInt<U2>> for PInt<U1> where
    U1: Unsigned + NonZero + Gcd<U2>,
    U2: Unsigned + NonZero,
    Gcf<U1, U2>: Unsigned + NonZero
[src]

type Output = PInt<Gcf<U1, U2>>

impl<U1, U2> Gcd<PInt<U2>> for NInt<U1> where
    U1: Unsigned + NonZero + Gcd<U2>,
    U2: Unsigned + NonZero,
    Gcf<U1, U2>: Unsigned + NonZero
[src]

type Output = PInt<Gcf<U1, U2>>

impl<U1, U2> Gcd<PInt<U2>> for PInt<U1> where
    U1: Unsigned + NonZero + Gcd<U2>,
    U2: Unsigned + NonZero,
    Gcf<U1, U2>: Unsigned + NonZero
[src]

type Output = PInt<Gcf<U1, U2>>

impl<X> Gcd<UTerm> for X where
    X: Unsigned + NonZero
[src]

gcd(x, 0) = x

type Output = X

impl<Xp, Yp> Gcd<UInt<Yp, B0>> for UInt<Xp, B0> where
    Xp: Gcd<Yp>,
    UInt<Xp, B0>: NonZero,
    UInt<Yp, B0>: NonZero
[src]

gcd(x, y) = 2*gcd(x/2, y/2) if both x and y even

type Output = UInt<Gcf<Xp, Yp>, B0>

impl<Xp, Yp> Gcd<UInt<Yp, B0>> for UInt<Xp, B1> where
    UInt<Xp, B1>: Gcd<Yp>,
    UInt<Yp, B0>: NonZero
[src]

gcd(x, y) = gcd(x, y/2) if x odd and y even

type Output = Gcf<UInt<Xp, B1>, Yp>

impl<Xp, Yp> Gcd<UInt<Yp, B1>> for UInt<Xp, B0> where
    Xp: Gcd<UInt<Yp, B1>>,
    UInt<Xp, B0>: NonZero
[src]

gcd(x, y) = gcd(x/2, y) if x even and y odd

type Output = Gcf<Xp, UInt<Yp, B1>>

impl<Xp, Yp> Gcd<UInt<Yp, B1>> for UInt<Xp, B1> where
    UInt<Xp, B1>: Max<UInt<Yp, B1>> + Min<UInt<Yp, B1>>,
    UInt<Yp, B1>: Max<UInt<Xp, B1>> + Min<UInt<Xp, B1>>,
    Maximum<UInt<Xp, B1>, UInt<Yp, B1>>: Sub<Minimum<UInt<Xp, B1>, UInt<Yp, B1>>>,
    Diff<Maximum<UInt<Xp, B1>, UInt<Yp, B1>>, Minimum<UInt<Xp, B1>, UInt<Yp, B1>>>: Gcd<Minimum<UInt<Xp, B1>, UInt<Yp, B1>>>, 
[src]

gcd(x, y) = gcd([max(x, y) - min(x, y)], min(x, y)) if both x and y odd

This will immediately invoke the case for x even and y odd because the difference of two odd numbers is an even number.

type Output = Gcf<Diff<Maximum<UInt<Xp, B1>, UInt<Yp, B1>>, Minimum<UInt<Xp, B1>, UInt<Yp, B1>>>, Minimum<UInt<Xp, B1>, UInt<Yp, B1>>>

impl<Y> Gcd<Y> for U0 where
    Y: Unsigned + NonZero
[src]

gcd(0, y) = y

type Output = Y

Loading content...