From c397c1eb193fe483e57800d69a0038eb99718903 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 24 Aug 2023 01:43:37 +0200 Subject: [PATCH] Remove gcd and gcdx for Rational{<:Integer} These are already provided by Julia --- src/julia/Rational.jl | 36 ------------------------------------ 1 file changed, 36 deletions(-) diff --git a/src/julia/Rational.jl b/src/julia/Rational.jl index a3f1c62357..eff7b65e69 100644 --- a/src/julia/Rational.jl +++ b/src/julia/Rational.jl @@ -126,42 +126,6 @@ function divides(a::T, b::T) where T <: Rational end end -############################################################################### -# -# GCD -# -############################################################################### - -function gcd(p::Rational{T}, q::Rational{T}) where T <: Integer - a = p.num*q.den - b = p.den*q.num - n = gcd(a, b) - d = p.den*q.den - if d != 1 && n != 0 - g = gcd(n, d) - n = divexact(n, g) - d = divexact(d, g) - end - if n == 0 - return Rational{T}(n, T(1)) - else - return Rational{T}(n, d) - end -end - -function gcdx(p::Rational{T}, q::Rational{T}) where {T <: Integer} - g = gcd(p, q) - if !iszero(p) - return (g, g//p, zero(q)) - elseif !iszero(q) - return (g, zero(p), g//q) - else - @assert iszero(g) - return (g, zero(p), zero(p)) - end -end - - ############################################################################### # # Square root