-
Notifications
You must be signed in to change notification settings - Fork 0
/
visuals.jl
57 lines (52 loc) · 1.26 KB
/
visuals.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Plots
gr
function permGroup(A::Union{Set,Array})
unique!(A)
P = Array{eltype(A),1}[]
function continuePerm(head,tail)
if length(tail) > 0
for t in tail
newHead = union(head, [t])
newTail = setdiff(tail, [t])
continuePerm(newHead, newTail)
end
else
push!(P, head)
end
end
continuePerm(eltype(A)[], A)
return P
end
function permGroup(n::Integer)
if n > 14 error(" you gave $n .... thats $(factorial(n)) element") end
A = collect(Int8, 1:n)
P = Array{eltype(A),1}[]
function continuePerm(head,tail)
if length(tail) > 0
for t in tail
newHead = union(head, [t])
newTail = setdiff(tail, [t])
continuePerm(newHead, newTail)
end
else
push!(P, head)
end
end
continuePerm(eltype(A)[], A)
return P
end
function PMatrix(τ::Array; inSnWithn=nothing)
if inSnWithn==nothing
p = zeros(Int16, length(τ),length(τ))
else
p = zeros(Int16, inSnWithn,inSnWithn)
end
for i in 1:length(τ)
p[ i , τ[i] ] = 1
end
return p
end
S9 = permGroup(9)
P9 = map(PMatrix, S9)
rand(P9)
histogram2d()