Skip to content

Commit

Permalink
add deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-roehrich committed Sep 11, 2023
1 parent bd27188 commit 13d2e6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
10 changes: 10 additions & 0 deletions experimental/LieAlgebras/src/AbstractRootSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ function Base.:(-)(w::WeightLatticeElem)
return WeightLatticeElem(w.root_system, -w.vec)
end

function Base.deepcopy_internal(w::WeightLatticeElem, dict::IdDict)
if haskey(dict, w)
return dict[w]
end

y = WeylGroupElem(w.root_system, deepcopy_internal(w.vec, dict))
dict[w] = y
return y
end

function expressify(w::WeightLatticeElem, s=:w; context=nothing)
sum = Expr(:call, :+)
for i in 1:length(w.vec)
Expand Down
14 changes: 12 additions & 2 deletions experimental/LieAlgebras/src/WeylGroup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ function Base.IteratorSize(::WeylGroup)
return Base.SizeUnkown()
end

function Base.one(G::WeylGroup)
WeylGroupElem(G, [])
function Base.one(W::WeylGroup)
WeylGroupElem(W, [])
end

function Base.show(io::IO, W::WeylGroup)
Expand Down Expand Up @@ -125,6 +125,16 @@ function Base.:(==)(x::WeylGroupElem, y::WeylGroupElem)
return x.parent === y.parent && x.word == y.word
end

function Base.deepcopy_internal(x::WeylGroupElem, dict::IdDict)
if haskey(dict, x)
return dict[x]
end

y = WeylGroupElem(x.parent, deepcopy_internal(x.word, dict))
dict[x] = y
return y
end

function Base.hash(x::WeylGroupElem, h::UInt)
b = 0x80f0abce1c544784 % UInt
h = hash(x.parent, h)
Expand Down

0 comments on commit 13d2e6c

Please sign in to comment.