@@ -2228,12 +2228,29 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
2228
2228
...
2229
2229
TypeError: this matrix is immutable;
2230
2230
use inplace=False or apply to a mutable copy.
2231
+
2232
+ The algorithm works collectly for a matrix with nrows=0 or ncols=0::
2233
+
2234
+ sage: A = Matrix( GF( 2) , 0, 2, [])
2235
+ sage: A. doubly_lexical_ordering( )
2236
+ (( ) , ( ))
2237
+ sage: B = Matrix( GF( 2) , 2, 0, [])
2238
+ sage: B. doubly_lexical_ordering( )
2239
+ (( ) , ( ))
2231
2240
"""
2232
2241
2233
2242
if inplace and self .is_immutable():
2234
2243
raise TypeError (" this matrix is immutable;"
2235
2244
" use inplace=False or apply to a mutable copy." )
2236
2245
2246
+ from sage.groups.perm_gps.permgroup_named import SymmetricGroup
2247
+ from sage.groups.perm_gps.permgroup_element import make_permgroup_element_v2
2248
+ symmetric_group_nrows = SymmetricGroup(self ._nrows)
2249
+ symmetric_group_ncols = SymmetricGroup(self ._ncols)
2250
+
2251
+ if self ._nrows == 0 or self ._ncols == 0 :
2252
+ return symmetric_group_nrows.one(), symmetric_group_ncols.one()
2253
+
2237
2254
cdef list partition_rows = [False for _ in range (self ._nrows - 1 )]
2238
2255
cdef int partition_num = 1
2239
2256
cdef list row_swapped = list (range (1 , self ._nrows + 1 ))
@@ -2285,10 +2302,6 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
2285
2302
A.swap_columns_c(largest_col, i - 1 )
2286
2303
col_swapped[largest_col], col_swapped[i - 1 ] = col_swapped[i - 1 ], col_swapped[largest_col]
2287
2304
2288
- from sage.groups.perm_gps.permgroup_named import SymmetricGroup
2289
- from sage.groups.perm_gps.permgroup_element import make_permgroup_element_v2
2290
- symmetric_group_nrows = SymmetricGroup(self ._nrows)
2291
- symmetric_group_ncols = SymmetricGroup(self ._ncols)
2292
2305
row_ordering = make_permgroup_element_v2(symmetric_group_nrows, row_swapped, symmetric_group_nrows.domain())
2293
2306
col_ordering = make_permgroup_element_v2(symmetric_group_ncols, col_swapped, symmetric_group_ncols.domain())
2294
2307
0 commit comments