move Group Ring specific functions (norm, aug, supp, star) to misc.jl

This commit is contained in:
kalmarek 2019-06-04 20:10:04 +02:00
parent c516ce286a
commit 9261df96ec
No known key found for this signature in database
GPG Key ID: 8BF1A3855328FC15
2 changed files with 23 additions and 31 deletions

View File

@ -81,37 +81,6 @@ function (==)(A::GroupRing, B::GroupRing)
end
###############################################################################
#
# *-involution
#
###############################################################################
function star(X::GroupRingElem{T}) where T
RG = parent(X)
isdefined(RG, :basis) || throw("*-involution without basis is not possible")
result = RG(T)
for (i,c) in enumerate(X.coeffs)
if c != zero(T)
g = inv(RG.basis[i])
result[g] = c
end
end
return result
end
###############################################################################
#
# Misc
#
###############################################################################
LinearAlgebra.norm(X::GroupRingElem, p::Int=2) = norm(X.coeffs, p)
aug(X::GroupRingElem) = sum(X.coeffs)
supp(X::GroupRingElem) = parent(X).basis[findall(!iszero, X.coeffs)]
function reverse_dict(::Type{I}, iter) where I<:Integer
length(iter) > typemax(I) && error("Can not produce reverse dict: $(length(iter)) is too large for $T")
return Dict{eltype(iter), I}(x => i for (i,x) in enumerate(iter))

View File

@ -53,3 +53,26 @@ Base.@propagate_inbounds function Base.setindex!(X::GroupRingElem, val, g::Grou
return X.coeffs[RG[g]] = val
end
###############################################################################
#
# GroupRing specifics: augmentation, support, *-involution
#
###############################################################################
aug(X::GroupRingElem) = sum(X.coeffs)
function supp(X::GroupRingElem)
@assert hasbasis(parent(X))
dropzeros!(X.coeffs)
return parent(X).basis[X.coeffs.nzind]
end
function star(X::GroupRingElem{T}) where T
RG = parent(X)
hasbasis(RG) || throw(ArgumentError("*-involution without basis is not possible"))
nzind = [RG.basis_dict[inv(RG.basis[i])] for i in X.coeffs.nzind]
return GroupRingElem(sparsevec(nzind, X.coeffs.nzval, X.coeffs.n), RG)
end
LinearAlgebra.norm(X::GroupRingElem, p::Int=2) = norm(X.coeffs, p)