mirror of
https://github.com/kalmarek/Groups.jl.git
synced 2024-11-19 14:35:28 +01:00
use the new api in freereduce!
This commit is contained in:
parent
b2d6c14515
commit
8abebbbd0c
@ -137,38 +137,32 @@ function deepcopy_internal(W::T, dict::IdDict) where {T<:GWord}
|
|||||||
return G(T(deepcopy(syllables(W))))
|
return G(T(deepcopy(syllables(W))))
|
||||||
end
|
end
|
||||||
|
|
||||||
function freereduce!(W::GWord)
|
function freereduce!(::Type{Bool}, w::GWord)
|
||||||
reduced = true
|
reduced = true
|
||||||
for i in 1:length(W.symbols) - 1
|
for i in 1:syllablelength(w)-1
|
||||||
if W.symbols[i].pow == 0
|
s, ns = syllables(w)[i], syllables(w)[i+1]
|
||||||
|
if isone(s)
|
||||||
continue
|
continue
|
||||||
elseif W.symbols[i].id == W.symbols[i+1].id
|
elseif s.id == ns.id
|
||||||
reduced = false
|
reduced = false
|
||||||
p1 = W.symbols[i].pow
|
setmodified!(w)
|
||||||
p2 = W.symbols[i+1].pow
|
p1 = s.pow
|
||||||
|
p2 = ns.pow
|
||||||
|
|
||||||
W.symbols[i+1] = change_pow(W.symbols[i], p1 + p2)
|
syllables(w)[i+1] = change_pow(s, p1 + p2)
|
||||||
W.symbols[i] = change_pow(W.symbols[i], 0)
|
syllables(w)[i] = change_pow(s, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
filter!(!isone, syllables(w))
|
filter!(!isone, syllables(w))
|
||||||
return reduced
|
return reduced
|
||||||
end
|
end
|
||||||
|
|
||||||
function reduce!(W::GWord)
|
function freereduce!(w::GWord)
|
||||||
if length(W) < 2
|
|
||||||
deleteids!(W)
|
|
||||||
else
|
|
||||||
reduced = false
|
reduced = false
|
||||||
while !reduced
|
while !reduced
|
||||||
reduced = freereduce!(W)
|
reduced = freereduce!(Bool, w)
|
||||||
end
|
end
|
||||||
end
|
return w
|
||||||
|
|
||||||
W.savedhash = hash(W.symbols, hash(typeof(W), hash(parent(W), zero(UInt))))
|
|
||||||
W.modified = false
|
|
||||||
|
|
||||||
return W
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc doc"""
|
@doc doc"""
|
||||||
|
Loading…
Reference in New Issue
Block a user