Skip to content

Commit 35cbd2f

Browse files
author
Release Manager
committed
gh-35612: Support linbox 1.7.0 and 1.6.3 at the same time ### 📚 Description 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: the two versions of the library are 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. See: #35148 for the actual update of linbox -- this PR should make that one easier as well as system support of linbox, since both linbox 1.6.3 and 1.7.0 wil be supported. ### 📝 Checklist - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: #35612 Reported by: Gonzalo Tornaría Reviewer(s): Dima Pasechnik
2 parents 72bd42e + 9c8796c commit 35cbd2f

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/sage/libs/linbox/conversion.pxd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,8 @@ cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_in
177177
- v -- linbox vector
178178
"""
179179
cdef Vector_integer_dense res = P()
180-
cdef cppvector[Integer] * vec = &v.refRep()
181180
cdef size_t i
182181
for i in range(<size_t> res._degree):
183-
mpz_set(res._entries[i], vec[0][i].get_mpz_const())
182+
mpz_set(res._entries[i], v.getEntry(i).get_mpz_const())
184183

185184
return res

src/sage/libs/linbox/linbox.pxd

Lines changed: 0 additions & 3 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, Element*, size_t m, size_t n)
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, Element*, size_t m, size_t n)
4644
void setEntry(size_t i, size_t j, Element& a)
4745
Element &getEntry(size_t i, size_t j)
4846

@@ -101,7 +99,6 @@ cdef extern from "linbox/vector/vector.h":
10199
DenseVector_integer (Field &F)
102100
DenseVector_integer (Field &F, long& m)
103101
DenseVector_integer (Field &F, cppvector[Integer]&)
104-
cppvector[Element]& refRep()
105102
size_t size()
106103
void resize(size_t)
107104
void resize(size_t n, const Element&)

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], <ModField.Element*>entries,<Py_ssize_t>nrows, <Py_ssize_t>ncols)
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)