Date: Monday, May 20, 2019 @ 15:51:43 Author: arojas Revision: 468112
Use upstream linbox patch Modified: sagemath/trunk/PKGBUILD sagemath/trunk/sagemath-linbox-1.6.patch ---------------------------+ PKGBUILD | 8 sagemath-linbox-1.6.patch | 597 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 532 insertions(+), 73 deletions(-) Modified: PKGBUILD =================================================================== --- PKGBUILD 2019-05-20 15:29:06 UTC (rev 468111) +++ PKGBUILD 2019-05-20 15:51:43 UTC (rev 468112) @@ -8,7 +8,7 @@ pkgbase=sagemath pkgname=(sagemath sagemath-jupyter) pkgver=8.7 -pkgrel=3 +pkgrel=4 pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab" arch=(x86_64) url="http://www.sagemath.org" @@ -63,7 +63,7 @@ 'a42f3b152b1aedb8abf16bc70971419919d1fe30328574e7fef8305f9d07d938' '9ec56a3788e32c54f35abeaeedf7cadf6670fa10d39007050b23b93d3c35278e' '3ee624bb47f757516a860799d817168fe9cf74e603416e18e70c93c692259242' - '7e126c73d12c39be9012a66f979897fa630d540d30906dadff6c1384af4ec166') + '81fc39e39e8508f742ccc784efd0492fd04474cee75edf7bd3cbea43edd49b2e') prepare(){ cd sage-$pkgver @@ -85,8 +85,6 @@ patch -p1 -i ../sagemath-sphinx-1.8.patch # port to GAP 4.10.1 API changes patch -p1 -i ../sagemath-gap-4.10.1.patch -# fix build with linbox 1.6 - patch -p1 -i ../sagemath-linbox-1.6.patch # Upstream patches # fix build against libfes 0.2 http://trac.sagemath.org/ticket/15209 @@ -99,6 +97,8 @@ patch -p1 -i ../sagemath-ecl-sigfpe.patch # Fix rendering with three.js r100 https://trac.sagemath.org/ticket/26718 patch -p1 -i ../sagemath-threejs-100.patch +# fix build with linbox 1.6 https://trac.sagemath.org/ticket/26932 + patch -p1 -i ../sagemath-linbox-1.6.patch # use python2 sed -e 's|sage-python23|python2|' -e 's|#!/usr/bin/env python\b|#!/usr/bin/env python2|' -i src/bin/* Modified: sagemath-linbox-1.6.patch =================================================================== --- sagemath-linbox-1.6.patch 2019-05-20 15:29:06 UTC (rev 468111) +++ sagemath-linbox-1.6.patch 2019-05-20 15:51:43 UTC (rev 468112) @@ -1,34 +1,89 @@ +diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd +index 810a197..7794c9e 100644 +--- a/src/sage/libs/linbox/conversion.pxd ++++ b/src/sage/libs/linbox/conversion.pxd +@@ -45,7 +45,7 @@ from sage.modules.vector_integer_sparse cimport mpz_vector, mpz_vector_get_entr + + ctypedef enum linbox_specifier: + METHOD_DEFAULT # no specification +- METHOD_BLAS_ELIMINATION # BlasElimination ++ METHOD_DENSE_ELIMINATION # DenseElimination + METHOD_SPARSE_ELIMINATION # SparseElimination + METHOD_BLACKBOX # Blackbox + METHOD_WIEDEMANN # Wiedeman +@@ -54,10 +54,10 @@ ctypedef enum linbox_specifier: + cdef inline linbox_specifier get_method(str algo) except ERROR: + if algo is None or algo == "default": + return METHOD_DEFAULT +- elif algo == "blas_elimination" or \ +- algo == "linbox_blas_elimination" or \ +- algo == "LinBox::BlasElimination": +- return METHOD_BLAS_ELIMINATION ++ elif algo == "dense_elimination" or \ ++ algo == "linbox_dense_elimination" or \ ++ algo == "LinBox::DenseElimination": ++ return METHOD_DENSE_ELIMINATION + elif algo == "sparse_elimination" or \ + algo == "linbox_sparse_elimination" or \ + algo == "LinBox::SparseElimination": diff --git a/src/sage/libs/linbox/fflas.pxd b/src/sage/libs/linbox/fflas.pxd -index f3a7ce37ea..7d8d64d3b5 100644 +index f3a7ce3..8bf62f1 100644 --- a/src/sage/libs/linbox/fflas.pxd +++ b/src/sage/libs/linbox/fflas.pxd -@@ -64,8 +64,8 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK": +@@ -63,8 +63,7 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK": + Modular_double.Element* Invert (Modular_double F, size_t order, Modular_double.Element* A, size_t A_stride, int nullity) - Modular_double.Element Det (Modular_double F, +- Modular_double.Element Det (Modular_double F, - size_t nrows, size_t ncols, -- Modular_double.Element* A, size_t A_stride) -+ Modular_double.Element det, size_t ncols, -+ Modular_double.Element* A, size_t A_stride, size_t* P, size_t* Q) ++ Modular_double.Element Det (Modular_double F, Modular_double.Element& d, size_t n, + Modular_double.Element* A, size_t A_stride) int Rank (Modular_double, - size_t nrows, size_t ncols, -@@ -98,8 +98,8 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK": +@@ -97,8 +96,7 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "FFPACK": + Modular_float.Element* Invert (Modular_float F, size_t order, Modular_float.Element* A, size_t A_stride, int nullity) - Modular_float.Element Det (Modular_float F, +- Modular_float.Element Det (Modular_float F, - size_t nrows, size_t ncols, -- Modular_float.Element* A, size_t A_stride) -+ Modular_float.Element det, size_t ncols, -+ Modular_float.Element* A, size_t A_stride, size_t* P, size_t* Q) ++ Modular_float.Element Det (Modular_float F, Modular_float.Element& d, size_t n, + Modular_float.Element* A, size_t A_stride) int Rank (Modular_float, - size_t nrows, size_t ncols, diff --git a/src/sage/libs/linbox/linbox.pxd b/src/sage/libs/linbox/linbox.pxd -index 35a3fa0125..a4bda24c0e 100644 +index 35a3fa0..fb0e0dc 100644 --- a/src/sage/libs/linbox/linbox.pxd +++ b/src/sage/libs/linbox/linbox.pxd -@@ -125,7 +125,7 @@ cdef extern from "linbox/solutions/methods.h" namespace "LinBox": +@@ -10,10 +10,10 @@ from .givaro cimport * + + cdef extern from "linbox/matrix/dense-matrix.h": + ## template <class _Field, class _blasRep=typename Vector<_Field>::Dense > +- ## class BlasMatrix ; ++ ## class DenseMatrix ; + ## + ## template <class _Field> +- ## using DenseMatrix = BlasMatrix<_Field> ; ++ ## using DenseMatrix = DenseMatrix<_Field> ; + cdef cppclass DenseMatrix_integer "LinBox::DenseMatrix<Givaro::ZRing<Givaro::Integer>>": + ctypedef ZRing Field + ctypedef Integer Element +@@ -30,6 +30,7 @@ cdef extern from "linbox/matrix/dense-matrix.h": + ctypedef Modular_double Field + ctypedef double Element + DenseMatrix_Modular_double(Field F, size_t m, size_t n) ++ DenseMatrix_Modular_double(Field F, Element*, size_t m, size_t n) + void setEntry(size_t i, size_t j, Element& a) + Element &getEntry(size_t i, size_t j) + +@@ -39,6 +40,7 @@ cdef extern from "linbox/matrix/dense-matrix.h": + ctypedef Modular_float Field + ctypedef float Element + DenseMatrix_Modular_float(Field F, size_t m, size_t n) ++ DenseMatrix_Modular_float(Field F, Element*, size_t m, size_t n) + void setEntry(size_t i, size_t j, Element& a) + Element &getEntry(size_t i, size_t j) + +@@ -125,7 +127,7 @@ cdef extern from "linbox/solutions/methods.h" namespace "LinBox": pass cdef struct WiedemannTraits: pass @@ -37,7 +92,7 @@ pass cdef struct SparseEliminationTraits: pass -@@ -135,7 +135,7 @@ cdef extern from "linbox/solutions/methods.h" namespace "LinBox": +@@ -135,7 +137,7 @@ cdef extern from "linbox/solutions/methods.h" namespace "LinBox": ctypedef BlackboxSpecifier Blackbox ctypedef EliminationSpecifier Elimination ctypedef WiedemannTraits Wiedemann @@ -46,31 +101,44 @@ ctypedef SparseEliminationTraits SparseElimination cdef extern from "linbox/solutions/charpoly.h" namespace "LinBox": -@@ -157,19 +157,20 @@ cdef extern from "linbox/algorithms/gauss.h": +@@ -157,18 +159,24 @@ cdef extern from "linbox/algorithms/gauss.h": unsigned long Ni, unsigned long Nj) -cdef extern from "linbox/algorithms/echelon-form.h": -+cdef extern from "linbox/solutions/echelon.h": - ## template<class Field> - ## class EchelonFormDomain - cdef cppclass EchelonForm_Modular_double "LinBox::EchelonFormDomain<Givaro::Modular<double>>": - ctypedef double Element - EchelonForm_Modular_double(Modular_double) +- ## template<class Field> +- ## class EchelonFormDomain +- cdef cppclass EchelonForm_Modular_double "LinBox::EchelonFormDomain<Givaro::Modular<double>>": +- ctypedef double Element +- EchelonForm_Modular_double(Modular_double) - int rowReducedEchelon(DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&) - - cdef cppclass EchelonForm_Modular_float "LinBox::EchelonFormDomain<Givaro::Modular<float>>": - ctypedef float Element - EchelonForm_Modular_float(Modular_float) +- +- cdef cppclass EchelonForm_Modular_float "LinBox::EchelonFormDomain<Givaro::Modular<float>>": +- ctypedef float Element +- EchelonForm_Modular_float(Modular_float) - int rowReducedEchelon(DenseMatrix_Modular_float, const DenseMatrix_Modular_float) ++cdef extern from "linbox/solutions/echelon.h" namespace "LinBox": ++ size_t rowEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&) ++ size_t rowEchelonize (DenseMatrix_Modular_float&) ++ size_t reducedRowEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&) ++ size_t reducedRowEchelonize (DenseMatrix_Modular_float&) ++ size_t colEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&) ++ size_t colEchelonize (DenseMatrix_Modular_float&) ++ size_t reducedColEchelon (DenseMatrix_Modular_float&, const DenseMatrix_Modular_float&) ++ size_t reducedColEchelonize (DenseMatrix_Modular_float&) ++ ++ size_t rowEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&) ++ size_t rowEchelonize (DenseMatrix_Modular_double&) ++ size_t reducedRowEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&) ++ size_t reducedRowEchelonize (DenseMatrix_Modular_double&) ++ size_t colEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&) ++ size_t colEchelonize (DenseMatrix_Modular_double&) ++ size_t reducedColEchelon (DenseMatrix_Modular_double&, const DenseMatrix_Modular_double&) ++ size_t reducedColEchelonize (DenseMatrix_Modular_double&) -+ int reducedRowEchelon(DenseMatrix_Modular_double, const DenseMatrix_Modular_double) -+ int reducedRowEchelon(DenseMatrix_Modular_float, const DenseMatrix_Modular_float) -+ cdef extern from "linbox/solutions/rank.h" namespace "LinBox": unsigned long & rank (unsigned long&, DenseMatrix_integer) - unsigned long & rank (unsigned long&, SparseMatrix_integer) -@@ -185,7 +186,7 @@ cdef extern from "linbox/solutions/solve.h" namespace "LinBox": +@@ -185,7 +193,7 @@ cdef extern from "linbox/solutions/solve.h" namespace "LinBox": Integer &, SparseMatrix_integer &, DenseVector_integer &, @@ -80,112 +148,503 @@ DenseVector_integer& solve (DenseVector_integer &, Integer &, diff --git a/src/sage/matrix/matrix_integer_sparse.pyx b/src/sage/matrix/matrix_integer_sparse.pyx -index 7fa386eab7..5937720a03 100644 +index 7fa386e..132140f 100644 --- a/src/sage/matrix/matrix_integer_sparse.pyx +++ b/src/sage/matrix/matrix_integer_sparse.pyx -@@ -1081,7 +1081,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): +@@ -42,7 +42,7 @@ from sage.libs.linbox.conversion cimport ( + new_linbox_vector_integer_dense, + new_sage_vector_integer_dense, + new_linbox_matrix_integer_sparse, +- METHOD_DEFAULT, METHOD_BLAS_ELIMINATION, ++ METHOD_DEFAULT, METHOD_DENSE_ELIMINATION, + METHOD_SPARSE_ELIMINATION, METHOD_BLACKBOX, + METHOD_WIEDEMANN, get_method) + +@@ -926,7 +926,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + - ``'linbox'`` or ``'linbox_default'`` - (default) use LinBox + and let it chooses the appropriate algorithm + +- - ``linbox_blas_elimination'`` - use LinBox dense elimination ++ - ``linbox_dense_elimination'`` - use LinBox dense elimination + + - ``'linbox_sparse_elimination'`` - use LinBox sparse elimination + +@@ -993,7 +993,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + + - ``b`` -- a dense integer vector + +- - ``algorithm`` -- (optional) either ``None``, ``'blas_elimination'``, ++ - ``algorithm`` -- (optional) either ``None``, ``'dense_elimination'``, + ``'sparse_elimination'``, ``'wiedemann'`` or ``'blackbox'``. + + OUTPUT: a pair ``(a, d)`` consisting of +@@ -1012,7 +1012,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + sage: b0 = vector((1,1,1,1)) + sage: m._solve_vector_linbox(b0) + ((-1, -7, -3, -1), 1) +- sage: m._solve_vector_linbox(b0, 'blas_elimination') ++ sage: m._solve_vector_linbox(b0, 'dense_elimination') + ((-1, -7, -3, -1), 1) + sage: m._solve_vector_linbox(b0, 'sparse_elimination') + ((-1, -7, -3, -1), 1) +@@ -1024,7 +1024,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + sage: b1 = vector((1,2,3,4)) + sage: m._solve_vector_linbox(b1) + ((-18, -92, -41, -17), 5) +- sage: m._solve_vector_linbox(b1, 'blas_elimination') ++ sage: m._solve_vector_linbox(b1, 'dense_elimination') + ((-18, -92, -41, -17), 5) + sage: m._solve_vector_linbox(b1, 'sparse_elimination') + ((-18, -92, -41, -17), 5) +@@ -1039,7 +1039,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + + TESTS:: + +- sage: algos = ["default", "blas_elimination", "sparse_elimination", ++ sage: algos = ["default", "dense_elimination", "sparse_elimination", + ....: "blackbox", "wiedemann"] + sage: for i in range(20): + ....: dim = randint(1, 30) +@@ -1080,8 +1080,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + linbox.solve(res[0], D, A[0], b[0]) elif method == METHOD_WIEDEMANN: linbox.solve(res[0], D, A[0], b[0], linbox.Method.Wiedemann()) - elif method == METHOD_BLAS_ELIMINATION: +- elif method == METHOD_BLAS_ELIMINATION: - linbox.solve(res[0], D, A[0], b[0], linbox.Method.BlasElimination()) ++ elif method == METHOD_DENSE_ELIMINATION: + linbox.solve(res[0], D, A[0], b[0], linbox.Method.DenseElimination()) elif method == METHOD_SPARSE_ELIMINATION: linbox.solve(res[0], D, A[0], b[0], linbox.Method.SparseElimination()) elif method == METHOD_BLACKBOX: -@@ -1192,7 +1192,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): +@@ -1136,7 +1136,7 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + + TESTS:: + +- sage: algos = ["default", "blas_elimination", "sparse_elimination", ++ sage: algos = ["default", "dense_elimination", "sparse_elimination", + ....: "blackbox", "wiedemann"] + + sage: for _ in range(10): +@@ -1191,8 +1191,8 @@ cdef class Matrix_integer_sparse(Matrix_sparse): + # solve the current row if algo == METHOD_DEFAULT: linbox.solve(res[0], D, A[0], b[0]) - elif algo == METHOD_BLAS_ELIMINATION: +- elif algo == METHOD_BLAS_ELIMINATION: - linbox.solve(res[0], D, A[0], b[0], linbox.Method.BlasElimination()) ++ elif algo == METHOD_DENSE_ELIMINATION: + linbox.solve(res[0], D, A[0], b[0], linbox.Method.DenseElimination()) elif algo == METHOD_SPARSE_ELIMINATION: linbox.solve(res[0], D, A[0], b[0], linbox.Method.SparseElimination()) elif algo == METHOD_BLACKBOX: diff --git a/src/sage/matrix/matrix_modn_dense_double.pyx b/src/sage/matrix/matrix_modn_dense_double.pyx -index c4b1a46444..4f140ad239 100644 +index c4b1a46..880caec 100644 --- a/src/sage/matrix/matrix_modn_dense_double.pyx +++ b/src/sage/matrix/matrix_modn_dense_double.pyx -@@ -25,7 +25,7 @@ from sage.libs.linbox.givaro cimport \ +@@ -24,8 +24,8 @@ from sage.libs.linbox.givaro cimport \ + Poly1Dom, Dense from sage.libs.linbox.linbox cimport \ - DenseMatrix_Modular_double as BlasMatrix, \ +- DenseMatrix_Modular_double as BlasMatrix, \ - EchelonForm_Modular_double as EchelonFormDomain -+ reducedRowEchelon ++ reducedRowEchelonize, \ ++ DenseMatrix_Modular_double as DenseMatrix from sage.libs.linbox.fflas cimport \ fgemm, fgemv, Det, Rank, ReducedRowEchelonForm, applyP, \ diff --git a/src/sage/matrix/matrix_modn_dense_float.pyx b/src/sage/matrix/matrix_modn_dense_float.pyx -index 89d1a94ab2..198896259b 100644 +index 89d1a94..8a468c1 100644 --- a/src/sage/matrix/matrix_modn_dense_float.pyx +++ b/src/sage/matrix/matrix_modn_dense_float.pyx -@@ -24,7 +24,7 @@ from sage.libs.linbox.givaro cimport \ +@@ -23,8 +23,8 @@ from sage.libs.linbox.givaro cimport \ + Poly1Dom, Dense from sage.libs.linbox.linbox cimport \ - DenseMatrix_Modular_float as BlasMatrix, \ +- DenseMatrix_Modular_float as BlasMatrix, \ - EchelonForm_Modular_float as EchelonFormDomain -+ reducedRowEchelon ++ DenseMatrix_Modular_float as DenseMatrix, \ ++ reducedRowEchelonize from sage.libs.linbox.fflas cimport \ fgemm, fgemv, Det, Rank, ReducedRowEchelonForm, applyP, \ diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi -index 6a5e164ede..7eb70dae86 100644 +index 6a5e164..230a16e 100644 --- a/src/sage/matrix/matrix_modn_dense_template.pxi +++ b/src/sage/matrix/matrix_modn_dense_template.pxi -@@ -207,7 +207,6 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_ +@@ -207,21 +207,12 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_ return 0,[] cdef ModField *F = new ModField(<long>modulus) - cdef EchelonFormDomain *EF = new EchelonFormDomain(F[0]) - cdef BlasMatrix *A = new BlasMatrix(F[0], <uint64_t>nrows, <uint64_t>ncols) - cdef BlasMatrix *E = new BlasMatrix(F[0], <uint64_t>nrows, <uint64_t>ncols) - -@@ -218,7 +217,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_ - for j in range(ncols): - A.setEntry(i, j, <ModField.Element>entries[i*ncols+j]) - +- cdef BlasMatrix *A = new BlasMatrix(F[0], <uint64_t>nrows, <uint64_t>ncols) +- cdef BlasMatrix *E = new BlasMatrix(F[0], <uint64_t>nrows, <uint64_t>ncols) +- ++ cdef DenseMatrix *A = new DenseMatrix(F[0], <ModField.Element*>entries,<Py_ssize_t>nrows, <Py_ssize_t>ncols) ++ cdef Py_ssize_t r = reducedRowEchelonize(A[0]) + cdef Py_ssize_t i,j +- +- # TODO: can we avoid this copy? +- for i in range(nrows): +- for j in range(ncols): +- A.setEntry(i, j, <ModField.Element>entries[i*ncols+j]) +- - cdef int r = EF.rowReducedEchelon(E[0], A[0]) -+ cdef int r = reducedRowEchelon(E[0], A[0]) for i in range(nrows): for j in range(ncols): - entries[i*ncols+j] = <celement>E.getEntry(i,j) -@@ -232,7 +231,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_ +- entries[i*ncols+j] = <celement>E.getEntry(i,j) ++ entries[i*ncols+j] = <celement>A.getEntry(i,j) + + cdef Py_ssize_t ii = 0 + cdef list pivots = [] +@@ -232,7 +223,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_ ii = j+1 break - del F, A, E, EF -+ del F, A, E ++ del F return r, pivots cdef inline celement *linbox_copy(celement modulus, celement *entries, Py_ssize_t nrows, Py_ssize_t ncols) except? NULL: -@@ -265,7 +264,8 @@ cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t +@@ -258,15 +249,16 @@ cdef inline int linbox_rank(celement modulus, celement* entries, Py_ssize_t nrow + del F + return r + +-cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t nrows, Py_ssize_t ncols): ++cdef inline celement linbox_det(celement modulus, celement* entries, Py_ssize_t n): + """ + Return the determinant of this matrix. + """ cdef ModField *F = new ModField(<long>modulus) - cdef celement *cpy = linbox_copy(modulus, entries, nrows, ncols) - if nrows*ncols > 1000: sig_on() +- cdef celement *cpy = linbox_copy(modulus, entries, nrows, ncols) +- if nrows*ncols > 1000: sig_on() - d = <celement>Det(F[0], nrows, ncols, <ModField.Element*>cpy, ncols) -+ cdef ModField.Element det -+ d = <celement>Det(F[0], det, ncols, <ModField.Element*>cpy, ncols, <size_t*>NULL, <size_t*>NULL) - if nrows*ncols > 1000: sig_off() +- if nrows*ncols > 1000: sig_off() ++ cdef celement *cpy = linbox_copy(modulus, entries, n, n) ++ if n*n > 1000: sig_on() ++ cdef celement d ++ Det(F[0], d, n, <ModField.Element*>cpy, n) ++ if n*n > 1000: sig_off() sig_free(cpy) del F + return d +@@ -1672,9 +1664,9 @@ cdef class Matrix_modn_dense_template(Matrix_dense): + + - ``algorithm`` + +- - ``linbox`` - uses the LinBox library (``EchelonFormDomain`` implementation, default) ++ - ``linbox`` - uses the LinBox library (wrapping fflas-ffpack) + +- - ``linbox_noefd`` - uses the LinBox library (FFPACK directly, less memory but slower) ++ - ``linbox_noefd`` - uses the FFPACK directly, less memory and faster + + - ``gauss`` - uses a custom slower `O(n^3)` Gauss + elimination implemented in Sage. +@@ -1929,7 +1921,6 @@ cdef class Matrix_modn_dense_template(Matrix_dense): + else: + r, pivots = linbox_echelonize(self.p, self._entries, self._nrows, self._ncols) + verbose('done with echelonize',t) +- + self.cache('in_echelon_form',True) + self.cache('rank', r) + self.cache('pivots', tuple(pivots)) +@@ -2468,7 +2459,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense): + x = self.fetch('det') + if not x is None: + return x +- d = linbox_det(self.p, self._entries, self._nrows, self._ncols) ++ d = linbox_det(self.p, self._entries, self._nrows) + d2 = self._coerce_element(d) + self.cache('det', d2) + return d2 diff --git a/src/sage/matrix/matrix_modn_sparse.pyx b/src/sage/matrix/matrix_modn_sparse.pyx -index 241167ace4..8e65cbb532 100644 +index 241167a..dd3a2f0 100644 --- a/src/sage/matrix/matrix_modn_sparse.pyx +++ b/src/sage/matrix/matrix_modn_sparse.pyx -@@ -1026,7 +1026,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): +@@ -882,7 +882,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + - ``'linbox'`` or ``'linbox_default'`` - (default) use LinBox + and let it chooses the appropriate algorithm + +- - ``linbox_blas_elimination'`` - use LinBox dense elimination ++ - ``linbox_dense_elimination'`` - use LinBox dense elimination + + - ``'linbox_sparse_elimination'`` - use LinBox sparse elimination + +@@ -949,7 +949,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + + - ``b`` -- a dense integer vector + +- - ``algorithm`` -- (optional) either ``None``, ``'blas_elimination'``, ++ - ``algorithm`` -- (optional) either ``None``, ``'dense_elimination'``, + ``'sparse_elimination'``, ``'wiedemann'`` or ``'blackbox'``. + + OUTPUT: a pair ``(a, d)`` consisting of +@@ -968,7 +968,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + sage: b0 = vector((1,1,1,1)) + sage: m._solve_vector_linbox(b0) + ((-1, -7, -3, -1), 1) +- sage: m._solve_vector_linbox(b0, 'blas_elimination') ++ sage: m._solve_vector_linbox(b0, 'dense_elimination') + ((-1, -7, -3, -1), 1) + sage: m._solve_vector_linbox(b0, 'sparse_elimination') + ((-1, -7, -3, -1), 1) +@@ -984,7 +984,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + + TESTS:: + +- sage: algos = ["default", "blas_elimination", "sparse_elimination", ++ sage: algos = ["default", "dense_elimination", "sparse_elimination", + ....: "blackbox", "wiedemann"] + sage: for i in range(20): + ....: dim = randint(1, 30) +@@ -1025,8 +1025,8 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + linbox.solve(res[0], D, A[0], b[0]) elif method == METHOD_WIEDEMANN: linbox.solve(res[0], D, A[0], b[0], linbox.Method.Wiedemann()) - elif method == METHOD_BLAS_ELIMINATION: +- elif method == METHOD_BLAS_ELIMINATION: - linbox.solve(res[0], D, A[0], b[0], linbox.Method.BlasElimination()) ++ elif method == METHOD_DENSE_ELIMINATION: + linbox.solve(res[0], D, A[0], b[0], linbox.Method.DenseElimination()) elif method == METHOD_SPARSE_ELIMINATION: linbox.solve(res[0], D, A[0], b[0], linbox.Method.SparseElimination()) elif method == METHOD_BLACKBOX: -@@ -1137,7 +1137,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): +@@ -1081,7 +1081,7 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + + TESTS:: + +- sage: algos = ["default", "blas_elimination", "sparse_elimination", ++ sage: algos = ["default", "dense_elimination", "sparse_elimination", + ....: "blackbox", "wiedemann"] + + sage: for _ in range(10): +@@ -1136,8 +1136,8 @@ cdef class Matrix_modn_sparse(matrix_sparse.Matrix_sparse): + # solve the current row if algo == METHOD_DEFAULT: linbox.solve(res[0], D, A[0], b[0]) - elif algo == METHOD_BLAS_ELIMINATION: +- elif algo == METHOD_BLAS_ELIMINATION: - linbox.solve(res[0], D, A[0], b[0], linbox.Method.BlasElimination()) ++ elif algo == METHOD_DENSE_ELIMINATION: + linbox.solve(res[0], D, A[0], b[0], linbox.Method.DenseElimination()) elif algo == METHOD_SPARSE_ELIMINATION: linbox.solve(res[0], D, A[0], b[0], linbox.Method.SparseElimination()) elif algo == METHOD_BLACKBOX: +diff --git a/src/sage/rings/finite_rings/element_givaro.pxd b/src/sage/rings/finite_rings/element_givaro.pxd +index f0fd7e35..8ae25c5 100644 +--- a/src/sage/rings/finite_rings/element_givaro.pxd ++++ b/src/sage/rings/finite_rings/element_givaro.pxd +@@ -20,35 +20,35 @@ cdef extern from "givaro/givrandom.h": + GivRandom GivRandomSeeded "Givaro::GivRandom"(unsigned long seed) + + cdef extern from "givaro/gfq.h": +- ctypedef struct GivaroGfq "Givaro::GFqDom<int>": ++ cdef cppclass GivaroGfq "Givaro::GFqDom<int>": + #attributes + unsigned int one + unsigned int zero + + # methods +- int (* mul)(int r, int a, int b) +- int (* add)(int r, int a, int b) +- int (* sub)(int r, int a, int b) +- int (* div)(int r, int a, int b) +- int (* inv)(int r, int x) +- int (* neg)(int r, int x) +- int (* mulin)(int a, int b) +- unsigned int (* characteristic)() +- unsigned int (* cardinality)() +- int (* exponent)() +- int (* random)(GivRandom gen, int res) +- int (* initi "init")(int res, int64_t e) +- int (* initd "init")(int res, double e) +- int (* indeterminate)() +- int (* convert)(int64_t r, int p) +- int (* read)(int r, int p) +- int (* axpyin)(int r, int a, int x) +- int (* axpy)(int r, int a, int b, int c) +- int (* axmy)(int r, int a, int b, int c) +- int (* maxpy)(int r, int a, int b, int c) +- bint (* isZero)(int e) +- bint (* isOne)(int e) +- bint (* isunit)(int e) ++ int mul(int r, int a, int b) ++ int add(int r, int a, int b) ++ int sub(int r, int a, int b) ++ int div(int r, int a, int b) ++ int inv(int r, int x) ++ int neg(int r, int x) ++ int mulin(int a, int b) ++ unsigned int characteristic() ++ unsigned int cardinality() ++ int exponent() ++ int random(GivRandom gen, int res) ++ int initi "init"(int& res, int64_t e) ++ int initd "init"(int& res, double e) ++ int indeterminate() ++ int64_t convert(int64_t& r, int p) ++ int read(int& r, int p) ++ int axpyin(int r, int a, int x) ++ int axpy(int r, int a, int b, int c) ++ int axmy(int r, int a, int b, int c) ++ int maxpy(int r, int a, int b, int c) ++ bint isZero(int e) ++ bint isOne(int e) ++ bint isunit(int e) + + GivaroGfq *gfq_factorypk "new Givaro::GFqDom<int>" (unsigned int p, unsigned int k) + GivaroGfq *gfq_factorypkp "new Givaro::GFqDom<int>" (unsigned int p, unsigned int k, intvec poly) +diff --git a/src/sage/rings/finite_rings/element_givaro.pyx b/src/sage/rings/finite_rings/element_givaro.pyx +index 3739020..a7f9c2f 100644 +--- a/src/sage/rings/finite_rings/element_givaro.pyx ++++ b/src/sage/rings/finite_rings/element_givaro.pyx +@@ -310,7 +310,7 @@ cdef class Cache_givaro(SageObject): + cdef int seed = current_randstate().c_random() + cdef int res + cdef GivRandom generator = GivRandomSeeded(seed) +- res = self.objectptr.random(generator,res) ++ self.objectptr.random(generator,res) + return make_FiniteField_givaroElement(self,res) + + cpdef FiniteField_givaroElement element_from_data(self, e): +@@ -386,16 +386,16 @@ cdef class Cache_givaro(SageObject): + isinstance(e, long) or is_IntegerMod(e): + try: + e_int = e % self.characteristic() +- res = self.objectptr.initi(res, e_int) ++ self.objectptr.initi(res, e_int) + except ArithmeticError: + raise TypeError("unable to coerce from a finite field other than the prime subfield") + elif e is None: + e_int = 0 +- res = self.objectptr.initi(res, e_int) ++ self.objectptr.initi(res, e_int) + + elif isinstance(e, float): + e_int = int(e) % self.characteristic() +- res = self.objectptr.initd(res, e_int) ++ self.objectptr.initd(res, e_int) + + elif isinstance(e, str): + return self.parent(eval(e.replace("^","**"),self.parent.gens_dict())) +@@ -406,7 +406,7 @@ cdef class Cache_givaro(SageObject): + ret = self._zero_element + for i in range(len(e)): + e_int = e[i] % self.characteristic() +- res = self.objectptr.initi(res, e_int) ++ self.objectptr.initi(res, e_int) + to_add = make_FiniteField_givaroElement(self, res) + ret = ret + to_add*self.parent.gen()**i + return ret +@@ -446,7 +446,7 @@ cdef class Cache_givaro(SageObject): + ret = self._zero_element + for i in range(len(e)): + e_int = e[i] % self.characteristic() +- res = self.objectptr.initi(res, e_int) ++ self.objectptr.initi(res, e_int) + to_add = make_FiniteField_givaroElement(self, res) + ret = ret + to_add*self.parent.gen()**i + return ret +@@ -475,8 +475,8 @@ cdef class Cache_givaro(SageObject): + + for i from 0 <= i <= degpol(t): + c = gtolong(gel(t, i+2)) +- res = self.objectptr.axpyin(res, self.int_to_log(c), x) +- x = self.objectptr.mul(x,x,g) ++ self.objectptr.axpyin(res, self.int_to_log(c), x) ++ self.objectptr.mulin(x,g) + clear_stack() + else: + clear_stack() +@@ -580,21 +580,10 @@ cdef class Cache_givaro(SageObject): + sage: 2^7 + 2^4 + 2^2 + 2 + 1 + 151 + """ +- cdef GivaroGfq *k = self.objectptr +- cdef int ret = k.zero +- cdef int a = k.indeterminate() +- cdef int at = k.one +- cdef int ch = k.characteristic() +- cdef int t, i +- +- if n<0 or n>k.cardinality(): ++ if n<0 or n>self.order(): + raise TypeError("n must be between 0 and self.order()") + +- for i from 0 <= i < k.exponent(): +- t = k.initi(t, n % ch) +- ret = k.axpy(ret, t, at, ret) +- at = k.mul(at,at,a) +- n //= ch ++ cdef int ret = self.int_to_log(n) + return make_FiniteField_givaroElement(self, ret) + + def _element_repr(self, FiniteField_givaroElement e): +@@ -715,7 +704,7 @@ cdef class Cache_givaro(SageObject): + """ + cdef int r + +- r = self.objectptr.axpy(r, a.element, b.element, c.element) ++ self.objectptr.axpy(r, a.element, b.element, c.element) + return make_FiniteField_givaroElement(self,r) + + def a_times_b_minus_c(self,FiniteField_givaroElement a, FiniteField_givaroElement b, FiniteField_givaroElement c): +@@ -734,7 +723,7 @@ cdef class Cache_givaro(SageObject): + """ + cdef int r + +- r = self.objectptr.axmy(r, a.element, b.element, c.element, ) ++ self.objectptr.axmy(r, a.element, b.element, c.element, ) + return make_FiniteField_givaroElement(self,r) + + def c_minus_a_times_b(self,FiniteField_givaroElement a, +@@ -754,7 +743,7 @@ cdef class Cache_givaro(SageObject): + """ + cdef int r + +- r = self.objectptr.maxpy(r , a.element, b.element, c.element, ) ++ self.objectptr.maxpy(r , a.element, b.element, c.element, ) + return make_FiniteField_givaroElement(self,r) + + def __reduce__(self): +@@ -1108,7 +1097,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): + 2*b^3 + 2*b^2 + 2*b + 1 + """ + cdef int r +- r = self._cache.objectptr.add(r, self.element , ++ self._cache.objectptr.add(r, self.element , + (<FiniteField_givaroElement>right).element ) + return make_FiniteField_givaroElement(self._cache,r) + +@@ -1125,7 +1114,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): + c^2 + """ + cdef int r +- r = self._cache.objectptr.mul(r, self.element, ++ self._cache.objectptr.mul(r, self.element, + (<FiniteField_givaroElement>right).element) + return make_FiniteField_givaroElement(self._cache,r) + +@@ -1147,7 +1136,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): + cdef int r + if (<FiniteField_givaroElement>right).element == 0: + raise ZeroDivisionError('division by zero in finite field') +- r = self._cache.objectptr.div(r, self.element, ++ self._cache.objectptr.div(r, self.element, + (<FiniteField_givaroElement>right).element) + return make_FiniteField_givaroElement(self._cache,r) + +@@ -1164,7 +1153,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): + 2*a^2 + 2*a + """ + cdef int r +- r = self._cache.objectptr.sub(r, self.element, ++ self._cache.objectptr.sub(r, self.element, + (<FiniteField_givaroElement>right).element) + return make_FiniteField_givaroElement(self._cache,r) + +@@ -1181,7 +1170,7 @@ cdef class FiniteField_givaroElement(FinitePolyExtElement): + """ + cdef int r + +- r = self._cache.objectptr.neg(r, self.element) ++ self._cache.objectptr.neg(r, self.element) + return make_FiniteField_givaroElement(self._cache,r) + + def __invert__(FiniteField_givaroElement self):
