Trait dashu::integer::ops::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

§

type OutputGcd = u8

§

type OutputCoeff = i8

source§

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

source§

impl ExtendedGcd for u16

§

type OutputGcd = u16

§

type OutputCoeff = i16

source§

fn gcd_ext(self, rhs: u16) -> (u16, i16, i16)

source§

impl ExtendedGcd for u32

§

type OutputGcd = u32

§

type OutputCoeff = i32

source§

fn gcd_ext(self, rhs: u32) -> (u32, i32, i32)

source§

impl ExtendedGcd for u64

§

type OutputGcd = u64

§

type OutputCoeff = i64

source§

fn gcd_ext(self, rhs: u64) -> (u64, i64, i64)

source§

impl ExtendedGcd for u128

§

type OutputGcd = u128

§

type OutputCoeff = i128

source§

fn gcd_ext(self, rhs: u128) -> (u128, i128, i128)

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