Skip to content

Commit 9c8796c

Browse files
committed
Support linbox 1.7.0 and 1.6.3 at the same time
The constructor `DenseMatrix(field, entries, m, n)` in 1.6.3 was changed to `DenseMatrix(field, m, n, entries)` in 1.7.0. We replace use of this constructor by a different way to initialize a matrix from entries using part of the API that works both in 1.6.3 and in 1.7.0. Note that the two versions of the library are still ABI-incompatible so changing linbox requires recompiling sagelib. To complicate matters, linbox doesn't change soname so the dynamic linker will let this go and sagemath will eventually crash.
1 parent 4dac911 commit 9c8796c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/sage/libs/linbox/linbox.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ cdef extern from "linbox/matrix/dense-matrix.h":
3232
ctypedef Modular_double Field
3333
ctypedef double Element
3434
DenseMatrix_Modular_double(Field F, size_t m, size_t n)
35-
DenseMatrix_Modular_double(Field F, size_t m, size_t n, Element*)
3635
void setEntry(size_t i, size_t j, Element& a)
3736
Element &getEntry(size_t i, size_t j)
3837

@@ -42,7 +41,6 @@ cdef extern from "linbox/matrix/dense-matrix.h":
4241
ctypedef Modular_float Field
4342
ctypedef float Element
4443
DenseMatrix_Modular_float(Field F, size_t m, size_t n)
45-
DenseMatrix_Modular_float(Field F, size_t m, size_t n, Element*)
4644
void setEntry(size_t i, size_t j, Element& a)
4745
Element &getEntry(size_t i, size_t j)
4846

src/sage/matrix/matrix_modn_dense_template.pxi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,14 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_
221221
return 0,[]
222222

223223
cdef ModField *F = new ModField(<long>modulus)
224-
cdef DenseMatrix *A = new DenseMatrix(F[0], <Py_ssize_t>nrows, <Py_ssize_t>ncols, <ModField.Element*>entries)
225-
cdef Py_ssize_t r = reducedRowEchelonize(A[0])
224+
cdef DenseMatrix *A = new DenseMatrix(F[0], nrows, ncols)
225+
226226
cdef Py_ssize_t i,j
227+
for i in range(nrows):
228+
for j in range(ncols):
229+
A.setEntry(i, j, entries[i*ncols+j])
230+
231+
cdef Py_ssize_t r = reducedRowEchelonize(A[0])
227232
for i in range(nrows):
228233
for j in range(ncols):
229234
entries[i*ncols+j] = <celement>A.getEntry(i,j)

0 commit comments

Comments
 (0)