Ticket #9591: genus2reduction-spkg.2.patch

File genus2reduction-spkg.2.patch, 64.8 KB (added by jdemeyer, 21 months ago)

New complete patch including trac_9591-g2red_remove_dist.patch

  • SPKG.txt

    diff -r c5a5a38cc3c1 SPKG.txt
    a b  
    99 
    1010== Releases == 
    1111 
     12=== genus2reduction-0.3.p8 (Jeroen Demeyer, Mitesh Patel, September 4, 2010) === 
     13 * #9738: don't catch signals and exit cleanly upon EOF 
     14 * #9738: Remove obsolete dist/ directory.  See #5903. 
     15 
     16=== genus2reduction-0.3.p7 (Jeroen Demeyer, July 24, 2010) === 
     17 * upgrade to PARI 2.4.3 
     18 
    1219=== genus2reduction-0.3.p6 (Jaap Spies, Jan 25th, 2010) === 
    1320 * made SAGE64=yes also work with Open Solaris 64 bit 
    1421 
  • deleted file dist/debian/changelog

    diff -r c5a5a38cc3c1 dist/debian/changelog
    + -  
    1 genus2reduction (0.3-1) unstable; urgency=low 
    2  
    3   * Initial release (Closes: #480091). 
    4  
    5  -- Tim Abbott <tabbott@mit.edu>  Wed, 14 Nov 2007 20:23:34 -0500 
  • deleted file dist/debian/compat

    diff -r c5a5a38cc3c1 dist/debian/compat
    + -  
    1 5 
  • deleted file dist/debian/control

    diff -r c5a5a38cc3c1 dist/debian/control
    + -  
    1 Source: genus2reduction 
    2 Section: math 
    3 Priority: extra 
    4 Maintainer: Tim Abbott <tabbott@mit.edu> 
    5 Homepage: http://www.math.u-bordeaux.fr/~liu/G2R/ 
    6 Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 5), quilt, patchutils (>= 0.2.25), cdbs (>= 0.4.27-1), libpari-dev, libgmp3-dev 
    7 Standards-Version: 3.7.3 
    8  
    9 Package: genus2reduction 
    10 Architecture: any 
    11 Depends: ${shlibs:Depends}, ${misc:Depends} 
    12 Description: Conductor and Reduction Types for Genus 2 Curves 
    13  Let C be a proper smooth curve of genus 2 defined by a hyperelliptic 
    14  equation 
    15  . 
    16                          y^2+Q(x)y=P(x) 
    17  . 
    18  where P(x) and Q(x) are polynomials with rational coefficients such 
    19  that deg(Q(x))<4, deg(P(x))<7. 
    20  . 
    21  Let J(C) be the Jacobian of C, let X be the minimal regular model of 
    22  C over the ring of integers Z. 
    23  . 
    24  This program determines the reduction of C at any prime number p (that 
    25  is the special fiber X_p of X over p), and the exponent f of the conductor 
    26  of J(C) at p. 
    27  . 
    28  Unfortunately, this program is not yet complete for p=2. 
  • deleted file dist/debian/control.in

    diff -r c5a5a38cc3c1 dist/debian/control.in
    + -  
    1 Source: genus2reduction 
    2 Section: math 
    3 Priority: extra 
    4 Maintainer: Tim Abbott <tabbott@mit.edu> 
    5 Homepage: http://www.math.u-bordeaux.fr/~liu/G2R/ 
    6 Build-Depends: @cdbs@, libpari-dev, libgmp3-dev 
    7 Standards-Version: 3.7.3 
    8  
    9 Package: genus2reduction 
    10 Architecture: any 
    11 Depends: ${shlibs:Depends}, ${misc:Depends} 
    12 Description: Conductor and Reduction Types for Genus 2 Curves 
    13  Let C be a proper smooth curve of genus 2 defined by a hyperelliptic 
    14  equation 
    15  . 
    16                          y^2+Q(x)y=P(x) 
    17  . 
    18  where P(x) and Q(x) are polynomials with rational coefficients such 
    19  that deg(Q(x))<4, deg(P(x))<7. 
    20  . 
    21  Let J(C) be the Jacobian of C, let X be the minimal regular model of 
    22  C over the ring of integers Z. 
    23  . 
    24  This program determines the reduction of C at any prime number p (that 
    25  is the special fiber X_p of X over p), and the exponent f of the conductor 
    26  of J(C) at p. 
    27  . 
    28  Unfortunately, this program is not yet complete for p=2. 
  • deleted file dist/debian/copyright

    diff -r c5a5a38cc3c1 dist/debian/copyright
    + -  
    1 This package was debianized by Tim Abbott <tabbott@mit.edu> in 2008. 
    2  
    3 It was downloaded from http://sagemath.org 
    4  
    5 Upstream Author: Qing Liu <math.u-bordeaux1.fr> 
    6                  and Henri Cohen <cohen@math.u-bordeaux.fr> 
    7  
    8 It is currently maintained by William Stein <wstein@gmail.com> 
    9  
    10 Copyright: (C) 1998 Qing Liu and Henry Cohen 
    11            (C) 2006 William Stein 
    12  
    13 License: 
    14  
    15    This package is free software; you can redistribute it and/or modify 
    16    it under the terms of the GNU General Public License as published by 
    17    the Free Software Foundation; either version 2 of the License, or 
    18    (at your option) any later version. 
    19  
    20    This package is distributed in the hope that it will be useful, 
    21    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    22    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    23    GNU General Public License for more details. 
    24  
    25    You should have received a copy of the GNU General Public License 
    26    along with this package; if not, write to the Free Software 
    27    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA 
    28  
    29 On Debian systems, the complete text of the GNU General 
    30 Public License can be found in `/usr/share/common-licenses/GPL'. 
    31  
    32 The Debian packaging is (C) 2008, Tim Abbott <tabbott@mit.edu> and is 
    33 licensed under the GPL, see above. 
  • deleted file dist/debian/patches/makefile.patch

    diff -r c5a5a38cc3c1 dist/debian/patches/makefile.patch
    + -  
    1 Index: src/Makefile 
    2 =================================================================== 
    3 --- /dev/null   1970-01-01 00:00:00.000000000 +0000 
    4 +++ src/Makefile        2008-02-08 15:22:00.000000000 -0800 
    5 @@ -0,0 +1,14 @@ 
    6 +CFLAGS = -O2 -I/usr/include/pari 
    7 +LDFLAGS = -lpari 
    8 +CC = gcc 
    9 + 
    10 +genus2reduction: 
    11 +       ${CC} ${CFLAGS} ${LDFLAGS} -o genus2reduction genus2reduction.c 
    12 + 
    13 +install: genus2reduction 
    14 +       mkdir -p ${DESTDIR}/usr/lib 
    15 +       install -p $< ${DESTDIR}/usr/lib 
    16 + 
    17 +clean: 
    18 +       rm -f genus2reduction 
    19 + 
  • deleted file dist/debian/patches/series

    diff -r c5a5a38cc3c1 dist/debian/patches/series
    + -  
    1 makefile.patch 
  • deleted file dist/debian/rules

    diff -r c5a5a38cc3c1 dist/debian/rules
    + -  
    1 #!/usr/bin/make -f 
    2  
    3 include /usr/share/cdbs/1/rules/debhelper.mk 
    4 include /usr/share/cdbs/1/class/makefile.mk 
    5 include /usr/share/cdbs/1/rules/patchsys-quilt.mk 
    6  
    7 CFLAGS += -I/usr/include/pari 
    8 LDFLAGS += -lpari 
    9 DEB_MAKE_INSTALL_TARGET = install DESTDIR=$(DEB_DESTDIR) 
  • new file src/genus2reduction.c

    diff -r c5a5a38cc3c1 src/genus2reduction.c
    - +  
     1/* genus2reduction  
     2   by Qing Liu <liu@math.u-bordeaux.fr> 
     3   and Henri Cohen <cohen@math.u-bordeaux.fr> 
     4 
     5   An algorithm 'à la Tate' for curves of genus 2 
     6 
     7   Current maintainer: William Stein (wstein@ucsd.edu) 
     8   (as part of SAGE: Software for Algebra and Geometry Experimentation) 
     9*/ 
     10 
     11/* Qing Liu: Last modified october 5th 1998 */  
     12 
     13/*  
     14   William Stein: Modified 2006-03-05. 
     15 
     16*/ 
     17 
     18#include "pari.h" 
     19 
     20 
     21#ifdef LONG_IS_64BIT 
     22#  define VERYBIGINT (9223372036854775807L) /* 2^63-1 */ 
     23#  define EXP220 (1099511627776L)          /* 2^40   */ 
     24#  define BIGINT (2147483647)              /* 2^31-1 */ 
     25#else 
     26#  define VERYBIGINT (2147483647L) /* 2^31-1 */ 
     27#  define EXP220 (1048576L)       /* 2^20   */ 
     28#  define BIGINT (32767)          /* 2^15-1 */ 
     29#endif 
     30 
     31INLINE long 
     32min(long a, long b) 
     33{ 
     34        if (a < b) return a; 
     35        return b; 
     36} 
     37 
     38INLINE long 
     39max(long a, long b) 
     40{ 
     41        if (a > b) return a; 
     42        return b; 
     43} 
     44 
     45INLINE GEN 
     46mppgcd(GEN a, GEN b) 
     47{ 
     48  if (typ(a) != t_INT || typ(b) != t_INT) pari_err(arither1); 
     49  return gcdii(a,b); 
     50} 
     51 
     52GEN 
     53caltheta(GEN pol, GEN p, long lambda); 
     54 
     55GEN 
     56calthetazi(GEN polh); 
     57 
     58GEN calthetazi2(GEN polh); 
     59 
     60GEN  
     61factmz(GEN polhp, GEN p); 
     62 
     63GEN  
     64polymini(GEN pol, GEN p); 
     65 
     66GEN  
     67polyminizi(GEN pol); 
     68 
     69GEN  
     70polyminizi2(GEN pol); 
     71 
     72GEN 
     73zi2mod(GEN u); 
     74 
     75long polval(GEN pol, GEN p); 
     76 
     77GEN factorpadicnonun(GEN pol, GEN p, long r); 
     78 
     79long 
     80discpart(GEN polh, GEN p, long ord); 
     81 
     82INLINE long 
     83myval(GEN x, GEN p) 
     84{ 
     85  return gequal0(x)?EXP220:ggval(x,p); 
     86} 
     87 
     88long 
     89myvalzi(GEN b); 
     90 
     91long 
     92myvalzi2(GEN b); 
     93 
     94int 
     95main() 
     96{ 
     97  char buf[1000]; 
     98  GEN a0,a1,a2,a3,a4,a5,a6,jpol2,jpol4,jpol6,j2,j4,j6,j8,j10,i4,i12,j12,q,p,r,n,m; 
     99  GEN p1,s,pro1,pro2,dk,d1k,d2k,dm,rk,polh,polh1,theta,theta1,polf,list,c1,c2,c3,c4,c5,c6,prod,facti,facto,factp,e0,b,polhp,unmodp; 
     100  GEN apol2,apol3,apol4,apol5,bpol2,A2,A3,A4,A5,B2,e1,e2,e3,vl,vm,vn,polr,Ieps,sjinv,pjinv,cond,matmin; 
     101  long eps,eps2,i,val[8],deg[8],va0,va2,va3,va4,va5,vb2,vb5,vb6,v12,flc; 
     102  long tt,d,d1,d2,d3,f1,f2,g,h,v1,v2,j2m,r1,r2,r3,r4,dismin,alpha,lambda; 
     103  long indice,vc6,mm,nb,dism,maxc,condp,R,alpha1,comp,beta,dd,pr,ip,j,temp; 
     104   
     105  pari_init_opts(10000000, 500000, INIT_JMPm | INIT_DFTm); 
     106  jpol2=readseq("a0;a1;a2;a3;a4;a5;a6;2^-2*(-120*a0*a6+20*a1*a5-8*a2*a4+3*a3^2)"); 
     107  jpol4=readseq("a0;a1;a2;a3;a4;a5;a6;2^-7*(240*(a0*a3*a4*a5+a1*a2*a3*a6)-400*(a0*a2*a5^2+a1^2*a4*a6)-64*(a0*a4^3+a2^3*a6)+16*(a1*a3*a4^2+a2^2*a3*a5)-672*a0*a3^2*a6+240*a1^2*a5^2-112*a1*a2*a4*a5-8*a1*a3^2*a5+16*a2^2*a4^2-16*a2*a3^2*a4+3*a3^4+2640*a0^2*a6^2-880*a0*a1*a5*a6+1312*a0*a2*a4*a6)"); 
     108  jpol6=readseq("a0;a1;a2;a3;a4;a5;a6;2^-10*(1600*(a0^2*a4^2*a5^2+a1^2*a2^2*a6^2)+1600*(a0*a1*a2*a5^3+a1^3*a4*a5*a6)+640*(a0*a1*a3*a4*a5^2+a1^2*a2*a3*a5*a6)-4000*(a0^2*a3*a5^3+a1^3*a3*a6^2)-384*(a0*a1*a4^3*a5+a1*a2^3*a5*a6)-640*(a0*a2^2*a4*a5^2+a1^2*a2*a4^2*a6)+80*(a0*a2*a3^2*a5^2+a1^2*a3^2*a4*a6)+192*(a0*a2*a3*a4^2*a5+a1*a2^2*a3*a4*a6)-48*(a0*a3^3*a4*a5+a1*a2*a3^3*a6)-224*(a1^2*a3*a4^2*a5+a1*a2^2*a3*a5^2)+64*(a1^2*a4^4+a2^4*a5^2)-64*(a1*a2*a3*a4^3+a2^3*a3*a4*a5)+16*(a1*a3^3*a4^2+a2^2*a3^3*a5)-4096*(a0^2*a4^3*a6+a0*a2^3*a6^2)+6400*(a0^2*a2*a5^2*a6+a0*a1^2*a4*a6^2)+10560*(a0^2*a3*a4*a5*a6+a0*a1*a2*a3*a6^2)+2624*(a0*a1*a3*a4^2*a6+a0*a2^2*a3*a5*a6)-4432*a0*a1*a3^2*a5*a6-8*a2*a3^4*a4+a3^6-320*a1^3*a5^3+64*a1^2*a2*a4*a5^2+176*a1^2*a3^2*a5^2+128*a1*a2^2*a4^2*a5+112*a1*a2*a3^2*a4*a5-28*a1*a3^4*a5+16*a2^2*a3^2*a4^2+5120*a0^3*a6^3-2544*a0^2*a3^2*a6^2+312*a0*a3^4*a6-14336*a0^2*a2*a4*a6^2+1024*a0*a2^2*a4^2*a6-2560*a0^2*a1*a5*a6^2-2240*a0*a1^2*a5^2*a6-6528*a0*a1*a2*a4*a5*a6-1568*a0*a2*a3^2*a4*a6)"); 
     109 labinf: 
     110  printf("   \n");fflush(stdout); 
     111  printf("enter Q(x) : ");fflush(stdout);fflush(stdin); 
     112  if (scanf("%s",buf) < 0) exit(0);  /* Exit on end-of-file */ 
     113  q=readseq(buf); 
     114  printf("enter P(x) : ");fflush(stdout);fflush(stdin); 
     115  if (scanf("%s",buf) < 0) exit(0);  /* Exit on end-of-file */ 
     116  p=readseq(buf); 
     117  printf(" \n");fflush(stdout); 
     118  polr=gadd(gmul(q,q),gmul2n(p,2));  
     119  if(gequal0(polr)) exit(0); 
     120  if(lg(polr)>9||lg(polr)<8) 
     121    { 
     122      printf("It is not a curve of genus 2\n");fflush(stdout); 
     123      goto labinf; 
     124    } 
     125  a0=truecoeff(polr,6); 
     126  a1=truecoeff(polr,5); 
     127  j10=gequal0(a0)?gmul2n(gmul(gmul(a1,a1),discsr(polr)),-12):gmul2n(discsr(polr),-12); 
     128  if(gequal0(j10)) {printf("singular curve\n");fflush(stdout);exit(1);} 
     129  facto=factor(gabs(j10, 0)); 
     130  temp=timer();  
     131  printf("factorization CPU time = %ld\n",temp);fflush(stdout);   
     132  factp=(GEN)facto[1]; 
     133  pr=1; if(!cmpis((GEN)factp[1],2)) pr=2; 
     134  matmin=cgetg(6,19); 
     135  for(j=1;j<=5;j++) 
     136    matmin[j]=(long)cgetg(lg(factp)-pr+1,18); 
     137  for(i=pr;i<lg(factp);i++) 
     138    {  
     139      p=(GEN)factp[i]; 
     140      polf=polymini(polr,p); 
     141      coeff(matmin,i,1)=polf[1]; 
     142      coeff(matmin,i,2)=polf[2]; 
     143      coeff(matmin,i,3)=polf[3]; 
     144      coeff(matmin,i,4)=polf[4]; 
     145      coeff(matmin,i,5)=polf[5]; 
     146      polr=gmul((GEN)polf[1],gpow(p,(GEN)polf[4],0)); 
     147    } 
     148  a0=truecoeff(polr,6); 
     149  a1=truecoeff(polr,5); 
     150  j10=gequal0(a0)?gmul2n(gmul(gmul(a1,a1),discsr(polr)),-12):gmul2n(discsr(polr),-12); 
     151  for(i=1;i<lg(factp);i++) 
     152    { 
     153      gcoeff(facto,i,2)=stoi(myval(j10,(GEN)factp[i])); 
     154    } 
     155  dd=itos(gmul(gen_2,gdivent(stoi(polval(polr,gen_2)),gen_2))); 
     156  printf("a minimal equation over Z[1/2] is : \n"); 
     157  printf("y^2 = ");output(gdiv(polr,gpowgs(gen_2,dd))); 
     158  printf(" \n");fflush(stdout); 
     159   
     160  printf("factorization of the minimal (away from 2) discriminant : \n"); 
     161  output(facto);printf(" \n");fflush(stdout);     
     162   
     163  a2=truecoeff(polr,4);a3=truecoeff(polr,3); 
     164  a4=truecoeff(polr,2);a5=truecoeff(polr,1); 
     165  a6=truecoeff(polr,0); 
     166  j2=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(jpol2,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     167  j4=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(jpol4,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     168  i4=gsub(gsqr(j2),gmulsg(24,j4)); 
     169  j6=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(jpol6,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     170  j8=gmul2n(gsub(gmul(j2,j6),gmul(j4,j4)),-2); 
     171  i12=gmul2n(gsub(gadd(gsqr(gmul(j2,j4)),gmulsg(36,gmul(gmul(j2,j4),j6))),gadd(gadd(gmulsg(32,gmul(gsqr(j4),j4)),gmul(j6,gmul(gsqr(j2),j2))),gmulsg(108,gsqr(j6)))),-2); 
     172  for(i=1;i<=2;i++) deg[i]=2*i; 
     173  for(i=3;i<=7;i++) deg[i]=2*i-2; 
     174  cond=gen_1; 
     175  condp=0; 
     176  ip=0; 
     177  p=gen_1; 
     178   
     179 recp: 
     180  cond=gmul(cond,gpowgs(p,condp)); 
     181  gcoeff(facto,ip,2)=stoi(condp);  
     182  ip=ip+1; 
     183  if(ip>=lg(factp))  
     184    { 
     185      printf("  \n");fflush(stdout);       
     186      dd=ggval(cond,gen_2); 
     187      if(dd<4) 
     188        { 
     189          printf("the conductor is ");output(cond); 
     190          printf("in factorized form : ");output(facto);  
     191          temp+=timer(); 
     192          printf("total CPU time = %ld\n",temp);fflush(stdout);   
     193          goto labinf; 
     194        } 
     195      cond=gdiv(cond,gpowgs(gen_2,dd)); 
     196      printf("the prime to 2 part of the conductor is ");output(cond); 
     197      gcoeff(facto,1,2)=gen_0; 
     198      printf("in factorized form : "); 
     199      output(facto); 
     200      temp+=timer(); 
     201      printf("total CPU time = %ld\n",temp);fflush(stdout);  
     202      goto labinf; 
     203    } 
     204  p=(GEN)factp[ip];   
     205  printf("p=");output(p); 
     206  dismin=ggval(j10,p); 
     207  val[1]=myval(j2,p);val[2]=myval(j4,p);val[3]=myval(i4,p); 
     208  val[4]=myval(j6,p);val[5]=myval(j8,p);val[6]=dismin; 
     209  val[7]=myval(i12,p); 
     210  if(gcmp(p,stoi(5))>0) maxc=4; 
     211  else   
     212    { 
     213      if(!cmpis(p,5)) maxc=9; 
     214      else 
     215        { 
     216          if(!cmpis(p,3)) maxc=10; 
     217          else maxc=20; 
     218        } 
     219    } 
     220/* maxc=maximum du conducteur  */  
     221  unmodp=gmodulo(gen_1,p);         
     222  
     223  printf("(potential) stable reduction : "); 
     224  p1=cgetg(8,18); 
     225  for(i=1;i<=7;i++) p1[i]=(long)gdiv(stoi(val[i]),stoi(deg[i])); 
     226  s=(GEN)p1[1];for(i=2;i<=7;i++) if(gcmp((GEN)p1[i],s)<0) s=(GEN)p1[i]; 
     227  if(gequal(s,(GEN)p1[6])) {tt=1;printf(" (I)\n");goto aff;} 
     228  if(gequal(s,(GEN)p1[7]))  
     229    { 
     230      tt=2; 
     231      printf(" (II), j=");fflush(stdout); 
     232      output(lift(gmul(unmodp,gdiv(gpowgs(i4,3),i12)))); 
     233      goto aff; 
     234    } 
     235  if(gequal(s,(GEN)p1[3])) 
     236  { 
     237    if((val[2]==val[3])||(2*val[4]==3*val[3])) 
     238    {tt=3;printf(" (III)\n");goto aff;} 
     239    else {tt=4;printf(" (IV)\n");goto aff;} 
     240  } 
     241  eps=1;if(gequal(p,gen_2)) eps=4;if(gequal(p,stoi(3))) eps=3; 
     242  eps2=1;if(gequal(p,gen_2)) eps2=5;if(gequal(p,stoi(3))) eps2=4; 
     243  Ieps=gdivgs(j2,12);if(gequal(p,gen_2)) Ieps=j8;if(gequal(p,stoi(3))) Ieps=j6; 
     244  r1=3*eps*val[3]; 
     245  r3=eps*val[6]+val[eps2]; 
     246  r2=eps*val[7]; 
     247  r4=r1;if(r2<r4) r4=r2;if(r3<r4) r4=r3; 
     248  if(r3==r4)  
     249    { 
     250      tt=5; 
     251      sjinv=lift(gmul(unmodp,gadd(stoi(1728),gdiv(gpowgs(i12,eps),gmul(gpowgs(j10,eps),Ieps))))); 
     252      pjinv=lift(gmul(unmodp,gdiv(gpowgs(i4,3*eps),gmul(gpowgs(j10,eps),Ieps))));  
     253      printf(" (V), j1+j2=");fflush(stdout);brute(sjinv,'g',-1); 
     254      printf(", j1*j2=");fflush(stdout);output(pjinv); 
     255      goto aff; 
     256    } 
     257  if(r2==r4)  
     258    { 
     259      tt=6; 
     260      printf(" (VI), j=");fflush(stdout); 
     261      output(lift(gmul(unmodp,gdiv(gpowgs(i4,3),i12)))); 
     262      goto aff; 
     263    } 
     264  if(r1==r4) {tt=7;printf(" (VII)\n");goto aff;} 
     265 aff: 
     266  if(!dismin)  
     267    { 
     268      printf("good reduction at p : [I{0-0-0}] page 155, (1), f=0\n"); 
     269      condp=0;fflush(stdout);goto recp;     
     270    } 
     271  if(dismin==1)  
     272    { 
     273      condp=1; 
     274      printf("reduction at p : [I{1-0-0}] page 170, (1), f=1\n"); 
     275      fflush(stdout);goto recp;     
     276    } 
     277  if(dismin==2)  
     278    { 
     279      switch(tt) 
     280        { 
     281        case 2: 
     282          { 
     283            condp=1; 
     284            printf("reduction at p : [I{2-0-0}] page 170, (2), f=1\n"); 
     285            fflush(stdout);goto recp;  
     286          } 
     287        case 3: 
     288          { 
     289            condp=2; 
     290            printf("reduction at p : [I{1-1-0}] page 179, (1), f=2\n"); 
     291            fflush(stdout);goto recp;  
     292          } 
     293        case 5: 
     294          { 
     295            if(!cmpis(p,2)||!cmpis(p,3)) 
     296              {printf("bug sur tt 1\n");fflush(stdout);exit(1);}    
     297            condp=2; 
     298            printf("reduction at p : [I{0}-II-0] page 159, (1), f=2\n"); 
     299            fflush(stdout);goto recp;  
     300          } 
     301        default: {printf("bug sur tt 2\n");fflush(stdout);exit(1);}    
     302        } 
     303    } 
     304  if(!cmpis(p,2)) {condp=4;goto recp;} 
     305  printf("reduction at p : ");fflush(stdout);   
     306  polh=gcoeff(matmin,ip,1);   
     307  lambda=itos(gcoeff(matmin,ip,2)); 
     308  theta=gcoeff(matmin,ip,3); 
     309  alpha=itos(gcoeff(matmin,ip,4)); 
     310  if(!gequal0(gcoeff(matmin,ip,5))) goto quadratic;   
     311  if(gequal0(theta)&&lambda<=2)  
     312    { 
     313      if(tt>=5) {printf("bug sur tt 3\n");fflush(stdout);exit(1);} 
     314      goto modere;   
     315    } 
     316  if(dismin==3)  
     317    { 
     318      switch(tt) 
     319        { 
     320        case 2: goto modere; 
     321        case 3: condp=2;printf("[I{2-1-0}] page 179, (2), f=2\n");break; 
     322        case 4: condp=2;printf("[I{1-1-1}] page 182, (3), f=2\n");break; 
     323        case 5: 
     324          { 
     325            if(cmpis(p,3)||gequal(theta,ghalf)) 
     326              { 
     327                condp=2;printf("[I{0}-III-0] page 161, (2), f=2\n"); 
     328              } 
     329            else 
     330              { 
     331                goto labelm3; 
     332              } 
     333          } 
     334          break; 
     335        case 6: 
     336          { 
     337            if(!cmpis(p,3))  
     338              {printf("bug de conducteur\n");fflush(stdout);exit(1);} 
     339            condp=3; 
     340            printf("[I{1}-II-0] page 172, (1), f=3\n"); 
     341          } 
     342          break; 
     343        default: printf("bug switch sur tt 4\n");fflush(stdout);exit(1); 
     344        } 
     345      fflush(stdout);goto recp;  
     346    } 
     347  switch(lambda) 
     348    { 
     349    case 0:  
     350      { 
     351        switch(itos(gmul(theta, stoi(60)))+alpha) 
     352          { 
     353          case 10: condp=dismin-1;printf("[V] page 156, (3), f=%ld\n",condp); 
     354            fflush(stdout);break; 
     355          case 11: condp=dismin-11;printf("[V*] page 156, (3), f=%ld\n",condp); 
     356            fflush(stdout);break; 
     357          case 12: condp=dismin-2;printf("[IX-2] page 157, (5), f=%ld\n",condp); 
     358            fflush(stdout);break; 
     359          case 13: condp=dismin-12;printf("[VIII-4] page 157, (1), f=%ld\n",condp); 
     360            fflush(stdout);break; 
     361          case 24: condp=dismin-8;printf("[IX-4] page 158, (5), f=%ld\n",condp); 
     362            fflush(stdout);break; 
     363          case 15: case 16:  
     364            { 
     365              if(tt>=5) {printf("bug sur tt 6\n");fflush(stdout);exit(1);} 
     366              goto modere; 
     367            } 
     368          case 20: case 21: 
     369            { 
     370              vb5=myval(truecoeff(polh,1),p);vb6=myval(truecoeff(polh,0),p); 
     371              if(vb6>=3) 
     372                { 
     373                  if(vb5>=3)  
     374                    { 
     375                      condp=dismin-8; 
     376                      printf("[II*-IV-(-1)] page 164, (3), f=%ld\n",condp); 
     377                      fflush(stdout); 
     378                    } 
     379                  else 
     380                    { 
     381                      if(vb5<2) {printf("bug red1");fflush(stdout);exit(1);}  
     382                      condp=dismin-7;                  
     383                      printf("[IV-III*-(-1)] page 167, (6), f=%ld\n",condp); 
     384                      fflush(stdout); 
     385                    } 
     386                } 
     387              else 
     388                { 
     389                  b=cgetg(8,18); 
     390                  b[1]=(long)truecoeff(polh,6);b[2]=(long)truecoeff(polh,5); 
     391                  b[3]=(long)truecoeff(polh,4);b[4]=(long)truecoeff(polh,3); 
     392                  b[5]=(long)truecoeff(polh,2);b[6]=(long)truecoeff(polh,1); 
     393                  b[7]=(long)truecoeff(polh,0); 
     394                  if(gdvd((GEN)b[1],p))  
     395                    {printf("bug sur b0");fflush(stdout);exit(1);} 
     396                  c1=gmul2n((GEN)b[2],-1); 
     397                  c2=gmul2n(gsub(gmul((GEN)b[1],(GEN)b[3]),gsqr(c1)),-1); 
     398                  c3=gmul2n(gsub(gmul(gsqr((GEN)b[1]),(GEN)b[4]),gmul2n(gmul(c1,c2),1)),-1); 
     399                  c4=gsub(gmul(gpowgs((GEN)b[1],3),(GEN)b[5]),gadd(gmul2n(gmul(c1,c3),1),gsqr(c2))); 
     400                  c5=gsub(gmul(gpowgs((GEN)b[1],4),(GEN)b[6]),gmul2n(gmul(c2,c3),1)); 
     401                  c6=gsub(gmul(gpowgs((GEN)b[1],5),(GEN)b[7]),gsqr(c3)); 
     402/* on a b0^5*H(x/b0)=(x^3+c1*x^2+c2*x+c3)^2+c4*x^2+c5*x+c6 */ 
     403                  vc6=myval(c6,p); 
     404                  if(vc6==2) 
     405                    {  
     406                      if(alpha)  
     407                        { 
     408                          condp=dismin-16; 
     409                          printf("[IV] page 155, (1), f=%ld\n",condp);fflush(stdout); 
     410                        } 
     411                      else   
     412                        { 
     413                          condp=dismin-6; 
     414                          printf("[III] page 155, (3)^2, f=%ld\n", condp);fflush(stdout); 
     415                        } 
     416                    } 
     417                  else 
     418                    { 
     419                      if(myval(c3,p)>1)  
     420                        {printf("bug c3");fflush(stdout);exit(1);} 
     421                      mm=min(min(3*myval(c4,p)-4,3*myval(c5,p)-5),3*vc6-6); 
     422                      if(alpha)  
     423                        { 
     424                          condp=dismin-mm-16; 
     425                          printf("[III*{%ld}] page 184, (1), f=%ld\n",mm,condp);fflush(stdout); 
     426                        } 
     427                      else   
     428                        {        
     429                          if(mm%3)  
     430                            { 
     431                              condp=dismin-mm-6; 
     432                              printf("[III{%ld}] page 184, (9), f=%ld\n",mm,condp);fflush(stdout); 
     433                            } 
     434                          else  
     435                            { 
     436                              condp=dismin-mm-6; 
     437                              printf("[III{%ld}] page 184, (3)^2, f=%ld\n",mm,condp);fflush(stdout); 
     438                            } 
     439                        } 
     440                    } 
     441                } 
     442            }  
     443            break;       
     444          case 30:  
     445            { 
     446              if(cmpis(p,3)) goto modere; 
     447              else goto quartic; 
     448            } 
     449            break;       
     450          default: printf("bug red2\n");fflush(stdout);exit(1);     
     451          } 
     452      } 
     453      break; 
     454    case 1: 
     455      { 
     456        switch(itos(gmul(theta, stoi(60)))+alpha) 
     457          { 
     458          case 12:  
     459            condp=dismin; 
     460            printf("[VIII-1] page 156, (1), f=%ld\n",condp);fflush(stdout);break; 
     461          case 13:  
     462            condp=dismin-10; 
     463            printf("[IX-3] page 157, (5), f=%ld\n",condp);fflush(stdout);break; 
     464          case 24:  
     465            condp=dismin-4; 
     466            printf("[IX-1] page 157, (5), f=%ld\n",condp);fflush(stdout);break; 
     467          case 25:  
     468            condp=dismin-14; 
     469            printf("[VIII-3] page 157, (1), f=%ld\n",condp);fflush(stdout);break; 
     470          case 36:  
     471            condp=dismin-8; 
     472            printf("[VIII-2] page 157, (1), f=%ld\n",condp);fflush(stdout);break; 
     473          case 15:  
     474            condp=dismin-1; 
     475            printf("[VII] page 156, (2), f=%ld\n",condp);fflush(stdout);break; 
     476          case 16:  
     477            condp=dismin-11; 
     478            printf("[VII*] page 156, (2), f=%ld\n",condp);fflush(stdout);break; 
     479          case 20:  
     480            {            
     481              if(cmpis(p,3)) 
     482                { 
     483                  d=6*val[6]-5*val[7]-2; 
     484                  if(d%6) 
     485                    { 
     486                      printf("bug dans le calcul d'un indice\n"); 
     487                      fflush(stdout);exit(1); 
     488                    } 
     489                  dism=(d/6); 
     490                } 
     491              else 
     492                { 
     493                  list=factorpadicnonun(polh,p,dismin-5); 
     494                  nb=lg(list);prod=pol_1(varn(polh)); 
     495                  for(i=1;i<nb;i++) 
     496                    { 
     497                      facti=(GEN)list[i]; 
     498                      if(valp((GEN)facti[2])&&lg(facti)<=5) 
     499                        prod=gmul(prod,facti); 
     500                    } 
     501                  if(lg(prod)>5)  
     502                    { 
     503                      printf("bug factorpadicnonun");fflush(stdout);exit(1); 
     504                    } 
     505                  e0=truecoeff(prod,2);e1=truecoeff(prod,1); 
     506                  e2=truecoeff(prod,0); 
     507                  dism=valp(gsub(gsqr(e1),gmul2n(gmul(e0,e2),2)))-1; 
     508                } 
     509              condp=dismin-dism-3; 
     510              printf("[II-II*{%ld}] page 176, H{%ld}, f=%ld\n",dism,dism+1,condp);fflush(stdout); 
     511            } 
     512            break; 
     513          case 21:  
     514            { 
     515              vb6=myval(truecoeff(polh,0),p); 
     516              if(vb6<2) {printf("bug red3\n");fflush(stdout);exit(1);} 
     517              condp=dismin-14; 
     518              printf("[IV*-II{0}] page 175, (1), f=%ld\n",condp);fflush(stdout); 
     519            } 
     520            break; 
     521          case 30:  
     522            {  
     523              vb5=myval(truecoeff(polh,1),p);  
     524              if(vb5==2)  
     525                { 
     526                  if(tt>=5) {printf("bug sur tt 6\n");fflush(stdout);exit(1);} 
     527                  goto modere; 
     528                } 
     529              condp=dismin-7; 
     530              printf("[II*-III-(-1)] page 167, (2), f=%ld\n",condp);fflush(stdout); 
     531            } 
     532            break; 
     533          } 
     534      } 
     535      break; 
     536    case 2: 
     537      { 
     538        if(!cmpis(denom(theta),4))  
     539          { 
     540            if(tt>4) {printf("bug sur tt 5\n");fflush(stdout);exit(1);} 
     541            goto modere; 
     542          } 
     543        if(cmpis(p,3)&&!cmpis(denom(theta),3)) goto modere; 
     544        list=factorpadicnonun(polh,p,dismin-10*alpha); 
     545        nb=lg(list);prod=pol_1(varn(polh)); 
     546        for(i=1;i<nb;i++) 
     547          { 
     548            facti=(GEN)list[i]; 
     549            if(!valp((GEN)facti[2]))  
     550              prod=gmul(prod,facti); 
     551          } 
     552        if(lg(prod)>5)  
     553          { 
     554            printf("bug factorpadicnonun 2"); 
     555            fflush(stdout);exit(1); 
     556          } 
     557        e0=truecoeff(prod,2);e1=truecoeff(prod,1);e2=truecoeff(prod,0); 
     558        dism=valp(gsub(gsqr(e1),gmul2n(gmul(e0,e2),2))); 
     559        switch(itos(gmulgs(theta,12))+alpha-4) 
     560          { 
     561          case 0: 
     562            condp=dismin-dism-1; 
     563            printf("[IV-II{%ld}] page 175, (%ld), f=%ld\n",dism,3*dism+2,condp); 
     564            fflush(stdout);break; 
     565          case 1:  
     566            condp=dismin-dism-10; 
     567            printf("[II*-II*{%ld}] page 175, H{%ld}, f=%ld\n",dism,dism+1,condp); 
     568            fflush(stdout);break; 
     569          case 2: case 3: 
     570            { 
     571              if(myval(truecoeff(polh,0),p)==2)  
     572                { 
     573                  if(tt>4) {printf("bug sur tt 5\n");fflush(stdout);exit(1);} 
     574                  goto modere; 
     575                } 
     576              else 
     577                {  
     578                  dism=dism+1; 
     579                  indice=val[6]-(5*val[3]/2)-dism; 
     580                  if((dism*indice)&1) 
     581                    { 
     582                      condp=dismin-dism-indice-2; 
     583                      printf("[II{%ld-%ld}] page 182, (2)x(%ld), f=%ld\n", 
     584                      dism,indice,2*dism,condp);fflush(stdout); 
     585                    } 
     586                  else  
     587                    { 
     588                      condp=dismin-dism-indice-2; 
     589                      printf("[II{%ld-%ld}] page 182, (%ld), f=%ld\n", 
     590                      dism,indice,4*dism,condp);fflush(stdout); 
     591                    } 
     592                } 
     593            } 
     594            break; 
     595          case 4:   
     596            condp=dismin-dism-5; 
     597            printf("[IV*-II{%ld}] page 175, (%ld), f=%ld\n",dism+1,3*dism+4,condp); 
     598            fflush(stdout);break; 
     599          } 
     600      } 
     601      break; 
     602    case 3: 
     603      { 
     604        if(cmpis(p,3)||tt<=4) goto modere; 
     605        goto labelm3; 
     606      } 
     607      break; 
     608    default: printf("bug switch sur lambda\n");fflush(stdout);exit(1);      
     609    } 
     610  if(condp<2||condp>maxc)  
     611    {printf("bug conducteur 3\n");fflush(stdout);exit(1);} 
     612  goto recp; 
     613 
     614 labelm3: 
     615  polh1=gcopy(polh); 
     616  theta1=gcopy(theta); 
     617  alpha1=alpha; 
     618  polh=gmul(gsubst(polh,0,ginv(pol_x(0))),gpowgs(pol_x(0),6)); 
     619  polf=polymini(gmul(polh,gpowgs(p,alpha)),p); 
     620  polh=(GEN)polf[1]; 
     621  lambda=itos((GEN)polf[2]);   
     622  theta=(GEN)polf[3]; 
     623  alpha=itos((GEN)polf[4]); 
     624  beta=itos((GEN)polf[6]); 
     625  if(!lambda==3)  
     626    {printf("bug lambda=3\n");fflush(stdout);exit(1);} 
     627  R=beta-alpha1-alpha; 
     628  if(R&1)  
     629    { 
     630      printf("bug R impair\n");fflush(stdout);exit(1); 
     631    } 
     632  R>>=1; 
     633  if(R<=-2)  
     634    { 
     635      printf("bug R <=-2\n");fflush(stdout);exit(1); 
     636    } 
     637  if(val[eps2]%(2*eps))  
     638    { 
     639      printf("bug sur val[eps2]\n");fflush(stdout);exit(1); 
     640    } 
     641  if(R>=0&&(alpha+alpha1)>=1)  
     642    { 
     643      printf("bug equation minimale\n");fflush(stdout);exit(1); 
     644    } 
     645  r1=itos(gmulgs(theta1,6))+6*alpha1;  
     646  r2=itos(gmulgs(theta,6))+6*alpha;  
     647  
     648 litredtp:  
     649  if((r1==0||r1==6)&&(r2==0||r2==6)) 
     650    { 
     651      if(tt==5) 
     652        {       
     653          switch(2*r2+r1) 
     654            { 
     655            case 0:  
     656              condp=0; 
     657              printf("[I{0}-I{0}-%ld] page 158, (1), f=0\n",R); 
     658              fflush(stdout);break; 
     659            case 6: case 12: 
     660              condp=2; 
     661              printf("[I*{0}-I{0}-%ld] page 159, (2)^2, f=2\n",R); 
     662              fflush(stdout);break; 
     663            case 18:  
     664              condp=4; 
     665              printf("[I*{0}-I*{0}-%ld] page 158, (2)^4, f=4\n",R); 
     666              fflush(stdout);break; 
     667            } 
     668          goto recp; 
     669        } 
     670      if(r1==r2) goto modere; 
     671      if(tt==6)  
     672        { 
     673          d=val[6]-val[7]+(val[eps2]/eps); 
     674          if(r1&&alpha1==0)  
     675            { 
     676              polh1=gdiv(gsubst(polh1,0,gmul(p,pol_x(0))),gpowgs(p,3)); 
     677            } 
     678          polhp=gmul(unmodp,polh1);        
     679          if(!gequal0(discsr(polhp)))  
     680            { 
     681              indice=0; condp=3-r2/6; 
     682            } 
     683          else  
     684            { 
     685              indice=d; condp=3-r1/6; 
     686            } 
     687        } 
     688      else /* donc tt==7 */  
     689        { 
     690          if(gequal1(theta1))  
     691            { 
     692              polh1=gdiv(gsubst(polh1,0,gmul(p,pol_x(0))),gpowgs(p,3)); 
     693            } 
     694          d=val[6]-3*val[3]+(val[eps2]/eps); 
     695          d1=min(val[7]-3*val[3],d/2); 
     696          if(d==2*d1) indice=d1; 
     697          else 
     698            { 
     699              indice=discpart(polh1,p,d1+1);       
     700              if(indice>=d1+1) indice=d-d1; 
     701              else indice=d1; 
     702            } 
     703          condp=3; 
     704        } 
     705      if(r1) 
     706        { 
     707          if(tt==6) 
     708            { 
     709              printf("[I*{%ld}-I{%ld}-%ld] page 170, H{%ld}x(%ld), f=%ld\n", 
     710                     indice,d-indice,R,indice,d-indice,condp); 
     711              fflush(stdout);goto recp; 
     712            } 
     713          else 
     714            { 
     715              printf("[I*{%ld}-I{%ld}-%ld] page 180, H{%ld}x(%ld), f=%ld\n", 
     716                     indice,d-indice,R,indice,d-indice,condp); 
     717              fflush(stdout);goto recp; 
     718            } 
     719        } 
     720      else 
     721        { 
     722          if(tt==6) 
     723            { 
     724              printf("[I{%ld}-I*{%ld}-%ld] page 170, (%ld)xH{%ld}, f=%ld\n", 
     725                     indice,d-indice,R,indice,d-indice,condp); 
     726              fflush(stdout);goto recp; 
     727            } 
     728          printf("[I{%ld}-I*{%ld}-%ld] page 180, (%ld)xH{%ld}, f=%ld\n", 
     729                 indice,d-indice,R,indice,d-indice,condp); 
     730          fflush(stdout);goto recp; 
     731        } 
     732    } 
     733  if(tt==7)  
     734    {printf("bug avant swith sur ri\n");fflush(stdout);exit(1);} 
     735  switch(r1)  
     736    { 
     737    case 0: case 6: 
     738      {  
     739        if(r1&&alpha1==0)  
     740          { 
     741            polh1=gdiv(gsubst(polh1,0,gmul(p,pol_x(0))),gpowgs(p, 3)); 
     742          } 
     743        polhp=gmul(unmodp,polh1);                
     744        if(!gequal0(discsr(polhp))) d=0; 
     745        else d=val[6]-val[7]+(val[eps2]/eps); 
     746        if(r1)  
     747          {printf("[I*{%ld}-",d);comp=d+5;} 
     748        else  
     749          { 
     750            printf("[I{%ld}-",d); 
     751            if(d) comp=d; 
     752            else comp=1; 
     753          } 
     754      } 
     755      fflush(stdout);break; 
     756    case 3: printf("[III-");fflush(stdout);comp=2;break; 
     757    case 9: printf("[III*-");fflush(stdout);comp=8;break; 
     758    case 2: printf("[II-");fflush(stdout);comp=1;break; 
     759    case 8: printf("[IV*-");fflush(stdout);comp=7;break; 
     760    case 4: printf("[IV-");fflush(stdout);comp=3;break; 
     761    case 10: printf("[II*-");fflush(stdout);comp=9;break; 
     762    default: printf("bug type1\n");fflush(stdout);exit(1); 
     763    } 
     764  switch(r2)   
     765    {  
     766    case 0: case 6: 
     767      { 
     768        if(r2&&alpha==0) 
     769          { 
     770            polh=gdiv(gsubst(polh,0,gmul(p,pol_x(0))),gpowgs(p,3)); 
     771          } 
     772        polhp=gmul(unmodp,polh);           
     773        if(!gequal0(discsr(polhp))) indice=0; 
     774        else indice=val[6]-val[7]+(val[eps2]/eps); 
     775        if(r2)  
     776          {printf("I*{%ld}-%ld] pages 159-177, ",indice,R);comp+=indice+5;} 
     777        else  
     778          { 
     779            printf("I{%ld}-%ld] pages 159-177, ",indice,R); 
     780            if(indice) comp+=indice; 
     781            else comp+=1; 
     782          } 
     783      } 
     784      break; 
     785    case 3: printf("III-%ld] pages 161-177, ",R);comp+=2;break; 
     786    case 9: printf("III*-%ld] pages 162-177, ",R);comp+=8;break; 
     787    case 2: printf("II-%ld] pages 159-174, ",R);comp+=1;break; 
     788    case 8: printf("IV*-%ld] pages 160-175, ",R);comp+=7;break; 
     789    case 4: printf("IV-%ld] pages 160-174, ",R);comp+=3;break; 
     790    case 10: printf("II*-%ld] pages 160-174, ",R);comp+=9;break; 
     791    default: printf("bug type2\n");fflush(stdout);exit(1); 
     792    } 
     793  if(R>=0) condp=dismin-comp+2-12*R; 
     794  else condp=dismin-comp+4; 
     795  if(condp>maxc)  
     796    {printf("bug conducteur\n");fflush(stdout);exit(1);} 
     797  switch(r1)  
     798    { 
     799    case 0:  
     800      if(indice) printf("(%ld)x",d); 
     801      else printf("(1)x"); 
     802      break; 
     803    case 6: printf("H{%ld}x",d);break; 
     804    case 3: printf("(2)x");break; 
     805    case 9: printf("(2)x");break; 
     806    case 2: printf("(1)x");break; 
     807    case 8: printf("(3)x");break; 
     808    case 4: printf("(3)x");break; 
     809    case 10: printf("(1)x");break; 
     810    default: printf("bug type3\n");fflush(stdout);exit(1); 
     811    } 
     812  switch(r2)  
     813    { 
     814    case 0:  
     815      if(indice)  
     816        {printf("(%ld), f=%ld\n",indice,condp);fflush(stdout);} 
     817      else  
     818        {printf("(1), f=%ld\n",condp);fflush(stdout);} 
     819      break; 
     820    case 6: printf("H{%ld}, f=%ld\n",indice,condp);fflush(stdout);break; 
     821    case 3: printf("(2), f=%ld\n",condp);fflush(stdout);break; 
     822    case 9: printf("(2), f=%ld\n",condp);fflush(stdout);break; 
     823    case 2: printf("(1), f=%ld\n",condp);fflush(stdout);break; 
     824    case 8: printf("(3), f=%ld\n",condp);fflush(stdout);break; 
     825    case 4: printf("(3), f=%ld\n",condp);fflush(stdout);break; 
     826    case 10: printf("(1), f=%ld\n",condp);fflush(stdout);break; 
     827    default: printf("bug type4\n");fflush(stdout);exit(1); 
     828    } 
     829  goto recp; 
     830 
     831 quadratic: 
     832  if(cmpis(p,3)) goto modere; 
     833  alpha1=alpha; 
     834  polf=(GEN)polyminizi(gmul(polh,gpowgs(p,alpha))); 
     835  theta=(GEN)polf[1]; 
     836  alpha=itos((GEN)polf[2]);  
     837  beta=itos((GEN)polf[3]);  
     838  if(alpha&&beta>=1)  
     839    {printf("bug, erreur d'appreciation\n");fflush(stdout);exit(1);} 
     840  R=beta-alpha; 
     841  if(R>=0&&alpha1)  
     842    {  
     843      dismin=dismin-10; 
     844      printf("(care, the minimal discriminant over Z[i] is smaller than over Z) ");fflush(stdout); 
     845    } 
     846  r1=itos(gmulgs(theta,6))+6*alpha; 
     847  r2=r1; 
     848  alpha1=alpha; 
     849  theta1=gcopy(theta); 
     850  goto litredtp; 
     851   
     852 quartic: 
     853  polf=(GEN)polyminizi2(gmul(polh,gpowgs(p,alpha))); 
     854  theta=(GEN)polf[1]; 
     855  beta=itos((GEN)polf[2]); 
     856  if(beta&1) 
     857    { 
     858      printf("bug, le type sur Z[i] doit etre [K-K-(2*m)]\n"); 
     859      fflush(stdout);exit(1); 
     860    } 
     861  R=beta/2; 
     862  r1=itos(gmulgs(theta,6)); 
     863  switch(tt) 
     864    { 
     865    case 1: case 5: d=0;break; 
     866    case 3: d=val[6]-5*val[3]/2;break; 
     867    case 7: d=val[6]-3*val[3]+val[eps2]/eps;break; 
     868    default: printf("bug choix de types\n");fflush(stdout);exit(1); 
     869    } 
     870  switch(r1)  
     871    { 
     872    case 0:  
     873      { 
     874        if(d)  
     875          { 
     876            condp=3;printf("[2I{%ld}-%ld] page 181, (%ld), f=3\n",d,R,d); 
     877          } 
     878        else  
     879          { 
     880            condp=2; 
     881            if(R) 
     882              { 
     883                printf("[2I{0}-%ld] page 159, (1), f=2\n",R); 
     884              } 
     885            else 
     886              { 
     887                printf("[II] page 155, (1), f=2\n"); 
     888              } 
     889          } 
     890      } 
     891      break; 
     892    case 6:  
     893      { 
     894        condp=4;printf("[2I*{%ld}-%ld] pages 159, 181, (2)^2, f=4\n",d,R); 
     895      } 
     896      break; 
     897    case 3:  
     898      condp=4;printf("[2III-%ld] page 168, (2), f=4\n",R);break; 
     899    case 9:  
     900      condp=4;printf("[2III*-%ld] page 168, (2), f=4\n",R);break; 
     901    case 2:  
     902      condp=dismin-12*R-13;printf("[2II-%ld] page 162, (1), f=%ld\n",R,condp);break; 
     903    case 8:  
     904      condp=dismin-12*R-19;printf("[2IV*-%ld] page 165, (3), f=%ld\n",R,condp);break; 
     905    case 4:  
     906      condp=dismin-12*R-15;printf("[2IV-%ld] page 165, (3), f=%ld\n",R,condp);break; 
     907    case 10:  
     908      condp=dismin-12*R-21;printf("[2II*-%ld] page 163, (1), f=%ld\n",R,condp);break; 
     909    default: printf("bug type1\n");fflush(stdout);exit(1); 
     910    } 
     911  fflush(stdout); 
     912  if(condp>maxc||condp<0)  
     913    {printf("bug conducteur\n");fflush(stdout);exit(1);} 
     914  goto recp; 
     915 
     916 modere: 
     917/*  printf("(moderee) ");fflush(stdout);  */ 
     918  apol2=readseq("a0;a1;a2;a3;a4;a5;a6;-5*a1^2+12*a0*a2"); 
     919  apol3=readseq("a0;a1;a2;a3;a4;a5;a6;5*a1^3+9*a0*(-2*a1*a2+3*a0*a3)"); 
     920  apol4=readseq("a0;a1;a2;a3;a4;a5;a6;-5*a1^4+24*a0*(a1^2*a2-3*a0*a1*a3+6*a0^2*a4)"); 
     921  apol5=readseq("a0;a1;a2;a3;a4;a5;a6;a1^5+3*a0*(-2*a1^3*a2+9*a0*a1^2*a3-36*a0^2*a1*a4+108*a0^3*a5)"); 
     922  bpol2=readseq("a0;a1;a2;a3;a4;a5;a6;2*a2^2-5*a1*a3+10*a0*a4"); 
     923  A2=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(apol2,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     924  A3=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(apol3,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     925  A4=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(apol4,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     926  A5=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(apol5,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     927  B2=gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(gsubst(bpol2,1,a0),2,a1),3,a2),4,a3),5,a4),6,a5),7,a6); 
     928  va0=myval(a0,p);va2=myval(A2,p);va3=myval(A3,p);va4=myval(A4,p); 
     929  va5=myval(A5,p);vb2=myval(B2,p);  
     930 
     931  switch(tt) 
     932    { 
     933    case 1: 
     934      if((!gequal0(A5))&&(20*va0+val[6]>6*va5)) 
     935        { 
     936          n=glcm(denom(pro1=gdiv(stoi(val[6]-2*va5),stoi(20))),denom(pro2=gdiv(stoi(5*val[6]-6*va5),stoi(40)))); 
     937          r=gmul(n,pro1);q=gmul(n,pro2); 
     938        } 
     939      else 
     940        { 
     941          n=glcm(denom(pro1=gdiv(stoi(10*va0-val[6]),stoi(30))),denom(pro2=gdiv(stoi(5*va0-val[6]),stoi(10)))); 
     942          r=gmul(n,pro1);q=gmul(n,pro2); 
     943        } 
     944      r=gmod(r,n);q=gmod(q,n); 
     945      switch(itos(n)) 
     946        { 
     947        case 1: condp=0; 
     948          printf("[I{0-0-0}] page 155, (1)");fflush(stdout);break; 
     949        case 2: 
     950          switch(itos(r)) 
     951            { 
     952            case 0: condp=4; 
     953              printf("[I*{0-0-0}] page 155, (2)^4");fflush(stdout);break; 
     954            case 1: condp=2; 
     955              printf("[II] page 155, (1)");fflush(stdout);break; 
     956            default: printf("bug1\n");fflush(stdout);exit(1); 
     957            } 
     958          break; 
     959        case 4: condp=4;printf("[VI] page 156, (2)^2");fflush(stdout);break;  
     960        default: printf("bug8\n");fflush(stdout);exit(1);          
     961        } 
     962      break; 
     963    case 2: case 3: case 4: 
     964      switch(tt) 
     965        { 
     966        case 2: j12=i12;break; 
     967        case 3: j12=gpowgs(i4,3);break; 
     968        case 4: j12=gpowgs(j2,6);break; 
     969        } 
     970      v12=myval(j12,p); 
     971      if((9*vb2>=(6*va0+v12))&&(36*va5>=(120*va0+5*v12))) 
     972        { 
     973          n=glcm(denom(pro1=gdiv(stoi(12*va0-v12),stoi(36))),denom(pro2=gdiv(stoi(6*va0-v12),stoi(12)))); 
     974          r=gmul(n,pro1);q=gmul(n,pro2);flc=1; 
     975        } 
     976      else 
     977        { 
     978          if(((120*va0+5*v12)>36*va5)&&(60*vb2>=(12*va5+5*v12))) 
     979            { 
     980              n=denom(pro1=gdiv(stoi(36*va5-25*v12),stoi(240))); 
     981              q=gmul(n,pro1);r=gmulsg(-2,q);flc=1; 
     982            } 
     983          else 
     984            { 
     985              if(((6*va0+v12)>9*vb2)&&((12*va5+5*v12)>60*vb2)) 
     986                { 
     987                  n=glcm(denom(pro1=gdiv(stoi(v12-6*vb2),stoi(12))),denom(pro2=gdiv(stoi(v12-9*vb2),stoi(12)))); 
     988                  r=gmul(n,pro1);q=gmul(n,pro2);flc=2; 
     989                } 
     990              else {printf("bug9\n");fflush(stdout);exit(1);} 
     991            } 
     992        } 
     993      r=gmod(r,n);q=gmod(q,n); 
     994      switch(tt) 
     995        { 
     996        case 2: 
     997          d=itos(gmul(n,gdivgs(stoi(6*val[6]-5*val[7]),6))); 
     998          switch(itos(n)) 
     999            { 
     1000            case 1: condp=1; 
     1001              printf("[I{%ld-0-0}] page 170, (%ld)",d,d);fflush(stdout);break;     
     1002            case 2: 
     1003              switch(itos(r)) 
     1004                { 
     1005                case 0: condp=4; 
     1006                  printf("[I*{%ld-0-0}] page 171, (2)^2xH{%ld}",d/2,d/2); 
     1007                  fflush(stdout);break;                    
     1008                case 1: 
     1009                  switch(itos(q)) 
     1010                    { 
     1011                    case 0: condp=2; 
     1012                      printf("[II*{%ld-0}] page 172, (1)",d/2); 
     1013                      fflush(stdout);break; 
     1014                    case 1: condp=3; 
     1015                      printf("[II{%ld-0}] page 171, (%ld)",d/2,2*d); 
     1016                      fflush(stdout);break; 
     1017                    default: {printf("bug10\n");fflush(stdout);exit(1);} 
     1018                    } 
     1019                  break; 
     1020                default: {printf("bug11\n");fflush(stdout);exit(1);} 
     1021                } 
     1022              break; 
     1023            case 3: 
     1024              switch(itos(r)) 
     1025                { 
     1026                case 1: condp=3; 
     1027                  printf("[IV-II{%ld}] page 175, (%ld)",(d-2)/3,d); 
     1028                  fflush(stdout);break;            
     1029                case 2: condp=3; 
     1030                  printf("[IV*-II{%ld}] page 175, (%ld)",(d-1)/3,d); 
     1031                  fflush(stdout);break; 
     1032                default: {printf("bug12\n");fflush(stdout);exit(1);} 
     1033                } 
     1034              break; 
     1035            case 4: 
     1036              switch(itos(r)) 
     1037                { 
     1038                case 1: 
     1039                  switch(itos(q)) 
     1040                    { 
     1041                    case 1: condp=3; 
     1042                      printf("[III-II{%ld}] page 177, (%ld)",(d-2)/4,d/2); 
     1043                      fflush(stdout);break; 
     1044                    case 3: condp=4; 
     1045                      printf("[III*-II*{%ld}] page 178, (8)",(d-2)/4); 
     1046                      fflush(stdout);break; 
     1047                    default: {printf("bug13\n");fflush(stdout);exit(1);} 
     1048                    } 
     1049                  break; 
     1050                case 3: 
     1051                  switch(itos(q)) 
     1052                    { 
     1053                    case 1: condp=4; 
     1054                      printf("[III-II*{%ld}] page 178, (8)",(d-2)/4); 
     1055                      fflush(stdout);break; 
     1056                    case 3: condp=3; 
     1057                      printf("[III*-II{%ld}] page 178, (%ld)",(d-2)/4,d/2); 
     1058                      fflush(stdout);break; 
     1059                    default: {printf("bug14\n");fflush(stdout);exit(1);} 
     1060                    } 
     1061                  break; 
     1062                default: {printf("bug15\n");fflush(stdout);exit(1);} 
     1063                } 
     1064              break; 
     1065            case 6: 
     1066              switch(itos(r)) 
     1067                { 
     1068                case 2: condp=4; 
     1069                  printf("[II*-II*{%ld}] page 176, H{%ld}",(d-4)/6,(d+2)/6); 
     1070                  fflush(stdout);break;            
     1071                case 4: condp=4; 
     1072                  printf("[II-II*{%ld}] page 176, H{%ld}",(d-2)/6,(d+4)/6); 
     1073                  fflush(stdout);break; 
     1074                default: {printf("bug16\n");fflush(stdout);exit(1);} 
     1075                } 
     1076              break; 
     1077            default: {printf("bug17\n");fflush(stdout);exit(1);} 
     1078            } 
     1079          break; 
     1080        case 3: 
     1081          va5=2*val[6]-5*val[3];e1=gmin(stoi(val[7]-3*val[3]),gmul2n(stoi(va5),-2)); 
     1082          e2=gsub(gmul2n(stoi(va5),-1),e1); 
     1083          d1=itos(gmul(n,e1));d2=itos(gmul(n,e2)); 
     1084          switch(itos(n)) 
     1085            { 
     1086            case 1: condp=2; 
     1087              printf("[I{%ld-%ld-0}] page 179, (%ld)x(%ld)",d1,d2,d1,d2); 
     1088              fflush(stdout);break;           
     1089            case 2: 
     1090              switch(itos(r)) 
     1091                { 
     1092                case 0: condp=4; 
     1093                  printf("[I*{%ld-%ld-0}] page 180, H{%ld}xH{%ld}",d1/2,d2/2,d1/2,d2/2); 
     1094                  fflush(stdout);break; 
     1095                case 1: 
     1096                  switch(flc) 
     1097                    { 
     1098                    case 1:condp=3; 
     1099                      printf("[2I{%ld}-0] page 181, (%ld)",d1,d1); 
     1100                      fflush(stdout);break;                    
     1101                    case 2: condp=3; 
     1102                      printf("[II{%ld-%ld}] page 182, ",d1/2,d2/2); 
     1103                      if((d1*d2-4)&7) printf("(%ld)",2*d1); 
     1104                      else printf("(%ld)x(2)",d1); 
     1105                      printf("ou [II{%ld-%ld}] page 182, ",d2/2,d1/2); 
     1106                      if((d1*d2-4)&7) printf("(%ld)",2*d2); 
     1107                      else printf("(%ld)x(2)",d2); 
     1108                      fflush(stdout);break; 
     1109                    default: {printf("bug19\n");fflush(stdout);exit(1);} 
     1110                    } 
     1111                  break; 
     1112                default: {printf("bug20\n");fflush(stdout);exit(1);} 
     1113                } 
     1114              break; 
     1115            case 4: condp=4; 
     1116              printf("[III{%ld}] page 182, H{%ld}",d1/2,d1/2); 
     1117              fflush(stdout);break;            
     1118            default: {printf("bug21\n");fflush(stdout);exit(1);} 
     1119            } 
     1120          break; 
     1121        case 4: 
     1122          vl=stoi(val[6]-5*val[1]);vn=stoi(val[7]-6*val[1]);vm=stoi(val[2]-2*val[1]); 
     1123          e1=gmin(gmin(gdivgs(vl,3),gmul2n(vn,-1)),vm); 
     1124          e2=gmin(gmul2n(gsub(vl,e1),-1),gsub(vn,e1)); 
     1125          e3=gsub(vl,gadd(e1,e2)); 
     1126          d1=itos(gmul(n,e1));d2=itos(gmul(n,e2));d3=itos(gmul(n,e3)); 
     1127          g=d1*d2+d1*d3+d2*d3;h=itos(mppgcd(mppgcd(stoi(d1),stoi(d2)),stoi(d3))); 
     1128          switch(itos(n)) 
     1129            { 
     1130            case 1: condp=2; 
     1131              printf("[I{%ld-%ld-%ld}] page 182, (%ld)x(%ld)",d1,d2,d3,h,g/h); 
     1132              fflush(stdout);break;           
     1133            case 2: 
     1134              switch(itos(r)) 
     1135                { 
     1136                case 0: condp=4;  
     1137                  printf("[I*{%ld-%ld-%ld}] page 183, H{%ld}xH{%ld}",d1/2,d2/2,d3/2,g/4,2-((h&2)>>1)); 
     1138                  fflush(stdout);break; 
     1139                case 1: 
     1140                  if(d1==d2) f2=d1; 
     1141                  else 
     1142                    { 
     1143                      if(d1==d3) f2=d1; 
     1144                      else 
     1145                        { 
     1146                          if(d2==d3) f2=d2; 
     1147                          else {printf("bug23\n");fflush(stdout);exit(1);} 
     1148                        } 
     1149                    } 
     1150                  f1=d1+d2+d3-2*f2; 
     1151                  switch(itos(q)) 
     1152                    { 
     1153                    case 0: condp=3; 
     1154                      printf("[II*{%ld-%ld}] page 184, (%ld)",f1/2,f2,f2); 
     1155                      fflush(stdout);break;                    
     1156                    case 1: condp=3; 
     1157                      printf("[II{%ld-%ld}] page 183, (%ld)",f1/2,f2,2*f1+f2); 
     1158                      fflush(stdout);break; 
     1159                    default: {printf("bug24\n");fflush(stdout);exit(1);} 
     1160                    } 
     1161                  break; 
     1162                default: {printf("bug25\n");fflush(stdout);exit(1);} 
     1163                } 
     1164              break; 
     1165            case 3: condp=4; 
     1166              printf("[III{%ld}] page 184, ",d1); 
     1167              if(d1%3) printf("(9)");else printf("(3)^2"); 
     1168              fflush(stdout);break;            
     1169            case 6: condp=4; 
     1170              printf("[III*{%ld}] page 184, (1)",d1/2); 
     1171              fflush(stdout);break;            
     1172            default: {printf("bug26\n");fflush(stdout);exit(1);} 
     1173            } 
     1174          break; 
     1175        } 
     1176      break; 
     1177    case 5: case 6: case 7: 
     1178      switch(tt) 
     1179        { 
     1180        case 5: dk=gdivgs(stoi(eps*val[6]-5*val[eps2]),12*eps);break; 
     1181        case 6: dk=gdivgs(stoi(eps*val[7]-6*val[eps2]),12*eps); 
     1182          d1k=gdivgs(stoi(eps*val[6]+val[eps2]-eps*val[7]),eps);break; 
     1183        case 7: dk=gdivgs(stoi(eps*val[3]-2*val[eps2]),4*eps); 
     1184          pro1=gdivgs(stoi(eps*val[6]+val[eps2]-3*eps*val[3]),eps); 
     1185          d1k=gmin(stoi(val[7]-3*val[3]),gmul2n(pro1,-1)); 
     1186          d2k=gsub(pro1,d1k);break; 
     1187        } 
     1188      rk=gadd(gmul2n(stoi(va0),-1),gmin(gmul2n(dk,-1),gmin(gmul2n(stoi(2*va3-3*va2),-3),gdivgs(stoi(2*myval(gsub(gmul(A2,A3),gmulsg(3,A5)),p)-5*va2),12)))); 
     1189      v1=2*va3-4*va0-val[1]; 
     1190      v2=6*va5-20*va0-5*val[1]; 
     1191/* la definition de n est differente suivant val[1] mod 2, ici elle n'est pas  
     1192   valable pour p=2 ou 3 */ 
     1193      if(!(val[eps2]&1)) 
     1194        { 
     1195          if((3*vb2>=(2*va0+2*val[1]))&&(v1>=0)&&(v2>=0)&&((v1==0)||(v2==0))) 
     1196            { 
     1197              n=glcm(denom(dk),denom(pro1=gdivgs(stoi(va0+val[1]),6))); 
     1198              r=gmul(n,pro1); 
     1199            } 
     1200          else 
     1201            { 
     1202              if(((20*va0+5*val[1])>6*va5)&&(10*vb2>=(2*va5+5*val[1]))) 
     1203                { 
     1204                  n=glcm(denom(dk),denom(pro1=gdivgs(stoi(2*va5+val[1]),8))); 
     1205                  r=gmul(n,pro1); 
     1206                } 
     1207              else 
     1208                { 
     1209                  if(((2*va0+2*val[1])>3*vb2)&&((2*va5+5*val[1])>10*vb2)) 
     1210                    { 
     1211                      n=glcm(denom(dk),denom(pro1=gmul2n(stoi(vb2),-2))); 
     1212                      r=gmul(n,pro1); 
     1213                    } 
     1214                  if((3*vb2>=(2*va0+2*val[1]))&&(2*va3>(4*va0+val[1]))&&(6*va5>(20*va0+5*val[1]))) 
     1215                    { 
     1216                      if(gequal0(A2)) {printf("bug27\n");fflush(stdout);exit(1);} 
     1217                      n=glcm(denom(dk),denom(rk));r=gmul(n,rk); 
     1218                    } 
     1219                  else  
     1220                    { 
     1221                      if(!cmpis(p,3)) /* following M. Stoll */ 
     1222                        { 
     1223                          printf("bug28\n");fflush(stdout);exit(1); 
     1224                        } 
     1225                    } 
     1226                } 
     1227            } 
     1228        } 
     1229      else 
     1230        { 
     1231          m=denom(dk);r=gmul(m,dk);n=gmul2n(m,1); 
     1232        } 
     1233      if(!cmpis(p,3)) n=stoi(1+r1/6);   
     1234      d=itos(gmul(n,dk));dm=gmod(stoi(d),n);r=gmod(r,n); 
     1235      if(!cmpis(p,3)) dm=gen_0;     
     1236      switch(tt) 
     1237        { 
     1238        case 5: 
     1239          if(!(val[eps2]&1)) 
     1240            { 
     1241              switch(itos(n)) 
     1242                { 
     1243                case 1: condp=0; 
     1244                  printf("[I{0}-I{0}-%ld] page 158, (1)",d); 
     1245                  fflush(stdout);break; 
     1246                case 2: 
     1247                  switch(itos(dm)) 
     1248                    { 
     1249                    case 0: condp=4; 
     1250                      printf("[I*{0}-I*{0}-%ld] page 158, (2)^4",(d-2)/2); 
     1251                      fflush(stdout);break; 
     1252                    case 1: condp=2; 
     1253                      printf("[I{0}-I*{0}-%ld] page 159, (2)^2",(d-1)/2); 
     1254                      fflush(stdout);break; 
     1255                    } 
     1256                  break; 
     1257                case 3: 
     1258                  switch(itos(dm)) 
     1259                    { 
     1260                    case 0: condp=4; 
     1261                      printf("[IV-IV*-%ld] page 165, (3)^2",(d-3)/3); 
     1262                      fflush(stdout);break; 
     1263                    case 1: 
     1264                      switch(itos(r)) 
     1265                    { 
     1266                    case 0: case 1: condp=2; 
     1267                      printf("[I{0}-IV-%ld] page 160, (3)",(d-1)/3); 
     1268                      fflush(stdout);break; 
     1269                    case 2: condp=4; 
     1270                      printf("[IV*-IV*-%ld] page 166, (3)^2",(d-4)/3); 
     1271                      fflush(stdout);break; 
     1272                    } 
     1273                      break; 
     1274                    case 2: 
     1275                      switch(itos(r)) 
     1276                        { 
     1277                        case 0: case 2: condp=2; 
     1278                          printf("[I{0}-IV*-%ld] page 160, (3)",(d-2)/3); 
     1279                          fflush(stdout);break; 
     1280                        case 1: condp=4; 
     1281                          printf("[IV-IV-%ld] page 165, (3)^2",(d-2)/3); 
     1282                          fflush(stdout);break; 
     1283                        } 
     1284                      break; 
     1285                    } 
     1286                  break;         
     1287                case 4: 
     1288                  switch(itos(dm)) 
     1289                    { 
     1290                    case 0: condp=4; 
     1291                      printf("[III-III*-%ld] page 169, (2)^2",(d-4)/4); 
     1292                      fflush(stdout);break; 
     1293                    case 1: 
     1294                      switch(itos(r)) 
     1295                        { 
     1296                        case 0: case 1: condp=2; 
     1297                          printf("[I{0}-III-%ld] page 161, (2)",(d-1)/4); 
     1298                          fflush(stdout);break; 
     1299                        case 2: case 3: condp=4; 
     1300                          printf("[I*{0}-III*-%ld] page 162, (2)^3",(d-5)/4); 
     1301                          fflush(stdout);break; 
     1302                        } 
     1303                      break; 
     1304                    case 2: 
     1305                      switch(itos(r)) 
     1306                        { 
     1307                        case 1: condp=4; 
     1308                          printf("[III-III-%ld] page 169, (2)^2",(d-2)/4); 
     1309                          fflush(stdout);break; 
     1310                        case 3: condp=4; 
     1311                          printf("[III*-III*-%ld] page 169, (2)^2",(d-6)/4); 
     1312                          fflush(stdout);break; 
     1313                        default: {printf("bug29\n");fflush(stdout);exit(1);} 
     1314                        } 
     1315                      break; 
     1316                    case 3:                  
     1317                      switch(itos(r)) 
     1318                        { 
     1319                        case 0: case 3: condp=2; 
     1320                          printf("[I{0}-III*-%ld] page 162, (2)",(d-3)/4); 
     1321                          fflush(stdout);break; 
     1322                        case 1: case 2: condp=4; 
     1323                          printf("[I*{0}-III-%ld] page 162, (2)^3",(d-3)/4); 
     1324                          fflush(stdout);break; 
     1325                        } 
     1326                      break; 
     1327                    } 
     1328                  break;             
     1329                case 6: 
     1330                  switch(itos(dm)) 
     1331                    { 
     1332                    case 0: condp=4; 
     1333                      printf("[II-II*-%ld] page 163, (1)",(d-6)/6); 
     1334                      fflush(stdout);break; 
     1335                    case 1: 
     1336                      switch(itos(r)) 
     1337                        { 
     1338                        case 0: case 1: condp=2; 
     1339                          printf("[I{0}-II-%ld] page 159, (1)",(d-1)/6); 
     1340                          fflush(stdout);break; 
     1341                        case 2: case 5: condp=4; 
     1342                          printf("[II*-IV-%ld] page 164, (3)",(d-7)/6); 
     1343                          fflush(stdout);break; 
     1344                        case 3: case 4: condp=4; 
     1345                          printf("[I*{0}-IV*-%ld] page 161, (2)^2x(3)",(d-7)/6); 
     1346                          fflush(stdout);break; 
     1347                        } 
     1348                      break; 
     1349                    case 2: 
     1350                      switch(itos(r)) 
     1351                        { 
     1352                        case 1: condp=4; 
     1353                          printf("[II-II-%ld] page 163, (1)",(d-2)/6); 
     1354                          fflush(stdout);break; 
     1355                        case 3: case 5: condp=4; 
     1356                          printf("[I*{0}-II*-%ld] page 160-161, (2)^2",(d-8)/6); 
     1357                          fflush(stdout);break; 
     1358                        default: {printf("bug30\n");fflush(stdout);exit(1);} 
     1359                        } 
     1360                      break; 
     1361                    case 3: 
     1362                      switch(itos(r)) 
     1363                        { 
     1364                        case 1: case 2: condp=4; 
     1365                          printf("[II-IV-%ld] page 164, (3)",(d-3)/6); 
     1366                          fflush(stdout);break; 
     1367                        case 4: case 5: condp=4; 
     1368                          printf("[II*-IV*-%ld] page 164-165, (3)",(d-9)/6); 
     1369                          fflush(stdout);break; 
     1370                        default: {printf("bug31\n");fflush(stdout);exit(1);} 
     1371                        } 
     1372                      break; 
     1373                    case 4: 
     1374                      switch(itos(r)) 
     1375                        { 
     1376                        case 1: case 3: condp=4; 
     1377                          printf("[I*{0}-II-%ld] page 160, (2)^2",(d-4)/6); 
     1378                          fflush(stdout);break; 
     1379                        case 5: condp=4; 
     1380                          printf("[II*-II*-%ld] page 163, (1)",(d-10)/6); 
     1381                          fflush(stdout);break; 
     1382                        default: {printf("bug32\n");fflush(stdout);exit(1);} 
     1383                        } 
     1384                      break; 
     1385                    case 5: 
     1386                      switch(itos(r)) 
     1387                        { 
     1388                        case 0: case 5: condp=2; 
     1389                          printf("[I{0}-II*-%ld] page 160, (1)",(d-5)/6); 
     1390                          fflush(stdout);break; 
     1391                        case 1: case 4: condp=4; 
     1392                          printf("[II-IV*-%ld] page 164, (3)",(d-5)/6); 
     1393                          fflush(stdout);break; 
     1394                        case 2: case 3: condp=4; 
     1395                          printf("[I*{0}-IV-%ld] page 161, (2)^2x(3)",(d-5)/6); 
     1396                          fflush(stdout);break; 
     1397                        } 
     1398                      break; 
     1399                    default: {printf("bug33\n");fflush(stdout);exit(1);} 
     1400                    } 
     1401                  break; 
     1402                case 12: 
     1403                  switch(itos(dm)) 
     1404                    { 
     1405                    case 1: 
     1406                      switch(itos(r)) 
     1407                        { 
     1408                        case 3: case 10: condp=4; 
     1409                          printf("[II*-III-%ld] page 166-167, (2)",(d-13)/12); 
     1410                          fflush(stdout);break; 
     1411                        case 4: case 9: condp=4; 
     1412                          printf("[IV-III*-%ld] page 167, (6)",(d-13)/12); 
     1413                          fflush(stdout);break; 
     1414                        default: {printf("bug34\n");fflush(stdout);exit(1);} 
     1415                        } 
     1416                      break; 
     1417                    case 5: 
     1418                      switch(itos(r)) 
     1419                        { 
     1420                        case 2: case 3: condp=4; 
     1421                          printf("[II-III-%ld] page 166, (2)",(d-5)/12); 
     1422                          fflush(stdout);break; 
     1423                        case 8: case 9: condp=4; 
     1424                          printf("[IV*-III*-%ld] page 168, (6)",(d-17)/12); 
     1425                          fflush(stdout);break; 
     1426                        default: {printf("bug35\n");fflush(stdout);exit(1);} 
     1427                        } 
     1428                      break; 
     1429                    case 7: 
     1430                      switch(itos(r)) 
     1431                        { 
     1432                        case 3: case 4: condp=4; 
     1433                          printf("[IV-III-%ld] page 167, (6)",(d-7)/12); 
     1434                          fflush(stdout);break; 
     1435                        case 9: case 10: condp=4; 
     1436                          printf("[II*-III*-%ld] page 167, (2)",(d-19)/12); 
     1437                          fflush(stdout);break; 
     1438                        default: {printf("bug36\n");fflush(stdout);exit(1);} 
     1439                        } 
     1440                      break; 
     1441                    case 11: 
     1442                      switch(itos(r)) 
     1443                        { 
     1444                        case 3: case 8: condp=4; 
     1445                          printf("[IV*-III-%ld] page 168, (6)",(d-11)/12); 
     1446                          fflush(stdout);break; 
     1447                        case 2: case 9: condp=4; 
     1448                          printf("[II-III*-%ld] page 166, (2)",(d-11)/12); 
     1449                          fflush(stdout);break; 
     1450                        default: {printf("bug37\n");fflush(stdout);exit(1);} 
     1451                        } 
     1452                      break; 
     1453                    default: {printf("bug38\n");fflush(stdout);exit(1);} 
     1454                    } 
     1455                  break; 
     1456                default: {printf("bug39\n");fflush(stdout);exit(1);} 
     1457                } 
     1458            } 
     1459          else 
     1460            { 
     1461              r=gmod(r,gmul2n(n,-1)); 
     1462              switch(itos(n)) 
     1463                { 
     1464                case 2: condp=2; 
     1465                  printf("[2I{0}-%ld] page 159, (1)",(d/2)); 
     1466                  fflush(stdout);break; 
     1467                case 4: condp=4; 
     1468                  printf("[2I*{0}-%ld] page 159, (2)^2",(d/2-1)/2); 
     1469                  fflush(stdout);break; 
     1470                case 6: 
     1471                  switch(itos(r)) 
     1472                    { 
     1473                    case 1: condp=4; 
     1474                      printf("[2IV-%ld] page 165, (3)",(d/2-1)/3); 
     1475                      fflush(stdout);break; 
     1476                    case 2: condp=4; 
     1477                      printf("[2IV*-%ld] page 165, (3)",(d/2-2)/3); 
     1478                      fflush(stdout);break; 
     1479                    default: {printf("bug40\n");fflush(stdout);exit(1);} 
     1480                    } 
     1481                  break; 
     1482                case 8: 
     1483                  switch(itos(r)) 
     1484                    { 
     1485                    case 1: condp=4; 
     1486                      printf("[2III-%ld] page 168, (2)",(d/2-1)/4); 
     1487                      fflush(stdout);break; 
     1488                    case 3: condp=4; 
     1489                      printf("[2III*-%ld] page 168, (2)",(d/2-3)/4); 
     1490                      fflush(stdout);break; 
     1491                    default: {printf("bug41\n");fflush(stdout);exit(1);} 
     1492                    } 
     1493                  break; 
     1494                case 12: 
     1495                  switch(itos(r)) 
     1496                    { 
     1497                    case 1: condp=4; 
     1498                      printf("[2II-%ld] page 162, (1)",(d/2-1)/6); 
     1499                      fflush(stdout);break; 
     1500                    case 5: condp=4; 
     1501                      printf("[2II*-%ld] page 163, (1)",(d/2-5)/6); 
     1502                      fflush(stdout);break; 
     1503                    default: {printf("bug42\n");fflush(stdout);exit(1);} 
     1504                    } 
     1505                  break; 
     1506                default: {printf("bug43\n");fflush(stdout);exit(1);} 
     1507                } 
     1508            } 
     1509          break; 
     1510        case 6: 
     1511          d1=itos(gmul(n,d1k)); 
     1512          switch(itos(n)) 
     1513            { 
     1514            case 1: condp=1; 
     1515              printf("[I{%ld}-I{0}-%ld] page 170, (%ld)",d1,d,d1); 
     1516              fflush(stdout);break; 
     1517            case 2: 
     1518              switch(itos(dm)) 
     1519                { 
     1520                case 0: condp=4; 
     1521                  printf("[I*{0}-I*{%ld}-%ld] page 171, (2)^2xH{%ld}", d1/2,(d-2)/2,d1/2); 
     1522                  fflush(stdout);break; 
     1523                case 1: goto labelm3; 
     1524                default: {printf("bug44\n");fflush(stdout);exit(1);} 
     1525                } 
     1526              break; 
     1527            case 3: 
     1528              switch(itos(dm)) 
     1529                { 
     1530                case 1: condp=3; 
     1531                  printf("[IV-I{%ld}-%ld] page 173, (3)x(%ld)",d1/3,(d-1)/3,d1/3); 
     1532                  fflush(stdout);break; 
     1533                case 2: condp=3; 
     1534                  printf("[IV*-I{%ld}-%ld] page 173, (3)x(%ld)",d1/3,(d-2)/3,d1/3); 
     1535                  fflush(stdout);break; 
     1536                default: {printf("bug45\n");fflush(stdout);exit(1);} 
     1537                } 
     1538              break; 
     1539            case 4: 
     1540              switch(itos(dm)) 
     1541                { 
     1542                case 1: 
     1543                  switch(itos(r)) 
     1544                    { 
     1545                    case 0: case 1: condp=3; 
     1546                      printf("[III-I{%ld}-%ld] page 176, (2)x(%ld)",d1/4,(d-1)/4,d1/4); 
     1547                      fflush(stdout);break; 
     1548                    case 2: case 3: condp=4; 
     1549                      printf("[III*-I*{%ld}-%ld] page 177, (2)xH{%ld}",d1/4,(d-5)/4,d1/4); 
     1550                      fflush(stdout);break; 
     1551                    default: {printf("bug46\n");fflush(stdout);exit(1);} 
     1552                    } 
     1553                  break; 
     1554                case 3: 
     1555                  switch(itos(r)) 
     1556                    { 
     1557                    case 0: case 3: condp=3; 
     1558                      printf("[III*-I{%ld}-%ld] page 176, (2)x(%ld)",d1/4,(d-3)/4,d1/4); 
     1559                      fflush(stdout);break; 
     1560                    case 1: case 2: condp=4; 
     1561                      printf("[III-I*{%ld}-%ld] page 177, (2)xH{%ld}",d1/4,(d-3)/4,d1/4); 
     1562                      fflush(stdout);break; 
     1563                    default: {printf("bug47\n");fflush(stdout);exit(1);} 
     1564                    } 
     1565                  break; 
     1566                default: {printf("bug48\n");fflush(stdout);exit(1);} 
     1567                } 
     1568              break; 
     1569            case 6: 
     1570              switch(itos(dm)) 
     1571                { 
     1572                case 1: 
     1573                  switch(itos(r)) 
     1574                    { 
     1575                    case 0: case 1: condp=3; 
     1576                      printf("[II-I{%ld}-%ld] page 172, (%ld)",d1/6,(d-1)/6,d1/6); 
     1577                      fflush(stdout);break; 
     1578                    case 3: case 4: condp=4; 
     1579                      printf("[IV*-I*{%ld}-%ld] page 174-175, (3)xH{%ld}",d1/6,(d-7)/6,d1/6); 
     1580                      fflush(stdout);break; 
     1581                    default: {printf("bug49\n");fflush(stdout);exit(1);} 
     1582                    } 
     1583                  break; 
     1584                case 2: condp=4; 
     1585                  printf("[II*-I*{%ld}-%ld] page 174, H{%ld}",d1/6,(d-8)/6,d1/6); 
     1586                  fflush(stdout);break; 
     1587                case 4: condp=4; 
     1588                  printf("[II-I*{%ld}-%ld] page 173, H{%ld}",d1/6,(d-4)/6,d1/6); 
     1589                  fflush(stdout);break; 
     1590                case 5: 
     1591                  switch(itos(r)) 
     1592                    { 
     1593                    case 0: case 5: condp=3; 
     1594                      printf("[II*-I{%ld}-%ld] page 172, (%ld)",d1/6,(d-5)/6,d1/6); 
     1595                      fflush(stdout);break; 
     1596                    case 2: case 3: condp=4; 
     1597                      printf("[IV-I*{%ld}-%ld] page 174, (3)xH{%ld}",d1/6,(d-5)/6,d1/6); 
     1598                      fflush(stdout);break; 
     1599                    default: {printf("bug50\n");fflush(stdout);exit(1);} 
     1600                    } 
     1601                  break; 
     1602                default: {printf("bug51\n");fflush(stdout);exit(1);} 
     1603                } 
     1604              break; 
     1605            default: {printf("bug52\n");fflush(stdout);exit(1);} 
     1606            } 
     1607          break; 
     1608        case 7: 
     1609          j2m=val[eps2]&1;d1=itos(gmul(n,d1k));d2=itos(gmul(n,d2k)); 
     1610          switch(itos(n)) 
     1611            { 
     1612            case 1: condp=2; 
     1613              printf("[I{%ld}-I{%ld}-%ld] page 179, (%ld)x(%ld)",d1,d2,d,d1,d2); 
     1614              fflush(stdout);break; 
     1615            case 2: 
     1616              if(j2m) 
     1617                { 
     1618                  condp=3;printf("[2I{%ld}-%ld] page 181, (%ld)",d1,d/2,d1); 
     1619                  fflush(stdout); 
     1620                } 
     1621             else 
     1622               { 
     1623                 if(itos(dm)==0) 
     1624                   { 
     1625                     condp=4; 
     1626                     printf("[I*{%ld}-I*{%ld}-%ld] page 180, H{%ld}xH{%ld}", 
     1627                            d1/2,d2/2,(d-2)/2, d1/2, d2/2); 
     1628                     fflush(stdout); 
     1629                   } 
     1630                 else 
     1631                   { 
     1632                     if(d1==d2) 
     1633                       { 
     1634                         condp=3;  
     1635                         printf("[I{%ld}-I*{%ld}-%ld] page 180, (%ld)xH{%ld}", 
     1636                                d1/2,d1/2,(d-1)/2,d1/2,d1/2); 
     1637                         fflush(stdout); 
     1638                       } 
     1639                     else goto labelm3; 
     1640                   } 
     1641               } 
     1642              break; 
     1643            case 4: condp=4; 
     1644              printf("[2I*{%ld}-%ld] page 181, H{%ld}",d1/2,(d-2)/4,d1/2); 
     1645              fflush(stdout);break; 
     1646            default: {printf("bug55\n");fflush(stdout);exit(1);} 
     1647            } 
     1648          break; 
     1649        default: {printf("bug56\n");fflush(stdout);exit(1);}       
     1650        } 
     1651      break;    
     1652    default: {printf("bug57\n");fflush(stdout);exit(1);} 
     1653    } 
     1654  printf(", f=%ld\n",condp);fflush(stdout); 
     1655  goto recp; 
     1656} 
     1657 
     1658long 
     1659polval(GEN pol, GEN p)      /* la plus grande puissance de p divisant pol */ 
     1660{ 
     1661  long lx,v,i; 
     1662 
     1663  lx=lg(pol); 
     1664  if(!signe(pol)) return EXP220; 
     1665  else 
     1666  { 
     1667    v=myval((GEN)pol[2],p); 
     1668    for(i=3;i<lx;i++) v=min(myval((GEN)pol[i],p),v); 
     1669  } 
     1670  return v; 
     1671} 
     1672 
     1673/* Factorisation p-adique (sur Q_p) a l'ordre r d'un polynome pol, de  
     1674contenu non divisible par p et sans racine multiple. Le resultat est 
     1675un vecteur. */  
     1676 
     1677GEN 
     1678factorpadicnonun(GEN pol, GEN p, long r)  
     1679{ 
     1680  long lx=lg(pol),vx=varn(pol),i,contpol,nb; 
     1681  GEN td,list,ep,fact,upol; 
     1682   
     1683  if(gequal1(td=(GEN)pol[lx-1]))  
     1684    { 
     1685      list=(GEN)factorpadic(pol,p,r)[1]; 
     1686      return list; 
     1687    } 
     1688  else 
     1689    { 
     1690      contpol=polval(pol,p); 
     1691      if(contpol) {printf("contenu non trivial, erreur\n");fflush(stdout);exit(1);} 
     1692      pol=gdiv(pol,gpowgs(p,contpol)); 
     1693      r=(lx-4)*ggval(td,p)+r; 
     1694      upol=gsubst(gmul(pol,gpowgs(td,lx-4)),vx,gdiv(pol_x(vx),td)); 
     1695      fact=gsubst(factorpadic(upol,p,r),vx,gmul(pol_x(vx),td)); 
     1696      list=(GEN)fact[1];ep=(GEN)fact[2];nb=lg(list)-1; 
     1697      for(i=1;i<=nb;i++) 
     1698        if(!gequal1((GEN)ep[i]))  
     1699          { 
     1700            printf("erreur, racine multiple\n");fflush(stdout);exit(1); 
     1701          }  
     1702      for(i=1;i<=nb;i++) 
     1703        /* (GEN)list[i] = gdiv((GEN)list[i],gpowgs(p,polval((GEN)list[i],p))); */ 
     1704        list[i] = (long) gdiv((GEN)list[i],gpowgs(p,polval((GEN)list[i],p)));  
     1705    } 
     1706  return list; 
     1707} 
     1708   
     1709GEN  
     1710polymini(GEN pol, GEN p)   /* polynome minimal dans Z_p, p\ne 2 */ 
     1711{ 
     1712  GEN polh,polhp,fac,rac,ent,pent,theta,polf,pro; 
     1713  long alpha,i,lambda,maxord,beta; 
     1714 
     1715  polf=cgetg(7,18); 
     1716 rec1: 
     1717  alpha=polval(pol,p);polh=gdiv(pol,gpowgs(p,alpha)); 
     1718  if(gdvd(truecoeff(polh,6),p)&&gdvd(truecoeff(polh,5),p)&&gdvd(truecoeff(polh,4),p)&&gdvd(truecoeff(polh,3),p)) 
     1719    {polh=gmul(gpowgs(pol_x(0),6),gsubst(polh,0,ginv(pol_x(0))));} 
     1720  alpha=alpha&1;       
     1721  beta=0;   
     1722  lambda=0;  
     1723  for(i=1;i<=3;i++) 
     1724    { 
     1725      if(!gdvd(truecoeff(polh,6-i),p)) lambda=i; 
     1726    } 
     1727    
     1728 labelm6: 
     1729  theta=caltheta(polh,p,lambda); 
     1730  polf[5]=(long)gen_0;          /* 1 si racine d'ordre 3 non dans F_p, 0 sinon */ 
     1731  if(gcmp(theta,gen_1)>=0) 
     1732    {  
     1733      ent=gfloor(theta);pent=gpow(p,ent,0); 
     1734      polh=gdiv(gsubst(polh,0,gmul(pent,pol_x(0))),gpowgs(pent,6-lambda)); 
     1735      alpha=(alpha+lambda*itos(ent))&1; 
     1736      beta=beta+itos(ent); 
     1737      theta=gsub(theta,ent); 
     1738    } 
     1739  polhp=gmul(gmodulo(gen_1,p),polh); 
     1740  if(gequal0(theta)) 
     1741    { 
     1742      fac=factmz(polhp,p); 
     1743      maxord=itos((GEN)fac[1]); 
     1744      if(maxord>=3) 
     1745        { 
     1746          rac=(GEN)fac[2]; 
     1747          if(lg(rac)==5)  
     1748            { 
     1749              polf[5]=(long)gen_1; 
     1750              goto sortie; 
     1751            }  
     1752          rac=lift(gdiv(gneg(truecoeff(rac,0)),truecoeff(rac,1))); 
     1753          polh=gsubst(polh,0,gadd(pol_x(0),rac)); 
     1754          lambda=6-maxord; goto labelm6; 
     1755        } 
     1756      if(maxord<=2&&lg(polhp)>=7) goto sortie; 
     1757    } 
     1758  if(lambda<=2) 
     1759    {  
     1760      if((myval(truecoeff(polh,2),p)>1-alpha)&&(myval(truecoeff(polh,1),p)>2-alpha)&&(myval(truecoeff(polh,0),p)>3-alpha)) 
     1761        { 
     1762          pol=gsubst(polh,0,gmul(p,pol_x(0))); 
     1763          if(alpha) pol=gmul(p,pol);  
     1764          goto rec1; 
     1765        } 
     1766      goto sortie; 
     1767    } 
     1768  if(lambda==3&&alpha==1) 
     1769    { 
     1770      if(lg(polhp)==6) 
     1771        { 
     1772          if(myval(truecoeff(polh,6),p)>=3&&myval(truecoeff(polh,5),p)>=2) 
     1773            { 
     1774              polh=gmul(gsubst(polh,0,gdiv(pol_x(0),p)),gpowgs(p,3)); 
     1775              theta=gadd(theta,gen_1); 
     1776              alpha=0; 
     1777              beta=beta-1;  
     1778              goto sortie;             
     1779            } 
     1780        } 
     1781      if(lg(polhp)==9&&!gequal0(theta)) 
     1782        { 
     1783          pro=gdiv(polhp,gpowgs(pol_x(0),3)); 
     1784          fac=factmz(pro,p); 
     1785          if(!cmpis((GEN)fac[1],3)) 
     1786            { 
     1787              rac=(GEN)fac[2]; 
     1788              rac=lift(gdiv(gneg(truecoeff(rac,0)),truecoeff(rac,1))); 
     1789              pro=gsubst(polh,0,gadd(rac,gmul(p,pol_x(0)))); 
     1790              if(polval(pro,p)>=3) 
     1791                { 
     1792                  polh=gdiv(pro,gpowgs(p,3)); 
     1793                  alpha=0; 
     1794                  beta=beta-1;  
     1795                  theta=caltheta(polh,p,3); 
     1796                } 
     1797            } 
     1798        } 
     1799    } 
     1800 sortie: 
     1801  polf[1]=(long)polh; 
     1802  polf[2]=(long)stoi(lambda);   
     1803  polf[3]=(long)theta; 
     1804  polf[4]=(long)stoi(alpha); 
     1805  polf[6]=(long)stoi(beta); 
     1806  return polf; 
     1807} 
     1808 
     1809GEN 
     1810caltheta(GEN pol, GEN p, long lambda) 
     1811{ 
     1812  GEN theta,b; 
     1813  long i; 
     1814  b=cgetg(8,17); 
     1815  b[1]=(long)truecoeff(pol,6);b[2]=(long)truecoeff(pol,5); 
     1816  b[3]=(long)truecoeff(pol,4);b[4]=(long)truecoeff(pol,3); 
     1817  b[5]=(long)truecoeff(pol,2);b[6]=(long)truecoeff(pol,1); 
     1818  b[7]=(long)truecoeff(pol,0); 
     1819  theta=stoi(myval((GEN)b[2+lambda],p)); 
     1820  for(i=2+lambda;i<=6;i++) 
     1821    theta=gmin(theta,gdivgs(stoi(myval((GEN)b[i+1],p)),i-lambda)); 
     1822  return theta; 
     1823} 
     1824 
     1825long 
     1826discpart(GEN polh, GEN p, long ord)    
     1827/* discriminant d'un facteur p-adic de degre 3 */ 
     1828{ 
     1829  GEN polhp,list,facti,prod,dis; 
     1830  long i,j,fl; 
     1831   
     1832  polhp=gmul(gmodulo(gen_1,p),polh); 
     1833  if(lg(polhp)!=6)  
     1834    {printf("bug, on ne doit pas arriver dans discpart");fflush(stdout);exit(1);} 
     1835  list=factorpadicnonun(polh,p,ord); 
     1836  prod=pol_1(varn(polh)); 
     1837  for(i=1;i<lg(list);i++) 
     1838    { 
     1839      facti=(GEN)list[i]; 
     1840      fl=0; 
     1841      for(j=2;j<lg(facti);j++)  
     1842        { 
     1843          if(!valp(facti[j])&&j>=3) fl=1; 
     1844        } 
     1845      if(fl) 
     1846        {prod=gmul(prod,facti);}  
     1847    } 
     1848  if(lg(prod)!=6) 
     1849    {printf("bug, degre de prod");fflush(stdout);exit(1);} 
     1850  dis=discsr(prod); 
     1851  if(gequal0(dis)) return ord+1; 
     1852  else return valp(dis); 
     1853} 
     1854 
     1855long 
     1856myvalzi(GEN b) /* valuation par rapport a 3 dans Z[i] */  
     1857{ 
     1858  return min(myval(greal(b),stoi(3)),myval(gimag(b),stoi(3))); 
     1859} 
     1860 
     1861GEN  
     1862polyminizi(GEN pol) /* polynome minimal dans Z[i] */ 
     1863{ 
     1864  GEN p,polh,ent,pent,unmodp,rac,theta,polf; 
     1865  long alpha,beta; 
     1866 
     1867  polf=cgetg(4,18); 
     1868  p=stoi(3); 
     1869  unmodp=gmodulo(gen_1,p); 
     1870  alpha=polval(pol,p)&1; 
     1871  polh=pol; 
     1872  if(alpha) polh=gdiv(pol,p); 
     1873  beta=0;   
     1874  rac=gadd(lift(gdiv(gmul(unmodp,truecoeff(polh,3)),gmul(unmodp,truecoeff(polh,6)))),gen_I()); 
     1875   
     1876 labelm6: 
     1877  polh=gsubst(polh,0,gadd(pol_x(0),rac));   
     1878  theta=calthetazi(polh); 
     1879  if(gcmp(theta,gen_1)>=0) 
     1880    {  
     1881      ent=gfloor(theta);pent=gpow(p,ent,0); 
     1882      polh=gdiv(gsubst(polh,0,gmul(pent,pol_x(0))),gpowgs(pent,3)); 
     1883      alpha=(alpha+itos(ent))&1; 
     1884      beta=beta+itos(ent); 
     1885      theta=gsub(theta,ent); 
     1886    } 
     1887  if(gequal0(theta)) 
     1888    { 
     1889      if(myvalzi(truecoeff(polh,2))&&myvalzi(truecoeff(polh,1))) 
     1890        { 
     1891          rac=gdiv(gmul(unmodp,truecoeff(polh,0)),gmul(unmodp,truecoeff(polh,3))); 
     1892          rac=lift(gneg(gmul(gmul(rac,rac),rac))); 
     1893          goto labelm6; 
     1894        } 
     1895    } 
     1896  if(alpha) 
     1897    { 
     1898      if(myvalzi(truecoeff(polh,6))>=3&&myvalzi(truecoeff(polh,5))>=2&&myvalzi(truecoeff(polh,4))>=1) 
     1899        { 
     1900          polh=gmul(gsubst(polh,0,gdiv(pol_x(0),p)),gpowgs(p,3)); 
     1901          theta=gadd(theta,gen_1); 
     1902          beta=beta-1; 
     1903          alpha=0;       
     1904        } 
     1905    } 
     1906  polf[1]=(long)theta; 
     1907  polf[2]=(long)stoi(alpha); 
     1908  polf[3]=(long)stoi(beta); 
     1909  return polf; 
     1910} 
     1911 
     1912GEN 
     1913calthetazi(GEN polh) 
     1914/* on calcule theta (avec lambda=3) pour un polh a coefficients dans Z[i] */ 
     1915{ 
     1916  GEN theta; 
     1917 
     1918  theta=gmin(stoi(myvalzi(truecoeff(polh,2))),gmul2n(stoi(myvalzi(truecoeff(polh,1))),-1)); 
     1919  theta=gmin(theta,gdivgs(stoi(myvalzi(truecoeff(polh,0))),3)); 
     1920  return theta; 
     1921} 
     1922 
     1923long 
     1924myvalzi2(GEN b)  
     1925/* on calcule la valuation de b dans Z[i, Y]/(Y^2-3) */ 
     1926 { 
     1927  b=lift(b); 
     1928  return min(2*myvalzi(truecoeff(b,0)),2*myvalzi(truecoeff(b,1))+1); 
     1929} 
     1930 
     1931GEN 
     1932calthetazi2(GEN polh)    
     1933/* on calcule theta (avec lambda=3) d'un polh a coefficients  
     1934dans Z[i, Y]/(Y^2-3) */ 
     1935{ 
     1936  GEN theta; 
     1937 
     1938  theta=gmin(stoi(myvalzi2(truecoeff(polh,2))),gmul2n(stoi(myvalzi2(truecoeff(polh,1))),-1)); 
     1939  theta=gmin(theta,gdivgs(stoi(myvalzi2(truecoeff(polh,0))),3)); 
     1940  return theta; 
     1941} 
     1942 
     1943GEN  
     1944polyminizi2(GEN pol)   /* polynome minimal dans Z_3[i,Y]/(Y^2-3) */ 
     1945{ 
     1946  GEN p,polh,ent,pent,rac,theta,polf,y,b3,b6; 
     1947  long alpha,beta; 
     1948   
     1949  p=stoi(3); 
     1950  polf=cgetg(3,18); 
     1951  y=readseq("Mod(y,y^2-3)"); 
     1952  if(polval(pol,p))  
     1953    {printf("bug, le polynome n'est pas minimal\n");fflush(stdout);exit(1);} 
     1954  polh=pol;alpha=0; 
     1955  beta=0;   
     1956  polh=gdivgs(gsubst(polh,0,gmul(pol_x(0),y)),27); 
     1957  if(myvalzi2(truecoeff(polh,4))>0&&myvalzi2(truecoeff(polh,2))>0)   
     1958    { 
     1959      if(myvalzi2(gsub(truecoeff(polh,6),truecoeff(polh,0)))>0) rac=gen_I(); 
     1960      else rac=gen_1; 
     1961    } 
     1962  else  
     1963    { 
     1964      theta=gen_0; 
     1965      goto sortie; 
     1966    } 
     1967 
     1968 labelm6: 
     1969  polh=gsubst(polh,0,gadd(pol_x(0),rac));   
     1970  theta=calthetazi2(polh); 
     1971  if(gcmp(theta,gen_1)>=0) 
     1972    {  
     1973      ent=gfloor(theta);pent=gpow(y,ent,0); 
     1974      polh=gdiv(gsubst(polh,0,gmul(pent,pol_x(0))),gpowgs(pent,3)); 
     1975      alpha=(alpha+itos(ent))&1; 
     1976      beta=beta+itos(ent); 
     1977      theta=gsub(theta,ent); 
     1978    } 
     1979  if(gequal0(theta)) 
     1980    { 
     1981      if(myvalzi2(truecoeff(polh,2))&&myvalzi2(truecoeff(polh,1))) 
     1982        { 
     1983          b3=zi2mod(truecoeff(polh,3)); 
     1984          b6=zi2mod(truecoeff(polh,0)); 
     1985          rac=gdiv(b6,gneg(b3)); 
     1986          rac=lift(gmul(gmul(rac,rac),rac)); 
     1987          goto labelm6; 
     1988        } 
     1989    } 
     1990  if(alpha) 
     1991    { 
     1992      if(myvalzi2(truecoeff(polh,6))>=3&&myvalzi2(truecoeff(polh,5))>=2&&myvalzi2(truecoeff(polh,5))>=1) 
     1993        { 
     1994          theta=gadd(theta,gen_1); 
     1995          beta=beta-1; 
     1996          alpha=0;       
     1997        } 
     1998      else 
     1999        { 
     2000          printf("bug dans polyminizi2\n");fflush(stdout);exit(1); 
     2001        } 
     2002    } 
     2003 sortie: 
     2004  polf[1]=(long)theta; 
     2005  polf[2]=(long)stoi(beta); 
     2006  return polf; 
     2007} 
     2008 
     2009GEN 
     2010zi2mod(GEN u)  /* u est un element de Z[i,Y]/(Y^2-3), on calcule u modulo y */  
     2011{ 
     2012  GEN a,b,unmodp; 
     2013 
     2014  unmodp=gmodulo(gen_1,stoi(3)); 
     2015  u=truecoeff(lift(u),0); 
     2016  a=gmul(unmodp,greal(u)); 
     2017  b=gmul(unmodp,gimag(u)); 
     2018  u=gadd(a,gmul(b,gen_I())); 
     2019  return u; 
     2020} 
     2021 
     2022GEN 
     2023factmz(GEN polhp, GEN p)   
     2024/* donne un facteur de multiplicite maximale d'un polynome  
     2025   dans F_p de degre <7 */ 
     2026{ 
     2027  GEN dh,z,b,fac; 
     2028  long m,i,vx,l; 
     2029   
     2030  b=cgetg(3,18); 
     2031  m=0; 
     2032  z=polhp; 
     2033  if(gcmp(p,stoi(5))<=0) 
     2034    { 
     2035      if(!gequal0(discsr(polhp))) m=1; 
     2036      else 
     2037        { 
     2038          fac=(GEN)factmod(polhp,p); 
     2039          for(i=1;i<lg((GEN)fac[2]);i++)  
     2040            m=max(m,itos(gcoeff(fac,i,2))); 
     2041          for(i=1;i<lg((GEN)fac[1]);i++)  
     2042            if(!cmpis(gcoeff(fac,i,2),m)) l=i; 
     2043          z=gcoeff(fac,l,1); 
     2044        } 
     2045      b[1]=(long)stoi(m); 
     2046      b[2]=(long)z; 
     2047      return b; 
     2048    } 
     2049  dh=polhp; 
     2050  vx=varn(polhp);  
     2051 lab: 
     2052  m=m+1;  
     2053  dh=deriv(dh,vx); 
     2054  if(lg(ggcd(z,dh))<=3) goto sort1; 
     2055  z=ggcd(z,dh);     
     2056  goto lab; 
     2057 sort1: 
     2058  if(m>=3 && lg(z)==5) 
     2059    { 
     2060      fac=(GEN)factmod(z,p); 
     2061      z=gcoeff(fac,1,1); 
     2062    } 
     2063 sort: 
     2064  b[1]=(long)stoi(m); 
     2065  b[2]=(long)z; 
     2066  return b; 
     2067}