[arch-commits] Commit in sagemath/trunk (PKGBUILD sagemath-cypari2.patch)

Antonio Rojas arojas at archlinux.org
Mon Oct 29 17:57:25 UTC 2018


    Date: Monday, October 29, 2018 @ 17:57:24
  Author: arojas
Revision: 399470

cypari2 2.0 rebuild, move openblas and three.js to depends

Added:
  sagemath/trunk/sagemath-cypari2.patch
Modified:
  sagemath/trunk/PKGBUILD

------------------------+
 PKGBUILD               |   17 +-
 sagemath-cypari2.patch |  380 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 390 insertions(+), 7 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2018-10-29 17:19:36 UTC (rev 399469)
+++ PKGBUILD	2018-10-29 17:57:24 UTC (rev 399470)
@@ -8,7 +8,7 @@
 pkgbase=sagemath
 pkgname=(sagemath sagemath-jupyter)
 pkgver=8.4
-pkgrel=1
+pkgrel=2
 pkgdesc="Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab"
 arch=(x86_64)
 url="http://www.sagemath.org"
@@ -17,7 +17,7 @@
   python2-matplotlib python2-scipy python2-sympy python2-networkx python2-pillow python2-future libgap flintqs lcalc lrcalc arb
   eclib gmp-ecm zn_poly gd python2-cvxopt pynac linbox rubiks pari-galdata pari-seadata-small planarity rankwidth tachyon
   sage-data-combinatorial_designs sage-data-elliptic_curves sage-data-graphs sage-data-polytopes_db sage-data-conway_polynomials
-  libgiac libhomfly libbraiding)
+  libgiac libhomfly libbraiding three.js openblas)
 optdepends=('cython2: to compile cython code' 'python2-pkgconfig: to compile cython code'
   'jmol: 3D plots' 'sage-notebook: Flask notebook interface (deprecated)'
   'sagemath-doc: Documentation and inline help' 'python2-igraph: igraph backend for graph theory'
@@ -28,10 +28,9 @@
   'lrs: Algorithms for linear reverse search used in game theory and for computing volume of polytopes'
   'libfes: exhaustive search of solutions for boolean equations' 'python2-pynormaliz: Normaliz backend for polyhedral computations'
   'latte-integrale: integral point count in polyhedra' 'polymake: polymake backend for polyhedral computations'
-  'shared_meataxe: faster matrix arithmetic over finite fields' 'openblas: faster linear algebra'
+  'shared_meataxe: faster matrix arithmetic over finite fields'
   'sirocco: for computing the fundamental group of the complement of a plane curve' 'primecount: faster prime_pi implementation'
-  'three.js: alternative 3D plots engine' 'dot2tex: for displaying some diagrams'
-  'cryptominisat5: SAT solver' 'python2-pycosat: picosat SAT solver'
+  'dot2tex: for displaying some diagrams' 'cryptominisat5: SAT solver' 'python2-pycosat: picosat SAT solver'
   'python2-pip: to install optional packages with sage -pip')
 makedepends=(cython2 boost ratpoints symmetrica python2-jinja coin-or-cbc sirocco
   mcqd coxeter bliss-graphs tdlib python2-pkgconfig shared_meataxe libfes primecount)
@@ -49,7 +48,8 @@
         sagemath-sphinx-1.8.patch
         sagemath-networkx-2.2.patch
         sagemath-cython-0.29.patch
-        sagemath-numpy-1.15.patch)
+        sagemath-numpy-1.15.patch
+        sagemath-cypari2.patch)
 sha256sums=('961a21f60d251531db4b9935cfb6f67f7a207e1029288b4dc5b807f021078ab0'
             '6032ec3d0c983e70d4daa1391bc5daa0c948d350f3697932fc2e8472f0778037'
             '960afe4fcbffe2762b66119b8f14355386ced0d8ee52b535d0dac1dba90d365b'
@@ -64,7 +64,8 @@
             '7dd2ab94fddda8e7c2cdd5250642c4cdd00b7702815d88762fbcd68416bacaee'
             '0e3436a68cca4165d3d8519a7d4357b1a59515e9e4cc8bd816a852ca4097e274'
             'd1af7916e21d0a4de7b3ab5d4054c6b3175b84551ea6639a2680e6102c0b990b'
-            '9ef22633ae5d0dde9afe922d5616e49cea4ef6178a4991c96a258981cba674b7')
+            '9ef22633ae5d0dde9afe922d5616e49cea4ef6178a4991c96a258981cba674b7'
+            'ef9e2d5b7bd9c2b79121fe771a97963527d97ac9c1d6736d931f00e3eb7f540a')
 
 prepare(){
   cd sage-$pkgver
@@ -100,6 +101,8 @@
   patch -p1 -i ../sagemath-cython-0.29.patch
 # Fixes for numpy 1.15 https://trac.sagemath.org/ticket/25260
   patch -p1 -i ../sagemath-numpy-1.15.patch
+# Fix build with cypari 2.0 https://trac.sagemath.org/ticket/26442
+  patch -p1 -i ../sagemath-cypari2.patch
 
 # use python2
   sed -e 's|sage-python23|python2|' -e 's|#!/usr/bin/env python\b|#!/usr/bin/env python2|' -i src/bin/*

Added: sagemath-cypari2.patch
===================================================================
--- sagemath-cypari2.patch	                        (rev 0)
+++ sagemath-cypari2.patch	2018-10-29 17:57:24 UTC (rev 399470)
@@ -0,0 +1,380 @@
+diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pxd 
+b/src/sage/rings/finite_rings/element_pari_ffelt.pxd
+index 10885d4..0b66436 100644
+--- a/src/sage/rings/finite_rings/element_pari_ffelt.pxd
++++ b/src/sage/rings/finite_rings/element_pari_ffelt.pxd
+@@ -1,9 +1,12 @@
+ from cypari2.types cimport GEN
+ from sage.rings.finite_rings.element_base cimport FinitePolyExtElement
+ 
++
+ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+-    cdef GEN val        # PARI t_FFELT describing the element
+-    cdef void* chunk    # memory block containing the data
+-    cdef FiniteFieldElement_pari_ffelt _new(FiniteFieldElement_pari_ffelt self)
+-    cdef void construct(FiniteFieldElement_pari_ffelt self, GEN g)
+-    cdef void construct_from(FiniteFieldElement_pari_ffelt self, object x) except *
++    # PARI t_FFELT describing the element.
++    # This holds a reference to a PARI clone.
++    cdef GEN val
++
++    cdef FiniteFieldElement_pari_ffelt _new(self)
++    cdef void construct(self, GEN g)
++    cdef int construct_from(self, x) except -1
+diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx 
+b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+index 78a35fe..727a058 100644
+--- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx
++++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+@@ -24,7 +24,7 @@ from cysignals.signals cimport sig_on, sig_off
+ from cypari2.paridecl cimport *
+ from cypari2.paripriv cimport *
+ from sage.libs.pari.convert_gmp cimport _new_GEN_from_mpz_t
+-from cypari2.stack cimport new_gen, clear_stack, deepcopy_to_python_heap
++from cypari2.stack cimport new_gen, new_gen_noclear, clear_stack
+ from cypari2.gen cimport Gen as pari_gen, objtogen
+ 
+ from .element_base cimport FinitePolyExtElement
+@@ -316,7 +316,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         0
+     """
+ 
+-    def __init__(FiniteFieldElement_pari_ffelt self, object parent, object x):
++    def __init__(self, parent, x):
+         """
+         Initialise ``self`` with the given ``parent`` and value
+         converted from ``x``.
+@@ -335,13 +335,14 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         self._parent = parent
+         self.construct_from(x)
+ 
+-    def __dealloc__(FiniteFieldElement_pari_ffelt self):
++    def __dealloc__(self):
+         """
+-        Cython deconstructor.
++        Cython destructor.
+         """
+-        sig_free(self.chunk)
++        if self.val is not NULL:
++            gunclone_deep(self.val)
+ 
+-    cdef FiniteFieldElement_pari_ffelt _new(FiniteFieldElement_pari_ffelt self):
++    cdef FiniteFieldElement_pari_ffelt _new(self):
+         """
+         Create an empty element with the same parent as ``self``.
+         """
+@@ -350,17 +351,17 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         x._parent = self._parent
+         return x
+ 
+-    cdef void construct(FiniteFieldElement_pari_ffelt self, GEN g):
++    cdef void construct(self, GEN g):
+         """
+         Initialise ``self`` to the FFELT ``g``, reset the PARI stack,
+         and call sig_off().
+ 
+         This should be called exactly once on every instance.
+         """
+-        self.val = deepcopy_to_python_heap(g, &self.chunk)
++        self.val = gcloneref(g)
+         clear_stack()
+ 
+-    cdef void construct_from(FiniteFieldElement_pari_ffelt self, object x) except *:
++    cdef int construct_from(self, x) except -1:
+         """
+         Initialise ``self`` to an FFELT constructed from the Sage
+         object `x`.
+@@ -424,29 +425,29 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             sig_on()
+             if gequal0(x_GEN):
+                 self.construct(FF_zero(g))
+-                return
++                return 0
+             elif gequal1(x_GEN):
+                 self.construct(FF_1(g))
+-                return
++                return 0
+ 
+             t = typ(x_GEN)
+             if t == t_FFELT:
+                 if FF_samefield(x_GEN, g):
+                     self.construct(x_GEN)
+-                    return
++                    return 0
+             elif t == t_INT:
+                 self.construct(_INT_to_FFELT(g, x_GEN))
+-                return
++                return 0
+             elif t == t_INTMOD:
+                 if gequal0(modii(gel(x_GEN, 1), FF_p_i(g))):
+                     self.construct(_INT_to_FFELT(g, gel(x_GEN, 2)))
+-                    return
++                    return 0
+             elif t == t_FRAC:
+                 if not gequal0(modii(gel(x_GEN, 2), FF_p_i(g))):
+                     elt = FF_div(_INT_to_FFELT(g, gel(x_GEN, 1)),
+                                  _INT_to_FFELT(g, gel(x_GEN, 2)))
+                     self.construct(elt)
+-                    return
++                    return 0
+             sig_off()
+             raise TypeError(f"unable to convert PARI {x.type()} to finite field element")
+ 
+@@ -460,7 +461,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             sig_on()
+             if n == 0:
+                 self.construct(FF_zero(g))
+-                return
++                return 0
+             if t == t_FF_FpXQ:
+                 f = cgetg(n + 2, t_POL)
+                 set_gel(f, 1, gmael(g, 2, 1))
+@@ -515,7 +516,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         else:
+             raise TypeError("no coercion defined")
+ 
+-    def _repr_(FiniteFieldElement_pari_ffelt self):
++    def _repr_(self):
+         """
+         Return the string representation of ``self``.
+ 
+@@ -525,10 +526,9 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             sage: c^20  # indirect doctest
+             c^4 + 2*c^3
+         """
+-        sig_on()
+-        return str(new_gen(self.val))
++        return str(new_gen_noclear(self.val))
+ 
+-    def __hash__(FiniteFieldElement_pari_ffelt self):
++    def __hash__(self):
+         """
+         Return the hash of ``self``.  This is by definition equal to
+         the hash of ``self.polynomial()``.
+@@ -542,7 +542,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         return hash(self.polynomial())
+ 
+-    def __reduce__(FiniteFieldElement_pari_ffelt self):
++    def __reduce__(self):
+         """
+         For pickling.
+ 
+@@ -554,7 +554,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         return unpickle_FiniteFieldElement_pari_ffelt, (self._parent, str(self))
+ 
+-    def __copy__(FiniteFieldElement_pari_ffelt self):
++    def __copy__(self):
+         """
+         Return a copy of ``self``.
+ 
+@@ -701,7 +701,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+                            (<FiniteFieldElement_pari_ffelt>right).val))
+         return x
+ 
+-    def is_zero(FiniteFieldElement_pari_ffelt self):
++    def is_zero(self):
+         """
+         Return ``True`` if ``self`` equals 0.
+ 
+@@ -715,7 +715,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         return bool(FF_equal0(self.val))
+ 
+-    def is_one(FiniteFieldElement_pari_ffelt self):
++    def is_one(self):
+         """
+         Return ``True`` if ``self`` equals 1.
+ 
+@@ -729,7 +729,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         return bool(FF_equal1(self.val))
+ 
+-    def is_unit(FiniteFieldElement_pari_ffelt self):
++    def is_unit(self):
+         """
+         Return ``True`` if ``self`` is non-zero.
+ 
+@@ -743,7 +743,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+ 
+     __nonzero__ = is_unit
+ 
+-    def __pos__(FiniteFieldElement_pari_ffelt self):
++    def __pos__(self):
+         """
+         Unitary positive operator...
+ 
+@@ -755,7 +755,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         return self
+ 
+-    def __neg__(FiniteFieldElement_pari_ffelt self):
++    def __neg__(self):
+         """
+         Negation.
+ 
+@@ -770,7 +770,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         x.construct(FF_neg_i((<FiniteFieldElement_pari_ffelt>self).val))
+         return x
+ 
+-    def __invert__(FiniteFieldElement_pari_ffelt self):
++    def __invert__(self):
+         """
+         Return the multiplicative inverse of ``self``.
+ 
+@@ -791,7 +791,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         x.construct(FF_inv((<FiniteFieldElement_pari_ffelt>self).val))
+         return x
+ 
+-    def __pow__(FiniteFieldElement_pari_ffelt self, object exp, object other):
++    def __pow__(FiniteFieldElement_pari_ffelt self, exp, other):
+         """
+         Exponentiation.
+ 
+@@ -836,7 +836,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         x.construct(FF_pow(self.val, (<pari_gen>exp).g))
+         return x
+ 
+-    def polynomial(FiniteFieldElement_pari_ffelt self, name=None):
++    def polynomial(self, name=None):
+         """
+         Return the unique representative of ``self`` as a polynomial
+         over the prime field whose degree is less than the degree of
+@@ -889,7 +889,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         sig_on()
+         return self._parent.polynomial_ring(var)(new_gen(FF_minpoly(self.val)))
+ 
+-    def charpoly(FiniteFieldElement_pari_ffelt self, object var='x'):
++    def charpoly(self, var='x'):
+         """
+         Return the characteristic polynomial of ``self``.
+ 
+@@ -907,7 +907,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         sig_on()
+         return self._parent.polynomial_ring(var)(new_gen(FF_charpoly(self.val)))
+ 
+-    def is_square(FiniteFieldElement_pari_ffelt self):
++    def is_square(self):
+         """
+         Return ``True`` if and only if ``self`` is a square in the
+         finite field.
+@@ -938,7 +938,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         sig_off()
+         return bool(i)
+ 
+-    def sqrt(FiniteFieldElement_pari_ffelt self, extend=False, all=False):
++    def sqrt(self, extend=False, all=False):
+         """
+         Return a square root of ``self``, if it exists.
+ 
+@@ -1015,7 +1015,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             else:
+                 raise ValueError("element is not a square")
+ 
+-    def log(FiniteFieldElement_pari_ffelt self, object base):
++    def log(self, base):
+         """
+         Return a discrete logarithm of ``self`` with respect to the
+         given base.
+@@ -1087,7 +1087,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         x = FF_log(self.val, (<FiniteFieldElement_pari_ffelt>base).val, base_order)
+         return Integer(new_gen(x))
+ 
+-    def multiplicative_order(FiniteFieldElement_pari_ffelt self):
++    def multiplicative_order(self):
+         """
+         Returns the order of ``self`` in the multiplicative group.
+ 
+@@ -1106,7 +1106,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         order = FF_order(self.val, NULL)
+         return Integer(new_gen(order))
+ 
+-    def lift(FiniteFieldElement_pari_ffelt self):
++    def lift(self):
+         """
+         If ``self`` is an element of the prime field, return a lift of
+         this element to an integer.
+@@ -1192,10 +1192,6 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+         """
+         Return a PARI object representing ``self``.
+ 
+-        INPUT:
+-
+-        - var -- ignored
+-
+         EXAMPLES::
+ 
+             sage: k.<a> = FiniteField(3^3, impl='pari_ffelt')
+@@ -1203,8 +1199,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             sage: b.__pari__()
+             a^2 + 2*a + 1
+         """
+-        sig_on()
+-        return new_gen(self.val)
++        return new_gen_noclear(self.val)
+ 
+     def _pari_init_(self):
+         """
+diff --git a/src/sage/rings/finite_rings/element_pari_ffelt.pyx b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+index ff73a1f..fba303a 100644
+--- a/src/sage/rings/finite_rings/element_pari_ffelt.pyx
++++ b/src/sage/rings/finite_rings/element_pari_ffelt.pyx
+@@ -869,7 +869,7 @@ cdef class FiniteFieldElement_pari_ffelt(FinitePolyExtElement):
+             Univariate Polynomial Ring in beta over Finite Field of size 3
+         """
+         sig_on()
+-        return self._parent.polynomial_ring(name)(new_gen(FF_to_FpXQ_i(self.val)))
++        return self._parent.polynomial_ring(name)(new_gen(FF_to_FpXQ(self.val)))
+ 
+     def minpoly(self, var='x'):
+         """
+diff --git a/src/sage/rings/number_field/maps.py b/src/sage/rings/number_field/maps.py
+index 1727c13..5717227 100644
+--- a/src/sage/rings/number_field/maps.py
++++ b/src/sage/rings/number_field/maps.py
+@@ -358,7 +358,7 @@ class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism):
+             g = g(beta).lift()
+         # Convert the coefficients to elements of the base field.
+         B, from_B, _ = K.absolute_base_field()
+-        return self.codomain()([from_B(B(z.lift(), check=False)) for z in g.Vecrev(-K.relative_degree())])
++        return self.codomain()([from_B(B(z.lift(), check=False)) for z in g.Vecrev(K.relative_degree())])
+ 
+ 
+ class NameChangeMap(NumberFieldIsomorphism):
+diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
+index 2b5504a..8bd32dd 100644
+--- a/src/sage/rings/polynomial/polynomial_element.pyx
++++ b/src/sage/rings/polynomial/polynomial_element.pyx
+@@ -4364,8 +4364,7 @@ cdef class Polynomial(CommutativeAlgebraElement):
+             sage: G.prod() == g
+             True
+         """
+-        pols = G[0]
+-        exps = G[1]
++        pols, exps = G
+         R = self._parent
+         F = [(R(f), int(e)) for f, e in zip(pols, exps)]
+ 
+diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx
+index e37e0a3..2e03ade 100644
+--- a/src/sage/rings/power_series_pari.pyx
++++ b/src/sage/rings/power_series_pari.pyx
+@@ -678,7 +678,8 @@ cdef class PowerSeries_pari(PowerSeries):
+             g = g.truncate()
+         if typ(g.g) == t_POL and varn(g.g) == vn:
+             # t_POL has 2 codewords.  Use new_ref instead of g[i] for speed.
+-            return [R(g.new_ref(gel(g.g, i))) for i in range(2, lg(g.g))]
++            G = g.fixGEN()
++            return [R(g.new_ref(gel(G, i))) for i in range(2, lg(G))]
+         else:
+             return [R(g)]
+ 
+@@ -729,6 +730,7 @@ cdef class PowerSeries_pari(PowerSeries):
+             return []
+ 
+         cdef pari_gen g = self.g
++        g.fixGEN()
+         cdef long l, m
+ 
+         R = self.base_ring()



More information about the arch-commits mailing list