Karim BELABAS on Tue, 19 Jan 1999 18:43:37 +0100 (MET) |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: nf.sign in 2.0.12 |
[Ilya:] > I see no purpose for the current user interface without (..., 3). The > result cannot be used without an additional check for the polynomial > to be monic, or the length of the result to be 2. Thus the automatic > conversion to monic does not simplify the program at all, but makes it > harder to understand. > > The only acceptable explanation for the current behaviour I can see > now would be something like > > "We are working over making all the places which accept nf to > accept [nf,var_change] too." > > but apparenlty it is not so. > [...] > I made an experiment: I had the documentation before my eyes, but > could not understand how to use nfinit(). This is a serious datapoint > against the current user interface. ;-) Ok, you have a point. The following patch implements the behaviour deemed acceptable above. You get the same warning as before, but then nf and bnf are accepted in the form [(b)nf, t_POLMOD]. Karim. *** src/basemath/base1.c.orig Mon Jan 18 18:35:40 1999 --- src/basemath/base1.c Tue Jan 19 18:26:09 1999 *************** *** 16,31 **** if (lg(rnf)!=12) err(idealer1); } ! void checkbnf(GEN bnf) { if (typ(bnf)!=t_VEC) err(idealer1); ! if (lg(bnf)!=11) { ! if (lg(bnf)==10 && typ(bnf[1])==t_POL) ! err(talker,"please apply bnfinit first"); ! err(idealer1); } } GEN --- 16,38 ---- if (lg(rnf)!=12) err(idealer1); } ! GEN checkbnf(GEN bnf) { if (typ(bnf)!=t_VEC) err(idealer1); ! switch (lg(bnf)) { ! case 11: return bnf; ! case 10: ! if (typ(bnf[1])==t_POL) ! err(talker,"please apply bnfinit first"); ! break; ! case 3: ! if (typ(bnf[2])==t_POLMOD) ! return checkbnf((GEN)bnf[1]); } + err(idealer1); + return NULL; /* not reached */ } GEN *************** *** 33,40 **** { if (typ(nf)==t_POL) err(talker,"please apply nfinit first"); if (typ(nf)!=t_VEC) err(idealer1); ! if (lg(nf)==10) return nf; ! if (lg(nf)==11) return checknf((GEN)nf[7]); err(idealer1); return NULL; /* not reached */ } --- 40,51 ---- { if (typ(nf)==t_POL) err(talker,"please apply nfinit first"); if (typ(nf)!=t_VEC) err(idealer1); ! switch(lg(nf)) ! { ! case 10: return nf; ! case 11: return checknf((GEN)nf[7]); ! case 3: if (typ(nf[2]) == t_POLMOD) return checknf((GEN)nf[1]); ! } err(idealer1); return NULL; /* not reached */ } *************** *** 44,50 **** { if (typ(bnr)!=t_VEC || lg(bnr)!=7) err(talker,"incorrect bigray field"); ! checkbnf((GEN)bnr[1]); } void --- 55,61 ---- { if (typ(bnr)!=t_VEC || lg(bnr)!=7) err(talker,"incorrect bigray field"); ! (void)checkbnf((GEN)bnr[1]); } void *************** *** 2213,2219 **** long av=avma,tetpil,j,N,n; GEN p1,id,Az,Iz,nf,A,I; ! checkbnf(bnf); if (typ(order)!=t_VEC || lg(order)<3) err(talker,"not a pseudo-basis in nfsimplifybasis"); A=(GEN)order[1]; I=(GEN)order[2]; n=lg(A)-1; nf=(GEN)bnf[7]; --- 2375,2381 ---- long av=avma,tetpil,j,N,n; GEN p1,id,Az,Iz,nf,A,I; ! bnf = checkbnf(bnf); if (typ(order)!=t_VEC || lg(order)<3) err(talker,"not a pseudo-basis in nfsimplifybasis"); A=(GEN)order[1]; I=(GEN)order[2]; n=lg(A)-1; nf=(GEN)bnf[7]; *************** *** 2333,2339 **** long av=avma,tetpil,j,N,n; GEN nf,A,I,classe,p1,p2,id; ! checkbnf(bnf); nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); if (typ(order)==t_POL) order=rnfpseudobasis(nf,order); if (typ(order)!=t_VEC || lg(order)<3) --- 2495,2501 ---- long av=avma,tetpil,j,N,n; GEN nf,A,I,classe,p1,p2,id; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); if (typ(order)==t_POL) order=rnfpseudobasis(nf,order); if (typ(order)!=t_VEC || lg(order)<3) *************** *** 2370,2376 **** long av=avma,tetpil,j,N,n; GEN nf,A,I,p1,id; ! checkbnf(bnf); nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); if (typ(order)==t_POL) { --- 2532,2538 ---- long av=avma,tetpil,j,N,n; GEN nf,A,I,p1,id; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); if (typ(order)==t_POL) { *************** *** 2403,2409 **** long av=avma,n,N,j; GEN nf,p1,id,I; ! checkbnf(bnf); if (gcmp1(gmael3(bnf,8,1,1))) return 1; nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); --- 2565,2571 ---- long av=avma,n,N,j; GEN nf,p1,id,I; ! bnf = checkbnf(bnf); if (gcmp1(gmael3(bnf,8,1,1))) return 1; nf=(GEN)bnf[7]; N=lgef(nf[1])-3; id=idmat(N); *** src/basemath/base3.c.orig Tue Dec 15 16:29:27 1998 --- src/basemath/base3.c Tue Jan 19 18:26:37 1999 *************** *** 1779,1785 **** init_units(GEN bnf, GEN *funits, GEN *racunit) { GEN p1; ! checkbnf(bnf); p1=(GEN)bnf[8]; if (lg(p1)==5) *funits=(GEN)buchfu(bnf)[1]; else { --- 1779,1785 ---- init_units(GEN bnf, GEN *funits, GEN *racunit) { GEN p1; ! bnf = checkbnf(bnf); p1=(GEN)bnf[8]; if (lg(p1)==5) *funits=(GEN)buchfu(bnf)[1]; else { *** src/basemath/buch1.c.orig Wed Dec 16 12:32:28 1998 --- src/basemath/buch1.c Tue Jan 19 18:33:16 1999 *************** *** 242,248 **** { if (typ(D)!=t_INT) { ! checkbnf(D); if (degree(gmael(D,7,1))!=2) err(talker,"not a polynomial of degree 2 in quadhilbert"); D=gmael(D,7,3); --- 242,248 ---- { if (typ(D)!=t_INT) { ! D = checkbnf(D); if (degree(gmael(D,7,1))!=2) err(talker,"not a polynomial of degree 2 in quadhilbert"); D=gmael(D,7,3); *************** *** 760,766 **** if (typ(D)!=t_INT) { ! bnf=D; checkbnf(bnf); if (degree(gmael(bnf,7,1))!=2) err(talker,"not a polynomial of degree 2 in quadray"); D=gmael(bnf,7,3); --- 760,766 ---- if (typ(D)!=t_INT) { ! bnf = checkbnf(D); if (degree(gmael(bnf,7,1))!=2) err(talker,"not a polynomial of degree 2 in quadray"); D=gmael(bnf,7,3); *** src/basemath/buch2.c.orig Tue Dec 15 16:29:35 1998 --- src/basemath/buch2.c Tue Jan 19 18:28:05 1999 *************** *** 610,616 **** GEN nf,xarch,reg,res,fu,y; long av=avma,tetpil,c,RU; ! checkbnf(bnf); nf = checknf(bnf); RU=itos(gmael(nf,2,1))+itos(gmael(nf,2,2)); res=(GEN)bnf[8]; if (lg(res)==7 && lg(res[5])==RU) --- 610,616 ---- GEN nf,xarch,reg,res,fu,y; long av=avma,tetpil,c,RU; ! bnf = checkbnf(bnf); nf = (GEN)bnf[7]; RU=itos(gmael(nf,2,1))+itos(gmael(nf,2,2)); res=(GEN)bnf[8]; if (lg(res)==7 && lg(res[5])==RU) *************** *** 934,942 **** long av = avma,c, tx = typ(x); GEN nf,y; ! if (typ(bnf)!=t_VEC || lg(bnf)!=11) ! err(talker,"not a big number field vector in isprincipal"); ! nf = checknf(bnf); if (tx==t_POLMOD || tx==t_POL) { if (tx==t_POLMOD) --- 934,940 ---- long av = avma,c, tx = typ(x); GEN nf,y; ! bnf = checkbnf(bnf); nf = (GEN)bnf[7]; if (tx==t_POLMOD || tx==t_POL) { if (tx==t_POLMOD) *************** *** 998,1004 **** long av=avma,tetpil,tx = typ(x),i,R1,RU,nru; GEN RES,matunit,y,p1,p2,p3,nf,ro1,pisurw,pish; ! checkbnf(bnf); nf=(GEN)bnf[7]; matunit=(GEN)bnf[3]; RU=lg(matunit); RES=(GEN)bnf[8]; ro1=(GEN)RES[4]; nru=itos((GEN)ro1[1]); --- 998,1004 ---- long av=avma,tetpil,tx = typ(x),i,R1,RU,nru; GEN RES,matunit,y,p1,p2,p3,nf,ro1,pisurw,pish; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; matunit=(GEN)bnf[3]; RU=lg(matunit); RES=(GEN)bnf[8]; ro1=(GEN)RES[4]; nru=itos((GEN)ro1[1]); *************** *** 1056,1062 **** long av,i,j,R1,RU,mun; GEN matunit,y,p1,p2,nf,pi; ! checkbnf(bnf); nf=checknf(bnf); matunit=(GEN)bnf[3]; RU=lg(matunit); R1=itos(gmael(nf,2,1)); pi=mppi(MEDDEFAULTPREC); y=cgetg(RU,t_MAT); mun = lnegi(gun); --- 1056,1062 ---- long av,i,j,R1,RU,mun; GEN matunit,y,p1,p2,nf,pi; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; matunit=(GEN)bnf[3]; RU=lg(matunit); R1=itos(gmael(nf,2,1)); pi=mppi(MEDDEFAULTPREC); y=cgetg(RU,t_MAT); mun = lnegi(gun); *************** *** 2134,2140 **** long av=avma,tetpil,k; GEN y,bnf,pfb,vp,nf,mas,res,uni,v1,v2,v3; ! if (typ(pol)==t_VEC) { checkbnf(pol); bnf=pol; } else bnf=buchall(pol,gcbach,gcbach2,gRELSUP,gborne,nbrelpid,minsfb,-3,prec); pfb=(GEN)bnf[5]; vp=(GEN)bnf[6]; nf=(GEN)bnf[7]; mas=(GEN)nf[5]; res=(GEN)bnf[8]; uni=(GEN)res[5]; --- 2134,2140 ---- long av=avma,tetpil,k; GEN y,bnf,pfb,vp,nf,mas,res,uni,v1,v2,v3; ! if (typ(pol)==t_VEC) bnf = checkbnf(pol); else bnf=buchall(pol,gcbach,gcbach2,gRELSUP,gborne,nbrelpid,minsfb,-3,prec); pfb=(GEN)bnf[5]; vp=(GEN)bnf[6]; nf=(GEN)bnf[7]; mas=(GEN)nf[5]; res=(GEN)bnf[8]; uni=(GEN)res[5]; *************** *** 2199,2205 **** long r1,r2,ru; GEN nf,ro,res,p1,y,funits,mun; ! checkbnf(bnf); nf = nfnewprec((GEN)bnf[7],prec); r1=itos(gmael(nf,2,1)); r2=itos(gmael(nf,2,2)); ru = r1+r2; --- 2199,2205 ---- long r1,r2,ru; GEN nf,ro,res,p1,y,funits,mun; ! bnf = checkbnf(bnf); nf = nfnewprec((GEN)bnf[7],prec); r1=itos(gmael(nf,2,1)); r2=itos(gmael(nf,2,2)); ru = r1+r2; *** src/basemath/buch3.c.orig Mon Jan 18 13:53:25 1999 --- src/basemath/buch3.c Tue Jan 19 18:29:49 1999 *************** *** 208,214 **** GEN racunit,bigres,bid,resbid2,resbid3,x,y,funits,hmat,vecel; long RU,R3,i,j,ngen,sizeh,lo,c,av=avma,tetpil,N; ! checkbnf(bnf); nf=checknf(bnf); bigres=(GEN)bnf[8]; if (lg(bigres)==5) funits=(GEN)buchfu(bnf)[1]; else { --- 208,214 ---- GEN racunit,bigres,bid,resbid2,resbid3,x,y,funits,hmat,vecel; long RU,R3,i,j,ngen,sizeh,lo,c,av=avma,tetpil,N; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; if (lg(bigres)==5) funits=(GEN)buchfu(bnf)[1]; else { *************** *** 404,410 **** GEN racunit,bigres,bid,resbid,resbid2,funits,hmat; long RU,R3,i,j,av=avma; ! checkbnf(bnf); nf=checknf(bnf); bigres=(GEN)bnf[8]; if (lg(bigres)==5) funits=(GEN)buchfu(bnf)[1]; else { --- 404,410 ---- GEN racunit,bigres,bid,resbid,resbid2,funits,hmat; long RU,R3,i,j,av=avma; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; if (lg(bigres)==5) funits=(GEN)buchfu(bnf)[1]; else { *************** *** 1201,1207 **** GEN big,nf,reg,rootsofone,funits,gen,p1,gbound,DK,alpha,factfd1,f1,h,cyc; byteptr delta = diffptr; ! checkbnf(bnf); nf = checknf(bnf); N=lgef(nf[1])-3; if (N==1) return 1; R1=itos(gmael(nf,2,1)); R2=itos(gmael(nf,2,2)); R=R1+R2-1; funits = (GEN)buchfu(bnf)[1]; --- 1201,1207 ---- GEN big,nf,reg,rootsofone,funits,gen,p1,gbound,DK,alpha,factfd1,f1,h,cyc; byteptr delta = diffptr; ! bnf = checkbnf(bnf); nf = (GEN)bnf[7]; N=lgef(nf[1])-3; if (N==1) return 1; R1=itos(gmael(nf,2,1)); R2=itos(gmael(nf,2,2)); R=R1+R2-1; funits = (GEN)buchfu(bnf)[1]; *************** *** 1313,1323 **** switch(lg(arg0)) { case 7: /* bnr */ ! bnr=arg0; bnf=(GEN) bnr[1]; checkbnf(bnf); *subgroup=arg1; break; case 11: /* bnf */ ! bnf=arg0; checkbnf(bnf); bnr=buchrayall(bnf,arg1,nf_INIT | nf_GEN,prec); *subgroup=arg2; break; --- 1313,1323 ---- switch(lg(arg0)) { case 7: /* bnr */ ! bnr=arg0; (void)checkbnf((GEN)bnr[1]); *subgroup=arg1; break; case 11: /* bnf */ ! bnf = checkbnf(arg0); bnr=buchrayall(bnf,arg1,nf_INIT | nf_GEN,prec); *subgroup=arg2; break; *************** *** 1485,1491 **** long av=avma,tetpil,R1,i,v; GEN nf,module,arch,bnr,group,p1,pol2; ! checkbnf(bnf); nf=(GEN)bnf[7]; module=cgetg(3,t_VEC); R1=itos(gmael(nf,2,1)); v=varn(polrel); p1=unifpol((GEN)bnf[7],polrel,0); --- 1485,1491 ---- long av=avma,tetpil,R1,i,v; GEN nf,module,arch,bnr,group,p1,pol2; ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; module=cgetg(3,t_VEC); R1=itos(gmael(nf,2,1)); v=varn(polrel); p1=unifpol((GEN)bnf[7],polrel,0); *************** *** 1677,1683 **** GEN h,modulist,unitlist,classlist,sous,sousu,sousclass,p2,m,bid,q,cyclic; if (typ(listes)!=t_VEC || lg(listes)!=3) err(typeer,"rayclassnolist"); ! checkbnf(bnf); h=gmael3(bnf,8,1,1); modulist=(GEN)listes[1]; unitlist=(GEN)listes[2]; lx=lg(modulist); classlist=cgetg(lx,t_VEC); for (i=1; i<lx; i++) --- 1677,1683 ---- GEN h,modulist,unitlist,classlist,sous,sousu,sousclass,p2,m,bid,q,cyclic; if (typ(listes)!=t_VEC || lg(listes)!=3) err(typeer,"rayclassnolist"); ! bnf = checkbnf(bnf); h=gmael3(bnf,8,1,1); modulist=(GEN)listes[1]; unitlist=(GEN)listes[2]; lx=lg(modulist); classlist=cgetg(lx,t_VEC); for (i=1; i<lx; i++) *************** *** 2112,2118 **** /* ce qui suit recopie d'assez pres ideallistzstarall */ if (DEBUGLEVEL>2) timer2(); if (bound <= 0) err(talker,"non-positive bound in discrayabslist"); ! av0=avma; checkbnf(bnf); flbou=0; nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; pol=(GEN)nf[1]; degk=lgef(pol)-3; r1=itos(gmael(nf,2,1)); fadkabs=factor(absi((GEN)nf[3])); clh=gmael(bigres,1,1); --- 2112,2118 ---- /* ce qui suit recopie d'assez pres ideallistzstarall */ if (DEBUGLEVEL>2) timer2(); if (bound <= 0) err(talker,"non-positive bound in discrayabslist"); ! av0=avma; bnf = checkbnf(bnf); flbou=0; nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; pol=(GEN)nf[1]; degk=lgef(pol)-3; r1=itos(gmael(nf,2,1)); fadkabs=factor(absi((GEN)nf[3])); clh=gmael(bigres,1,1); *** src/basemath/buch4.c.orig Tue Dec 15 16:29:37 1998 --- src/basemath/buch4.c Tue Jan 19 18:30:08 1999 *************** *** 477,483 **** GEN sunites,sunites_entieres,card,sreg,res,pow, modpol; if (typ(S) != t_VEC) err(typeer,"bnfsunit"); ! checkbnf(bnf); nf=checknf(bnf); pol = (GEN)nf[1]; d=lg(pol); classgp=gmael(bnf,8,1); l=lg(classgp[2]); cyc = (GEN)classgp[2]; gen = (GEN)classgp[3]; --- 477,483 ---- GEN sunites,sunites_entieres,card,sreg,res,pow, modpol; if (typ(S) != t_VEC) err(typeer,"bnfsunit"); ! bnf = checkbnf(bnf); nf=(GEN)bnf[7]; pol = (GEN)nf[1]; d=lg(pol); classgp=gmael(bnf,8,1); l=lg(classgp[2]); cyc = (GEN)classgp[2]; gen = (GEN)classgp[3]; *************** *** 605,611 **** long i,k,ls,tetpil, av = avma; GEN S,v,p1,xp,xm; ! checkbnf(bnf); if (typ(suni)!=t_VEC || lg(suni)!=7) err(typeer,"bnfissunit"); switch (typ(x)) { --- 605,611 ---- long i,k,ls,tetpil, av = avma; GEN S,v,p1,xp,xm; ! bnf = checkbnf(bnf); if (typ(suni)!=t_VEC || lg(suni)!=7) err(typeer,"bnfissunit"); switch (typ(x)) { *************** *** 682,688 **** GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); ! checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degree((GEN)ext[1])&1))) { res[1]=lcopy(x); res[2]=un; return res; --- 682,688 ---- GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); ! bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degree((GEN)ext[1])&1))) { res[1]=lcopy(x); res[2]=un; return res; *************** *** 790,796 **** long ltop = avma, lbot; GEN ext = cgetg(4,t_VEC); ! checkbnf(bnf); ext[1] = mael(bnf,7,1); ext[2] = zero; ext[3] = (long) bnf; --- 790,796 ---- long ltop = avma, lbot; GEN ext = cgetg(4,t_VEC); ! bnf = checkbnf(bnf); ext[1] = mael(bnf,7,1); ext[2] = zero; ext[3] = (long) bnf; *** src/headers/paridecl.h.orig Tue Jan 5 18:31:42 1999 --- src/headers/paridecl.h Tue Jan 19 18:25:58 1999 *************** *** 237,243 **** /* base1.c */ void checkbid(GEN bid); ! void checkbnf(GEN bnf); void checkbnr(GEN bnr); void checkbnrgen(GEN bnr); void checkid(GEN x, long N); --- 237,243 ---- /* base1.c */ void checkbid(GEN bid); ! GEN checkbnf(GEN bnf); void checkbnr(GEN bnr); void checkbnrgen(GEN bnr); void checkid(GEN x, long N); *** src/modules/thue.c.orig Tue Dec 15 16:30:33 1998 --- src/modules/thue.c Tue Jan 19 18:30:40 1999 *************** *** 25,31 **** deg=lgef(tnf[1])-3; if (deg<=2) err(talker,"invalid polynomial in thue (need deg>2)"); s=sturm((GEN)tnf[1]); t=(deg-s)>>1; r=s+t-1; ! checkbnf((GEN)tnf[2]); if (typ(tnf[3]) != t_COL || lg(tnf[3]) != deg+1) return 0; if (typ(tnf[4]) != t_COL || lg(tnf[4]) != r+1) return 0; if (typ(tnf[5]) != t_MAT || lg(tnf[5]) != r+1 --- 25,31 ---- deg=lgef(tnf[1])-3; if (deg<=2) err(talker,"invalid polynomial in thue (need deg>2)"); s=sturm((GEN)tnf[1]); t=(deg-s)>>1; r=s+t-1; ! (void)checkbnf((GEN)tnf[2]); if (typ(tnf[3]) != t_COL || lg(tnf[3]) != deg+1) return 0; if (typ(tnf[4]) != t_COL || lg(tnf[4]) != r+1) return 0; if (typ(tnf[5]) != t_MAT || lg(tnf[5]) != r+1 *************** *** 1068,1074 **** GEN nf,pol,res,unit,x,id, *Primes; long av = avma, tetpil,sa,i,j,norm_1; ! checkbnf(bnf); nf = checknf(bnf); pol = (GEN)nf[1]; if (typ(a)!=t_INT) err(talker,"expected an integer in bnfisintnorm"); sa = signe(a); --- 1068,1074 ---- GEN nf,pol,res,unit,x,id, *Primes; long av = avma, tetpil,sa,i,j,norm_1; ! bnf = checkbnf(bnf); nf = (GEN)bnf[7]; pol = (GEN)nf[1]; if (typ(a)!=t_INT) err(talker,"expected an integer in bnfisintnorm"); sa = signe(a); -- Karim Belabas email: Karim.Belabas@math.u-psud.fr Dep. de Mathematiques, Bat. 425 Universite Paris-Sud Tel: (00 33) 1 69 15 57 48 F-91405 Orsay (France) Fax: (00 33) 1 69 15 60 19 -- PARI/GP Home Page: http://pari.home.ml.org