diff --git a/src/OrbitDecomposition.jl b/src/OrbitDecomposition.jl index fb58045..9adff7b 100644 --- a/src/OrbitDecomposition.jl +++ b/src/OrbitDecomposition.jl @@ -39,14 +39,6 @@ function orbit_spvector(vect::AbstractVector, orbits) return orb_vector end -function orbit_constraint(constraints::Vector{Vector{Int}}, n) - result = spzeros(n,n) - for cnstr in constraints - result[cnstr] += 1.0/length(constraints) - end - return result -end - ############################################################################### # # Matrix-, Permutation- and C*-representations diff --git a/src/SDPs.jl b/src/SDPs.jl index 279ca66..5c9fa1f 100644 --- a/src/SDPs.jl +++ b/src/SDPs.jl @@ -7,14 +7,15 @@ function constraints(pm::Matrix{I}, total_length=maximum(pm)) where {I<:Integer} return cnstrs end -function constraint(pm::Matrix{I}, k) where {I<:Integer} - cnstr = Vector{I}() - for i in eachindex(pm) - if pm[i] == k - push!(cnstr, i) +function orbit_constraint!(result::SparseMatrixCSC, cnstrs, orbit; val=1.0/length(orbit)) + result .= zero(eltype(result)) + dropzeros!(result) + for constraint in cnstr_orbit + for idx in constraint + result[idx] = val end end - return cnstr + return result end