From e92a5d72e828ebf2b0a9d63e8914fdde8e9ab8d5 Mon Sep 17 00:00:00 2001 From: kalmar Date: Tue, 11 Jul 2017 15:58:45 +0200 Subject: [PATCH] add divexact function --- src/GroupRings.jl | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/GroupRings.jl b/src/GroupRings.jl index 5686c9e..d5059c8 100644 --- a/src/GroupRings.jl +++ b/src/GroupRings.jl @@ -1,7 +1,7 @@ module GroupRings using Nemo -import Nemo: Group, GroupElem, Ring, RingElem, parent, elem_type, parent_type, mul!, addeq! +import Nemo: Group, GroupElem, Ring, RingElem, parent, elem_type, parent_type, mul!, addeq!, divexact import Base: convert, show, hash, ==, +, -, *, //, /, length, norm, rationalize, deepcopy_internal, getindex, setindex!, eltype, one, zero @@ -368,6 +368,16 @@ function *{T<:Number, S<:Number}(X::GroupRingElem{T}, Y::GroupRingElem{S}) return GroupRingElem(result, RG) end +function divexact{T}(X::GroupRingElem{T}, Y::GroupRingElem{T}) + if length(Y) != 1 + throw("Can not divide by a non-primitive element $(Y)!") + else + idx = findfirst(Y) + c = Y[idx] + g = parent(Y).basis[idx] + return X*1//c*parent(Y)(inv(g)) + end +end ############################################################################### # # *-involution