Trait dashu_base::ring::ExtendedGcd
source · [−]pub trait ExtendedGcd<Rhs = Self> {
type OutputGcd;
type OutputCoeff;
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.
Example
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 two oprands are both zero.
Required Associated Types
type OutputCoeff
Required Methods
fn 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 and the Bézout coefficients respectively.