Skip to content

Commit

Permalink
add gcdx
Browse files Browse the repository at this point in the history
  • Loading branch information
fieker committed Dec 5, 2024
1 parent 49b9905 commit cad3977
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/generic/Residue.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

0 comments on commit cad3977

Please sign in to comment.