PropertyT.jl/src/OrbitDecomposition.jl

102 lines
2.6 KiB
Julia
Raw Normal View History

2017-06-22 14:12:35 +02:00
###############################################################################
#
# Orbit stuff
#
###############################################################################
2018-07-31 10:21:54 +02:00
function orbit_decomposition(G::Group, E::Vector, rdict=GroupRings.reverse_dict(E))
2017-06-22 14:12:35 +02:00
elts = collect(elements(G))
tovisit = trues(E);
orbits = Vector{Vector{Int}}()
orbit = zeros(Int, length(elts))
2017-06-22 14:12:35 +02:00
for i in 1:endof(E)
if tovisit[i]
g = E[i]
Threads.@threads for j in 1:length(elts)
orbit[j] = rdict[elts[j](g)]
2017-06-22 14:12:35 +02:00
end
2017-08-27 18:32:19 +02:00
tovisit[orbit] = false
2017-06-22 14:12:35 +02:00
push!(orbits, unique(orbit))
end
end
return orbits
end
function orbit_spvector(vect::AbstractVector, orbits)
orb_vector = spzeros(length(orbits))
for (i,o) in enumerate(orbits)
k = vect[collect(o)]
val = k[1]
@assert all(k .== val)
orb_vector[i] = val
end
return orb_vector
end
###############################################################################
#
2017-11-08 09:28:04 +01:00
# Matrix-, Permutation- and C*-representations
2017-06-22 14:12:35 +02:00
#
###############################################################################
2017-11-08 09:28:04 +01:00
function matrix_repr(p::perm)
N = parent(p).n
return sparse(1:N, p.d, [1.0 for _ in 1:N])
2017-06-22 14:12:35 +02:00
end
2018-01-26 13:20:56 +01:00
function matrix_reps(preps::Dict{T,perm{I}}) where {T<:GroupElem, I<:Integer}
2017-11-08 09:28:04 +01:00
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))
2017-06-22 14:12:35 +02:00
end
2017-11-08 09:28:04 +01:00
function perm_repr(g::GroupElem, E::Vector, E_dict)
2018-01-01 14:06:33 +01:00
p = Vector{Int}(length(E))
for (i,elt) in enumerate(E)
p[i] = E_dict[g(elt)]
end
return p
2017-08-27 18:35:35 +02:00
end
2017-11-08 09:28:04 +01:00
function perm_reps(G::Group, E::Vector, E_rdict=GroupRings.reverse_dict(E))
2018-01-01 14:06:33 +01:00
elts = collect(elements(G))
l = length(elts)
2018-07-31 10:21:54 +02:00
preps = Vector{perm}(l)
2017-08-27 18:35:35 +02:00
2018-07-31 10:21:54 +02:00
permG = PermutationGroup(length(E))
2017-08-27 18:35:35 +02:00
2018-01-01 14:06:33 +01:00
Threads.@threads for i in 1:l
preps[i] = permG(PropertyT.perm_repr(elts[i], E, E_rdict), false)
2018-01-01 14:06:33 +01:00
end
2017-08-27 18:35:35 +02:00
2018-01-01 14:06:33 +01:00
return Dict(elts[i]=>preps[i] for i in 1:l)
2017-08-27 18:35:35 +02:00
end
2017-11-08 09:56:28 +01:00
function perm_reps(S::Vector, autS::Group, radius::Int)
2018-01-01 14:06:33 +01:00
E, _ = Groups.generate_balls(S, radius=radius)
return perm_reps(autS, E)
2017-08-27 18:35:35 +02:00
end
2017-08-03 11:35:34 +02:00
2017-10-03 14:46:05 +02:00
function Cstar_repr(x::GroupRingElem{T}, mreps::Dict) where {T}
2018-08-20 04:02:44 +02:00
nzeros = findn(x.coeffs)
return sum(x[i].*mreps[parent(x).basis[i]] for i in nzeros)
2017-06-22 14:12:35 +02:00
end
2018-08-20 03:58:09 +02:00
function orthSVD(M::AbstractMatrix{T}) where {T<:AbstractFloat}
2018-01-01 14:06:33 +01:00
M = full(M)
fact = svdfact(M)
M_rank = sum(fact[:S] .> maximum(size(M))*eps(T))
return fact[:U][:,1:M_rank]
2017-06-22 14:12:35 +02:00
end
end