move reconstruct to OrbitDecomposition.jl
also: AutS_mreps becomes a dictionary
This commit is contained in:
parent
ee08c52305
commit
b6cf402260
24
Orb_AutFN.jl
24
Orb_AutFN.jl
@ -155,28 +155,6 @@ function λandP(m::JuMP.Model, data::OrbitData)
|
|||||||
return λ, Ps
|
return λ, Ps
|
||||||
end
|
end
|
||||||
|
|
||||||
function matrix_reps{T<:GroupElem}(G::Group, S::Vector{T}, AutS::Group, radius::Int)
|
|
||||||
Id = (isa(G, Nemo.Ring) ? one(G) : G())
|
|
||||||
E2, _ = Groups.generate_balls(S, Id, radius=radius)
|
|
||||||
Edict = GroupRings.reverse_dict(E2)
|
|
||||||
|
|
||||||
mreps = Dict(g => matrix_repr(g, E2, Edict) for g in elements(AutS))
|
|
||||||
return mreps
|
|
||||||
end
|
|
||||||
|
|
||||||
function reconstruct(mreps::Dict, Us::Vector, Ps::Vector, dims::Vector)
|
|
||||||
recP = zeros(size(Us[1],1), size(Us[1],1))
|
|
||||||
|
|
||||||
for g in keys(mreps)
|
|
||||||
for π in 1:endof(Us)
|
|
||||||
recP .+= dims[π] .* mreps[g]*transform(Us[π]', Ps[π])*mreps[inv(g)]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
recP .*= 1/length(collect(keys(mreps)))
|
|
||||||
|
|
||||||
return recP
|
|
||||||
end
|
|
||||||
|
|
||||||
function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
|
function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
|
||||||
info(PropertyT.logger, "Solving SDP problem...")
|
info(PropertyT.logger, "Solving SDP problem...")
|
||||||
λ, Ps = λandP(m, data)
|
λ, Ps = λandP(m, data)
|
||||||
@ -184,7 +162,7 @@ function λandP(m::JuMP.Model, data::OrbitData, sett::Settings)
|
|||||||
info(PropertyT.logger, "Reconstructing P...")
|
info(PropertyT.logger, "Reconstructing P...")
|
||||||
mreps = matrix_reps(sett.G, sett.S, sett.AutS, sett.radius)
|
mreps = matrix_reps(sett.G, sett.S, sett.AutS, sett.radius)
|
||||||
|
|
||||||
recP = reconstruct(mreps, data.Us, Ps, data.dims)
|
recP = reconstruct_sol(mreps, data.Us, Ps, data.dims)
|
||||||
|
|
||||||
fname = PropertyT.λSDPfilenames(data.name)[2]
|
fname = PropertyT.λSDPfilenames(data.name)[2]
|
||||||
save(fname, "origP", Ps, "P", recP)
|
save(fname, "origP", Ps, "P", recP)
|
||||||
|
@ -117,10 +117,34 @@ function matrix_repr(g::GroupElem, E, E_dict)
|
|||||||
return rep_matrix
|
return rep_matrix
|
||||||
end
|
end
|
||||||
|
|
||||||
function Cstar_repr(x::GroupRingElem, matrix_reps)
|
function matrix_reps{T<:GroupElem}(G::Nemo.Group, S::Vector{T}, AutS::Nemo.Group, radius::Int)
|
||||||
res = zeros(matrix_reps[1])
|
Id = (isa(G, Nemo.Ring) ? one(G) : G())
|
||||||
for i in 1:length(parent(x).basis)
|
E2, _ = Groups.generate_balls(S, Id, radius=radius)
|
||||||
res += x.coeffs[i]*matrix_reps[i]
|
Edict = GroupRings.reverse_dict(E2)
|
||||||
|
|
||||||
|
mreps = Dict(g=>matrix_repr(g, E2, Edict) for g in elements(AutS))
|
||||||
|
return mreps
|
||||||
|
end
|
||||||
|
|
||||||
|
function reconstruct_sol(mreps::Dict, Us::Vector, Ps::Vector, dims::Vector)
|
||||||
|
recP = zeros(size(Us[1],1), size(Us[1],1))
|
||||||
|
|
||||||
|
for g in keys(mreps)
|
||||||
|
for π in 1:endof(Us)
|
||||||
|
recP .+= dims[π] .* mreps[g]*transform(Us[π]', Ps[π])*mreps[inv(g)]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
recP .*= 1/length(collect(keys(mreps)))
|
||||||
|
|
||||||
|
return recP
|
||||||
|
end
|
||||||
|
|
||||||
|
function Cstar_repr(x::GroupRingElem, mreps)
|
||||||
|
k = collect(keys(mreps))[1]
|
||||||
|
res = zeros(size(mreps[k])...)
|
||||||
|
|
||||||
|
for g in parent(x).basis
|
||||||
|
res .+= x[g]*mreps[g]
|
||||||
end
|
end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
@ -162,12 +186,12 @@ function compute_orbit_data{T<:GroupElem}(logger, name::String, G::Nemo.Group, S
|
|||||||
|
|
||||||
info(logger, "Action matrices")
|
info(logger, "Action matrices")
|
||||||
E2 = E4[1:sizes[radius]]
|
E2 = E4[1:sizes[radius]]
|
||||||
@time AutS_matrixreps = [matrix_repr(g, E2, E_dict) for g in elements(AutS)]
|
@time AutS_mreps = Dict(g=>matrix_repr(g, E2, E_dict) for g in elements(AutS))
|
||||||
|
|
||||||
info(logger, "Projections")
|
info(logger, "Projections")
|
||||||
@time AutS_mps = rankOne_projections(AutS);
|
@time AutS_mps = rankOne_projections(AutS);
|
||||||
|
|
||||||
@time π_E_projections = [Cstar_repr(p, AutS_matrixreps) for p in AutS_mps]
|
@time π_E_projections = [Cstar_repr(p, AutS_mreps) for p in AutS_mps]
|
||||||
|
|
||||||
info(logger, "Uπs...")
|
info(logger, "Uπs...")
|
||||||
@time Uπs = orthSVD.(π_E_projections)
|
@time Uπs = orthSVD.(π_E_projections)
|
||||||
|
Loading…
Reference in New Issue
Block a user