From 54825b49641ebde2900c3ca15f38d370b0fffb17 Mon Sep 17 00:00:00 2001 From: kalmarek Date: Wed, 5 Jun 2019 10:58:44 +0200 Subject: [PATCH] add AbstractAlgebra.mul! --- Project.toml | 4 +--- src/Groups.jl | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 7103c41..82170e7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Groups" uuid = "5d8bd718-bd84-11e8-3b40-ad14f4a32557" authors = ["Marek Kaluba "] -version = "0.2.0" +version = "0.2.1" [deps] AbstractAlgebra = "c3fe647b-3220-5bb0-a1ea-a7954cac585d" @@ -13,5 +13,3 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] test = ["Test"] - -[compat] diff --git a/src/Groups.jl b/src/Groups.jl index 916cc04..a038e99 100644 --- a/src/Groups.jl +++ b/src/Groups.jl @@ -233,6 +233,20 @@ 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 +end + function r_multiply!(W::GWord, x; reduced::Bool=true) if length(x) > 0 append!(W.symbols, x)