mirror of
https://github.com/kalmarek/GroupRings.jl.git
synced 2024-12-28 18:50:29 +01:00
move Group Ring specific functions (norm, aug, supp, star) to misc.jl
This commit is contained in:
parent
c516ce286a
commit
9261df96ec
@ -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))
|
||||
|
23
src/misc.jl
23
src/misc.jl
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user