diff --git a/src/generic/Residue.jl b/src/generic/Residue.jl index 051ff73f19..d9ff8ae663 100644 --- a/src/generic/Residue.jl +++ b/src/generic/Residue.jl @@ -151,7 +151,7 @@ euclid(n::EuclideanRingResidueRingElem) = degree(gcd(data(n), modulus(n))) #horrible - and copied from fmpz_mod #don't know how to seriously simplify it -#maybe a durect gcdx should be added as well +#maybe a direct gcdx should be added as well function Base.divrem(n::T, m::T) where {T <: EuclideanRingResidueRingElem} @assert !iszero(m) R = parent(n) @@ -199,3 +199,12 @@ function Base.divrem(n::T, m::T) where {T <: EuclideanRingResidueRingElem} return (qq,rr)::Tuple{T, T} end +#copied from fmpz_mod +function gcdx(a::T, b::T) where {T <: EuclideanRingResidueRingElem} + m = modulus(a) + R = parent(a) + g, u, v = gcdx(data(a), data(b)) + G, U, V = gcdx(g, m) + return R(G), R(U)*R(u), R(U)*R(v) +end +