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

Stop using addeq! #206

Merged
merged 1 commit into from
Sep 30, 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
13 changes: 8 additions & 5 deletions src/GenericCyclotomics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Oscar.Random: Random, SamplerTrivial, GLOBAL_RNG
using Oscar.RandomExtensions: RandomExtensions, Make2, AbstractRNG

import Oscar.AbstractAlgebra: parent_type, elem_type, base_ring, base_ring_type, parent, is_domain_type,
is_exact_type, canonical_unit, isequal, divexact, zero!, mul!, add!, addeq!, get_cached!, is_unit,
is_exact_type, canonical_unit, isequal, divexact, zero!, mul!, add!, get_cached!, is_unit,
characteristic, Ring, RingElem, expressify, evaluate, normal_form, divexact
import Oscar: pretty, Indent, Dedent, terse, is_terse
import Base: show, +, -, *, ^, ==, inv, isone, iszero, one, zero, rand, deepcopy_internal, hash, conj, promote_rule
Expand Down Expand Up @@ -367,10 +367,13 @@ end

mul!(x::GenericCyclo, y::GenericCyclo, z::GenericCyclo) = y*z

add!(x::GenericCyclo, y::GenericCyclo, z::GenericCyclo) = y+z

function addeq!(x::GenericCyclo, y::GenericCyclo)
mergewith!(+, x.f, y.f)
function add!(x::GenericCyclo, y::GenericCyclo, z::GenericCyclo)
if x === z
y,z=z,y
fingolfin marked this conversation as resolved.
Show resolved Hide resolved
elseif x !== y
x.f = deepcopy(y.f)
end
mergewith!(+, x.f, z.f)
strip_zeros!(x.f)
return x
end
Expand Down
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ test_Ring_interface(S)
@test isone((S(1)//S(2))*2)

@test conj(a//c) == conj(a)//conj(c)

x=deepcopy(a)
y=deepcopy(b)
ab=a+b
@test add!(y, a, y) == ab
@test y == ab
@test a == x

add!(a, a, a)
@test a == 2*x

y=deepcopy(b)
z=deepcopy(c)
cb=c+b
add!(a, c, b)
@test a == cb
@test b == y
@test c == z
end

@testset "Shifts" begin
Expand Down
Loading