Trait dashu_int::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§
type OutputGcd
type OutputCoeff
Required Methods§
sourcefn gcd_ext(
self,
rhs: Rhs
) -> (Self::OutputGcd, Self::OutputCoeff, Self::OutputCoeff)
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