@@ -2148,18 +2148,18 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
2148
2148
2149
2149
- ``inplace`` -- boolean ( default: ``False``) ; using ``inplace=True``
2150
2150
will permute the rows and columns of the current matrix
2151
- according to a doubly lexical ordering. This will modify the matrix.
2151
+ according to a doubly lexical ordering; this will modify the matrix
2152
2152
2153
2153
OUTPUT:
2154
2154
2155
- Returns a pair ( `` row_ordering``, `` col_ordering`` ) . Each item
2156
- is a `` PermutationGroupElement`` that represents a doubly lexical
2157
- ordering of the rows or columns.
2155
+ A pair `` ( row_ordering, col_ordering) `` of
2156
+ :class:`~sage . groups . perm_gps . constructor . PermutationGroupElement`
2157
+ that represents a doubly lexical ordering of the rows or columns.
2158
2158
2159
2159
.. SEEALSO::
2160
2160
2161
- - :meth:`~sage. matrix. matrix2. Matrix. permutation_normal_form` --
2162
- a similar matrix normal form
2161
+ :meth:`~sage. matrix. matrix2. Matrix. permutation_normal_form`;
2162
+ a similar matrix normal form
2163
2163
2164
2164
ALGORITHM:
2165
2165
@@ -2204,27 +2204,18 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
2204
2204
.... : [0, 0, 0, 1, 1, 1, 0 ]])
2205
2205
sage: r, c = A. doubly_lexical_ordering( )
2206
2206
sage: B = A. with_permuted_rows_and_columns( r, c)
2207
- sage: flag = True
2208
2207
sage: for i in range( B. ncols( )) :
2209
2208
.... : for j in range( i) :
2210
2209
.... : for k in reversed( range( B. nrows( ))) :
2211
- .... : if B[k ][j ] > B[k ][i ]:
2212
- .... : flag = False
2213
- .... : break
2210
+ .... : assert B[k ][j ] <= B[k ][i ]
2214
2211
.... : if B[k ][j ] < B[k ][i ]:
2215
2212
.... : break
2216
- sage: flag
2217
- True
2218
2213
sage: for i in range( B. nrows( )) :
2219
2214
.... : for j in range( i) :
2220
2215
.... : for k in reversed( range( B. ncols( ))) :
2221
- .... : if B[j ][k ] > B[i ][k ]:
2222
- .... : flag = False
2223
- .... : break
2216
+ .... : assert B[j ][k ] <= B[i ][k ]
2224
2217
.... : if B[j ][k ] < B[i ][k ]:
2225
2218
.... : break
2226
- sage: flag
2227
- True
2228
2219
sage: r, c = A. doubly_lexical_ordering( inplace=True)
2229
2220
sage: A == B
2230
2221
True
@@ -2235,25 +2226,26 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
2235
2226
sage: r, c = A. doubly_lexical_ordering( inplace=True)
2236
2227
Traceback ( most recent call last) :
2237
2228
...
2238
- TypeError: This matrix is immutable and can thus not be changed .
2239
- Use inplace=False or create a mutable copy.
2229
+ TypeError: this matrix is immutable;
2230
+ use inplace=False or apply to a mutable copy.
2240
2231
"""
2241
2232
2242
2233
if inplace and self .is_immutable():
2243
- raise TypeError (" This matrix is immutable and can thus not be changed. "
2244
- " Use inplace=False or create a mutable copy." )
2234
+ raise TypeError (" this matrix is immutable; "
2235
+ " use inplace=False or apply to a mutable copy." )
2245
2236
2246
- partition_rows = [False for _ in range (self ._nrows - 1 )]
2247
- partition_num = 1
2248
- row_swapped = list (range (1 , self ._nrows + 1 ))
2249
- col_swapped = list (range (1 , self ._ncols + 1 ))
2237
+ cdef list partition_rows = [False for _ in range (self ._nrows - 1 )]
2238
+ cdef int partition_num = 1
2239
+ cdef list row_swapped = list (range (1 , self ._nrows + 1 ))
2240
+ cdef list col_swapped = list (range (1 , self ._ncols + 1 ))
2250
2241
2251
2242
cdef Matrix_mod2_dense A = self if inplace else self .__copy__()
2252
2243
2244
+ cdef int i, col, row, partition_i, partition_start, partition_end
2245
+ cdef int largest_col, row_start, row_end
2253
2246
for i in reversed (range (1 , A._ncols + 1 )):
2254
-
2255
2247
# count 1 for each partition and column
2256
- count1 = [[0 for _ in range (partition_num)] for _ in range (i)]
2248
+ count1 = [[0 ] * partition_num for _ in range (i)]
2257
2249
for col in range (i):
2258
2250
parition_i = 0
2259
2251
for row in reversed (range (A._nrows)):
0 commit comments