[arch-commits] Commit in sagemath/trunk (PKGBUILD sagemath-linbox-1.5.patch)
Antonio Rojas
arojas at archlinux.org
Sat Nov 18 17:07:35 UTC 2017
Date: Saturday, November 18, 2017 @ 17:07:35
Author: arojas
Revision: 267315
linbox 1.5 rebuild
Added:
sagemath/trunk/sagemath-linbox-1.5.patch
Modified:
sagemath/trunk/PKGBUILD
---------------------------+
PKGBUILD | 10 +
sagemath-linbox-1.5.patch | 272 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 279 insertions(+), 3 deletions(-)
Modified: PKGBUILD
===================================================================
--- PKGBUILD 2017-11-18 17:06:54 UTC (rev 267314)
+++ PKGBUILD 2017-11-18 17:07:35 UTC (rev 267315)
@@ -9,7 +9,7 @@
pkgbase=sagemath
pkgname=(sagemath sagemath-jupyter)
pkgver=8.0
-pkgrel=9
+pkgrel=10
pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab"
arch=(x86_64)
url="http://www.sagemath.org"
@@ -37,7 +37,8 @@
source=("$pkgname-$pkgver.tar.gz::https://github.com/sagemath/sage/archive/$pkgver.tar.gz"
env.patch package.patch latte-count.patch jupyter-path.patch sagemath-python3-notebook.patch test-optional.patch
r-no-readline.patch fes02.patch sagemath-ecl-no-sigfpe.patch sagemath-cython-0.26.patch sagemath-threejs.patch
- sagemath-pynac-0.7.11.patch sagemath-pynac-0.7.12.patch sagemath-detect-igraph.patch sagemath-networkx2.patch sagemath-brial-1.2.patch)
+ sagemath-pynac-0.7.11.patch sagemath-pynac-0.7.12.patch sagemath-detect-igraph.patch sagemath-networkx2.patch
+ sagemath-brial-1.2.patch sagemath-linbox-1.5.patch)
sha256sums=('91df3e303add71616e24b38c04789f66d57ada7b1017e5369e850c42d5e8753d'
'e0b5b8673300857fde823209a7e90faecf9e754ab812cc5e54297eddc0c79571'
'4a2297e4d9d28f0b3a1f58e1b463e332affcb109eafde44837b1657e309c8212'
@@ -54,7 +55,8 @@
'719bb39c9c2cd1c6e75be0969000ba5ffcd2875bb5190fce6bb6a6feaa76b96f'
'90be1d1a90120bd5bd3620769480106ba809dd23e896bc4a3f8931e5340f3cda'
'a1a0ab5b794136b518f5f66fe9f1689411fabb3b81560b159eae81f6f69000e3'
- '64ee1930049a17a7295bb45513efc9d484299132900fc9b8e308a9fe1a2df149')
+ '64ee1930049a17a7295bb45513efc9d484299132900fc9b8e308a9fe1a2df149'
+ 'a52d03e04c9d64bb957a1f8dcdae3280ebb9450a7fd76aaf5ae5de5c6f74774f')
prepare(){
cd sage-$pkgver
@@ -97,6 +99,8 @@
patch -p1 -i ../sagemath-pynac-0.7.11.patch
# fix build with pynac 0.7.12 https://trac.sagemath.org/ticket/23950
patch -p1 -i ../sagemath-pynac-0.7.12.patch
+# fix build with linbox 1.5 https://trac.sagemath.org/ticket/24214
+ patch -p1 -i ../sagemath-linbox-1.5.patch
# use python2
sed -e 's|#!/usr/bin/env python|#!/usr/bin/env python2|' -e 's|exec python|exec python2|' -i src/bin/*
Added: sagemath-linbox-1.5.patch
===================================================================
--- sagemath-linbox-1.5.patch (rev 0)
+++ sagemath-linbox-1.5.patch 2017-11-18 17:07:35 UTC (rev 267315)
@@ -0,0 +1,272 @@
+diff --git a/src/sage/libs/linbox/fflas.pxd b/src/sage/libs/linbox/fflas.pxd
+index ca23d71..03bbee9 100644
+--- a/src/sage/libs/linbox/fflas.pxd
++++ b/src/sage/libs/linbox/fflas.pxd
+@@ -20,19 +20,29 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h" namespace "std":
+ iterator end()
+ size_t size()
+
+- cdef cppclass list[T]:
+- cppclass iterator:
+- T operator*()
+- iterator operator++()
+- bint operator==(iterator)
+- bint operator!=(iterator)
+- void push_back(T&)
+- void pop_front()
+- T& front()
+- iterator begin()
+- iterator end()
++cdef extern from "givaro/givpoly1.h":
++ ## template < typename T, typename A=std::allocator<T> >
++ ## class givvector : public __GIV_STANDARD_VECTOR<T,A>
++ cdef cppclass givvector "Givaro::givvector" [T,ALLOCATOR=*]:
++ T& operator[](size_t i)
+ size_t size()
+- void clear()
++
++ctypedef givvector[ModDoubleFieldElement] ModDoubleDensePolynomial
++ctypedef givvector[ModFloatFieldElement] ModFloatDensePolynomial
++
++cdef extern from "givaro/givpoly1.h":
++ ## template <class Domain, class StorageTag= Givaro::Dense>
++ ## class GivPolynomialRing : public Givaro::Poly1FactorDom< Domain,StorageTag>
++ cdef cppclass ModDoublePolynomialRing "Givaro::Poly1Dom<Givaro::Modular<double>, Givaro::Dense>":
++ ctypedef givvector[ModDoubleField] Element
++ ctypedef givvector[ModDoubleField] Polynomial
++ ModDoublePolynomialRing(ModDoubleField& F)
++ ## template <class Domain, class StorageTag= Givaro::Dense>
++ ## class GivPolynomialRing : public Givaro::Poly1FactorDom< Domain,StorageTag>
++ cdef cppclass ModFloatPolynomialRing "Givaro::Poly1Dom<Givaro::Modular<float>, Givaro::Dense>":
++ ctypedef givvector[ModFloatField] Element
++ ctypedef givvector[ModFloatField] Polynomial
++ ModFloatPolynomialRing(ModFloatField& F)
+
+ cdef extern from "fflas-ffpack/fflas-ffpack.h":
+ ctypedef enum fflas_trans_enum "FFLAS::FFLAS_TRANSPOSE":
+@@ -105,13 +115,12 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h":
+ size_t nr, size_t foo, size_t r,
+ ModDoubleFieldElement* matrix, size_t nc, size_t* Q)
+
+- void ModDouble_MinPoly "FFPACK::MinPoly" ( ModDoubleField F,
++ void ModDouble_MinPoly "FFPACK::MinPoly" ( ModDoubleField& F,
+ vector[ModDoubleFieldElement] minP, size_t N,
+- ModDoubleFieldElement* A, size_t lda,
+- ModDoubleFieldElement* X, size_t ldx, size_t* P)
++ ModDoubleFieldElement*A, size_t lda)
+
+- void ModDouble_CharPoly "FFPACK::CharPoly" ( ModDoubleField F,
+- list[vector[ModDoubleFieldElement]] charp, size_t N,
++ void ModDouble_CharPoly "FFPACK::CharPoly" ( ModDoublePolynomialRing& R,
++ ModDoubleDensePolynomial& charp, size_t N,
+ ModDoubleFieldElement* A, size_t lda)
+
+ # float
+@@ -142,9 +151,8 @@ cdef extern from "fflas-ffpack/fflas-ffpack.h":
+
+ void ModFloat_MinPoly "FFPACK::MinPoly" ( ModFloatField F,
+ vector[ModFloatFieldElement] minP, size_t N,
+- ModFloatFieldElement* A, size_t lda,
+- ModFloatFieldElement* X, size_t ldx, size_t* P)
++ ModFloatFieldElement* A, size_t lda)
+
+- void ModFloat_CharPoly "FFPACK::CharPoly" ( ModFloatField F,
+- list[vector[ModFloatFieldElement]] charp, size_t N,
++ void ModFloat_CharPoly "FFPACK::CharPoly" ( ModFloatPolynomialRing& F,
++ ModFloatDensePolynomial& charp, size_t N,
+ ModFloatFieldElement* A, size_t lda )
+diff --git a/src/sage/libs/linbox/linbox_flint_interface.pyx b/src/sage/libs/linbox/linbox_flint_interface.pyx
+index 02a6151..a00d303 100644
+--- a/src/sage/libs/linbox/linbox_flint_interface.pyx
++++ b/src/sage/libs/linbox/linbox_flint_interface.pyx
+@@ -76,19 +76,23 @@ cdef extern from "givaro/zring.h":
+ ctypedef GivaroInteger Element
+
+
+-cdef extern from "givaro/givpoly1.h":
+- ## template < typename T, typename A=std::allocator<T> >
+- ## class givvector : public __GIV_STANDARD_VECTOR<T,A>
+- cdef cppclass givvector "Givaro::givvector" [T,ALLOCATOR=*]:
+- T& operator[](size_t i)
++cdef extern from "linbox/polynomial/dense-polynomial.h":
++ ## template<class Field>
++ ## class DensePolynomial : public Givaro::Poly1FactorDom<Field, Givaro::Dense>::Element
++ cdef cppclass LinBoxIntegerDensePolynomial "LinBox::DensePolynomial<Givaro::ZRing<Givaro::Integer> >":
++ ctypedef GivaroIntegerRing BaseRing
++ ctypedef GivaroInteger BaseRingElement
++ LinBoxIntegerDensePolynomial(BaseRing &F)
++ LinBoxIntegerDensePolynomial(BaseRing &F, size_t s)
++ BaseRingElement& operator[](size_t i)
+ size_t size()
+
+-cdef extern from "linbox/ring/givaro-polynomial.h":
+- ## template <class Domain, class StorageTag= Givaro::Dense>
+- ## class GivPolynomialRing : public Givaro::Poly1FactorDom< Domain,StorageTag>
+- cdef cppclass LinBoxIntegerPolynomialRing "LinBox::GivPolynomialRing<Givaro::ZRing<Givaro::Integer>, Givaro::Dense>":
+- ctypedef givvector[GivaroInteger] Element
+- ctypedef givvector[GivaroInteger] Polynomial
++cdef extern from "linbox/ring/polynomial-ring.h":
++ ## template <class BaseRing, class StorageTag= Givaro::Dense>
++ ## class PolynomialRing : public Givaro::Poly1FactorDom<BaseRing,StorageTag>
++ cdef cppclass LinBoxIntegerPolynomialRing "LinBox::PolynomialRing<Givaro::ZRing<Givaro::Integer>, Givaro::Dense>":
++ ctypedef LinBoxIntegerDensePolynomial Element
++ ctypedef LinBoxIntegerDensePolynomial Polynomial
+
+ cdef extern from "linbox/matrix/matrix-domain.h":
+ ## template <class Field_ >
+@@ -190,40 +194,32 @@ cdef void linbox_fmpz_mat_mul(fmpz_mat_t C, fmpz_mat_t A, fmpz_mat_t B):
+ cdef void linbox_fmpz_mat_charpoly(fmpz_poly_t cp, fmpz_mat_t A):
+ cdef GivaroIntegerRing ZZ
+ cdef LinBoxIntegerDenseMatrix * LBA
+- cdef LinBoxIntegerPolynomialRing.Element m_A
+-
+- # FIXME: bug in LinBox
+- # see https://github.com/linbox-team/linbox/issues/51
+- if fmpz_mat_nrows(A) == 0:
+- fmpz_poly_one(cp)
+- return
++ cdef LinBoxIntegerDensePolynomial * m_A
+
+ LBA = new LinBoxIntegerDenseMatrix(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
+ fmpz_mat_get_linbox(LBA[0], A)
+- LinBoxIntegerDense_charpoly(m_A, LBA[0])
+- fmpz_poly_set_linbox(cp, m_A)
++ m_A = new LinBoxIntegerDensePolynomial(ZZ, fmpz_mat_nrows(A))
++ LinBoxIntegerDense_charpoly(m_A[0], LBA[0])
++ fmpz_poly_set_linbox(cp, m_A[0])
+
+ del LBA
++ del m_A
+
+
+ # set mp to the minimal polynomial of A
+ cdef void linbox_fmpz_mat_minpoly(fmpz_poly_t mp, fmpz_mat_t A):
+ cdef GivaroIntegerRing ZZ
+ cdef LinBoxIntegerDenseMatrix * LBA
+- cdef LinBoxIntegerPolynomialRing.Element m_A
+-
+- # FIXME: bug in LinBox
+- # see https://github.com/linbox-team/linbox/issues/51
+- if fmpz_mat_nrows(A) == 0:
+- fmpz_poly_one(mp)
+- return
++ cdef LinBoxIntegerDensePolynomial * m_A
+
+ LBA = new LinBoxIntegerDenseMatrix(ZZ, fmpz_mat_nrows(A), fmpz_mat_ncols(A))
++ m_A = new LinBoxIntegerDensePolynomial(ZZ)
+ fmpz_mat_get_linbox(LBA[0], A)
+- LinBoxIntegerDense_minpoly(m_A, LBA[0])
+- fmpz_poly_set_linbox(mp, m_A)
++ LinBoxIntegerDense_minpoly(m_A[0], LBA[0])
++ fmpz_poly_set_linbox(mp, m_A[0])
+
+ del LBA
++ del m_A
+
+
+ # return the rank of A
+diff --git a/src/sage/matrix/matrix_modn_dense_double.pyx b/src/sage/matrix/matrix_modn_dense_double.pyx
+index 15c35cb..b1f6154 100644
+--- a/src/sage/matrix/matrix_modn_dense_double.pyx
++++ b/src/sage/matrix/matrix_modn_dense_double.pyx
+@@ -27,7 +27,9 @@ from sage.libs.linbox.fflas cimport ModDouble_fgemm as Mod_fgemm, ModDouble_fgem
+ ModDoubleRank as ModRank, ModDouble_echelon as Mod_echelon, \
+ ModDouble_applyp as Mod_applyp, \
+ ModDouble_MinPoly as Mod_MinPoly, \
+- ModDouble_CharPoly as Mod_CharPoly
++ ModDouble_CharPoly as Mod_CharPoly, \
++ ModDoublePolynomialRing as ModDensePolyRing,\
++ ModDoubleDensePolynomial as ModDensePoly
+
+ # Limit for LinBox Modular<double>
+ MAX_MODULUS = 2**23
+diff --git a/src/sage/matrix/matrix_modn_dense_float.pyx b/src/sage/matrix/matrix_modn_dense_float.pyx
+index 61457ce..eda8f0b 100644
+--- a/src/sage/matrix/matrix_modn_dense_float.pyx
++++ b/src/sage/matrix/matrix_modn_dense_float.pyx
+@@ -25,7 +25,10 @@ from sage.libs.linbox.fflas cimport ModFloat_fgemm as Mod_fgemm, ModFloat_fgemv
+ ModFloatRank as ModRank, ModFloat_echelon as Mod_echelon, \
+ ModFloat_applyp as Mod_applyp, \
+ ModFloat_MinPoly as Mod_MinPoly, \
+- ModFloat_CharPoly as Mod_CharPoly
++ ModFloat_CharPoly as Mod_CharPoly, \
++ ModFloatPolynomialRing as ModDensePolyRing,\
++ ModFloatDensePolynomial as ModDensePoly
++
+
+ # LinBox supports up to 2^11 using float but that's double dog slow,
+ # so we pick a smaller value for crossover
+diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi
+index 3da3e31..819ef2d 100644
+--- a/src/sage/matrix/matrix_modn_dense_template.pxi
++++ b/src/sage/matrix/matrix_modn_dense_template.pxi
+@@ -306,23 +306,15 @@ cdef inline linbox_minpoly(celement modulus, Py_ssize_t nrows, celement* entries
+ cdef Py_ssize_t i
+ cdef ModField *F = new ModField(<long>modulus)
+ cdef vector[ModFieldElement] *minP = new vector[ModFieldElement]()
+- cdef ModFieldElement *X = <ModFieldElement*>check_allocarray(nrows * (nrows+1), sizeof(ModFieldElement))
+- cdef size_t *P = <size_t*>check_allocarray(nrows, sizeof(size_t))
+-
+- cdef celement *cpy = linbox_copy(modulus, entries, nrows, nrows)
+
+ if nrows*nrows > 1000: sig_on()
+- Mod_MinPoly(F[0], minP[0], nrows, <ModFieldElement*>cpy, nrows, X, nrows, P)
++ Mod_MinPoly(F[0], minP[0], nrows, <ModFieldElement*>entries, nrows)
+ if nrows*nrows > 1000: sig_off()
+
+- sig_free(cpy)
+-
+ l = []
+ for i in range(minP.size()):
+ l.append( <celement>minP.at(i) )
+
+- sig_free(P)
+- sig_free(X)
+ del F
+ return l
+
+@@ -332,27 +324,23 @@ cdef inline linbox_charpoly(celement modulus, Py_ssize_t nrows, celement* entrie
+ """
+ cdef Py_ssize_t i
+ cdef ModField *F = new ModField(<long>modulus)
+- cdef std_list[vector[ModFieldElement]] P_list
+- P_list.clear()
++ cdef ModDensePolyRing * R = new ModDensePolyRing(F[0])
++ cdef ModDensePoly P
+
+ cdef celement *cpy = linbox_copy(modulus, entries, nrows, nrows)
+
+ if nrows*nrows > 1000: sig_on()
+- Mod_CharPoly(F[0], P_list, nrows, <ModFieldElement*>cpy, nrows)
++ Mod_CharPoly(R[0], P, nrows, <ModFieldElement*>cpy, nrows)
+ if nrows*nrows > 1000: sig_off()
+
+ sig_free(cpy)
+
+- cdef vector[ModFieldElement] tmp
+ l = []
+- while P_list.size():
+- l.append([])
+- tmp = P_list.front()
+- for i in range(tmp.size()):
+- l[-1].append(<celement>tmp.at(i))
+- P_list.pop_front()
++ for i in range(P.size()):
++ l.append(<celement>P[i])
+
+ del F
++ del R
+ return l
+
+
+@@ -1731,9 +1719,7 @@ cdef class Matrix_modn_dense_template(Matrix_dense):
+ R = self._base_ring[var]
+ # call linbox for charpoly
+ v = linbox_charpoly(self.p, self._nrows, self._entries)
+- r = R(1)
+- for e in v:
+- r *= R(e)
++ r = R(v)
+ return r
+
+ def echelonize(self, algorithm="linbox", **kwds):
More information about the arch-commits
mailing list