Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import combinations
- from sympy import Matrix, lcm
- from fractions import Fraction
- f = open('output.txt', 'w')
- l1 = Matrix([[1, 0, 0, 0]])
- l2 = Matrix([[1, 1, 0, 0]])
- l3 = Matrix([[2, 1, 1, 0]])
- l4 = Matrix([[Fraction(3, 2), Fraction(1, 2), Fraction(1, 2), Fraction(1, 2)]])
- weights = [l1, l2, l3, l4]
- weight_Mat = Matrix([l1, l2, l3, l4])
- e1 = Matrix([[0, 1, -1, 0]])
- e2 = Matrix([[0, 0, 1, -1]])
- e3 = Matrix([[0, 0, 0, 1]])
- e4 = Matrix([[Fraction(1, 2), Fraction(-1, 2), Fraction(-1, 2), Fraction(-1, 2)]])
- basis = [e1, e2, e3, e4]
- rank = len(basis)
- W = [weight_Mat]
- i = 0
- while i != len(W):
- weight = W[i]
- for e_i in basis:
- a = weight - ((2 * (weight * e_i.T) / (e_i * e_i.T)) * e_i)
- t = False
- for elem in W:
- if a == elem:
- t = True
- break
- if not t:
- W.append(a)
- i += 1
- S = weights
- i = 0
- while i != len(S):
- weight = S[i]
- for e_i in basis:
- a = weight - ((2 * (weight * e_i.T) / (e_i * e_i.T)) * e_i)
- t = False
- for elem in S:
- if a == elem or a == -elem:
- t = True
- break
- if not t:
- S.append(a)
- i += 1
- X_set = set()
- for vectors in combinations(S, rank - 1):
- A = Matrix([vectors[0], vectors[1], vectors[2]])
- if A.rank() == rank - 1:
- v = A.nullspace()[0]
- m = lcm([val.q for val in v])
- solve = m * v
- X_set.add(tuple(solve))
- X_set.add(tuple(-solve))
- X_list = list()
- for vector in X_set:
- X_list.append(Matrix(vector))
- sep = 5
- mask = [[0] * 37776] * 1152
- print(mask)
- for i in range(len(W)):
- for j in range(len(X_list)):
- sc_vect = W[i] * X_list[j]
- cnt_plus = 0
- for i in range(rank):
- if sc_vect[i] > 0:
- cnt_plus += 1
- if cnt_plus == rank:
- mask[i][j] = 1
- f.write(str(mask))
- f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement