mirror of
https://github.com/kalmarek/PropertyT.jl.git
synced 2024-11-22 16:05:27 +01:00
rework OrbitData
This commit is contained in:
parent
b9de894fb1
commit
bc7118f41d
@ -3,54 +3,99 @@ using SCS
|
||||
|
||||
export Settings, OrbitData
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# OrbitData
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
struct OrbitData{T<:AbstractArray{Float64, 2}}
|
||||
struct OrbitData{T<:AbstractArray{Float64, 2}, GEl<:GroupElem, P<:perm}
|
||||
orbits::Vector{Vector{Int}}
|
||||
preps::Dict{GEl, P}
|
||||
Uπs::Vector{T}
|
||||
dims::Vector{Int}
|
||||
end
|
||||
|
||||
function OrbitData(sett::Settings)
|
||||
function OrbitData(RG::GroupRing, autS::Group)
|
||||
orbs = orbit_decomposition(autS, RG.basis, RG.basis_dict)
|
||||
@assert sum(length(o) for o in orbs) == length(RG.basis)
|
||||
|
||||
autS_mps = Projections.rankOne_projections(GroupRing(autS))
|
||||
|
||||
preps = perm_reps(autS, RG.basis[1:size(RG.pm,1)], RG.basis_dict)
|
||||
mreps = matrix_reps(preps)
|
||||
|
||||
Uπs = [orthSVD(matrix_repr(p, mreps)) for p in autS_mps]
|
||||
|
||||
multiplicities = size.(Uπs,2)
|
||||
dimensions = [Int(p[autS()]*Int(order(autS))) for p in autS_mps]
|
||||
@assert dot(multiplicities, dimensions) == size(RG.pm,1)
|
||||
|
||||
nzros = [i for i in 1:length(Uπs) if size(Uπs[i],2) !=0]
|
||||
|
||||
return OrbitData(orbs, preps, Uπs[nzros], dims[nzros])
|
||||
end
|
||||
|
||||
function compute_OrbitData(RG::GroupRing, autS::Group)
|
||||
|
||||
info("Decomposing E into orbits of $(autS)")
|
||||
@time orbs = orbit_decomposition(autS, RG.basis, RG.basis_dict)
|
||||
@assert sum(length(o) for o in orbs) == length(RG.basis)
|
||||
info("E consists of $(length(orbs)) orbits!")
|
||||
|
||||
info("Action matrices")
|
||||
@time preps = perm_reps(autS, RG.basis[1:size(RG.pm,1)], RG.basis_dict)
|
||||
mreps = matrix_reps(preps)
|
||||
|
||||
info("Projections")
|
||||
@time autS_mps = Projections.rankOne_projections(GroupRing(autS));
|
||||
|
||||
info("Uπs...")
|
||||
@time Uπs = [orthSVD(matrix_repr(p, mreps)) for p in autS_mps]
|
||||
|
||||
multiplicities = size.(Uπs,2)
|
||||
info("multiplicities = $multiplicities")
|
||||
dimensions = [Int(p[autS()]*Int(order(autS))) for p in autS_mps];
|
||||
info("dimensions = $dimensions")
|
||||
@assert dot(multiplicities, dimensions) == size(RG.pm,1)
|
||||
|
||||
return OrbitData(orbs, preps, Uπs, dimensions)
|
||||
end
|
||||
|
||||
function decimate(od::OrbitData)
|
||||
nzros = [i for i in 1:length(od.Uπs) if size(od.Uπs[i],2) !=0]
|
||||
|
||||
Us = map(x -> PropertyT.sparsify!(x, eps(Float64)*1e3, verbose=true), od.Uπs[nzros])
|
||||
#dimensions of the corresponding πs:
|
||||
dims = od.dims[nzros]
|
||||
|
||||
return OrbitData(od.orbits, od.preps, full.(Us), dims);
|
||||
end
|
||||
|
||||
function save_OrbitData(sett::Settings, data::OrbitData)
|
||||
save_preps(filename(prepath(sett), :preps), data.preps)
|
||||
|
||||
save(filename(prepath(sett), :orbits),
|
||||
"orbits", data.orbits)
|
||||
|
||||
save(filename(prepath(sett), :Uπs),
|
||||
"Uπs", data.Uπs,
|
||||
"dims", data.dims)
|
||||
end
|
||||
|
||||
function load_OrbitData(sett::Settings)
|
||||
info("Loading Uπs, dims, orbits...")
|
||||
Uπs = load(filename(prepath(sett), :Uπs), "Uπs")
|
||||
nzros = [i for i in 1:length(Uπs) if size(Uπs[i],2) !=0]
|
||||
Uπs = Uπs[nzros]
|
||||
|
||||
Uπs = map(x -> sparsify!(x, sett.tol/100, verbose=true), Uπs)
|
||||
#dimensions of the corresponding πs:
|
||||
dims = load(filename(prepath(sett), :Uπs), "dims")[nzros]
|
||||
|
||||
orbits = load(filename(prepath(sett), :orbits), "orbits");
|
||||
|
||||
return OrbitData(orbits, Uπs, dims)
|
||||
end
|
||||
|
||||
include("OrbitDecomposition.jl")
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
dims = load(filename(prepath(sett), :Uπs), "dims")
|
||||
|
||||
orbits = load(filename(prepath(sett), :orbits), "orbits")
|
||||
preps = load_preps(filename(prepath(sett), :preps), sett.autS)
|
||||
|
||||
return OrbitData(orbits, preps, Uπs, dims)
|
||||
end
|
||||
|
||||
function load_preps(fname::String, G::Group)
|
||||
|
@ -108,33 +108,4 @@ function orthSVD(M::AbstractMatrix{T}) where {T<:AbstractFloat}
|
||||
return fact[:U][:,1:M_rank]
|
||||
end
|
||||
|
||||
function compute_orbit_data(name::String, RG::GroupRing, autS::Group)
|
||||
|
||||
info("Decomposing E into orbits of $(autS)")
|
||||
@time orbs = orbit_decomposition(autS, RG.basis, RG.basis_dict)
|
||||
@assert sum(length(o) for o in orbs) == length(RG.basis)
|
||||
info("E consists of $(length(orbs)) orbits!")
|
||||
|
||||
info("Action matrices")
|
||||
@time preps = perm_reps(autS, RG.basis[1:size(RG.pm,1)], RG.basis_dict)
|
||||
mreps = matrix_reps(preps)
|
||||
|
||||
info("Projections")
|
||||
@time autS_mps = Projections.rankOne_projections(GroupRing(autS));
|
||||
|
||||
@time π_E_projections = [Cstar_repr(p, mreps) for p in autS_mps]
|
||||
|
||||
info("Uπs...")
|
||||
@time Uπs = orthSVD.(π_E_projections)
|
||||
|
||||
multiplicities = size.(Uπs,2)
|
||||
info("multiplicities = $multiplicities")
|
||||
dimensions = [Int(p[autS()]*Int(order(autS))) for p in autS_mps];
|
||||
info("dimensions = $dimensions")
|
||||
@assert dot(multiplicities, dimensions) == size(RG.pm,1)
|
||||
|
||||
save(filename(name, :orbits), "orbits", orbs)
|
||||
save_preps(filename(name, :preps), preps)
|
||||
save(filename(name, :Uπs), "Uπs", Uπs, "dims", dimensions)
|
||||
return 0
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user