@@ -166,7 +166,7 @@ cdef class LeanMatrix:
166
166
cdef long i, j
167
167
cdef LeanMatrix A = type (self )(self .nrows(), self .ncols() + self .nrows())
168
168
for i in range (self .nrows()):
169
- A.set_unsafe(i, i, self .base_ring()( 1 ))
169
+ A.set_unsafe(i, i, self .base_ring().one( ))
170
170
for j in range (self .ncols()):
171
171
A.set_unsafe(i, self .nrows() + j, self .get_unsafe(i, j))
172
172
return A
@@ -696,8 +696,8 @@ cdef class GenericMatrix(LeanMatrix):
696
696
# Default:
697
697
if self ._base_ring is None :
698
698
self ._base_ring = ZZ
699
- self ._zero = self ._base_ring( 0 )
700
- self ._one = self ._base_ring( 1 )
699
+ self ._zero = self ._base_ring.zero( )
700
+ self ._one = self ._base_ring.one( )
701
701
self ._entries = [self ._zero] * nrows * ncols
702
702
if M is not None :
703
703
if isinstance (M, GenericMatrix):
@@ -995,8 +995,8 @@ cdef class BinaryMatrix(LeanMatrix):
995
995
global GF2, GF2_zero, GF2_one, GF2_not_defined
996
996
if GF2_not_defined:
997
997
GF2 = GF(2 )
998
- GF2_zero = GF2( 0 )
999
- GF2_one = GF2( 1 )
998
+ GF2_zero = GF2.zero( )
999
+ GF2_one = GF2.one( )
1000
1000
GF2_not_defined = False
1001
1001
if M is not None :
1002
1002
if isinstance (M, BinaryMatrix):
@@ -1433,7 +1433,7 @@ cdef class BinaryMatrix(LeanMatrix):
1433
1433
if s_eq.nrows() != o_eq.nrows():
1434
1434
return False
1435
1435
if s_eq.nrows() == s_eq.ncols(): # s_eq and o_eq partition into singletons
1436
- morph = [0 for i in range (self ._nrows)]
1436
+ morph = [0 for _ in range (self ._nrows)]
1437
1437
for i in range (self ._nrows):
1438
1438
morph[bitset_first(s_eq._M[i])] = bitset_first(o_eq._M[i])
1439
1439
for i in range (self ._nrows):
@@ -1580,8 +1580,8 @@ cdef class TernaryMatrix(LeanMatrix):
1580
1580
global GF3, GF3_zero, GF3_one, GF3_minus_one, GF3_not_defined
1581
1581
if GF3_not_defined:
1582
1582
GF3 = GF(3 )
1583
- GF3_zero = GF3( 0 )
1584
- GF3_one = GF3( 1 )
1583
+ GF3_zero = GF3.zero( )
1584
+ GF3_one = GF3.one( )
1585
1585
GF3_minus_one = GF3(2 )
1586
1586
GF3_not_defined = False
1587
1587
@@ -2170,37 +2170,37 @@ cdef class QuaternaryMatrix(LeanMatrix):
2170
2170
if M is not None :
2171
2171
if isinstance (M, QuaternaryMatrix):
2172
2172
self ._gf4 = (< QuaternaryMatrix> M)._gf4
2173
- self ._zero = self ._gf4( 0 )
2174
- self ._one = self ._gf4( 1 )
2173
+ self ._zero = self ._gf4.zero( )
2174
+ self ._one = self ._gf4.one( )
2175
2175
self ._x_zero = self ._gf4.gens()[0 ]
2176
2176
self ._x_one = self ._x_zero + self ._one
2177
2177
for i in range ((< QuaternaryMatrix> M)._nrows):
2178
2178
bitset_copy(self ._M0[i], (< QuaternaryMatrix> M)._M0[i])
2179
2179
bitset_copy(self ._M1[i], (< QuaternaryMatrix> M)._M1[i])
2180
2180
elif isinstance (M, LeanMatrix):
2181
2181
self ._gf4 = (< LeanMatrix> M).base_ring()
2182
- self ._zero = self ._gf4( 0 )
2183
- self ._one = self ._gf4( 1 )
2182
+ self ._zero = self ._gf4.zero( )
2183
+ self ._one = self ._gf4.one( )
2184
2184
self ._x_zero = self ._gf4.gens()[0 ]
2185
2185
self ._x_one = self ._x_zero + self ._one
2186
2186
for i in range (M.nrows()):
2187
2187
for j in range (M.ncols()):
2188
2188
self .set(i, j, (< LeanMatrix> M).get_unsafe(i, j))
2189
2189
elif isinstance (M, Matrix):
2190
2190
self ._gf4 = (< Matrix> M).base_ring()
2191
- self ._zero = self ._gf4( 0 )
2192
- self ._one = self ._gf4( 1 )
2191
+ self ._zero = self ._gf4.zero( )
2192
+ self ._one = self ._gf4.one( )
2193
2193
self ._x_zero = self ._gf4.gens()[0 ]
2194
2194
self ._x_one = self ._x_zero + self ._one
2195
2195
for i in range (M.nrows()):
2196
2196
for j in range (M.ncols()):
2197
2197
self .set(i, j, (< Matrix> M).get_unsafe(i, j))
2198
2198
else :
2199
- raise TypeError (" unrecognized input type. " )
2199
+ raise TypeError (" unrecognized input type" )
2200
2200
else :
2201
2201
self ._gf4 = ring
2202
- self ._zero = self ._gf4( 0 )
2203
- self ._one = self ._gf4( 1 )
2202
+ self ._zero = self ._gf4.zero( )
2203
+ self ._one = self ._gf4.one( )
2204
2204
self ._x_zero = self ._gf4.gens()[0 ]
2205
2205
self ._x_one = self ._x_zero + self ._one
2206
2206
0 commit comments