diff --git a/src/types.jl b/src/types.jl index 336b570..b2482d9 100644 --- a/src/types.jl +++ b/src/types.jl @@ -144,7 +144,18 @@ end function Base.:(*)(g::GEl, h::GEl) where {GEl<:AbstractFPGroupElement} @boundscheck @assert parent(g) === parent(h) - return GEl(word(g) * word(h), parent(g)) + A = alphabet(parent(g)) + k = 0 + while k + 1 ≤ min(length(word(g)), length(word(h))) + if inv(word(g)[end-k], A) == word(h)[k+1] + k += 1 + else + break + end + end + w = @view(word(g)[1:end-k]) * @view(word(h)[k+1:end]) + res = GEl(w, parent(g)) + return res end function GroupsCore.isfiniteorder(g::AbstractFPGroupElement) diff --git a/test/matrix_groups.jl b/test/matrix_groups.jl index e93c70e..ec6dfef 100644 --- a/test/matrix_groups.jl +++ b/test/matrix_groups.jl @@ -22,8 +22,6 @@ using Groups.MatrixGroups S = unique([S; inv.(S)]) _, sizes = Groups.wlmetric_ball(S; radius = 4) @test sizes == [7, 33, 141, 561] - _, sizes = Groups.wlmetric_ball_serial(S; radius = 4) - @test sizes == [7, 33, 141, 561] Logging.with_logger(Logging.NullLogger()) do @testset "GroupsCore conformance" begin @@ -35,9 +33,9 @@ using Groups.MatrixGroups end end - x = w * inv(w) * r + x = w * inv(SL3Z(word(w)[end:end])) * r - @test length(word(x)) == 5 + @test length(word(x)) == length(word(r)) @test size(x) == (3, 3) @test eltype(x) == Int8 @@ -65,10 +63,10 @@ using Groups.MatrixGroups end end - x = gens(Sp6, 1) - x *= inv(x) * gens(Sp6, 2) + x = gens(Sp6, 1) * gens(Sp6, 2)^2 + x *= inv(gens(Sp6, 2)^2) * gens(Sp6, 3) - @test length(word(x)) == 3 + @test length(word(x)) == 2 @test size(x) == (6, 6) @test eltype(x) == Int8 @@ -80,7 +78,7 @@ using Groups.MatrixGroups @test contains(sprint(show, MIME"text/plain"(), x), "∈ Sp{6,Int8}") @test sprint(print, x) isa String - @test length(word(x)) == 1 + @test length(word(x)) == 2 for g in gens(Sp6) @test MatrixGroups.issymplectic(MatrixGroups.matrix(g)) @@ -101,10 +99,10 @@ using Groups.MatrixGroups end end - x = gens(G, 1) - x *= inv(x) * gens(G, 2) + x = gens(G, 1) * gens(G, 2)^3 + x *= gens(G, 2)^-3 - @test length(word(x)) == 3 + @test length(word(x)) == 1 @test size(x) == (6, 6) @test eltype(x) == Int16