1
0
mirror of https://github.com/kalmarek/GroupRings.jl.git synced 2024-07-30 06:05:31 +02:00

Allow limited use of GroupRings without basis

This commit is contained in:
kalmar 2017-06-05 11:02:38 +02:00
parent 1e990f5896
commit 2eeb85d2ed

View File

@ -36,8 +36,13 @@ type GroupRingElem{T<:Number} <: RingElem
function GroupRingElem(c::AbstractVector{T}, RG::GroupRing, check=true) function GroupRingElem(c::AbstractVector{T}, RG::GroupRing, check=true)
if check if check
isdefined(RG, :basis) || complete(RG) if isdefined(RG, :basis)
length(c) == length(RG.basis) || throw("Can't create GroupRingElem -- lengths differ: length(c) = $(length(c)) != $(length(RG.basis)) = length(RG.basis)") length(c) == length(RG.basis) || throw(
"Can't create GroupRingElem -- lengths differ: length(c) =
$(length(c)) != $(length(RG.basis)) = length(RG.basis)")
else
warn("Basis of the GroupRing is not defined.")
end
end end
return new(c, RG) return new(c, RG)
end end
@ -73,7 +78,9 @@ end
function GroupRing(G::Group, pm::Array{Int,2}) function GroupRing(G::Group, pm::Array{Int,2})
size(pm,1) == size(pm,2) || throw("pm must be square, got $(size(pm))") size(pm,1) == size(pm,2) || throw("pm must be square, got $(size(pm))")
return GroupRing(G, pm) RG = GroupRing(G, initialise=false)
RG.pm = pm
return RG
end end
function GroupRing(G::Group, basis::Vector) function GroupRing(G::Group, basis::Vector)
@ -174,14 +181,17 @@ function show(io::IO, A::GroupRing)
end end
function show(io::IO, X::GroupRingElem) function show(io::IO, X::GroupRingElem)
T = eltype(X.coeffs)
RG = parent(X) RG = parent(X)
if X == RG(T) if X.coeffs == zero(X.coeffs)
T = eltype(X.coeffs)
print(io, "$(zero(T))*$((RG.group)())") print(io, "$(zero(T))*$((RG.group)())")
else elseif isdefined(RG, :basis)
non_zeros = ((X.coeffs[i], RG.basis[i]) for i in findn(X.coeffs)) non_zeros = ((X.coeffs[i], RG.basis[i]) for i in findn(X.coeffs))
elts = ("$(sign(c)> 0? " + ": " - ")$(abs(c))*$g" for (c,g) in non_zeros) elts = ("$(sign(c)> 0? " + ": " - ")$(abs(c))*$g" for (c,g) in non_zeros)
join(io, elts, "") join(io, elts, "")
else
warn("Basis of the parent Group is not defined, showing coeffs")
print(io, X.coeffs)
end end
end end
@ -202,7 +212,12 @@ end
function (==)(A::GroupRing, B::GroupRing) function (==)(A::GroupRing, B::GroupRing)
A.group == B.group || return false A.group == B.group || return false
A.basis == B.basis || return false if isdefined(A, :basis) && isdefined(B, :basis)
A.basis == B.basis || return false
else
warn("Bases of GroupRings are not defined, comparing products mats.")
end
A.pm == B.pm || return false
return true return true
end end