Trait ExtendedGcd

Source
pub trait ExtendedGcd<Rhs = Self> {
    type OutputGcd;
    type OutputCoeff;

    // Required method
    fn gcd_ext(
        self,
        rhs: Rhs,
    ) -> (Self::OutputGcd, Self::OutputCoeff, Self::OutputCoeff);
}
Expand description

Compute the greatest common divisor between self and the other operand, and return both the common divisor g and the Bézout coefficients respectively.

For negative integers, the common divisor is still kept positive.

§Examples

use dashu_base::{Gcd, ExtendedGcd};
let (g, cx, cy) = 12u8.gcd_ext(10u8);
assert_eq!(g, 12u8.gcd(10u8));
assert_eq!(g as i8, 12 * cx + 10 * cy);

§Panics

Panics if both operands are zeros

Required Associated Types§

Required Methods§

Source

fn gcd_ext( self, rhs: Rhs, ) -> (Self::OutputGcd, Self::OutputCoeff, Self::OutputCoeff)

Calculate the greatest common divisor between the two operands, returns the common divisor g and the Bézout coefficients respectively.

Panics if both operands are zeros

Implementations on Foreign Types§

Source§

impl ExtendedGcd for u8

Source§

type OutputGcd = u8

Source§

type OutputCoeff = i8

Source§

fn gcd_ext(self, rhs: u8) -> (u8, i8, i8)

Source§

impl ExtendedGcd for u16

Source§

impl ExtendedGcd for u32

Source§

impl ExtendedGcd for u64

Source§

impl ExtendedGcd for u128

Source§

impl ExtendedGcd for usize

Implementors§

Source§

impl ExtendedGcd for IBig

Source§

impl ExtendedGcd for UBig

Source§

impl ExtendedGcd<IBig> for UBig

Source§

impl ExtendedGcd<UBig> for IBig

Source§

impl<'l> ExtendedGcd<IBig> for &'l IBig

Source§

impl<'l> ExtendedGcd<IBig> for &'l UBig

Source§

impl<'l> ExtendedGcd<UBig> for &'l IBig

Source§

impl<'l> ExtendedGcd<UBig> for &'l UBig

Source§

impl<'l, 'r> ExtendedGcd<&'r IBig> for &'l IBig

Source§

impl<'l, 'r> ExtendedGcd<&'r IBig> for &'l UBig

Source§

impl<'l, 'r> ExtendedGcd<&'r UBig> for &'l IBig

Source§

impl<'l, 'r> ExtendedGcd<&'r UBig> for &'l UBig

Source§

impl<'r> ExtendedGcd<&'r IBig> for IBig

Source§

impl<'r> ExtendedGcd<&'r IBig> for UBig

Source§

impl<'r> ExtendedGcd<&'r UBig> for IBig

Source§

impl<'r> ExtendedGcd<&'r UBig> for UBig