Skip to content

Commit 0ee6b70

Browse files
committed
Trac #33201: fix Cython warnings for dense float/double matrices.
In our template for dense float/double matrices mod-n, we define a few variables "zero", "one", and "d" that are passed by reference to C functions to be overwritten. Cython however is not smart enough to know that these uninitialized variables are about to be initialized in C, and throws warnings like warning: sage/matrix/matrix_modn_dense_template.pxi:283:19: local variable 'd' referenced before assignment To avoid the warnings, we initialize all of these variables (whose type is either float or double, depending on the context) to zero.
1 parent f9b2db9 commit 0ee6b70

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sage/matrix/matrix_modn_dense_template.pxi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t
274274
cdef ModField *F = new ModField(<long>modulus)
275275
cdef celement *cpy = linbox_copy(modulus, entries, n, n)
276276

277-
cdef celement d
277+
cdef celement d = 0
278278
cdef size_t nbthreads
279279
nbthreads = Parallelism().get('linbox')
280280

@@ -293,7 +293,7 @@ cdef inline celement linbox_matrix_matrix_multiply(celement modulus, celement* a
293293
C = A*B
294294
"""
295295
cdef ModField *F = new ModField(<long>modulus)
296-
cdef ModField.Element one, zero
296+
cdef ModField.Element one = 0, zero = 0
297297
F[0].init(one, <int>1)
298298
F[0].init(zero, <int>0)
299299

@@ -319,7 +319,7 @@ cdef inline int linbox_matrix_vector_multiply(celement modulus, celement* C, cel
319319
C = A*v
320320
"""
321321
cdef ModField *F = new ModField(<long>modulus)
322-
cdef ModField.Element one, zero
322+
cdef ModField.Element one = 0, zero = 0
323323
F.init(one, <int>1)
324324
F.init(zero, <int>0)
325325

0 commit comments

Comments
 (0)