1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-25 18:15:29 +01:00

favour append! and prepend! in place of rmul! and lmul!

This commit is contained in:
kalmarek 2020-03-25 00:42:23 +01:00
parent 189850858f
commit 6c53b3b7c0
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 23 additions and 33 deletions

View File

@ -65,12 +65,14 @@ parent_type(::Automorphism{N}) where N = AutGroup{N}
###############################################################################
function (ϱ::RTransvect)(v, pow::Integer=1)
@inbounds Groups.r_multiply!(v[ϱ.i], (v[ϱ.j]^pow).symbols, reduced=false)
append!(v[ϱ.i], v[ϱ.j]^pow)
freereduce!(v[ϱ.i])
return v
end
function (λ::LTransvect)(v, pow::Integer=1)
@inbounds Groups.l_multiply!(v[λ.i], (v[λ.j]^pow).symbols, reduced=false)
prepend!(v[λ.i], v[λ.j]^pow)
freereduce!(v[λ.i])
return v
end

View File

@ -234,44 +234,32 @@ end
#
###############################################################################
function AbstractAlgebra.mul!(out::GWord, x::GWord, y::GWord; reduced::Bool=true)
resize!(out.symbols, length(x.symbols)+length(y.symbols))
for i in eachindex(x.symbols)
out.symbols[i] = x.symbols[i]
end
for i in eachindex(y.symbols)
out.symbols[length(x.symbols)+i] = y.symbols[i]
end
if reduced
reduce!(out)
end
return out
function Base.append!(w::GWord{T}, v::AbstractVector{T}) where T
append!(syllables(w), v)
return w
end
function r_multiply!(W::GWord, x; reduced::Bool=true)
if length(x) > 0
append!(W.symbols, x)
end
if reduced
reduce!(W)
end
return W
function Base.prepend!(w::GWord{T}, v::AbstractVector{T}) where T
prepend!(syllables(w), v)
return w
end
function l_multiply!(W::GWord, x; reduced::Bool=true)
if length(x) > 0
prepend!(W.symbols, x)
Base.append!(w::T, v::T) where T <: GWord = append!(w, syllables(v))
Base.prepend!(w::T, v::T) where T <: GWord = prepend!(w, syllables(v))
for (mul, f) in ((:rmul!, :push!), (:lmul!, :pushfirst!))
@eval begin
function $mul(out::T, w::T, s::GSymbol) where T <:GWord
$f(syllables(out), s)
return freereduce!(out)
end
end
end
end
end
if reduced
reduce!(W)
end
return W
end
r_multiply(W::GWord, x; reduced=true) =
r_multiply!(deepcopy(W),x, reduced=reduced)
l_multiply(W::GWord, x; reduced=true) =
l_multiply!(deepcopy(W),x, reduced=reduced)
(*)(W::GWord, Z::GWord) = r_multiply(W, Z.symbols)
(*)(W::GWord, s::GSymbol) = r_multiply(W, [s])