-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_matrix.py
73 lines (69 loc) · 1.8 KB
/
create_matrix.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import numpy as np
def left_matrix(n):
array = []
for k in range(n//2):
row = []
for j in range(2*k):
row.append(0)
row.append(1)
row.append(1)
for j in range(n - 2*k-2):
row.append(0)
array.append(row)
for k in range(n//3):
row = []
for j in range (3*k):
row.append(0)
row.append(1)
row.append(1)
row.append(1)
for j in range(n - 3*k - 3):
row.append(0)
array.append(row)
for k in range(n-n//2-n//3):
row = []
for j in range(n):
row.append(0)
array.append(row)
return np.array(array)
def right_matrix(n):
array = []
for k in range(n//2):
row = []
for j in range(k):
row.append(0)
row.append(1)
for j in range(n//2-k-1):
row.append(0)
for j in range(k):
row.append(0)
row.append(1)
for j in range(n//2-k-1):
row.append(0)
array.append(row)
for k in range(n//3):
row = []
for j in range(k):
row.append(0)
row.append(1)
for j in range(n//3-k-1):
row.append(0)
for j in range(k):
row.append(0)
row.append(1)
for j in range(n//3-k-1):
row.append(0)
for j in range(k):
row.append(0)
row.append(1)
for j in range(n//3-k-1):
row.append(0)
array.append(row)
for k in range(n-n//2-n//3):
row = []
for j in range(n):
row.append(0)
array.append(row)
return np.array(array)
if __name__ == "__main__":
print(np.transpose(right_matrix(6)))