ExtendedGcd

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§