1
0
mirror of https://github.com/kalmarek/PropertyT.jl.git synced 2024-12-24 02:00:30 +01:00

add common routines for (unique) products and generation of balls

This commit is contained in:
kalmar 2017-04-10 21:46:33 +02:00
parent 76a2135063
commit 85e07a5a57

View File

@ -10,6 +10,32 @@ const solver_logger = basic_config("info", fmt="{msg}")
include("sdps.jl")
include("checksolution.jl")
function products{T}(X::AbstractVector{T}, Y::AbstractVector{T})
result = Vector{T}()
seen = Set{T}()
for x in X
for y in Y
z = x*y
if !in(z, seen)
push!(seen, z)
push!(result, z)
end
end
end
return result
end
function generate_balls{T}(S::Vector{T}, Id::T; radius=4)
sizes = Vector{Int}()
S = vcat([Id], S)
B = [Id]
for i in 1:radius
B = products(B, S);
push!(sizes, length(B))
end
return B, sizes
end
function pmΔfilenames(name::String)
if !isdir(name)
mkdir(name)