• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# Untitled

a guest Sep 15th, 2019 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. from itertools import combinations
2. from sympy import Matrix, lcm
3. from fractions import Fraction
4.
5. f = open('output.txt', 'w')
6.
7. l1 = Matrix([[1, 0, 0, 0]])
8. l2 = Matrix([[1, 1, 0, 0]])
9. l3 = Matrix([[2, 1, 1, 0]])
10. l4 = Matrix([[Fraction(3, 2), Fraction(1, 2), Fraction(1, 2), Fraction(1, 2)]])
11.
12. weights = [l1, l2, l3, l4]
13. weight_Mat = Matrix([l1, l2, l3, l4])
14.
15. e1 = Matrix([[0, 1, -1, 0]])
16. e2 = Matrix([[0, 0, 1, -1]])
17. e3 = Matrix([[0, 0, 0, 1]])
18. e4 = Matrix([[Fraction(1, 2), Fraction(-1, 2), Fraction(-1, 2), Fraction(-1, 2)]])
19.
20. basis = [e1, e2, e3, e4]
21.
22. rank = len(basis)
23.
24. W = [weight_Mat]
25.
26. i = 0
27. while i != len(W):
28.     weight = W[i]
29.     for e_i in basis:
30.         a = weight - ((2 * (weight * e_i.T) / (e_i * e_i.T)) * e_i)
31.         t = False
32.         for elem in W:
33.             if a == elem:
34.                 t = True
35.                 break
36.         if not t:
37.             W.append(a)
38.     i += 1
39.
40. S = weights
41.
42. i = 0
43. while i != len(S):
44.     weight = S[i]
45.     for e_i in basis:
46.         a = weight - ((2 * (weight * e_i.T) / (e_i * e_i.T)) * e_i)
47.         t = False
48.         for elem in S:
49.             if a == elem or a == -elem:
50.                 t = True
51.                 break
52.         if not t:
53.             S.append(a)
54.     i += 1
55.
56. X_set = set()
57. for vectors in combinations(S, rank - 1):
58.     A = Matrix([vectors[0], vectors[1], vectors[2]])
59.     if A.rank() == rank - 1:
60.         v = A.nullspace()[0]
61.         m = lcm([val.q for val in v])
62.         solve = m * v
65.
66. X_list = list()
67. for vector in X_set:
68.     X_list.append(Matrix(vector))
69.
70. sep = 5
71.
72. mask = [[0] * 37776] * 1152
73.
75.
76. for i in range(len(W)):
77.     for j in range(len(X_list)):
78.         sc_vect = W[i] * X_list[j]
79.         cnt_plus = 0
80.         for i in range(rank):
81.             if sc_vect[i] > 0:
82.                 cnt_plus += 1
83.         if cnt_plus == rank: