sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.46k stars 485 forks source link

Upgrade: pari 2.13 #30801

Closed slel closed 3 years ago

slel commented 4 years ago

This is to upgrade to PARI 2.13.x. https://repology.org/project/pari/versions

This new PARI release brings a lot of bug fixes, new functionality, and speedups.

Changes in the PARI library that needs adaptation in SageMath code

 34- bnfissunit is obsolete, use bnfisunit
 35- bnfsunit is mostly obsolete, use bnfunits
 36- bnfisunit and bnfissunit: torsion unit exponent is now a t_INT (used
     to be a t_INTMOD)
 1- Removed member functions .futu and .tufu [deprecated since 2.2], used in simon two descent scripts.
 56- zetamultall: add flag

Last upgrade:

Follow-up ticket: #31754

Upstream: Fixed upstream, but not in a stable release.

CC: @dimpase @orlitzky @mkoeppe @slel @antonio-rojas @kiwifb @videlec @tobihan @collares @isuruf @dkwo @xcaruso @loefflerd @kliem

Component: packages: standard

Keywords: upgrade, pari

Author: Vincent Delecroix, Antonio Rojas, Gonzalo Tornaría

Branch: c78b147

Reviewer: Dima Pasechnik, David Loeffler

Issue created by migration from https://trac.sagemath.org/ticket/30801

antonio-rojas commented 4 years ago
comment:2

This needs first a new cypari release including https://github.com/sagemath/cypari2/commit/1a4be24489c2e457727d76bf6dd71daa5c45aee4, otherwise it crashes immediately. After that, things don't look good:

sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/quadratic_forms/genera/genus.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/libs/pari/tests.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/libs/pari/__init__.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/structure/factorization.py  # 4 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/lfunctions/pari.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/matrix/matrix2.pyx  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/coding/linear_code.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/arith/misc.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/groups/fqf_orthogonal.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/groups/abelian_gps/abelian_group.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/groups/additive_abelian/additive_abelian_group.py  # 10 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modules/torsion_quadratic_module.py  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modules/fg_pid/fgp_module.py  # 30 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modules/fg_pid/fgp_morphism.py  # 5 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modules/fg_pid/fgp_element.py  # 8 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/tests/parigp.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/tests/books/judson-abstract-algebra/galois-sage.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/tests/books/computational-mathematics-with-sagemath/linalg_doctest.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/integer.pyx  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/complex_number.pyx  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/qqbar.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/polynomial/polynomial_element.pyx  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/polynomial/multi_polynomial_element.py  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/polynomial/multi_polynomial_ideal.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/polynomial/plural.pyx  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/polynomial/polynomial_quotient_ring.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/function_field/function_field.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/finite_rings/residue_field.pyx  # 7 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/finite_rings/finite_field_constructor.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/finite_rings/integer_mod_ring.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/maps.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/number_field_rel.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/unit_group.py  # 17 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/S_unit_solver.py  # 8 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/number_field_element.pyx  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/number_field_ideal_rel.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/splitting_field.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/order.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/number_field_ideal.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/number_field.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/rings/number_field/class_group.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/gal_reps.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_generic.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_finite_field.py  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/height.py  # 6 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_number_field.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_torsion.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/period_lattice.py  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/gp_simon.py  # 4 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_rational_field.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/kraus.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/ell_curve_isogeny.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/heegner.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/gal_reps_number_field.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/elliptic_curves/isogeny_small_degree.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/toric/homset.py  # 3 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/toric/points.py  # 9 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/toric/chow_group.py  # 4 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/schemes/plane_conics/con_rational_function_field.py  # Timed out
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/geometry/cone.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modular/multiple_zeta.py  # 403 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modular/local_comp/smoothchar.py  # 2 doctests failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modular/local_comp/liftings.py  # 1 doctest failed
sage -t --long --random-seed=0 /usr/lib/python3.8/site-packages/sage/modular/modsym/p1list_nf.py  # 1 doctest failed
antonio-rojas commented 4 years ago
comment:3

The timeouts are hangs when calling nffactor. A minimal test case:

sage: K=NumberField(x^12 + 5, 't')
sage: P.<x>=K[]
sage: f=x^2 - 1
sage: f.factor()

I've bisected it to upstream commit [1], but running the same code directly in gp works fine.

[1] https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=commitdiff;h=473226c477c674838de87f4aaa67939eaa2fb034

antonio-rojas commented 4 years ago
comment:5

So, the actual issue seems to be:

sage: pari("default")
...
  primelimit = 0

If I set primelimit to 0 in gp I can reproduce the hangs. Reported to cypari https://github.com/sagemath/cypari2/issues/96

thierry-FreeBSD commented 4 years ago
comment:6

Another issue is the return of:

$ echo "bnf = bnfinit(y^4-y-1); bnfisunit(bnf,-y^3+2*y^2-1)" | gp -qf

returns:

[0, 2, 0]~

but configure expects [[0, 2, Mod(0, 2)]]~ (from build/pkgs/pari/spkg-configure.m4)

dimpase commented 4 years ago
comment:7

ok, they changed the output format. This is certainly easy to take care of.

videlec commented 4 years ago

Description changed:

--- 
+++ 
@@ -5,6 +5,8 @@

 - [pari-2.13 release announcement](http://pari.math.u-bordeaux.fr/archives/pari-announce-20/msg00006.html)

+Needs an upgrade of cypari2: https://github.com/sagemath/cypari2/pull/99
+
 Last upgrade:

 - #29313 (Upgrade: pari 2.11.4), merged in Sage 9.2.beta7 (released 2020-08-03)
videlec commented 4 years ago

Description changed:

--- 
+++ 
@@ -7,6 +7,15 @@

 Needs an upgrade of cypari2: https://github.com/sagemath/cypari2/pull/99

+Changes in the PARI library that needs adaptation in [SageMath](../wiki/SageMath) code
+
+```
+ 34- bnfissunit is obsolete, use bnfisunit
+ 35- bnfsunit is mostly obsolete, use bnfunits
+ 36- bnfisunit and bnfissunit: torsion unit exponent is now a t_INT (used
+     to be a t_INTMOD)
+```
+
 Last upgrade:

 - #29313 (Upgrade: pari 2.11.4), merged in Sage 9.2.beta7 (released 2020-08-03)
videlec commented 4 years ago

Author: Vincent Delecroix

videlec commented 4 years ago

Commit: 390d870

videlec commented 4 years ago

New commits:

3df29d3upgrade to pari 2.13.0
e16c581upgrade cypari2 to 2.1.2b1
68214e4adapt libs/pari to 2.13.0
ec9fbb5doctests in libs/pari
3af9483fix some doctests and discard .pari_nf() in number_field.py
ace4395doctests in unit_group.py
5358fc2poldegree is now a GEN
390d870fix cygwin patch
videlec commented 4 years ago

Branch: u/vdelecroix/pari-2.13.0-cypari-2.1.2

videlec commented 4 years ago

Description changed:

--- 
+++ 
@@ -1,11 +1,11 @@
-This is to upgrade to PARI 2.13.0, the new stable version of PARI.
+This is to upgrade to PARI 2.13.0 and cypari to 2.1.2.

 This new PARI release brings a lot of bug fixes,
 new functionality, and speedups.

 - [pari-2.13 release announcement](http://pari.math.u-bordeaux.fr/archives/pari-announce-20/msg00006.html)

-Needs an upgrade of cypari2: https://github.com/sagemath/cypari2/pull/99
+cypari2 merge request in progress https://github.com/sagemath/cypari2/pull/99

 Changes in the PARI library that needs adaptation in [SageMath](../wiki/SageMath) code
antonio-rojas commented 4 years ago
comment:13

Many test failures are caused by pari having changed the normal Smith form algorithm, which now gives different transition matrices. Most of them are still correct, but it also has some unfortunate side effects:

sage: V=ZZ^2
sage: W=span([[1,0],[0,6]],ZZ)
sage: M=V/W
sage: a=M[1]; a
(1)
sage: a.lift()
(0, -1)
antonio-rojas commented 4 years ago

Description changed:

--- 
+++ 
@@ -14,6 +14,8 @@
  35- bnfsunit is mostly obsolete, use bnfunits
  36- bnfisunit and bnfissunit: torsion unit exponent is now a t_INT (used
      to be a t_INTMOD)
+ 1- Removed member functions .futu and .tufu [deprecated since 2.2], used in simon two descent scripts.
+ 56- zetamultall: add flag

Last upgrade:

videlec commented 4 years ago
comment:15

On Tuesday (November 3) from 14h to 17h (UTC+2) there is a virtual PARI/GP workshop. I intend to discuss with Bill the cypari2 release and the adaptation in SageMath. Anybody interested is more than welcome. Just send me a private e-mail so that I can forward the announcement.

antonio-rojas commented 4 years ago
comment:16

The update to cypari 2.1.2b causes some additional issues (not present in 2.1.1, both tested with pari 2.13)

File "/usr/lib/python3.8/site-packages/sage/rings/rational.pyx", line 1450, in sage.rings.rational.Rational.is_norm
Failed example:
    7.is_norm(K)
Expected:
    Traceback (most recent call last):
    ...
    NotImplementedError: is_norm is not implemented unconditionally for norms from non-Galois number fields
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/usr/lib/python3.8/site-packages/sage/doctest/forker.py", line 720, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/usr/lib/python3.8/site-packages/sage/doctest/forker.py", line 1145, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.rational.Rational.is_norm[13]>", line 1, in <module>
        Integer(7).is_norm(K)
      File "sage/rings/integer.pyx", line 5443, in sage.rings.integer.Integer.is_norm (build/cythonized/sage/rings/integer.c:34562)
        return QQ(self).is_norm(K, element=element, proof=proof)
      File "sage/rings/rational.pyx", line 1464, in sage.rings.rational.Rational.is_norm (build/cythonized/sage/rings/rational.c:13741)
        return self.is_norm(L, element=True, proof=proof)[0]
      File "sage/rings/rational.pyx", line 1484, in sage.rings.rational.Rational.is_norm (build/cythonized/sage/rings/rational.c:14464)
        M = L.galois_closure('a')
      File "/usr/lib/python3.8/site-packages/sage/rings/number_field/number_field.py", line 8606, in galois_closure
        L, self_into_L = self._galois_closure_and_embedding(names)
      File "/usr/lib/python3.8/site-packages/sage/rings/number_field/number_field.py", line 8541, in _galois_closure_and_embedding
        L, self_into_L = self.defining_polynomial().change_ring(self).splitting_field(names, map=True, degree_multiple=deg)
      File "sage/rings/polynomial/polynomial_element.pyx", line 4635, in sage.rings.polynomial.polynomial_element.Polynomial.splitting_field (build/cythonized/sage/rings/polynomial/polynomial_element.c:39244)
        return splitting_field(f, name, map, **kwds)
      File "/usr/lib/python3.8/site-packages/sage/rings/number_field/splitting_field.py", line 454, in splitting_field
        rel_degree_divisor = rel_degree_divisor.lcm(q.poldegree())
      File "sage/structure/element.pyx", line 3917, in sage.structure.element.PrincipalIdealDomainElement.lcm (build/cythonized/sage/structure/element.c:24871)
        return coercion_model.bin_op(self, right, lcm)
      File "sage/structure/coerce.pyx", line 1248, in sage.structure.coerce.CoercionModel.bin_op (build/cythonized/sage/structure/coerce.c:11304)
        raise bin_op_exception(op, x, y)
    TypeError: unsupported operand parent(s) for lcm: 'Integer Ring' and '<class 'cypari2.gen.Gen'>'
videlec commented 4 years ago
comment:17

This is the problematic line

      File "/usr/lib/python3.8/site-packages/sage/rings/number_field/splitting_field.py", line 454, in splitting_field
        rel_degree_divisor = rel_degree_divisor.lcm(q.poldegree())

poldgree used to return an Python integer. But now that it is auto-generated in cypari it returns a Gen which is not accepted by lcm

sage: 4.lcm(pari(5))
Traceback (most recent call last):
...
TypeError: unsupported operand parent(s) for lcm: 'Integer Ring' and '<class 'cypari2.gen.Gen'>'

Some of these poldegree are "corrected" in commit 5358fc2.

I see several solutions

videlec commented 4 years ago
comment:18

To my mind, fixing Sage gcd/lcm makes more sense.

videlec commented 4 years ago
comment:19

Related: the functions gcd/lcm are not commutative

sage: type(lcm(2, pari(3)))
<class 'sage.rings.integer.Integer'>
sage: type(lcm(pari(3), 2))
<class 'cypari2.gen.Gen'>
videlec commented 4 years ago
comment:20

See #30849

videlec commented 4 years ago

Dependencies: #30849

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

75c1516make gcd/lcm of Integer works with gmpy2/pari types
8c675b4upgrade to pari 2.13.0
2833d06upgrade cypari2 to 2.1.2b1
886e9d2adapt libs/pari to 2.13.0
d93c350doctests in libs/pari
b7fed64fix some doctests and discard .pari_nf() in number_field.py
b4afd2adoctests in unit_group.py
7679cfafix cygwin patch
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 390d870 to 7679cfa

videlec commented 4 years ago
comment:22

(Rebased on top of #30849 dropping modification to gcd/lcm when poldegree is involved)

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

e04727dfix argument order in rnfisnorm call
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 7679cfa to e04727d

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

92ad1bbfix call to zetamultall
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from e04727d to 92ad1bb

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 92ad1bb to 1ce6c22

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

1ce6c22fix invalid t_INT + t_INFINITY operation in multi_polynomial_ring.py
antonio-rojas commented 4 years ago
comment:26

For Simon's scripts, this works for me:

diff --git a/src/sage/ext_data/pari/simon/ell.gp b/src/sage/ext_data/pari/simon/ell.gp
index 74f0786646..21cff9cbb3 100644
--- a/src/sage/ext_data/pari/simon/ell.gp
+++ b/src/sage/ext_data/pari/simon/ell.gp
@@ -1038,7 +1038,7 @@ if( DEBUGLEVEL_ell >= 1, print(" trivial points on E(K) = ");
   KS2gen = KS2gen[1];
   for( i = 1, #KS2gen,
     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
+  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
 if( DEBUGLEVEL_ell >= 2,
   print("  #K(b,2)gen          = ",#KS2gen);
   print("  K(b,2)gen = ",KS2gen));
@@ -1072,7 +1072,7 @@ if( DEBUGLEVEL_ell >= 1,
   KS2gen = KS2gen[1];
   for( i = 1, #KS2gen,
     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
+  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
 if( DEBUGLEVEL_ell >= 2,
   print("  #K(a^2-4b,2)gen     = ",#KS2gen);
   print("  K(a^2-4b,2)gen     = ",KS2gen));
@@ -1244,11 +1244,11 @@ if( DEBUGLEVEL_ell >= 4, print("    bbbnf.clgp = ",bbbnf.clgp));
   SL1 = idealmul(bbbnf,SL0,rnfeltup(rrrnf,bleg));
   SL = idealfactor(bbbnf,SL1)[,1]~;
   sunL = bnfsunit(bbbnf,SL);
-  fondsunL = concat(bbbnf.futu,vector(#sunL[1],i,nfbasistoalg(bbbnf,sunL[1][i])));
+  fondsunL = concat(concat(bbbnf.fu, bbbnf.tu[2]),vector(#sunL[1],i,nfbasistoalg(bbbnf,sunL[1][i])));
   normfondsunL = vector(#fondsunL, i, norm(rnfeltabstorel(rrrnf,fondsunL[i])));
   SK = idealfactor(bnf,idealnorm(bbbnf,SL1))[,1]~;
   sunK = bnfsunit(bnf,SK);
-  fondsunK = concat(bnf.futu,vector(#sunK[1],i,nfbasistoalg(bnf,sunK[1][i])));
+  fondsunK = concat(concat(bnf.fu, bnf.tu[2]),vector(#sunK[1],i,nfbasistoalg(bnf,sunK[1][i])));
   vecbleg = bnfissunit(bnf,sunK,bleg);
   matnorm = matrix(#fondsunK,#normfondsunL,i,j,0);
   for( i = 1, #normfondsunL,
@@ -1345,7 +1345,7 @@ if( DEBUGLEVEL_ell >= 4, print("on factorise bb = ",bb));
       sun = bnfsunit(bnf,idealfactor(bnf,bb)[,1]~);
       fact = lift(bnfissunit(bnf,sun,bb));
 if( DEBUGLEVEL_ell >= 4, print("fact = ",fact));
-      suni = concat(bnf.futu,vector(#sun[1],i,nfbasistoalg(bnf,sun[1][i])));
+      suni = concat(concat(bnf.fu, bnf.tu[2]),vector(#sun[1],i,nfbasistoalg(bnf,sun[1][i])));
       for( i = 1, #suni,
         if( (f = fact[i]>>1), 
           test =0;
@@ -1554,7 +1554,7 @@ if( DEBUGLEVEL_ell >= 3, print("    KS2gen = ",KS2gen[1]));

   LS2gen = LS2gen[1];
   LS2 = vector(#LS2gen,i,lift(nfbasistoalg(Lrnf,LS2gen[i])));
-  LS2 = concat(lift(Lrnf.futu),LS2);
+  LS2 = concat(lift(concat(Lrnf.fu, Lrnf.tu[2])),LS2);

   LS2 = subst(LS2,'x,ttheta);
   LS2 = LS2*Mod(1,polrel);
@@ -1992,7 +1992,7 @@ if( DEBUGLEVEL_ell >= 2, print("  Algorithm of complete 2-descent"));
   KS2gen = KS2gen[1];
   for( i = 1, #KS2gen,
     KS2gen[i] = nfbasistoalg(bnf, KS2gen[i]));
-  KS2gen = concat(Mod(lift(bnf.tufu),bnf.pol),KS2gen);
+  KS2gen = concat(Mod(lift(concat(bnf.tu[2], bnf.fu)),bnf.pol),KS2gen);
 if( DEBUGLEVEL_ell >= 2,
   print("  #K(S,2)gen = ",#KS2gen);
   print("   K(S,2)gen = ",KS2gen)
diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
index aede9fc941..27cc124372 100644
--- a/src/sage/ext_data/pari/simon/ellQ.gp
+++ b/src/sage/ext_data/pari/simon/ellQ.gp
@@ -1162,7 +1162,7 @@ if( DEBUGLEVEL_ell >= 4, print("    kerval = ",kerval));
       LS2gen[j]^kerval[j,i]));

 \\ Add the units
-  LS2gen = concat(Mod(bnf[8][5],bnf.pol),LS2gen); \\ LS2gen = concat(bnf.fu,LS2gen);
+  LS2gen = concat(bnf.fu,LS2gen); \\ LS2gen = concat(bnf.fu,LS2gen);
 \\ Add also the torsion unit if its order is divisible by p.
   if( bnf[8][4][1]%p == 0, \\ if( bnf.tu[1]%p == 0,
     LS2gen = concat( [Mod(bnf[8][4][2],bnf.pol)], LS2gen)); \\ LS2gen = concat( [Mod(bnf.tu[2],bnf.pol)], LS2gen));
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

264775bFix Denis Simon GP script (following A. Rojas)
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 1ce6c22 to 264775b

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

165c470fix units in number fields
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 264775b to 165c470

videlec commented 4 years ago
comment:29

I think all necessary adaptations in Sage code (not doctests) are done. The only remaining trouble is the following computation that now hangs

sage: p = next_prime(10^40); q = next_prime(10^41)
sage: K.<a> = NumberField(x^2 - p*q, maximize_at_primes=[p])
sage: K.pari_nf()

(see doctest line 4134 in sage/rings/number_field/number_field.py)

NB: In unit_group.py I am using methods bnf_get_fu and bnf_get_tu from cypari2 that are not yet in 2.1.2b1.

antonio-rojas commented 4 years ago
comment:30

Replying to @videlec:

I think all necessary adaptations in Sage code (not doctests) are done. The only remaining trouble is the following computation that now hangs

It doesn't really hang, it's just factoring the discriminant. See https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2257

antonio-rojas commented 4 years ago
comment:31

Any reason you're including the deprecation warnings for Strchr and besseln instead of replacing the functions themselves (with strchr and bessely)? Do we want to keep compatibility with older pari?

videlec commented 4 years ago
comment:32

No. Let me change that.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from 165c470 to db1f7a4

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

8879b2cStrchr -> strchr and .besseln -> bessely
f63e719add primes to pari when maximize_at_primes is provided
7eac5c9use bnf_get_fu instead of bnfunit
db1f7a4be more precise in documentation
videlec commented 4 years ago
comment:34

Replying to @antonio-rojas:

Replying to @videlec:

I think all necessary adaptations in Sage code (not doctests) are done. The only remaining trouble is the following computation that now hangs

It doesn't really hang, it's just factoring the discriminant. See https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2257

In f63e719I I tweaked the pari_nf to add primes to pari in this situation so that discriminant factorizes. The doctests pass now.

antonio-rojas commented 4 years ago
comment:35

I'm also experiencing a hang in sage/tests/parigp.py, at

sage: pari('K = bnfinit(y^4-52*y^2+26,1); pol = rnfkummer(bnrinit(K,3,1),Mat(5)); L = rnfinit(K, pol); polredabs(polredbest(L.polabs))')  # long time

Running the same code in gp gives a stack overflow

? pol = rnfkummer(bnrinit(K,3,1),Mat(5))
  ***   at top-level: pol=rnfkummer(bnrinit(K,3,1),Mat(5))
  ***                     ^--------------------------------
  *** rnfkummer: the PARI stack overflows !
  current stack size: 8000000 (7.629 Mbytes)
  [hint] set 'parisizemax' to a nonzero value in your GPRC
videlec commented 4 years ago
comment:36

PARI doc says: rnfkummer is deprecated use bnrclassfield

videlec commented 4 years ago
comment:37

In GP, did you do add the relevant primes first?

? addprimes([31438243, 238576291, 18775387483, 24217212463267, 1427657500359111961, 135564809928627323997297867381959])
antonio-rojas commented 4 years ago
comment:38

Replying to @videlec:

In GP, did you do add the relevant primes first?

? addprimes([31438243, 238576291, 18775387483, 24217212463267, 1427657500359111961, 135564809928627323997297867381959])

yes

videlec commented 4 years ago

Description changed:

--- 
+++ 
@@ -5,7 +5,7 @@

 - [pari-2.13 release announcement](http://pari.math.u-bordeaux.fr/archives/pari-announce-20/msg00006.html)

-cypari2 merge request in progress https://github.com/sagemath/cypari2/pull/99
+- [cypari2 2.1.2](https://files.pythonhosted.org/packages/22/d9/4374baf5749257362f6d163096f9f5a3fa2a6f231edbe0d61c7bdf281d6e/cypari2-2.1.2.tar.gz)

 Changes in the PARI library that needs adaptation in [SageMath](../wiki/SageMath) code
videlec commented 4 years ago

Description changed:

--- 
+++ 
@@ -5,7 +5,7 @@

 - [pari-2.13 release announcement](http://pari.math.u-bordeaux.fr/archives/pari-announce-20/msg00006.html)

-- [cypari2 2.1.2](https://files.pythonhosted.org/packages/22/d9/4374baf5749257362f6d163096f9f5a3fa2a6f231edbe0d61c7bdf281d6e/cypari2-2.1.2.tar.gz)
+- [cypari2 2.1.2 on PyPI](https://files.pythonhosted.org/packages/22/d9/4374baf5749257362f6d163096f9f5a3fa2a6f231edbe0d61c7bdf281d6e/cypari2-2.1.2.tar.gz)

 Changes in the PARI library that needs adaptation in [SageMath](../wiki/SageMath) code
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Changed commit from db1f7a4 to 4e43afd

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 4 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

4e43afdupgrade cypari2 to 2.1.2b1