Skip to content

Commit df75932

Browse files
committed
make a code simpler
1 parent 0d68323 commit df75932

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

src/sage/matrix/matrix_mod2_dense.pyx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,8 +2169,7 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
21692169
21702170
EXAMPLES::
21712171
2172-
sage: A = Matrix(GF(2), [
2173-
....: [0, 1],
2172+
sage: A = Matrix(GF(2), [[0, 1],
21742173
....: [1, 0]])
21752174
sage: r, c = A.doubly_lexical_ordering()
21762175
sage: r
@@ -2183,17 +2182,15 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
21832182
21842183
::
21852184
2186-
sage: A = Matrix(GF(2), [
2187-
....: [0, 1],
2185+
sage: A = Matrix(GF(2), [[0, 1],
21882186
....: [1, 0]])
21892187
sage: r, c = A.doubly_lexical_ordering(inplace=True); A
21902188
[1 0]
21912189
[0 1]
21922190
21932191
TESTS:
21942192
2195-
sage: A = Matrix(GF(2), [
2196-
....: [1, 1, 0, 0, 0, 0, 0],
2193+
sage: A = Matrix(GF(2), [[1, 1, 0, 0, 0, 0, 0],
21972194
....: [1, 1, 0, 0, 0, 0, 0],
21982195
....: [1, 1, 0, 1, 0, 0, 0],
21992196
....: [0, 0, 1, 1, 0, 0, 0],
@@ -2245,17 +2242,12 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
22452242
for col in range(i):
22462243
parition_i = 0
22472244
for row in reversed(range(A._nrows)):
2248-
count1[col][parition_i] += 1 if mzd_read_bit(A._entries, row, col) else 0
2245+
count1[col][parition_i] += mzd_read_bit(A._entries, row, col)
22492246
if row > 0 and partition_rows[row - 1]:
22502247
parition_i += 1
22512248

22522249
# calculate largest_col = col s.t. count1[col] is lexicographically largest (0 <= col < i)
2253-
largest_col = 0
2254-
largest_count1 = count1[0]
2255-
for col in range(1, i):
2256-
if count1[col] >= largest_count1:
2257-
largest_col = col
2258-
largest_count1 = count1[col]
2250+
_, largest_col = max((c, i) for i, c in enumerate(count1))
22592251

22602252
# We refine each partition of rows according to the value of A[:][largest_col].
22612253
# and also move down rows that satisfy A[row][largest_col] = 1 in each partition.

0 commit comments

Comments
 (0)