From e98784bd987bb982605f7d13d54a2bdeb34ded07 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 31 Jan 2017 16:56:49 +0100 Subject: [PATCH] =?UTF-8?q?rename=20freegroup=5Freduce=20=E2=86=92=20reduc?= =?UTF-8?q?e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Groups.jl | 17 ++++++++--------- test/runtests.jl | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Groups.jl b/src/Groups.jl index 910cd4f..7cfb6db 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -78,7 +78,7 @@ function join_free_symbols!(W::GWord) return reduced end -function freegroup_reduce!{T}(W::GWord{T}) +function reduce!{T}(W::GWord{T}) if length(W) < 2 deleteat!(W.symbols, find(x -> x.pow == 0, W.symbols)) else @@ -94,16 +94,16 @@ function freegroup_reduce!{T}(W::GWord{T}) return W end -freegroup_reduce(W::GWord) = freegroup_reduce!(deepcopy(W)) +reduce(W::GWord) = reduce!(deepcopy(W)) function hash{T}(W::GWord{T}, h::UInt) - W.modified && freegroup_reduce!(W) + W.modified && reduce!(W) return W.savedhash + h end function (==){T}(W::GWord{T}, Z::GWord{T}) - W.modified && freegroup_reduce!(W) # reduce clears the flag and recalculate the hash - Z.modified && freegroup_reduce!(Z) + W.modified && reduce!(W) # reduce clears the flag and recalculate the hash + Z.modified && reduce!(Z) return W.savedhash == Z.savedhash && W.symbols == Z.symbols end @@ -123,7 +123,7 @@ function r_multiply!(W::GWord, x; reduced::Bool=true) push!(W.symbols, x...) end if reduced - freegroup_reduce!(W) + reduce!(W) end return W end @@ -133,7 +133,7 @@ function l_multiply!(W::GWord, x; reduced::Bool=true) unshift!(W.symbols, reverse(x)...) end if reduced - freegroup_reduce!(W) + reduce!(W) end return W end @@ -221,8 +221,7 @@ function replace!(W::GWord, index, toreplace::GWord, replacement::GWord; asserts last = W.symbols[index+n-1]*inv(toreplace.symbols[end]) replacement = first*replacement*last splice!(W.symbols, index:index+n-1, replacement.symbols) - Groups.freegroup_reduce!(W) - return W + return reduce!(W) end function replace(W::GWord, index, toreplace::GWord, replacement::GWord) diff --git a/test/runtests.jl b/test/runtests.jl index d32f6d2..c5845cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -69,14 +69,14 @@ end @test one(FGWord) == one(s)*one(s) w = GWord{FGSymbol}([s]) push!(w.symbols, (s^-1).symbols[1]) - @test Groups.freegroup_reduce!(w) == one(FGWord) + @test Groups.reduce!(w) == one(FGWord) o = (t*s)^3 @test o == t*s*t*s*t*s p = (t*s)^-3 @test p == s^-1*t^-1*s^-1*t^-1*s^-1*t^-1 @test o*p == one(FGWord) w = FGWord([o.symbols..., p.symbols...]) - @test Groups.freegroup_reduce!(w).symbols ==Vector{FGSymbol}([]) + @test Groups.reduce!(w).symbols ==Vector{FGSymbol}([]) end @testset "arithmetic" begin @test Groups.r_multiply!(FGWord(t),[s,t]; reduced=true) == t*s*t