Move Orbit related functions to OrbitDecomposition.jl

This commit is contained in:
kalmar 2017-06-08 20:04:04 +02:00
parent 72ea3f5e0a
commit fbfa968e78
2 changed files with 21 additions and 23 deletions

View File

@ -31,29 +31,6 @@ sparsify{T}(U::AbstractArray{T}, eps=eps(T)) = sparsify!(deepcopy(U), eps)
small_to_zero!{T}(A::AbstractArray{T}, eps=eps(T)) = A[abs(A) .< eps] = zero(T) small_to_zero!{T}(A::AbstractArray{T}, eps=eps(T)) = A[abs(A) .< eps] = zero(T)
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
function orbit_constraint(cnstrs::Vector{Vector{Vector{Int64}}}, n)
result = spzeros(n,n)
for cnstr in cnstrs
for p in cnstr
result[p[1],p[2]] += 1.0
end
end
return 1/length(cnstrs)*result
end
function init_model(Uπs) function init_model(Uπs)
m = JuMP.Model(); m = JuMP.Model();
l = size(Uπs,1) l = size(Uπs,1)

View File

@ -65,6 +65,11 @@ function (p::Nemo.perm)(A::Nemo.MatElem)
return R(Nemo.matrix_repr(p))*A*R(Nemo.matrix_repr(inv_p)) return R(Nemo.matrix_repr(p))*A*R(Nemo.matrix_repr(inv_p))
end end
###############################################################################
#
# Orbit stuff
#
###############################################################################
function orbit_decomposition(G::Nemo.Group, E::Vector, rdict=GroupRings.reverse_dict(E)) function orbit_decomposition(G::Nemo.Group, E::Vector, rdict=GroupRings.reverse_dict(E))
@ -88,11 +93,27 @@ function orbit_decomposition(G::Nemo.Group, E::Vector, rdict=GroupRings.reverse_
return orbits return orbits
end 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 end
return orb_vector
end end
function orbit_constraint(cnstrs::Vector{Vector{Vector{Int64}}}, n)
result = spzeros(n,n)
for cnstr in cnstrs
for p in cnstr
result[p[1],p[2]] += 1.0
end
end
return 1/length(cnstrs)*result
end end
############################################################################### ###############################################################################