-
Notifications
You must be signed in to change notification settings - Fork 4
/
floyd.py
110 lines (109 loc) · 5.18 KB
/
floyd.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# autogenerated by bellmaniac
import sys
plus = min
zero = sys.maxint
DIM = 128
MIN = 0
MAX = 1000
from numpy import *
def f(T, oi, oj, ok):
for k0 in xrange(0,(n + 1)):
for i0 in xrange(0,n):
for j0 in xrange(0,n):
i = i0
j = j0
k = k0
assert ((((((0 <= i) and (i < n)) and (0 <= j)) and (j < n)) and (0 <= k)) and (k <= n))
T[(i + oi), (j + oj), (k + ok)] = (r[i, j] if (k == 0) else plus(T[(i + oi), (j + oj), ((k - 1) + ok)], (T[(i + oi), ((k - 1) + oj), ((k - 1) + ok)] + T[((k - 1) + oi), (j + oj), ((k - 1) + ok)])))
r = random.randint(MIN, MAX, size=(DIM, DIM))
n = 64
def a1(T, oi, oj, ok, n, r, r_0, r_1):
if (n < 4):
a(T, oi, oj, ok, n, r, r_0, r_1)
return
T865 = zeros((n, n, (n + 1)), int)
T866 = zeros((n, n, (n + 1)), int)
# partition
a1(T, oi, oj, ok, n/2, r, r_0, r_1)
# partition
a1(T865, 0, 0, 0, n, r, r_0, r_1)
a1(T866, 0, 0, 0, n, r, r_0, r_1)
d(T, oi, oj, (ok + n/2), n, T, T865, T866, oi, oj, 0, n/2, n/2, n/2, 0, n/2)
# partition
b1(T, oi, (oj + n/2), ok, n, r, T, r_0, (n/2 + r_1), oi, oj, ok)
# partition
a1(T, (((2*oi + (-1)*ok) + (-1)*n) + 1), oj, (ok + 1), n, r, r_0, r_1)
c(T, oi, (oj + n/2), (ok + n/2), n, T, T, oi, (oj + n/2), ((((-1)*n/2 + 2*oi) + (-1)*ok) + 1), (n/2 + oj), ((n/2 + ok) + 1))
# partition
c(T, (oi + n/2), oj, ok, n, r, T, (n/2 + r_0), r_1, oi, oj, ok)
# partition
a1(T, oi, (((2*oj + (-1)*ok) + (-1)*n) + 1), (ok + 1), n, r, r_0, r_1)
b1(T, (oi + n/2), oj, (ok + n/2), n, T, T, (oi + n/2), oj, (n/2 + oi), ((((-1)*n/2 + 2*oj) + (-1)*ok) + 1), ((n/2 + ok) + 1))
# partition
d(T, (oi + n/2), (oj + n/2), ok, n, r, T, T, (n/2 + r_0), (n/2 + r_1), (oi + n/2), oj, ok, oi, (oj + n/2), ok)
# partition
a1(T, (oi + n/2), (oj + n/2), (ok + n/2), n/2, T, (oi + n/2), (oj + n/2))
def b1(T, oi, oj, ok, n, r, s, r_0, r_1, s_0, s_1, s_2):
if (n < 4):
b(T, oi, oj, ok, n, r, s, r_0, r_1, s_0, s_1, s_2)
return
T884 = zeros((n, n, (n + 1)), int)
T886 = zeros((n, n, (n + 1)), int)
T887 = zeros((n, n, (n + 1)), int)
T889 = zeros((n, n, (n + 1)), int)
# partition
b1(T, oi, oj, ok, n/2, r, s, r_0, r_1, s_0, s_1, s_2)
# partition
d(T884, 0, 0, (i142 + (-1)*n/2), n, r, s, T, r_0, r_1, s_0, s_1, s_2, oi, oj, ok)
b1(T886, 0, 0, 0, n, r, s, r_0, r_1, s_0, s_1, s_2)
d(T, oi, oj, (ok + n/2), n/2, T884, s, T886, 0, 0, s_0, (n/2 + s_1), (n/2 + s_2), n/2, 0, n/2)
# partition
b1(T, oi, (oj + n/2), ok, n/2, r, s, r_0, (n/2 + r_1), s_0, s_1, s_2)
# partition
d(T887, 0, 0, (i163 + (-1)*n/2), n, r, s, T, r_0, r_1, s_0, s_1, s_2, oi, oj, ok)
b1(T889, 0, 0, 0, n, r, s, r_0, r_1, s_0, s_1, s_2)
d(T, oi, (oj + n/2), (ok + n/2), n/2, T887, s, T889, 0, n/2, s_0, (n/2 + s_1), (n/2 + s_2), n/2, n/2, n/2)
# partition
d(T, (oi + n/2), oj, ok, n/2, r, s, T, (n/2 + r_0), r_1, (n/2 + s_0), s_1, s_2, oi, oj, ok)
# partition
b1(T, (oi + n/2), oj, (ok + n/2), n/2, T, s, (oi + n/2), oj, (n/2 + s_0), (n/2 + s_1), (n/2 + s_2))
# partition
d(T, (oi + n/2), (oj + n/2), ok, n/2, r, s, T, (n/2 + r_0), (n/2 + r_1), (n/2 + s_0), s_1, s_2, oi, (oj + n/2), ok)
# partition
b1(T, (oi + n/2), (oj + n/2), (ok + n/2), n/2, T, s, (oi + n/2), (oj + n/2), (n/2 + s_0), (n/2 + s_1), (n/2 + s_2))
def d(T, oi, oj, ok, n, r, s, t, r_0, r_1, s_0, s_1, s_2, t_0, t_1, t_2):
for i0 in xrange(0,n):
for j0 in xrange(0,n):
for k0 in xrange(0,(n + 1)):
i = i0
j = j0
k = k0
assert ((((((0 <= i) and (i < n)) and (0 <= j)) and (j < n)) and (0 <= k)) and (k <= n))
T[(i + oi), (j + oj), (k + ok)] = (r[(i + r_0), (j + r_1)] if (k == 0) else plus(T[(i + oi), (j + oj), ((k - 1) + ok)], (s[(i + s_0), ((k - 1) + s_1), ((k - 1) + s_2)] + t[((k - 1) + t_0), (j + t_1), ((k - 1) + t_2)])))
def c(T, oi, oj, ok, n, r, t, r_0, r_1, t_0, t_1, t_2):
for i0 in xrange(0,n):
for k0 in xrange(0,(n + 1)):
for j0 in xrange(0,n):
i = i0
j = j0
k = k0
assert ((((((0 <= i) and (i < n)) and (0 <= j)) and (j < n)) and (0 <= k)) and (k <= n))
T[(i + oi), (j + oj), (k + ok)] = (r[(i + r_0), (j + r_1)] if (k == 0) else plus(T[(i + oi), (j + oj), ((k - 1) + ok)], (T[(i + oi), ((k - 1) + oj), ((k - 1) + ok)] + t[((k - 1) + t_0), (j + t_1), ((k - 1) + t_2)])))
def b(T, oi, oj, ok, n, r, s, r_0, r_1, s_0, s_1, s_2):
for j0 in xrange(0,n):
for k0 in xrange(0,(n + 1)):
for i0 in xrange(0,n):
i = i0
j = j0
k = k0
assert ((((((0 <= i) and (i < n)) and (0 <= j)) and (j < n)) and (0 <= k)) and (k <= n))
T[(i + oi), (j + oj), (k + ok)] = (r[(i + r_0), (j + r_1)] if (k == 0) else plus(T[(i + oi), (j + oj), ((k - 1) + ok)], (s[(i + s_0), ((k - 1) + s_1), ((k - 1) + s_2)] + T[((k - 1) + oi), (j + oj), ((k - 1) + ok)])))
def a(T, oi, oj, ok, n, r, r_0, r_1):
for k0 in xrange(0,(n + 1)):
for i0 in xrange(0,n):
for j0 in xrange(0,n):
i = i0
j = j0
k = k0
assert ((((((0 <= i) and (i < n)) and (0 <= j)) and (j < n)) and (0 <= k)) and (k <= n))
T[(i + oi), (j + oj), (k + ok)] = (r[(i + r_0), (j + r_1)] if (k == 0) else plus(T[(i + oi), (j + oj), ((k - 1) + ok)], (T[(i + oi), ((k - 1) + oj), ((k - 1) + ok)] + T[((k - 1) + oi), (j + oj), ((k - 1) + ok)])))