Changeset 7764:cd445dcb4bb7
- Timestamp:
- 11/18/07 23:10:14 (6 years ago)
- Branch:
- default
- Location:
- sage/coding
- Files:
-
- 2 edited
-
binary_code.pxd (modified) (1 diff)
-
binary_code.pyx (modified) (40 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sage/coding/binary_code.pxd
r7763 r7764 56 56 cdef int sat_225(self, int) 57 57 cdef int min_cell_reps(self, int) 58 cdef void new_min_cell_reps(self, int, int *, int) 58 59 cdef int fixed_cols(self, int, int) 60 cdef void fixed_vertices(self, int, int *, int *, int) 59 61 cdef int first_smallest_nontrivial(self, int) 60 62 cdef int new_first_smallest_nontrivial(self, int, int *, int) -
sage/coding/binary_code.pyx
r7763 r7764 740 740 for k from 0 <= k < nwords-1: 741 741 wd_ents[k] = k 742 wd_lvls[k] = nwords742 wd_lvls[k] = 2*ncols 743 743 for k from 0 <= k < ncols-1: 744 744 col_ents[k] = k 745 col_lvls[k] = ncols745 col_lvls[k] = 2*ncols 746 746 wd_ents[nwords-1] = nwords-1 747 747 wd_lvls[nwords-1] = -1 … … 905 905 cdef int i, j, k 906 906 s = '' 907 for i from 0 <= i < self.nwords:908 s += '({'909 for j from 0 <= j < self.nwords:910 s += str(self.wd_ents[j])911 if self.wd_lvls[j] <= i:912 s += '},{'913 else:914 s += ','915 s = s[:-2] + ')\n'916 for i from 0 <= i < self.ncols:917 s += '({'918 for j from 0 <= j < self.ncols:919 s += str(self.col_ents[j])920 if self.col_lvls[j] <= i:921 s += '},{'922 else:923 s += ','924 s = s[:-2] + ')\n'907 for i from 0 <= i < 2*self.ncols: 908 if i == 0 or not self.is_discrete(i-1): 909 s += '({' 910 for j from 0 <= j < self.nwords: 911 s += str(self.wd_ents[j]) 912 if self.wd_lvls[j] <= i: 913 s += '},{' 914 else: 915 s += ',' 916 s = s[:-2] + ') ' 917 s += '({' 918 for j from 0 <= j < self.ncols: 919 s += str(self.col_ents[j]) 920 if self.col_lvls[j] <= i: 921 s += '},{' 922 else: 923 s += ',' 924 s = s[:-2] + ')\n' 925 925 return s 926 926 … … 1098 1098 return reps 1099 1099 1100 cdef void new_min_cell_reps(self, int k, int *Omega, int start): 1101 cdef int i, j 1102 cdef int *self_col_lvls = self.col_lvls, *self_wd_lvls = self.wd_lvls 1103 cdef int *self_col_ents = self.col_ents, *self_wd_ents = self.wd_ents 1104 cdef int reps = (1 << self_col_ents[0]) 1105 cdef int radix = self.radix, nwords = self.nwords, ncols = self.ncols 1106 for i from 0 < i < ncols: 1107 if self_col_lvls[i-1] <= k: 1108 reps += (1 << self_col_ents[i]) 1109 Omega[start] = reps 1110 reps = 1 1111 for i from 0 < i < min(radix, nwords): 1112 if self_wd_lvls[i-1] <= k: 1113 reps += (1 << self_wd_ents[i]) 1114 Omega[start+1] = reps 1115 j = radix 1116 while j < nwords: 1117 reps = 0 1118 for i from 0 <= i < min(radix, nwords - j): 1119 if self_wd_lvls[j + i - 1] <= k: 1120 reps += (1 << self_wd_ents[i]) 1121 Omega[start+1+j] = reps 1122 j += radix 1123 1100 1124 def _fixed_cols(self, mcrs, k): #TODO 1101 1125 """ … … 1135 1159 fixed += (1 << i) 1136 1160 return fixed & mcrs 1161 1162 cdef void fixed_vertices(self, int k, int *Phi, int *Omega, int start): 1163 cdef int i, j, ell 1164 cdef int fixed = 0, ncols = self.ncols, nwords = self.nwords 1165 cdef int *self_col_lvls = self.col_lvls, *self_wd_lvls = self.wd_lvls 1166 cdef int *self_col_ents = self.col_ents, *self_wd_ents = self.wd_ents 1167 for i from 0 <= i < ncols: 1168 if self_col_lvls[i] <= k: 1169 fixed += (1 << self_col_ents[i]) 1170 Phi[start] = fixed & Omega[start] 1171 # zero out the rest of Phi 1172 ell = 1 + nwords/self.radix 1173 if nwords%self.radix: 1174 ell += 1 1175 for i from 0 < i < ell: 1176 Phi[start+i] = 0 1177 for i from 0 <= i < nwords: 1178 if self_wd_lvls[i] <= k: 1179 ell = self_wd_ents[i] 1180 j = ell/self.radix 1181 ell = ell%self.radix 1182 if Omega[start+1+j]&(1 << ell): 1183 Phi[start+1+j] ^= (1 << ell) 1137 1184 1138 1185 def _first_smallest_nontrivial(self, k): #TODO … … 1184 1231 j += 1 1185 1232 # j now points to the last element of the cell 1186 print "fsnt:", location, j-location+11233 # print "fsnt:", location, j-location+1 1187 1234 i = self.radix - j - 1 # the cell is represented in binary, reading from the right: 1188 1235 cell = (~0 << location) ^ (~0 << j+1) # <------- self.radix -----> … … 1190 1237 1191 1238 cdef int new_first_smallest_nontrivial(self, int k, int *W, int start): 1192 cdef int cell1239 cdef int ell 1193 1240 cdef int i = 0, j = 0, location = 0, min = self.ncols, nwords = self.nwords 1194 1241 cdef int min_is_col = 1, radix = self.radix 1195 1242 cdef int *self_col_lvls = self.col_lvls, *self_wd_lvls = self.wd_lvls 1243 cdef int *self_col_ents = self.col_ents, *self_wd_ents = self.wd_ents 1196 1244 while True: 1197 1245 if self_col_lvls[i] <= k: … … 1208 1256 min = i - j + 1 1209 1257 min_is_col = 0 1210 location = k1258 location = j 1211 1259 j = i + 1 1212 1260 if self_wd_lvls[i] == -1: break … … 1215 1263 # nontrivial cell 1216 1264 j = location 1265 #zero out this level of W: 1266 ell = 1 + nwords/radix 1267 if nwords%radix: 1268 ell += 1 1269 for i from 0 <= i < ell: 1270 W[start+i] = 0 1217 1271 if min_is_col: 1218 1272 while True: … … 1220 1274 j += 1 1221 1275 # j now points to the last element of the cell 1222 W[start] = (~0 << location) ^ (~0 << (j + 1)) 1223 return self.col_ents[location] 1276 i = location 1277 while i <= j: 1278 W[start] ^= (1 << self_col_ents[i]) 1279 i += 1 1280 return self_col_ents[location] 1224 1281 else: 1225 1282 while True: … … 1227 1284 j += 1 1228 1285 # j now points to the last element of the cell 1229 i = 0 1230 while location >= radix*i + radix: 1286 i = location 1287 while i <= j: 1288 ell = self_wd_ents[i] 1289 W[start+1+ell/radix] ^= (1 << ell%radix) 1231 1290 i += 1 1232 if j < radix*i + radix: 1233 W[1 + i] = (~0 << (location - radix*i)) ^ (~0 << (j - radix*i + 1)) 1234 else: # it will span at most two ints: 1235 W[1 + i] = (~0 << (location - radix*i)) 1236 W[1 + i + 1] = ~(~0 << (j - radix*(i+1) + 1)) 1237 return self.wd_ents[location] ^ self.flag 1291 return self_wd_ents[location] ^ self.flag 1238 1292 1239 1293 def _dangerous_dont_use_set_ents_lvls(self, col_ents, col_lvls, wd_ents, wd_lvls): … … 1432 1486 1433 1487 cdef int split_vertex(self, int v, int k): 1434 cdef int i = 0, j 1488 cdef int i = 0, j, flag = self.flag 1435 1489 cdef int *ents 1436 1490 cdef int *lvls 1437 if v & self.flag:1491 if v & flag: 1438 1492 ents = self.wd_ents 1439 1493 lvls = self.wd_lvls 1494 v = v ^ flag 1495 while ents[i] != v: i += 1 1496 v = v ^ flag 1440 1497 else: 1441 1498 ents = self.col_ents 1442 1499 lvls = self.col_lvls 1443 while ents[i] != v: i += 11500 while ents[i] != v: i += 1 1444 1501 j = i 1445 1502 while lvls[i] > k: i += 1 … … 1453 1510 ents[j] = ents[j-1] 1454 1511 j -= 1 1455 ents[j] = v 1512 if v & flag: 1513 ents[j] = v ^ flag 1514 else: 1515 ents[j] = v 1456 1516 lvls[j] = k 1457 return j 1517 if v & flag: 1518 return j ^ flag 1519 else: 1520 return j 1458 1521 1459 1522 def _col_degree(self, C, col, wd_ptr, k): … … 1494 1557 cdef int i = 0 1495 1558 cdef int *self_wd_lvls = self.wd_lvls, *self_wd_ents = self.wd_ents 1496 col = self.col_ents[col]1497 1559 while True: 1498 1560 if CG.is_one(self_wd_ents[wd_ptr], col): i += 1 … … 1540 1602 cdef int wd_degree(self, BinaryCode CG, int wd, int col_ptr, int k, int *ham_wts): 1541 1603 1542 cdef int mask = (1 << col_ptr)1543 cdef int *self_col_lvls = self.col_lvls1604 cdef int *self_col_lvls = self.col_lvls, *self_col_ents = self.col_ents 1605 cdef int mask = (1 << self_col_ents[col_ptr]) 1544 1606 while self_col_lvls[col_ptr] > k: 1545 1607 col_ptr += 1 1546 mask += (1 << col_ptr)1547 mask &= CG.words[ self.wd_ents[wd]]1608 mask += (1 << self_col_ents[col_ptr]) 1609 mask &= CG.words[wd] 1548 1610 return ham_wts[mask & 65535] + ham_wts[(mask >> 16) & 65535] 1549 1611 … … 1789 1851 cdef int q, r, s, t, flag = self.flag, self_ncols = self.ncols 1790 1852 cdef int t_w, self_nwords = self.nwords, invariant = 0, i, j, m = 0 1791 cdef int *self_wd_degs = self.wd_degs, *self_wd_lvls = self.wd_lvls, *self_ col_lvls = self.col_lvls1792 cdef int *self_col_degs = self.col_degs 1853 cdef int *self_wd_degs = self.wd_degs, *self_wd_lvls = self.wd_lvls, *self_wd_ents = self.wd_ents 1854 cdef int *self_col_degs = self.col_degs, *self_col_lvls = self.col_lvls, *self_col_ents = self.col_ents 1793 1855 while not self.is_discrete(k) and m < alpha_length: 1794 # print "m:", m 1795 # print "alpha:", ','.join(['w'+str(alpha[i]^flag) if alpha[i]&flag else 'c'+str(alpha[i]) for i from 0 <= i < alpha_length]) 1856 print "m:", m 1857 print "alpha:", ','.join(['w'+str(alpha[i]^flag) if alpha[i]&flag else 'c'+str(alpha[i]) for i from 0 <= i < alpha_length]) 1858 print self 1796 1859 invariant += 1 1797 1860 j = 0 1798 1861 if alpha[m] & flag: 1862 # print 'word' 1799 1863 while j < self_ncols: 1864 # print 'j', j 1865 # print self 1800 1866 i = j; s = 0 1801 1867 invariant += 8 1802 1868 while True: 1803 self_col_degs[i-j] = self.col_degree(CG, i, alpha[m]^flag, k) 1869 # print 'col_i', self_col_ents[i] 1870 # print 'alpha[m]^flag', alpha[m]^flag 1871 self_col_degs[i-j] = self.col_degree(CG, self_col_ents[i], alpha[m]^flag, k) 1872 # print 'deg', self_col_degs[i-j] 1804 1873 if s == 0 and self_col_degs[i-j] != self_col_degs[0]: s = 1 1805 1874 i += 1 1806 1875 if self_col_lvls[i-1] <= k: break 1807 1876 if s: 1877 # print 's' 1808 1878 invariant += 8 1809 1879 t = self.sort_cols(j, k) … … 1826 1896 j += 1 1827 1897 j += 1 1898 # print 'end s j:', j 1828 1899 invariant += (i-j) 1829 1900 else: j = i 1830 1901 else: 1902 print 'col' 1831 1903 while j < self.nwords: 1904 print 'j', j 1905 print self 1832 1906 i = j; s = 0 1833 1907 invariant += 64 1834 1908 while True: 1835 self_wd_degs[i-j] = self.wd_degree(CG, i, alpha[m], k, ham_wts) 1909 print 'i', i 1910 self_wd_degs[i-j] = self.wd_degree(CG, self_wd_ents[i], alpha[m], k, ham_wts) 1911 print 'deg', self_wd_degs[i-j] 1836 1912 if s == 0 and self_wd_degs[i-j] != self_wd_degs[0]: s = 1 1837 1913 i += 1 … … 2180 2256 self.w_gamma = <int *> sage_malloc( self.w_gamma_size * sizeof(int) ) 2181 2257 self.alpha = <int *> sage_malloc( self.alpha_size * sizeof(int) ) 2182 self. new_Phi = <int *> sage_malloc( self.Phi_size * self.L* sizeof(int) )2183 self. new_Omega = <int *> sage_malloc( self.Phi_size * self.L * sizeof(int) )2184 self. new_W = <int *> sage_malloc( self.Phi_size * self.radix * 2 * sizeof(int) )2258 self.Phi = <int *> sage_malloc( self.Phi_size * (self.L+1) * sizeof(int) ) 2259 self.Omega = <int *> sage_malloc( self.Phi_size * self.L * sizeof(int) ) 2260 self.W = <int *> sage_malloc( self.Phi_size * self.radix * 2 * sizeof(int) ) 2185 2261 2186 2262 self.aut_gp_gens = <int *> sage_malloc( self.aut_gens_size * sizeof(int) ) … … 2193 2269 self.e = <int *> sage_malloc( self.radix * 2 * sizeof(int) ) 2194 2270 2195 # TODO: remove these2196 self.Phi = <int *> sage_malloc( self.L * sizeof(int) )2197 self.Omega = <int *> sage_malloc( self.L * sizeof(int) )2198 self.W = <int *> sage_malloc( self.radix * sizeof(int) )2199 2200 2271 if not (self.Phi and self.Omega and self.W and self.Lambda1 and self.Lambda2 and self.Lambda3 \ 2201 2272 and self.w_gamma and self.c_gamma and self.alpha and self.v and self.e and self.aut_gp_gens \ 2202 and self.labeling and self.new_Phi and self.new_Omega and self.new_W):2273 and self.labeling): 2203 2274 if self.Phi: sage_free(self.Phi) 2204 2275 if self.Omega: sage_free(self.Omega) 2205 2276 if self.W: sage_free(self.W) 2206 if self.new_Phi: sage_free(self.new_Phi)2207 if self.new_Omega: sage_free(self.new_Omega)2208 if self.new_W: sage_free(self.new_W)2209 2277 if self.Lambda1: sage_free(self.Lambda1) 2210 2278 if self.Lambda2: sage_free(self.Lambda2) … … 2231 2299 if self.w_gamma: sage_free(self.w_gamma) 2232 2300 if self.alpha: sage_free(self.alpha) 2233 if self.new_Phi: sage_free(self.new_Phi)2234 if self.new_Omega: sage_free(self.new_Omega)2235 if self.new_W: sage_free(self.new_W)2236 2301 2237 2302 if self.v: sage_free(self.v) … … 2269 2334 2270 2335 # declare variables: 2271 cdef int i, j, ii, jj # local variables2336 cdef int i, j, ii, jj, iii, jjj # local variables 2272 2337 2273 2338 cdef PartitionStack nu, zeta, rho # nu is the current position in the tree, … … 2291 2356 cdef OrbitPartition Theta # keeps track of which vertices have been discovered to be equivalent 2292 2357 cdef int *Phi = self.Phi # Phi stores the fixed point sets of each automorphism 2293 cdef int *new_Phi = self.new_Phi2294 2358 cdef int *Omega = self.Omega # Omega stores the minimal elements of each cell of the orbit partition 2295 cdef int *new_Omega = self.new_Omega2296 2359 cdef int l = -1 # current index for storing values in Phi and Omega- we start at -1 so that when 2297 2360 # we increment first, the first place we write to is 0. … … 2299 2362 # the current partition, at k. Phi and Omega are ultimately used to make the size of 2300 2363 # W as small as possible 2301 cdef int *new_W = self.new_W2302 2364 cdef int *e = self.e # 0 or 1, whether or not we have used Omega and Phi to narrow down W[k] yet: see states 12 and 17 2303 2365 … … 2326 2388 self.alpha_size = self.w_gamma_size + self.radix 2327 2389 self.Phi_size = self.w_gamma_size/self.radix + 1 2328 self.w_gamma = <int *> sage_realloc(self.w_gamma, self.w_gamma_size * sizeof(int) )2329 self.alpha = <int *> sage_realloc(self.alpha, self.alpha_size * sizeof(int) )2330 self. new_Phi = <int *> sage_realloc(self.new_Phi, self.Phi_size * self.L * sizeof(int) )2331 self. new_Omega = <int *> sage_realloc(self.new_Omega, self.Phi_size * self.L * sizeof(int) )2332 self. new_W = <int *> sage_realloc(self.new_W, self.Phi_size * self.radix * 2 * sizeof(int) )2333 if not (self.w_gamma and self.alpha and self. new_Phi and self.new_Omega and self.new_W):2390 self.w_gamma = <int *> sage_realloc(self.w_gamma, self.w_gamma_size * sizeof(int) ) 2391 self.alpha = <int *> sage_realloc(self.alpha, self.alpha_size * sizeof(int) ) 2392 self.Phi = <int *> sage_realloc(self.new_Phi, self.Phi_size * self.L * sizeof(int) ) 2393 self.Omega = <int *> sage_realloc(self.new_Omega, self.Phi_size * self.L * sizeof(int) ) 2394 self.W = <int *> sage_realloc(self.new_W, self.Phi_size * self.radix * 2 * sizeof(int) ) 2395 if not (self.w_gamma and self.alpha and self.Phi and self.Omega and self.W): 2334 2396 if self.w_gamma: sage_free(self.w_gamma) 2335 2397 if self.alpha: sage_free(self.alpha) 2336 if self. new_Phi: sage_free(self.new_Phi)2337 if self. new_Omega: sage_free(self.new_Omega)2338 if self. new_W: sage_free(self.new_W)2398 if self.Phi: sage_free(self.Phi) 2399 if self.Omega: sage_free(self.Omega) 2400 if self.W: sage_free(self.W) 2339 2401 raise MemoryError("Memory.") 2340 2402 word_gamma = self.w_gamma … … 2351 2413 state = 1 2352 2414 while state != -1: 2353 print "state:", state 2354 print "k:", k 2355 print "h:", h 2356 print "hzf:", hzf 2357 print "v[k]", v[k] 2358 print "tvc", tvc 2359 print "W[k]", Integer(W[k]).binary() 2360 print "aut_gp_index", self.aut_gp_index 2361 print nu 2362 badass += 1 #168-195 2363 #if badass > 168: break 2415 if True:#badass > 39: 2416 print '-----' 2417 print badass 2418 print "k:", k 2419 if k != -1: 2420 if v[k]&nu.flag: 2421 print "v[k]: word ", v[k]^nu.flag 2422 else: 2423 print "v[k]: col ", v[k] 2424 if tvc&nu.flag: 2425 print "tvc- wd", tvc^nu.flag 2426 else: 2427 print "tvc- col", tvc 2428 if W[self.Phi_size * k]: 2429 print "W[k]: cols", Integer(W[self.Phi_size * k]).binary() 2430 else: 2431 j = nwords/self.radix 2432 if nwords%self.radix: 2433 j += 1 2434 print "W[k]: words", [Integer(W[self.Phi_size * k + 1 + i]).binary() for i from 0 <= i < j] 2435 print nu 2436 if hh != -1: print zeta 2437 if False: 2438 print "h:", h 2439 print "hzf:", hzf__h_zeta 2440 print "aut_gp_index", self.aut_gp_index 2441 print 'hh', hh 2442 print 'ht', ht 2443 print 'hzf__h_zeta', hzf__h_zeta 2444 print 'qzb', qzb 2445 if True: 2446 print "state:", state 2447 print '-----' 2448 badass += 1 2449 #if badass > 92: break 2450 #if badass > 2: break 2364 2451 2365 2452 if state == 1: # Entry point: once only … … 2372 2459 # store the first smallest nontrivial cell in W[k], and set v[k] 2373 2460 # equal to its minimum element 2374 v[k] = nu.new_first_smallest_nontrivial(k, new_W, 2*self.radix*k) 2375 W[k] = nu.first_smallest_nontrivial(k) # TODO: remove 2376 v[k] = nu.v # stored during first_smallest_nontrivial # TODO: remove 2461 v[k] = nu.new_first_smallest_nontrivial(k, W, self.Phi_size * k) 2377 2462 2378 2463 Lambda[k] = 0 … … 2389 2474 2390 2475 alpha[0] = nu.split_vertex(v[k-1], k) 2391 alpha[0] = nu.split_column(v[k-1], k) # TODO: remove this 2392 2476 print nu 2393 2477 Lambda[k] = nu.refine(k, alpha, 1, C, ham_wts) # store the invariant to Lambda[k] 2394 2478 # only if this is the first time moving down the search tree: … … 2427 2511 # store the first smallest nontrivial cell in W[k], and set v[k] 2428 2512 # equal to its minimum element 2429 v[k] = nu.new_first_smallest_nontrivial(k, new_W, 2*self.radix*k) 2430 W[k] = nu.first_smallest_nontrivial(k) # TODO: remove 2431 v[k] = nu.v # stored during first_smallest_nontrivial # TODO: remove 2513 v[k] = nu.new_first_smallest_nontrivial(k, W, self.Phi_size * k) 2432 2514 if not nu.sat_225(k): hh = k + 1 2433 2515 e[k] = 0 # see state 12 and 17 … … 2443 2525 elif state == 6: # at this stage, there is no reason to continue downward, so backtrack 2444 2526 j = k 2527 # print 'current k', j 2528 # print 'ht', ht 2529 # print 'hzb__h_rho', hzb__h_rho 2530 # print 'hh', hh 2445 2531 # return to the longest ancestor nu[i] of nu that could have a 2446 2532 # descendant equivalent to zeta or could improve on rho. … … 2473 2559 # pruning, so we store its fixed set and a set of representatives of its cells. 2474 2560 if l < self.L-1: l += 1 2475 Omega[l] = nu.min_cell_reps(hh) 2476 Phi[l] = nu.fixed_cols(Omega[l], hh) 2561 nu.new_min_cell_reps(hh, Omega, self.Phi_size*l) 2562 nu.fixed_vertices(hh, Phi, Omega, self.Phi_size*l) 2563 2477 2564 state = 12 2478 2565 … … 2484 2571 # hzf is the extremal height of ancestors of both nu and zeta, so if k < hzf, nu is not 2485 2572 # equivalent to zeta, i.e. there is no automorphism to discover. 2486 if k < hzf : state = 8; continue2573 if k < hzf__h_zeta: state = 8; continue 2487 2574 2488 2575 nu.get_permutation(zeta, word_gamma, col_gamma, ham_wts) … … 2511 2598 2512 2599 # if C(nu) == C(rho), get the automorphism and goto 10 2513 nu.find_basis(ham_wts)2514 2600 rho.get_permutation(nu, word_gamma, col_gamma, ham_wts) 2515 2601 print "gamma:", [word_gamma[i] for i from 0 <= i < nwords], [col_gamma[i] for i from 0 <= i < ncols] … … 2529 2615 # increment l 2530 2616 if l < self.L-1: l += 1 2617 2531 2618 # store information about the automorphism to Omega and Phi 2619 ii = self.Phi_size*l 2620 Omega[ii] = ~(~0 << ncols) 2621 Phi[ii] = 0 2622 jj = 1 + nwords/self.radix 2623 if nwords%self.radix: 2624 jj += 1 2625 for i from 0 < i < jj: 2626 Omega[ii+i] = ~0 2627 Phi[ii+i] = 0 2628 Omega[ii+jj-1] = ~(~0 << nwords%self.radix) 2532 2629 # Omega stores the minimum cell representatives 2533 Omega[l] = ~02534 2630 i = 0 2535 2631 while i < ncols: 2536 2632 j = col_gamma[i] # i is a minimum 2537 2633 while j != i: # cell rep, 2538 Omega[ l] ^= (1<<j)# so cancel2634 Omega[ii] ^= (1<<j) # so cancel 2539 2635 j = col_gamma[j] # cellmates 2540 2636 i += 1 2541 while i < ncols and not Omega[l]&(1<<i): # find minimal element 2542 i += 1 # of next cell 2637 while i < ncols and not Omega[ii]&(1<<i): # find minimal element 2638 i += 1 # of next cell 2639 i = 0 2640 jj = self.radix 2641 while i < nwords: 2642 j = word_gamma[i] 2643 while j != i: 2644 Omega[ii+1+j/jj] ^= (1<<(j%jj)) 2645 j = word_gamma[j] 2646 i += 1 2647 while i < nwords and not Omega[ii+1+i/jj]&(1<<(i%jj)): 2648 i += 1 2543 2649 # Phi stores the columns fixed by the automorphism 2544 Phi[l] = 02545 2650 for i from 0 <= i < ncols: 2546 2651 if col_gamma[i] == i: 2547 Phi[l] ^= (1 << i) 2652 Phi[ii] ^= (1 << i) 2653 for i from 0 <= i < nwords: 2654 if word_gamma[i] == i: 2655 Phi[ii+1+i/jj] ^= (1<<(i%jj)) 2656 2548 2657 # Now incorporate the automorphism into Theta 2549 2658 j = Theta.merge_perm(col_gamma, word_gamma) 2550 if not j: print "no j"2659 # if not j: print "no j" 2551 2660 # j stores whether anything happened or not- if not, then the automorphism we have 2552 2661 # discovered is already in the subgroup spanned by the generators we have output … … 2558 2667 # algorithm came up to meet zeta. At this point, we were considering the new 2559 2668 # possibilities for descending away from zeta at this level. 2560 if Theta.col_min_cell_rep[Theta.col_find(tvc)] == tvc: 2561 # if this is still a minimum cell representative of Theta, even in light 2562 # of this new automorphism, then the current branch off of zeta hasn't been 2563 # found equivalent to one already searched yet, so there may still be a 2564 # better canonical label downward. 2565 state = 11; continue 2669 # if this is still a minimum cell representative of Theta, even in light 2670 # of this new automorphism, then the current branch off of zeta hasn't been 2671 # found equivalent to one already searched yet, so there may still be a 2672 # better canonical label downward. 2673 if tvc & nu.flag: 2674 i = tvc^nu.flag 2675 if Theta.wd_min_cell_rep[Theta.wd_find(i)] == i: 2676 state = 11; continue 2677 else: 2678 if Theta.col_min_cell_rep[Theta.col_find(tvc)] == tvc: 2679 state = 11; continue 2566 2680 2567 2681 # Otherwise, proceed to where zeta meets nu: … … 2589 2703 # before, so we have already intersected W[k] with the bulk of Omega and Phi, but 2590 2704 # we should still catch up with the latest ones 2591 W[k] &= Omega[l] 2705 ii = self.Phi_size*l 2706 jj = self.Phi_size*k 2707 j = 1 + nwords/self.radix 2708 if nwords%self.radix: 2709 j += 1 2710 W[jj] &= Omega[ii] 2711 for i from 0 < i < j: 2712 W[jj+i] &= Omega[ii+i] 2592 2713 state = 13 2593 2714 … … 2602 2723 h = k 2603 2724 tvc = 0 2604 while not (1 << tvc) & W[k]: 2605 tvc += 1 2725 jj = self.Phi_size*k 2726 if W[jj]: 2727 # print 'W[jj]', W[jj] 2728 # print tvc 2729 while not (1 << tvc) & W[jj]: 2730 tvc += 1 2731 else: 2732 ii = 0 2733 while not W[jj+1+ii]: 2734 ii += 1 2735 while not W[jj+1+ii] & (1 << tvc): 2736 tvc += 1 2737 tvc = (ii*self.radix + tvc) ^ nu.flag 2606 2738 # now tvc points to the minimal cell representative of W[k] 2607 2739 state = 14 2608 2740 2609 2741 elif state == 14: # see if there are any more splits to make from this level of zeta (see state 17) 2610 if Theta.col_find(v[k]) == Theta.col_find(tvc): 2611 index += 1 2612 # keep tabs on how many elements are in the same cell of Theta as tvc 2742 if v[k]&nu.flag == tvc&nu.flag: 2743 if tvc&nu.flag: 2744 if Theta.wd_find(v[k]^nu.flag) == Theta.wd_find(tvc^nu.flag): 2745 index += 1 2746 else: 2747 if Theta.col_find(v[k]) == Theta.col_find(tvc): 2748 index += 1 2749 # keep tabs on how many elements are in the same cell of Theta as tvc 2613 2750 # find the next split 2614 i = v[k] + 1 2615 while i < ncols and not (1 << i) & W[k]: 2616 i += 1 2617 if i < ncols: 2618 v[k] = i 2751 jj = self.Phi_size*k 2752 if v[k]&nu.flag: 2753 ii = self.radix 2754 i = (v[k]^nu.flag) + 1 2755 while i < nwords and not (1 << i%ii) & W[jj+1+i/ii]: 2756 i += 1 2757 if i < nwords: 2758 v[k] = i^nu.flag 2759 else: 2760 # there is no new split at this level 2761 state = 16; continue 2762 # new split column better be a minimal representative in Theta, or wasted effort 2763 if Theta.wd_min_cell_rep[Theta.wd_find(i)] == i: 2764 state = 15 2765 else: 2766 state = 14 2619 2767 else: 2620 # there is no new split at this level 2621 v[k] = -1 2622 state = 16; continue 2623 2624 # new split column better be a minimal representative in Theta, or wasted effort 2625 if Theta.col_min_cell_rep[Theta.col_find(tvc)] == tvc: 2626 state = 15 2627 else: 2628 state = 14 2768 i = v[k] + 1 2769 while i < ncols and not (1 << i) & W[jj]: 2770 i += 1 2771 if i < ncols: 2772 v[k] = i 2773 else: 2774 # there is no new split at this level 2775 state = 16; continue 2776 # new split column better be a minimal representative in Theta, or wasted effort 2777 if Theta.col_min_cell_rep[Theta.col_find(v[k])] == v[k]: 2778 state = 15 2779 else: 2780 state = 14 2629 2781 2630 2782 elif state == 15: # split out the column v[k] … … 2634 2786 hh = k + 1 2635 2787 # hzf is maximal such that indicators line up for nu and zeta 2636 if k < hzf :2637 hzf = k2788 if k < hzf__h_zeta: 2789 hzf__h_zeta = k 2638 2790 # hb is longest common ancestor of nu and rho 2639 2791 if hb >= k: … … 2643 2795 2644 2796 elif state == 16: # backtrack up zeta, updating information about stabilizer vector 2645 i = W[k] 2646 j = ham_wts[i & 65535] + ham_wts[(i >> 16) & 65535] 2797 jj = self.Phi_size*k 2798 if W[jj]: 2799 i = W[jj] 2800 j = ham_wts[i & 65535] + ham_wts[(i >> 16) & 65535] 2801 else: 2802 i = 0; j = 0 2803 ii = self.radix 2804 while i*ii < nwords: 2805 iii = W[jj+1+i] 2806 j += ham_wts[iii & 65535] + ham_wts[(iii >> 16) & 65535] 2807 i += 1 2647 2808 if j == index and ht == k + 1: ht = k 2648 2809 size = size*index … … 2655 2816 if e[k] == 0: # now is the time to narrow down W[k] by Omega and Phi 2656 2817 # intersect W[k] with each Omega[i] such that v[0]...v[k-1] is in Phi[i] 2657 ii = 0 2658 for i from 0 <= i < k: 2659 ii ^= (1 << v[i]) 2818 jjj = self.Phi_size*k 2819 jj = self.Phi_size*self.L 2820 iii = nwords/self.radix + 1 2821 if nwords%self.radix: 2822 iii += 1 2823 for ii from 0 <= ii < iii: 2824 Phi[jj+ii] = 0 2825 for ii from 0 <= ii < k: 2826 if v[ii]&nu.flag: 2827 i = v[ii]^nu.flag 2828 Phi[jj+1+i/self.radix] ^= (1 << i%self.radix) 2829 else: 2830 Phi[jj] ^= (1 << v[ii]) 2660 2831 for i from 0 <= i <= l: 2661 if Phi[i] & ii == ii: 2662 W[k] &= Omega[i] 2832 ii = self.Phi_size*i 2833 for j from 0 <= j < iii: 2834 if Phi[ii + j] & Phi[jj + j] == Phi[jj + j]: 2835 W[jjj + j] &= Omega[ii + j] 2663 2836 e[k] = 1 2664 2837 # see if there is a vertex to split out 2665 i = v[k] + 1 2666 while i < ncols: 2667 i += 1 2668 if (1 << i) & W[k]: break 2669 if i < ncols: 2670 v[k] = i 2671 state = 15; continue 2672 2673 v[k] = -1 2838 if nu.flag&v[k]: 2839 i = (v[k]^nu.flag) + 1 2840 while i < nwords: 2841 i += 1 2842 if (1 << i%self.radix) & W[jjj+1+i/self.radix]: break 2843 if i < nwords: 2844 v[k] = i^nu.flag 2845 state = 15; continue 2846 else: 2847 i = v[k] + 1 2848 while i < ncols: 2849 i += 1 2850 if (1 << i) & W[jjj]: break 2851 if i < ncols: 2852 v[k] = i 2853 state = 15; continue 2854 2674 2855 k -= 1 2675 2856 state = 13 … … 2679 2860 h = k # zeta[h] == nu[h] 2680 2861 ht = k # nodes descended from zeta[ht] are all equivalent 2681 hzf = k # max such that indicators for zeta and nu agree2862 hzf__h_zeta = k # max such that indicators for zeta and nu agree 2682 2863 zeta = PartitionStack(nu) 2683 2864 # (POINT B) … … 2692 2873 2693 2874 # end big while loop 2694 rho.find_basis(ham_wts)2695 for i from 0 <= i < ncols:2696 self.labeling[rho.col_ents[i]] = i2697 for i from 0 <= i < nrows:2698 self.labeling[i+ncols] = rho.basis_locations[i]2699 2700 2701 2702 2703 2875 # rho.find_basis(ham_wts) 2876 # for i from 0 <= i < ncols: 2877 # self.labeling[rho.col_ents[i]] = i 2878 # for i from 0 <= i < nrows: 2879 # self.labeling[i+ncols] = rho.basis_locations[i] 2880 2881 2882 2883 2884
Note: See TracChangeset
for help on using the changeset viewer.
