Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some bad add! dispatches #1796

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "AbstractAlgebra"
uuid = "c3fe647b-3220-5bb0-a1ea-a7954cac585d"
version = "0.43.0"
version = "0.43.1"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Expand Down
52 changes: 0 additions & 52 deletions src/Fraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -831,58 +831,6 @@ function mul!(c::FracElem{T}, a::FracElem{T}, b::FracElem{T}) where {T <: RingEl
return c
end

function add!(a::FracElem{T}, b::FracElem{T}) where {T <: RingElem}
d1 = denominator(a, false)
d2 = denominator(b, false)
n1 = numerator(a, false)
n2 = numerator(b, false)
if d1 == d2
a.num = add!(a.num, b.num)
if !isone(d1)
gd = gcd(a.num, d1)
if !isone(gd)
a.num = divexact(a.num, gd)
a.den = divexact(d1, gd)
end
end
elseif isone(d1)
if n1 !== n2
a.num = mul!(a.num, a.num, d2)
a.num = add!(a.num, n2)
else
a.num = n1*d2 + n2
end
a.den = deepcopy(d2)
elseif isone(d2)
a.num = add!(a.num, n2*d1)
a.den = deepcopy(d1)
else
gd = gcd(d1, d2)
if isone(gd)
if n1 !== n2
a.num = mul!(a.num, a.num, d2)
a.num = add!(a.num, n2*d1)
else
a.num = n1*d2 + n2*d1
end
a.den = d1*d2
else
q1 = divexact(d1, gd)
q2 = divexact(d2, gd)
a.num = q1*n2 + q2*n1
t = gcd(a.num, gd)
if isone(t)
a.den = mul!(a.den, a.den, q2)
else
gd = divexact(d1, t)
a.num = divexact(a.num, t)
a.den = gd*q2
end
end
end
return a
end

function add!(c::FracElem{T}, a::FracElem{T}, b::FracElem{T}) where {T <: RingElem}
d1 = denominator(a, false)
d2 = denominator(b, false)
Expand Down
5 changes: 0 additions & 5 deletions src/generic/FactoredFraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -481,11 +481,6 @@ function add!(c::FactoredFracFieldElem{T}, a::FactoredFracFieldElem{T}, b::Facto
return a + b
end

# needed as add!(a::FracElem{T}, b::FracElem{T}) is incompatible
function add!(a::FactoredFracFieldElem{T}, b::FactoredFracFieldElem{T}) where T <: RingElement
return a + b
end

# needed as mul!(c::FracElem{T}, a::FracElem{T}, b::FracElem{T}) is incompatible
function mul!(c::FactoredFracFieldElem{T}, a::FactoredFracFieldElem{T}, b::FactoredFracFieldElem{T}) where T <: RingElement
return a*b
Expand Down
Loading