1
0
mirror of https://github.com/kalmarek/Groups.jl.git synced 2024-12-26 02:20:30 +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) 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 return v
end end
function (λ::LTransvect)(v, pow::Integer=1) 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 return v
end end

View File

@ -234,44 +234,32 @@ end
# #
############################################################################### ###############################################################################
function AbstractAlgebra.mul!(out::GWord, x::GWord, y::GWord; reduced::Bool=true) function Base.append!(w::GWord{T}, v::AbstractVector{T}) where T
resize!(out.symbols, length(x.symbols)+length(y.symbols)) append!(syllables(w), v)
for i in eachindex(x.symbols) return w
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
end end
function r_multiply!(W::GWord, x; reduced::Bool=true) function Base.prepend!(w::GWord{T}, v::AbstractVector{T}) where T
if length(x) > 0 prepend!(syllables(w), v)
append!(W.symbols, x) return w
end
if reduced
reduce!(W)
end
return W
end end
function l_multiply!(W::GWord, x; reduced::Bool=true) Base.append!(w::T, v::T) where T <: GWord = append!(w, syllables(v))
if length(x) > 0 Base.prepend!(w::T, v::T) where T <: GWord = prepend!(w, syllables(v))
prepend!(W.symbols, x)
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 end
if reduced
reduce!(W)
end
return W
end 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, Z::GWord) = r_multiply(W, Z.symbols)
(*)(W::GWord, s::GSymbol) = r_multiply(W, [s]) (*)(W::GWord, s::GSymbol) = r_multiply(W, [s])