@@ -3209,54 +3209,54 @@ def index_of_max(iterable):
3209
3209
return m
3210
3210
3211
3211
n_s = 1
3212
- permutations_inv = {0 : [S_f .one (), S_v .one ()]}
3212
+ permutations = {0 : [S_f .one (), S_v .one ()]}
3213
3213
for j in range (n_v ):
3214
3214
m = index_of_max ([PM [0 ][i ] for i in range (j , n_v )])
3215
3215
if m > 0 :
3216
- permutations_inv [0 ][1 ] = permutations_inv [ 0 ][ 1 ] * PGE (S_v , j + 1 , m + j + 1 )
3216
+ permutations [0 ][1 ] = PGE (S_v , j + 1 , m + j + 1 ) * permutations [ 0 ][ 1 ]
3217
3217
first_row = list (PM [0 ])
3218
3218
3219
3219
# Arrange other rows one by one and compare with first row
3220
3220
for k in range (1 , n_f ):
3221
3221
# Error for k == 1 already!
3222
- permutations_inv [n_s ] = [S_f .one (), S_v .one ()]
3223
- m = index_of_max (tuple (PM [k , permutations_inv [n_s ][1 ](j + 1 ) - 1 ] for j in range (n_v )))
3222
+ permutations [n_s ] = [S_f .one (), S_v .one ()]
3223
+ m = index_of_max (tuple (PM [k , permutations [n_s ][1 ](j + 1 ) - 1 ] for j in range (n_v )))
3224
3224
if m > 0 :
3225
- permutations_inv [n_s ][1 ] = permutations_inv [ n_s ][ 1 ] * PGE (S_v , 1 , m + 1 )
3226
- d = (PM [k , permutations_inv [n_s ][1 ](1 ) - 1 ]
3227
- - ( permutations_inv [0 ][1 ]. inverse ()) (first_row )[0 ])
3225
+ permutations [n_s ][1 ] = PGE (S_v , 1 , m + 1 ) * permutations [ n_s ][ 1 ]
3226
+ d = (PM [k , permutations [n_s ][1 ](1 ) - 1 ]
3227
+ - permutations [0 ][1 ](first_row )[0 ])
3228
3228
if d < 0 :
3229
3229
# The largest elt of this row is smaller than largest elt
3230
3230
# in 1st row, so nothing to do
3231
3231
continue
3232
3232
# otherwise:
3233
3233
for i in range (1 , n_v ):
3234
- m = index_of_max (tuple (PM [k , permutations_inv [n_s ][1 ](j + 1 ) - 1 ] for j in range (i ,n_v )))
3234
+ m = index_of_max (tuple (PM [k , permutations [n_s ][1 ](j + 1 ) - 1 ] for j in range (i ,n_v )))
3235
3235
if m > 0 :
3236
- permutations_inv [n_s ][1 ] = permutations_inv [ n_s ][ 1 ] \
3237
- * PGE ( S_v , i + 1 , m + i + 1 )
3236
+ permutations [n_s ][1 ] = PGE ( S_v , i + 1 , m + i + 1 ) \
3237
+ * permutations [ n_s ][ 1 ]
3238
3238
if d == 0 :
3239
- d = (PM [k , permutations_inv [n_s ][1 ](i + 1 ) - 1 ]
3240
- - ( permutations_inv [0 ][1 ]. inverse ()) (first_row )[i ])
3239
+ d = (PM [k , permutations [n_s ][1 ](i + 1 ) - 1 ]
3240
+ - permutations [0 ][1 ](first_row )[i ])
3241
3241
if d < 0 :
3242
3242
break
3243
3243
if d < 0 :
3244
3244
# This row is smaller than 1st row, so nothing to do
3245
- del permutations_inv [n_s ]
3245
+ del permutations [n_s ]
3246
3246
continue
3247
- permutations_inv [n_s ][0 ] = permutations_inv [ n_s ][ 0 ] * PGE (S_f , 1 , k + 1 )
3247
+ permutations [n_s ][0 ] = PGE (S_f , 1 , k + 1 ) * permutations [ n_s ][ 0 ]
3248
3248
if d == 0 :
3249
3249
# This row is the same, so we have a symmetry!
3250
3250
n_s += 1
3251
3251
else :
3252
3252
# This row is larger, so it becomes the first row and
3253
3253
# the symmetries reset.
3254
3254
first_row = list (PM [k ])
3255
- permutations_inv = {0 : permutations_inv [n_s ]}
3255
+ permutations = {0 : permutations [n_s ]}
3256
3256
n_s = 1
3257
- permutations_inv = {k : permutations_inv [k ] for k in permutations_inv if k < n_s }
3257
+ permutations = {k : permutations [k ] for k in permutations if k < n_s }
3258
3258
3259
- b = tuple (PM [permutations_inv [0 ][0 ](1 ) - 1 , permutations_inv [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3259
+ b = tuple (PM [permutations [0 ][0 ](1 ) - 1 , permutations [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3260
3260
# Work out the restrictions the current permutations
3261
3261
# place on other permutations as a automorphisms
3262
3262
# of the first row
@@ -3274,7 +3274,7 @@ def index_of_max(iterable):
3274
3274
# We determine the other rows of PM_max in turn by use of perms and
3275
3275
# aut on previous rows.
3276
3276
for l in range (1 , n_f - 1 ):
3277
- n_s = len (permutations_inv )
3277
+ n_s = len (permutations )
3278
3278
n_s_bar = n_s
3279
3279
cf = 0
3280
3280
l_r = [0 ]* n_v
@@ -3284,42 +3284,42 @@ def index_of_max(iterable):
3284
3284
# number of local permutations associated with current global
3285
3285
n_p = 0
3286
3286
ccf = cf
3287
- permutations_inv_bar = {0 : copy (permutations_inv [k ])}
3287
+ permutations_bar = {0 : copy (permutations [k ])}
3288
3288
# We look for the line with the maximal entry in the first
3289
3289
# subsymmetry block, i.e. we are allowed to swap elements
3290
3290
# between 0 and S(0)
3291
3291
for s in range (l , n_f ):
3292
3292
for j in range (1 , S [0 ]):
3293
- v = tuple (PM [permutations_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3293
+ v = tuple (PM [permutations_bar [n_p ][0 ](s + 1 ) - 1 , permutations_bar [n_p ][1 ](i + 1 ) - 1 ] for i in range (n_v ))
3294
3294
if v [0 ] < v [j ]:
3295
- permutations_inv_bar [n_p ][1 ] = permutations_inv_bar [ n_p ][ 1 ] * PGE (S_v , 1 , j + 1 )
3295
+ permutations_bar [n_p ][1 ] = PGE (S_v , 1 , j + 1 ) * permutations_bar [ n_p ][ 1 ]
3296
3296
if ccf == 0 :
3297
- l_r [0 ] = PM [permutations_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](1 ) - 1 ]
3298
- permutations_inv_bar [n_p ][0 ] = permutations_inv_bar [ n_p ][ 0 ] * PGE (S_f , l + 1 , s + 1 )
3297
+ l_r [0 ] = PM [permutations_bar [n_p ][0 ](s + 1 ) - 1 , permutations_bar [n_p ][1 ](1 ) - 1 ]
3298
+ permutations_bar [n_p ][0 ] = PGE (S_f , l + 1 , s + 1 ) * permutations_bar [ n_p ][ 0 ]
3299
3299
n_p += 1
3300
3300
ccf = 1
3301
- permutations_inv_bar [n_p ] = copy (permutations_inv [k ])
3301
+ permutations_bar [n_p ] = copy (permutations [k ])
3302
3302
else :
3303
- d1 = PM [permutations_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](1 ) - 1 ]
3303
+ d1 = PM [permutations_bar [n_p ][0 ](s + 1 ) - 1 , permutations_bar [n_p ][1 ](1 ) - 1 ]
3304
3304
d = d1 - l_r [0 ]
3305
3305
if d < 0 :
3306
3306
# We move to the next line
3307
3307
continue
3308
3308
elif d == 0 :
3309
3309
# Maximal values agree, so possible symmetry
3310
- permutations_inv_bar [n_p ][0 ] = permutations_inv_bar [ n_p ][ 0 ] * PGE (S_f , l + 1 , s + 1 )
3310
+ permutations_bar [n_p ][0 ] = PGE (S_f , l + 1 , s + 1 ) * permutations_bar [ n_p ][ 0 ]
3311
3311
n_p += 1
3312
- permutations_inv_bar [n_p ] = copy (permutations_inv [k ])
3312
+ permutations_bar [n_p ] = copy (permutations [k ])
3313
3313
else :
3314
3314
# We found a greater maximal value for first entry.
3315
3315
# It becomes our new reference:
3316
3316
l_r [0 ] = d1
3317
- permutations_inv_bar [n_p ][0 ] = permutations_inv_bar [ n_p ][ 0 ] * PGE (S_f , l + 1 , s + 1 )
3317
+ permutations_bar [n_p ][0 ] = PGE (S_f , l + 1 , s + 1 ) * permutations_bar [ n_p ][ 0 ]
3318
3318
# Forget previous work done
3319
3319
cf = 0
3320
- permutations_inv_bar = {0 :copy (permutations_inv_bar [n_p ])}
3320
+ permutations_bar = {0 :copy (permutations_bar [n_p ])}
3321
3321
n_p = 1
3322
- permutations_inv_bar [n_p ] = copy (permutations_inv [k ])
3322
+ permutations_bar [n_p ] = copy (permutations [k ])
3323
3323
n_s = k + 1
3324
3324
# Check if the permutations found just now work
3325
3325
# with other elements
@@ -3336,20 +3336,21 @@ def index_of_max(iterable):
3336
3336
s -= 1
3337
3337
# Find the largest value in this symmetry block
3338
3338
for j in range (c + 1 , h ):
3339
- v = tuple (PM [(permutations_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(j + 1 ) - 1 ] for j in range (n_v ))
3339
+ v = tuple (PM [(permutations_bar [s ][0 ])(l + 1 ) - 1 , (permutations_bar [s ][1 ])(i + 1 ) - 1 ] for i in range (n_v ))
3340
+ print (v )
3340
3341
if (v [c ] < v [j ]):
3341
- permutations_inv_bar [s ][1 ] = permutations_inv_bar [ s ][ 1 ] * PGE (S_v , c + 1 , j + 1 )
3342
+ permutations_bar [s ][1 ] = PGE (S_v , c + 1 , j + 1 ) * permutations_bar [ s ][ 1 ]
3342
3343
if ccf == 0 :
3343
3344
# Set reference and carry on to next permutation
3344
- l_r [c ] = PM [(permutations_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(c + 1 ) - 1 ]
3345
+ l_r [c ] = PM [(permutations_bar [s ][0 ])(l + 1 ) - 1 , (permutations_bar [s ][1 ])(c + 1 ) - 1 ]
3345
3346
ccf = 1
3346
3347
else :
3347
- d1 = PM [(permutations_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(c + 1 ) - 1 ]
3348
+ d1 = PM [(permutations_bar [s ][0 ])(l + 1 ) - 1 , (permutations_bar [s ][1 ])(c + 1 ) - 1 ]
3348
3349
d = d1 - l_r [c ]
3349
3350
if d < 0 :
3350
3351
n_p -= 1
3351
3352
if s < n_p :
3352
- permutations_inv_bar [s ] = copy (permutations_inv_bar [n_p ])
3353
+ permutations_bar [s ] = copy (permutations_bar [n_p ])
3353
3354
elif d > 0 :
3354
3355
# The current case leads to a smaller matrix,
3355
3356
# hence this case becomes our new reference
@@ -3359,21 +3360,21 @@ def index_of_max(iterable):
3359
3360
n_s = k + 1
3360
3361
# Update permutations
3361
3362
if (n_s - 1 ) > k :
3362
- permutations_inv [k ] = copy (permutations_inv [n_s - 1 ])
3363
+ permutations [k ] = copy (permutations [n_s - 1 ])
3363
3364
n_s -= 1
3364
3365
for s in range (n_p ):
3365
- permutations_inv [n_s ] = copy (permutations_inv_bar [s ])
3366
+ permutations [n_s ] = copy (permutations_bar [s ])
3366
3367
n_s += 1
3367
3368
cf = n_s
3368
- permutations_inv = {k : permutations_inv [k ] for k in permutations_inv if k < n_s }
3369
+ permutations = {k : permutations [k ] for k in permutations if k < n_s }
3369
3370
# If the automorphisms are not already completely restricted,
3370
3371
# update them
3371
3372
if S != list (range (1 , n_v + 1 )):
3372
3373
# Take the old automorphisms and update by
3373
3374
# the restrictions the last worked out
3374
3375
# row imposes.
3375
3376
c = 0
3376
- M = tuple (PM [permutations_inv [0 ][0 ](l + 1 ) - 1 , permutations_inv [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3377
+ M = tuple (PM [permutations [0 ][0 ](l + 1 ) - 1 , permutations [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3377
3378
while c < n_v :
3378
3379
s = S [c ] + 1
3379
3380
S [c ] = c + 1
@@ -3386,9 +3387,9 @@ def index_of_max(iterable):
3386
3387
S [c ] = c + 1
3387
3388
c += 1
3388
3389
# Now we have the perms, we construct PM_max using one of them
3389
- PM_max = PM .with_permuted_rows_and_columns (permutations_inv [0 ][ 0 ]. inverse (), permutations_inv [ 0 ][ 1 ]. inverse () )
3390
+ PM_max = PM .with_permuted_rows_and_columns (* permutations [0 ])
3390
3391
if check :
3391
- return (PM_max , { p : [ permutations_inv [ p ][ 0 ]. inverse (), permutations_inv [ p ][ 1 ]. inverse ()] for p in permutations_inv . keys ()} )
3392
+ return (PM_max , permutations )
3392
3393
else :
3393
3394
return PM_max
3394
3395
0 commit comments