@@ -3194,12 +3194,11 @@ def PGE(S, u, v):
3194
3194
return S .one ()
3195
3195
return S ((u , v ), check = False )
3196
3196
3197
- PM_old = self .vertex_facet_pairing_matrix ()
3198
- n_v = PM_old .ncols ()
3199
- n_f = PM_old .nrows ()
3197
+ PM = self .vertex_facet_pairing_matrix ()
3198
+ n_v = PM .ncols ()
3199
+ n_f = PM .nrows ()
3200
3200
S_v = SymmetricGroup (n_v )
3201
3201
S_f = SymmetricGroup (n_f )
3202
- PM = PermutedMatrixWindow (PM_old , 0 , 0 , n_f , n_v )
3203
3202
3204
3203
# and find all the ways of making the first row of PM_max
3205
3204
def index_of_max (iterable ):
@@ -3213,9 +3212,7 @@ def index_of_max(iterable):
3213
3212
n_s = 1
3214
3213
permutations = {0 : [S_f .one (), S_v .one ()]}
3215
3214
for j in range (n_v ):
3216
- m = index_of_max (
3217
- [(PM .with_permuted_columns (permutations [0 ][1 ]))[0 ][i ]
3218
- for i in range (j , n_v )])
3215
+ m = index_of_max ([PM [0 ][i ] for i in range (j , n_v )])
3219
3216
if m > 0 :
3220
3217
permutations [0 ][1 ] = PGE (S_v , j + 1 , m + j + 1 ) * permutations [0 ][1 ]
3221
3218
first_row = list (PM [0 ])
@@ -3224,25 +3221,23 @@ def index_of_max(iterable):
3224
3221
for k in range (1 , n_f ):
3225
3222
# Error for k == 1 already!
3226
3223
permutations [n_s ] = [S_f .one (), S_v .one ()]
3227
- m = index_of_max (PM . with_permuted_columns ( permutations [n_s ][1 ])[ k ])
3224
+ m = index_of_max (PM [ k , tuple (( permutations [n_s ][1 ]. inverse ())( j + 1 ) - 1 for j in range ( n_v )) ])
3228
3225
if m > 0 :
3229
3226
permutations [n_s ][1 ] = PGE (S_v , 1 , m + 1 ) * permutations [n_s ][1 ]
3230
- d = (( PM . with_permuted_columns (permutations [n_s ][1 ]))[ k ][ 0 ]
3227
+ d = (PM [ k , (permutations [n_s ][1 ]. inverse ())( 1 ) - 1 ]
3231
3228
- permutations [0 ][1 ](first_row )[0 ])
3232
3229
if d < 0 :
3233
3230
# The largest elt of this row is smaller than largest elt
3234
3231
# in 1st row, so nothing to do
3235
3232
continue
3236
3233
# otherwise:
3237
3234
for i in range (1 , n_v ):
3238
- m = index_of_max (
3239
- [PM .with_permuted_columns (permutations [n_s ][1 ])[k ][j ]
3240
- for j in range (i , n_v )])
3235
+ m = index_of_max (PM [k , tuple ((permutations [n_s ][1 ].inverse ())(j + 1 )- 1 for j in range (i ,n_v ))])
3241
3236
if m > 0 :
3242
3237
permutations [n_s ][1 ] = PGE (S_v , i + 1 , m + i + 1 ) \
3243
3238
* permutations [n_s ][1 ]
3244
3239
if d == 0 :
3245
- d = (PM . with_permuted_columns (permutations [n_s ][1 ])[ k ][ i ]
3240
+ d = (PM [ k , (permutations [n_s ][1 ]. inverse ())( i + 1 ) - 1 ]
3246
3241
- permutations [0 ][1 ](first_row )[i ])
3247
3242
if d < 0 :
3248
3243
break
@@ -3262,7 +3257,7 @@ def index_of_max(iterable):
3262
3257
n_s = 1
3263
3258
permutations = {k :permutations [k ] for k in permutations if k < n_s }
3264
3259
3265
- b = PM . with_permuted_rows_and_columns ( * permutations [0 ]) [0 ]
3260
+ b = tuple ( PM [( permutations [0 ][ 0 ]. inverse ())( 1 ) - 1 , ( permutations [0 ][ 1 ]. inverse ())( j + 1 ) - 1 ] for j in range ( n_v ))
3266
3261
# Work out the restrictions the current permutations
3267
3262
# place on other permutations as a automorphisms
3268
3263
# of the first row
@@ -3296,20 +3291,17 @@ def index_of_max(iterable):
3296
3291
# between 0 and S(0)
3297
3292
for s in range (l , n_f ):
3298
3293
for j in range (1 , S [0 ]):
3299
- v = PM .with_permuted_rows_and_columns (
3300
- * permutations_bar [n_p ])[s ]
3294
+ v = tuple (PM [(permutations_bar [n_p ][0 ].inverse ())(s + 1 )- 1 , (permutations_bar [n_p ][1 ].inverse ())(j + 1 )- 1 ] for j in range (n_v ))
3301
3295
if v [0 ] < v [j ]:
3302
3296
permutations_bar [n_p ][1 ] = PGE (S_v , 1 , j + 1 ) * permutations_bar [n_p ][1 ]
3303
3297
if ccf == 0 :
3304
- l_r [0 ] = PM .with_permuted_rows_and_columns (
3305
- * permutations_bar [n_p ])[s ][0 ]
3298
+ l_r [0 ] = PM [(permutations_bar [n_p ][0 ].inverse ())(s + 1 )- 1 , (permutations_bar [n_p ][1 ].inverse ())(1 )- 1 ]
3306
3299
permutations_bar [n_p ][0 ] = PGE (S_f , l + 1 , s + 1 ) * permutations_bar [n_p ][0 ]
3307
3300
n_p += 1
3308
3301
ccf = 1
3309
3302
permutations_bar [n_p ] = copy (permutations [k ])
3310
3303
else :
3311
- d1 = PM .with_permuted_rows_and_columns (
3312
- * permutations_bar [n_p ])[s ][0 ]
3304
+ d1 = PM [(permutations_bar [n_p ][0 ].inverse ())(s + 1 )- 1 , (permutations_bar [n_p ][1 ].inverse ())(1 )- 1 ]
3313
3305
d = d1 - l_r [0 ]
3314
3306
if d < 0 :
3315
3307
# We move to the next line
@@ -3345,18 +3337,15 @@ def index_of_max(iterable):
3345
3337
s -= 1
3346
3338
# Find the largest value in this symmetry block
3347
3339
for j in range (c + 1 , h ):
3348
- v = PM .with_permuted_rows_and_columns (
3349
- * permutations_bar [s ])[l ]
3340
+ v = tuple (PM [(permutations_bar [s ][0 ].inverse ())(l + 1 )- 1 , (permutations_bar [s ][1 ].inverse ())(j + 1 )- 1 ] for j in range (n_v ))
3350
3341
if (v [c ] < v [j ]):
3351
3342
permutations_bar [s ][1 ] = PGE (S_v , c + 1 , j + 1 ) * permutations_bar [s ][1 ]
3352
3343
if ccf == 0 :
3353
3344
# Set reference and carry on to next permutation
3354
- l_r [c ] = PM .with_permuted_rows_and_columns (
3355
- * permutations_bar [s ])[l ][c ]
3345
+ l_r [c ] = PM [(permutations_bar [s ][0 ].inverse ())(l + 1 )- 1 , (permutations_bar [s ][1 ].inverse ())(c + 1 )- 1 ]
3356
3346
ccf = 1
3357
3347
else :
3358
- d1 = PM .with_permuted_rows_and_columns (
3359
- * permutations_bar [s ])[l ][c ]
3348
+ d1 = PM [(permutations_bar [s ][0 ].inverse ())(l + 1 )- 1 , (permutations_bar [s ][1 ].inverse ())(c + 1 )- 1 ]
3360
3349
d = d1 - l_r [c ]
3361
3350
if d < 0 :
3362
3351
n_p -= 1
@@ -3385,7 +3374,7 @@ def index_of_max(iterable):
3385
3374
# the restrictions the last worked out
3386
3375
# row imposes.
3387
3376
c = 0
3388
- M = (PM . with_permuted_rows_and_columns ( * permutations [0 ]))[ l ]
3377
+ M = tuple (PM [( permutations [0 ][ 0 ]. inverse ())( l + 1 ) - 1 , ( permutations [ 0 ][ 1 ]. inverse ())( j + 1 ) - 1 ] for j in range ( n_v ))
3389
3378
while c < n_v :
3390
3379
s = S [c ] + 1
3391
3380
S [c ] = c + 1
@@ -3398,7 +3387,7 @@ def index_of_max(iterable):
3398
3387
S [c ] = c + 1
3399
3388
c += 1
3400
3389
# Now we have the perms, we construct PM_max using one of them
3401
- PM_max = PM_old .with_permuted_rows_and_columns (* permutations [0 ])
3390
+ PM_max = PM .with_permuted_rows_and_columns (* permutations [0 ])
3402
3391
if check :
3403
3392
return (PM_max , permutations )
3404
3393
else :
0 commit comments