1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-11-23 08:15:29 +01:00

unified marix_reps and perm_reps

This commit is contained in:
kalmarek 2017-11-08 09:28:04 +01:00
parent 0c9fb40e65
commit e636c97738

View File

@ -91,77 +91,75 @@ end
############################################################################### ###############################################################################
# #
# Matrix- and C*-representations # Matrix-, Permutation- and C*-representations
# #
############################################################################### ###############################################################################
function matrix_repr(g::GroupElem, E, E_dict) function matrix_repr(p::perm)
rep_matrix = spzeros(Int, length(E), length(E)) N = parent(p).n
return sparse(1:N, p.d, [1.0 for _ in 1:N])
end
function matrix_repr(g::GroupElem, E, E_rdict)
repmat = spzeros(Int, length(E), length(E))
for (i,elt) in enumerate(E) for (i,elt) in enumerate(E)
j = E_dict[g(elt)] j = E_rdict[g(elt)]
rep_matrix[i,j] = 1 repmat[i,j] = 1
end end
return rep_matrix return repmat
end end
function matrix_reps{T<:GroupElem}(G::Group, S::Vector{T}, AutS::Group, radius::Int) function matrix_reps(G::Nemo.Group, E, E_rdict=GroupRings.reverse_dict(E))
Id = (isa(G, Nemo.Ring) ? one(G) : G())
E2, _ = Groups.generate_balls(S, Id, radius=radius)
Edict = GroupRings.reverse_dict(E2)
elts = collect(elements(AutS))
l = length(elts)
mreps = Vector{SparseMatrixCSC{Int, Int}}(l)
Threads.@threads for i in 1:l
mreps[i] = PropertyT.matrix_repr(elts[i], E2, Edict)
end
mreps_dict = Dict(elts[i]=>mreps[i] for i in 1:l)
return mreps_dict
end
function matrix_reps(G::Group, E2, E_dict)
elts = collect(elements(G)) elts = collect(elements(G))
l = length(elts) l = length(elts)
mreps = Vector{SparseMatrixCSC{Int, Int}}(l) mreps = Vector{SparseMatrixCSC{Int, Int}}(l)
Threads.@threads for i in 1:l Threads.@threads for i in 1:l
mreps[i] = matrix_repr(elts[i], E2, E_dict) mreps[i] = matrix_repr(elts[i], E, E_rdict)
end end
return Dict(elts[i]=>mreps[i] for i in 1:l) return Dict(elts[i]=>mreps[i] for i in 1:l)
end end
function perm_reps{T<:GroupElem}(G::Group, S::Vector{T}, AutS::Group, radius::Int) function matrix_reps{T<:GroupElem}(autS::Nemo.Group, S::Vector{T}, radius::Int)
Id = (isa(G, Nemo.Ring) ? one(G) : G()) E, _ = Groups.generate_balls(S, radius=radius)
E_R, _ = Groups.generate_balls(S, Id, radius=radius) return matrix_reps(autS, E)
Edict = GroupRings.reverse_dict(E_R) end
elts = collect(elements(AutS)) function matrix_reps{T<:GroupElem}(preps::Dict{T,perm})
kk = collect(keys(preps))
mreps = Vector{SparseMatrixCSC{Float64, Int}}(length(kk))
Threads.@threads for i in 1:length(kk)
mreps[i] = matrix_repr(preps[kk[i]])
end
return Dict(kk[i] => mreps[i] for i in 1:length(kk))
end
function perm_repr(g::GroupElem, E::Vector, E_dict)
p = Vector{Int}(length(E))
for (i,elt) in enumerate(E)
p[i] = E_dict[g(elt)]
end
return p
end
function perm_reps(G::Group, E::Vector, E_rdict=GroupRings.reverse_dict(E))
elts = collect(elements(G))
l = length(elts) l = length(elts)
preps = Vector{Nemo.perm}(l) preps = Vector{Nemo.perm}(l)
G = Nemo.PermutationGroup(length(E_R)) permG = Nemo.PermutationGroup(length(E))
Threads.@threads for i in 1:l Threads.@threads for i in 1:l
preps[i] = G(perm_repr(elts[i], E_R, Edict)) preps[i] = permG(PropertyT.perm_repr(elts[i], E, E_rdict))
end end
preps_dict = Dict(elts[i]=>preps[i] for i in 1:l) return Dict(elts[i]=>preps[i] for i in 1:l)
return preps_dict
end end
function perm_repr(g::GroupElem, E, E_dict) function perm_reps(S::Vector, AutS::Group, radius::Int)
l = length(E) E, _ = Groups.generate_balls(S, radius=radius)
p = Vector{Int}(l) return perm_reps(AutS, E)
for (i,elt) in enumerate(E)
j = E_dict[g(elt)]
p[i] = j
end
return p
end end
function reconstruct_sol{T<:GroupElem, S<:Nemo.perm}(preps::Dict{T, S}, function reconstruct_sol{T<:GroupElem, S<:Nemo.perm}(preps::Dict{T, S},