142
142
from sage .structure .richcmp import richcmp_method , richcmp
143
143
from sage .geometry .convex_set import ConvexSet_compact
144
144
import sage .geometry .abc
145
- from sage .matrix .permuted_matrix_window import PermutedMatrixWindow
146
145
147
146
from copy import copy
148
147
from collections .abc import Hashable
@@ -3210,7 +3209,7 @@ def index_of_max(iterable):
3210
3209
return m
3211
3210
3212
3211
n_s = 1
3213
- permutations_inv = {0 : [S_f .one (), S_v .one ()]}
3212
+ permutations_inv = {0 : [S_f .one (), S_v .one ()]}
3214
3213
for j in range (n_v ):
3215
3214
m = index_of_max ([PM [0 ][i ] for i in range (j , n_v )])
3216
3215
if m > 0 :
@@ -3221,23 +3220,23 @@ def index_of_max(iterable):
3221
3220
for k in range (1 , n_f ):
3222
3221
# Error for k == 1 already!
3223
3222
permutations_inv [n_s ] = [S_f .one (), S_v .one ()]
3224
- m = index_of_max (PM [k , tuple (( permutations_inv [n_s ][1 ]) (j + 1 )- 1 for j in range (n_v ))])
3223
+ m = index_of_max (PM [k , tuple (permutations_inv [n_s ][1 ](j + 1 ) - 1 for j in range (n_v ))])
3225
3224
if m > 0 :
3226
3225
permutations_inv [n_s ][1 ] = permutations_inv [n_s ][1 ] * PGE (S_v , 1 , m + 1 )
3227
- d = (PM [k , ( permutations_inv [n_s ][1 ]) (1 )- 1 ]
3226
+ d = (PM [k , permutations_inv [n_s ][1 ](1 ) - 1 ]
3228
3227
- (permutations_inv [0 ][1 ].inverse ())(first_row )[0 ])
3229
3228
if d < 0 :
3230
3229
# The largest elt of this row is smaller than largest elt
3231
3230
# in 1st row, so nothing to do
3232
3231
continue
3233
3232
# otherwise:
3234
3233
for i in range (1 , n_v ):
3235
- m = index_of_max (PM [k , tuple (( permutations_inv [n_s ][1 ]) (j + 1 )- 1 for j in range (i ,n_v ))])
3234
+ m = index_of_max (PM [k , tuple (permutations_inv [n_s ][1 ](j + 1 ) - 1 for j in range (i ,n_v ))])
3236
3235
if m > 0 :
3237
3236
permutations_inv [n_s ][1 ] = permutations_inv [n_s ][1 ] \
3238
3237
* PGE (S_v , i + 1 , m + i + 1 )
3239
3238
if d == 0 :
3240
- d = (PM [k , ( permutations_inv [n_s ][1 ]) (i + 1 )- 1 ]
3239
+ d = (PM [k , permutations_inv [n_s ][1 ](i + 1 ) - 1 ]
3241
3240
- (permutations_inv [0 ][1 ].inverse ())(first_row )[i ])
3242
3241
if d < 0 :
3243
3242
break
@@ -3255,9 +3254,9 @@ def index_of_max(iterable):
3255
3254
first_row = list (PM [k ])
3256
3255
permutations_inv = {0 : permutations_inv [n_s ]}
3257
3256
n_s = 1
3258
- permutations_inv = {k :permutations_inv [k ] for k in permutations_inv if k < n_s }
3257
+ permutations_inv = {k : permutations_inv [k ] for k in permutations_inv if k < n_s }
3259
3258
3260
- 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_inv [0 ][0 ](1 ) - 1 , permutations_inv [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3261
3260
# Work out the restrictions the current permutations
3262
3261
# place on other permutations as a automorphisms
3263
3262
# of the first row
@@ -3291,17 +3290,17 @@ def index_of_max(iterable):
3291
3290
# between 0 and S(0)
3292
3291
for s in range (l , n_f ):
3293
3292
for j in range (1 , S [0 ]):
3294
- 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_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3295
3294
if v [0 ] < v [j ]:
3296
3295
permutations_inv_bar [n_p ][1 ] = permutations_inv_bar [n_p ][1 ] * PGE (S_v , 1 , j + 1 )
3297
3296
if ccf == 0 :
3298
- l_r [0 ] = PM [( permutations_inv_bar [n_p ][0 ]) (s + 1 )- 1 , ( permutations_inv_bar [n_p ][1 ]) (1 )- 1 ]
3297
+ l_r [0 ] = PM [permutations_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](1 ) - 1 ]
3299
3298
permutations_inv_bar [n_p ][0 ] = permutations_inv_bar [n_p ][0 ] * PGE (S_f , l + 1 , s + 1 )
3300
3299
n_p += 1
3301
3300
ccf = 1
3302
3301
permutations_inv_bar [n_p ] = copy (permutations_inv [k ])
3303
3302
else :
3304
- d1 = PM [( permutations_inv_bar [n_p ][0 ]) (s + 1 )- 1 , ( permutations_inv_bar [n_p ][1 ]) (1 )- 1 ]
3303
+ d1 = PM [permutations_inv_bar [n_p ][0 ](s + 1 ) - 1 , permutations_inv_bar [n_p ][1 ](1 ) - 1 ]
3305
3304
d = d1 - l_r [0 ]
3306
3305
if d < 0 :
3307
3306
# We move to the next line
@@ -3337,15 +3336,15 @@ def index_of_max(iterable):
3337
3336
s -= 1
3338
3337
# Find the largest value in this symmetry block
3339
3338
for j in range (c + 1 , h ):
3340
- 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_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(j + 1 ) - 1 ] for j in range (n_v ))
3341
3340
if (v [c ] < v [j ]):
3342
3341
permutations_inv_bar [s ][1 ] = permutations_inv_bar [s ][1 ] * PGE (S_v , c + 1 , j + 1 )
3343
3342
if ccf == 0 :
3344
3343
# Set reference and carry on to next permutation
3345
- l_r [c ] = PM [(permutations_inv_bar [s ][0 ])(l + 1 )- 1 , (permutations_inv_bar [s ][1 ])(c + 1 )- 1 ]
3344
+ l_r [c ] = PM [(permutations_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(c + 1 ) - 1 ]
3346
3345
ccf = 1
3347
3346
else :
3348
- d1 = PM [(permutations_inv_bar [s ][0 ])(l + 1 )- 1 , (permutations_inv_bar [s ][1 ])(c + 1 )- 1 ]
3347
+ d1 = PM [(permutations_inv_bar [s ][0 ])(l + 1 ) - 1 , (permutations_inv_bar [s ][1 ])(c + 1 ) - 1 ]
3349
3348
d = d1 - l_r [c ]
3350
3349
if d < 0 :
3351
3350
n_p -= 1
@@ -3374,7 +3373,7 @@ def index_of_max(iterable):
3374
3373
# the restrictions the last worked out
3375
3374
# row imposes.
3376
3375
c = 0
3377
- M = tuple (PM [( permutations_inv [0 ][0 ]) (l + 1 )- 1 , ( permutations_inv [0 ][1 ]) (j + 1 )- 1 ] for j in range (n_v ))
3376
+ M = tuple (PM [permutations_inv [0 ][0 ](l + 1 ) - 1 , permutations_inv [0 ][1 ](j + 1 ) - 1 ] for j in range (n_v ))
3378
3377
while c < n_v :
3379
3378
s = S [c ] + 1
3380
3379
S [c ] = c + 1
@@ -3387,12 +3386,9 @@ def index_of_max(iterable):
3387
3386
S [c ] = c + 1
3388
3387
c += 1
3389
3388
# Now we have the perms, we construct PM_max using one of them
3390
- PM_max = PM .with_permuted_rows_and_columns (permutations_inv [0 ][0 ].inverse (),permutations_inv [0 ][1 ].inverse ())
3389
+ PM_max = PM .with_permuted_rows_and_columns (permutations_inv [0 ][0 ].inverse (), permutations_inv [0 ][1 ].inverse ())
3391
3390
if check :
3392
- for p in permutations_inv .keys ():
3393
- permutations_inv [p ][0 ] = permutations_inv [p ][0 ].inverse ()
3394
- permutations_inv [p ][1 ] = permutations_inv [p ][1 ].inverse ()
3395
- return (PM_max , permutations_inv )
3391
+ return (PM_max , {p : [permutations_inv [p ][0 ].inverse (),permutations_inv [p ][1 ].inverse ()] for p in permutations_inv .keys ()})
3396
3392
else :
3397
3393
return PM_max
3398
3394
0 commit comments