Skip to content

Commit

Permalink
Remove some bad add! dispatches (#1796)
Browse files Browse the repository at this point in the history
* Remove some bad `add!` dispatches

* Bump version to 0.43.1
  • Loading branch information
lgoettgens authored Sep 18, 2024
1 parent 956093d commit 1791989
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 58 deletions.
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

0 comments on commit 1791989

Please sign in to comment.