Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to pari 2.17, cypari 2.2.1 #38749

Open
wants to merge 29 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f59ea66
Fix build with pari 2.17
antonio-rojas Oct 1, 2024
dee7334
Adapt new_gen_from_real_mpfr_element to pari 2.17 changes in precision
antonio-rojas Oct 2, 2024
34af90b
Update tests output for pari 2.17
antonio-rojas Oct 5, 2024
48f18f1
Account for random output in some tests
antonio-rojas Oct 6, 2024
ff1b011
Rename prec_words_to_bits to prec_pari_to_bits
antonio-rojas Oct 6, 2024
14dd562
Account for more pari 2.17 random output in some tests
antonio-rojas Oct 27, 2024
23ff7d6
Replace prec_pari_to_bits usage
antonio-rojas Oct 30, 2024
fbb32fd
Replace prec_pari_to_bits usage
antonio-rojas Oct 30, 2024
91db307
Merge remote-tracking branch 'upstream/develop' into pari-2.17
antonio-rojas Nov 16, 2024
51c045c
Fix doctests for pari 2.17 on 32-bit
tornaria Nov 6, 2024
a4d1efb
make reduced_basis() deterministic for pari 2.17
tornaria Nov 7, 2024
bcb9c3d
make pari_bnf() deterministic for pari 2.17
tornaria Nov 7, 2024
a5c65e1
Fix doctests for 'make pari_bnf() deterministic'
tornaria Nov 7, 2024
bb38ebf
Fix build with pari 2.17
antonio-rojas Oct 1, 2024
a723576
Adapt new_gen_from_real_mpfr_element to pari 2.17 changes in precision
antonio-rojas Oct 2, 2024
457daa5
Update tests output for pari 2.17
antonio-rojas Oct 5, 2024
6a374d3
Account for random output in some tests
antonio-rojas Oct 6, 2024
29d8cc2
Account for more pari 2.17 random output in some tests
antonio-rojas Oct 27, 2024
0861e82
Merge remote-tracking branch 'tornaria/pari-2.17' into pari-2.17
antonio-rojas Dec 24, 2024
2767669
Test output is no longer random
antonio-rojas Dec 24, 2024
e033512
Fix merge
antonio-rojas Dec 24, 2024
75f614f
fix test by sorting (fails on aarch64)
tornaria Dec 27, 2024
26f411e
fix two 32-bit tests
tornaria Dec 26, 2024
36cf809
Merge remote-tracking branch 'upstream/develop' into pari-2.17
antonio-rojas Jan 4, 2025
f5af542
Fix rebase
antonio-rojas Jan 4, 2025
ce1531d
Fix merge
antonio-rojas Jan 5, 2025
427c2ea
Update pari to 2.17.1
antonio-rojas Jan 7, 2025
252efcc
Update cypari to 2.2.1
antonio-rojas Jan 7, 2025
1570ab0
Restore SAGE_PARI_MAXVER
antonio-rojas Jan 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build/pkgs/cypari/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=cypari2-VERSION.tar.gz
sha1=4e9f14d218bc1cea29e03a2ceec9bf3dfbfd5eb3
sha256=817606bf661b71d33e1d012421907a4f8fb09dd81b7d3e3ae179b3978020bbf1
sha1=556d1a16818663ba6e6a3c9d2b14cc907a7eef4c
sha256=aaa017a6a280581902f73cf5ce1695712b6598a032be14cfab81f97c475f83b8
upstream_url=https://files.pythonhosted.org/packages/source/c/cypari2/cypari2-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/cypari/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.2.0
2.2.1
6 changes: 3 additions & 3 deletions build/pkgs/pari/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=pari-VERSION.tar.gz
sha1=377593dfe72df13578ea0a517fcb0f81cc9758d4
sha256=0efdda7515d9d954f63324c34b34c560e60f73a81c3924a71260a2cc91d5f981
upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/OLD/${VERSION_MAJOR}.${VERSION_MINOR}/pari-VERSION.tar.gz
sha1=f5f5656a68947ef6a4841d40dd09a72fe96762a5
sha256=67ba6f3071233725258541e4f174b5efbc64c65ae5115bade9edfc45f1fde5dc
upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/pari/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.15.5
2.17.1
5 changes: 2 additions & 3 deletions build/pkgs/pari/spkg-configure.m4
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
SAGE_SPKG_CONFIGURE([pari], [
dnl See gp_version below on how the version is computed from MAJV.MINV.PATCHV
m4_pushdef([SAGE_PARI_MINVER],["134916"])dnl this version and higher allowed
dnl Do not allow Pari 2.17 or later, see #38769:
m4_pushdef([SAGE_PARI_MAXVER],["135424"])dnl this version and higher not allowed
m4_pushdef([SAGE_PARI_MINVER],["135245"])dnl this version and higher allowed
m4_pushdef([SAGE_PARI_MAXVER],["999999"])dnl this version and higher not allowed
SAGE_SPKG_DEPCHECK([gmp readline], [
AC_PATH_PROG([GP], [gp])
if test x$GP = x; then dnl GP test
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build-backend = 'mesonpy'
# Minimum requirements for the build system to execute.
requires = [
'meson-python',
'cypari2 >=2.1.1',
'cypari2 >=2.2.1',
# cysignals 1.11.2 is the newest version that is available on conda:
# https://github.com/conda-forge/cysignals-feedstock/pull/49
'cysignals >=1.11.2',
Expand All @@ -20,7 +20,7 @@ description = "Sage: Open Source Mathematics Software: Standard Python Library"
dependencies = [
'six >=1.15.0',
'conway-polynomials >=0.8',
'cypari2 >=2.1.1',
'cypari2 >=2.2.1',
'cysignals >=1.10.2',
'cython >=3.0, != 3.0.3',
'gmpy2 ~=2.1.b999',
Expand Down
2 changes: 1 addition & 1 deletion src/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ requires = [
'setuptools >= 68.1.1',
# version constraint for macOS Big Sur support (see https://github.com/sagemath/sage/issues/31050)
'wheel >=0.36.2',
'cypari2 >=2.1.1',
'cypari2 >=2.2.1',
'cysignals >=1.10.2',
# Exclude 3.0.3 because of https://github.com/cython/cython/issues/5748
'cython >=3.0, != 3.0.3, <4.0',
Expand Down
11 changes: 6 additions & 5 deletions src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2691,9 +2691,10 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):

Any object which has a factor method can be factored like this::

sage: K.<i> = QuadraticField(-1) # needs sage.rings.number_field
sage: factor(122 - 454*i) # needs sage.rings.number_field
(-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
sage: # needs sage.rings.number_field
sage: K.<i> = QuadraticField(-1)
sage: f = factor(122 - 454*i); f
(-1) * (i - 1)^3 * (2*i - 1)^3 * (3*i + 2) * (i + 4)

To access the data in a factorization::

Expand Down Expand Up @@ -2776,7 +2777,7 @@ def radical(n, *args, **kwds):
ArithmeticError: radical of 0 is not defined
sage: K.<i> = QuadraticField(-1) # needs sage.rings.number_field
sage: radical(K(2)) # needs sage.rings.number_field
i + 1
i - 1

Tests with numpy and gmpy2 numbers::

Expand Down Expand Up @@ -3031,7 +3032,7 @@ def is_squarefree(n):
sage: is_squarefree(O(2))
False
sage: O(2).factor()
(-I) * (I + 1)^2
(I) * (I - 1)^2

This method fails on domains which are not Unique Factorization Domains::

Expand Down
3 changes: 1 addition & 2 deletions src/sage/calculus/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,7 @@ def nintegral(ex, x, a, b,
to high precision::

sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))')
'2.565728500561051474934096410 E-127' # 32-bit
'2.5657285005610514829176211363206621657 E-127' # 64-bit
'2.5657285005610514829176211363206621657 E-127'
sage: old_prec = gp.set_real_precision(50)
sage: gp.eval('intnum(x=17,42,exp(-x^2)*log(x))')
'2.5657285005610514829173563961304957417746108003917 E-127'
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/quotient_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def gcd(self, other):
sage: R = ZZ.extension(x^2 + 1, names='i')
sage: i = R.1
sage: gcd(5, 3 + 4*i)
-i - 2
2*i - 1
sage: P.<t> = R[]
sage: gcd(t, i)
Traceback (most recent call last):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/doctest/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,11 @@ def create_doctests(self, namespace):

sage: import sys
sage: bitness = '64' if sys.maxsize > (1 << 32) else '32'
sage: gp.get_precision() == 38 # needs sage.libs.pari
sage: sys.maxsize == 2^63 - 1
False # 32-bit
True # 64-bit
sage: ex = doctests[20].examples[11]
sage: ((bitness == '64' and ex.want == 'True \n') # needs sage.libs.pari
sage: ((bitness == '64' and ex.want == 'True \n')
....: or (bitness == '32' and ex.want == 'False \n'))
True

Expand Down
4 changes: 2 additions & 2 deletions src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,10 @@ def conjugate(self, M, adjugate=False, new_ideal=None):

sage: # needs sage.rings.number_field
sage: ideal = A.ideal(5).factor()[1][0]; ideal
Fractional ideal (2*a + 1)
Fractional ideal (-2*a - 1)
sage: g = f.conjugate(conj, new_ideal=ideal)
sage: g.domain().ideal()
Fractional ideal (2*a + 1)
Fractional ideal (-2*a - 1)
"""
if self.domain().is_padic_base():
return DynamicalSystem_Berkovich(self._system.conjugate(M, adjugate=adjugate))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/dynamics/arithmetic_dynamics/projective_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1791,7 +1791,7 @@
sage: P.<x,y> = ProjectiveSpace(K,1)
sage: f = DynamicalSystem_projective([1/3*x^2+1/a*y^2, y^2])
sage: f.primes_of_bad_reduction() # needs sage.rings.function_field
[Fractional ideal (a), Fractional ideal (3)]
[Fractional ideal (-a), Fractional ideal (3)]

This is an example where ``check=False`` returns extra primes::

Expand Down Expand Up @@ -6974,7 +6974,7 @@
sage: P.<x,y>=ProjectiveSpace(QQbar, 1)
sage: E=EllipticCurve([1, 2])
sage: f=P.Lattes_map(E, 2)
sage: f.Lattes_to_curve(check_lattes=true)

Check warning on line 6977 in src/sage/dynamics/arithmetic_dynamics/projective_ds.py

View workflow job for this annotation

GitHub Actions / test-new

Warning: slow doctest:

slow doctest:
Elliptic Curve defined by y^2 = x^3 + x + 2 over Rational Field

"""
Expand Down
42 changes: 14 additions & 28 deletions src/sage/interfaces/gp.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@
::

sage: gp("a = intnum(x=0,6,sin(x))")
0.03982971334963397945434770208 # 32-bit
0.039829713349633979454347702077075594548 # 64-bit
0.039829713349633979454347702077075594548
sage: gp("a")
0.03982971334963397945434770208 # 32-bit
0.039829713349633979454347702077075594548 # 64-bit
0.039829713349633979454347702077075594548
sage: gp.kill("a")
sage: gp("a")
a
Expand Down Expand Up @@ -375,8 +373,7 @@ def get_precision(self):
EXAMPLES::

sage: gp.get_precision()
28 # 32-bit
38 # 64-bit
38
"""
return self.get_default('realprecision')

Expand All @@ -396,15 +393,13 @@ def set_precision(self, prec):
EXAMPLES::

sage: old_prec = gp.set_precision(53); old_prec
28 # 32-bit
38 # 64-bit
38
sage: gp.get_precision()
57
sage: gp.set_precision(old_prec)
57
sage: gp.get_precision()
28 # 32-bit
38 # 64-bit
38
"""
return self.set_default('realprecision', prec)

Expand Down Expand Up @@ -520,8 +515,7 @@ def set_default(self, var, value):
sage: gp.set_default('realprecision', old_prec)
115
sage: gp.get_default('realprecision')
28 # 32-bit
38 # 64-bit
38
"""
old = self.get_default(var)
self._eval_line('default(%s,%s)' % (var, value))
Expand All @@ -547,8 +541,7 @@ def get_default(self, var):
sage: gp.get_default('seriesprecision')
16
sage: gp.get_default('realprecision')
28 # 32-bit
38 # 64-bit
38
"""
return eval(self._eval_line('default(%s)' % var))

Expand Down Expand Up @@ -773,8 +766,7 @@ def _exponent_symbol(self):
::

sage: repr(gp(10.^80)).replace(gp._exponent_symbol(), 'e')
'1.0000000000000000000000000000000000000e80' # 64-bit
'1.000000000000000000000000000e80' # 32-bit
'1.0000000000000000000000000000000000000e80'
"""
return ' E'

Expand All @@ -800,27 +792,23 @@ def new_with_bits_prec(self, s, precision=0):

sage: # needs sage.symbolic
sage: pi_def = gp(pi); pi_def
3.141592653589793238462643383 # 32-bit
3.1415926535897932384626433832795028842 # 64-bit
3.1415926535897932384626433832795028842
sage: pi_def.precision()
28 # 32-bit
38 # 64-bit
38
sage: pi_150 = gp.new_with_bits_prec(pi, 150)
sage: new_prec = pi_150.precision(); new_prec
48 # 32-bit
57 # 64-bit
sage: old_prec = gp.set_precision(new_prec); old_prec
28 # 32-bit
38 # 64-bit
38
sage: pi_150
3.14159265358979323846264338327950288419716939938 # 32-bit
3.14159265358979323846264338327950288419716939937510582098 # 64-bit
sage: gp.set_precision(old_prec)
48 # 32-bit
57 # 64-bit
sage: gp.get_precision()
28 # 32-bit
38 # 64-bit
38
"""
if precision:
old_prec = self.get_real_precision()
Expand Down Expand Up @@ -856,11 +844,9 @@ class GpElement(ExpectElement, sage.interfaces.abc.GpElement):
sage: loads(dumps(x)) == x
False
sage: x
1.047197551196597746154214461 # 32-bit
1.0471975511965977461542144610931676281 # 64-bit
1.0471975511965977461542144610931676281
sage: loads(dumps(x))
1.047197551196597746154214461 # 32-bit
1.0471975511965977461542144610931676281 # 64-bit
1.0471975511965977461542144610931676281

The two elliptic curves look the same, but internally the floating
point numbers are slightly different.
Expand Down
3 changes: 1 addition & 2 deletions src/sage/interfaces/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,7 @@ def _sage_repr(self):
::

sage: gp(10.^80)._sage_repr()
'1.0000000000000000000000000000000000000e80' # 64-bit
'1.000000000000000000000000000e80' # 32-bit
'1.0000000000000000000000000000000000000e80'
sage: mathematica('10.^80')._sage_repr() # optional - mathematica
'1.e80'

Expand Down
3 changes: 1 addition & 2 deletions src/sage/interfaces/mathematica.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@
Note that this agrees with what the PARI interpreter gp produces::

sage: gp('solve(x=1,2,exp(x)-3*x)')
1.512134551657842473896739678 # 32-bit
1.5121345516578424738967396780720387046 # 64-bit
1.5121345516578424738967396780720387046

Next we find the minimum of a polynomial using the two different
ways of accessing Mathematica::
Expand Down
3 changes: 1 addition & 2 deletions src/sage/interfaces/mathics.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@
Note that this agrees with what the PARI interpreter gp produces::

sage: gp('solve(x=1,2,exp(x)-3*x)')
1.512134551657842473896739678 # 32-bit
1.5121345516578424738967396780720387046 # 64-bit
1.5121345516578424738967396780720387046

Next we find the minimum of a polynomial using the two different
ways of accessing Mathics::
Expand Down
3 changes: 1 addition & 2 deletions src/sage/interfaces/maxima_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
EXAMPLES::

# The output is kind of random
sage: sorted(maxima._commands(verbose=False))

Check warning on line 307 in src/sage/interfaces/maxima_abstract.py

View workflow job for this annotation

GitHub Actions / test-new

Warning: slow doctest:

slow doctest:
[...
'display',
...
Expand Down Expand Up @@ -1489,8 +1489,7 @@
high precision very quickly::

sage: gp('intnum(x=0,1,exp(-sqrt(x)))')
0.5284822353142307136179049194 # 32-bit
0.52848223531423071361790491935415653022 # 64-bit
0.52848223531423071361790491935415653022
sage: _ = gp.set_precision(80)
sage: gp('intnum(x=0,1,exp(-sqrt(x)))')
0.52848223531423071361790491935415653021675547587292866196865279321015401702040079
Expand Down
5 changes: 2 additions & 3 deletions src/sage/libs/pari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,11 @@
sage: e = pari([0,0,0,-82,0]).ellinit()
sage: eta1 = e.elleta(precision=50)[0]
sage: eta1.sage()
3.6054636014326520859158205642077267748 # 64-bit
3.605463601432652085915820564 # 32-bit
3.6054636014326520859158205642077267748
sage: eta1 = e.elleta(precision=150)[0]
sage: eta1.sage()
3.605463601432652085915820564207726774810268996598024745444380641429820491740 # 64-bit
3.60546360143265208591582056420772677481026899659802474544 # 32-bit
3.605463601432652085915820564207726774810268996598024745444380641430 # 32-bit
"""


Expand Down
15 changes: 7 additions & 8 deletions src/sage/libs/pari/convert_sage.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,16 @@ cpdef list pari_prime_range(long c_start, long c_stop, bint py_ints=False):
sage: pari_prime_range(2, 19)
[2, 3, 5, 7, 11, 13, 17]
"""
cdef long p = 0
cdef byteptr pari_prime_ptr = diffptr
cdef ulong i = 1
res = []
while p < c_start:
NEXT_PRIME_VIADIFF(p, pari_prime_ptr)
while p < c_stop:
while pari_PRIMES[i] < c_start:
i+=1
while pari_PRIMES[i] < c_stop:
if py_ints:
res.append(p)
res.append(pari_PRIMES[i])
else:
z = <Integer>PY_NEW(Integer)
mpz_set_ui(z.value, p)
mpz_set_ui(z.value, pari_PRIMES[i])
res.append(z)
NEXT_PRIME_VIADIFF(p, pari_prime_ptr)
i+=1
return res
4 changes: 2 additions & 2 deletions src/sage/libs/pari/convert_sage_real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ cpdef Gen new_gen_from_real_mpfr_element(RealNumber self):

# We round up the precision to the nearest multiple of wordsize.
cdef int rounded_prec
rounded_prec = (self.prec() + wordsize - 1) & ~(wordsize - 1)
rounded_prec = nbits2prec(self.prec())

# Yes, assigning to self works fine, even in Cython.
if rounded_prec > prec:
Expand All @@ -48,7 +48,7 @@ cpdef Gen new_gen_from_real_mpfr_element(RealNumber self):
exponent = mpfr_get_z_exp(mantissa, self.value)

# Create a PARI REAL
pari_float = cgetr(2 + rounded_prec / wordsize)
pari_float = cgetr(rounded_prec)
pari_float[1] = evalexpo(exponent + rounded_prec - 1) + evalsigne(mpfr_sgn(self.value))
mpz_export(&pari_float[2], NULL, 1, wordsize // 8, 0, 0, mantissa)
mpz_clear(mantissa)
Expand Down
Loading
Loading