Ilya Zakharevich on Sun, 10 Nov 2002 01:16:56 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: sizeof(long) > sizeof(long*)? |
On Mon, Nov 04, 2002 at 08:07:31PM +0100, Bill Allombert wrote: > On Fri, Nov 01, 2002 at 12:13:16AM -0800, Ilya Zakharevich wrote: > > On which architectures can PARI run with sizeof(long) > sizeof(long*)? > > I tested, and it does not work on x86. > > None, as far as I know. > None of the 11 architectures I have access to exhibit this behaviour. This patch kinda-allows compiling with GEN = long long*. The result of make bench is * Testing objets for gp-sta..TIME=480 * Testing analyz for gp-sta..TIME=540 * Testing number for gp-sta..TIME=760 * Testing polyser for gp-sta..BUG [0] * Testing linear for gp-sta..TIME=470 * Testing elliptic for gp-sta..TIME=590 * Testing sumiter for gp-sta..TIME=800 * Testing graph for gp-sta..TIME=190 * Testing program for gp-sta..BUG [360] * Testing trans for gp-sta..TIME=960 * Testing nfields for gp-sta..BUG [0] with program failing due to install() issues, and polyser and nfields being manually killed due to (apparent) infinite loops. It is out of my league to debug these problems - I get lost in the labirinth of small undocumented functions with zillions of undocumented arguments. [The polyser loop happens in polroots(x^5-5*x^2-5*x-5) - dft() is called again and again with increasing precision.] As I might guess, the current test suite may touch only circa 5% of the branches in the core, so the success of many tests is not a *very* good indication. In addition to long long, the patch also fixes one memory overrun (in vpariputs()), and wrong prototypes (see paridecl.h). Before applying the patch, a massive replace should be made, e.g., by running (pfind is available from my directory 'scripts' on CPAN): pfind src '/\.[ch]$/' '=~ s/\b(unsigned\s+|u)long\b/PARI_uword/g' pfind src '/\.[ch]$/' '=~ s/\blong\b/PARI_word/g' pfind src '/\.[ch]$/' '=~ s/\b(\d+|0[0-7]+|0x[\da-fA-F])(U?)L\b/as_${2}WORD($1)/g' pfind src '/\.[ch]$/' '=~ s/(%[.0-9]*)l([ux])\"/$1\"UW${2}f/g' pfind src '/\.[ch]$/' '=~ s/(%[.0-9]*)l([d])\"/$1\"IW${2}f/g' pfind src '/\.[ch]$/' '=~ s/(%[.0-9]*)l([ux])/$1\"UW${2}f\"/g' pfind src '/\.[ch]$/' '=~ s/(%[.0-9]*)l([d])/$1\"IW${2}f\"/g' See also the first XXXX comment in the text of the patch (for gaussmoduloall()). I'm not absolutely sure, but it may be little-endian specific. Two others XXXX's are for some incredibly fishy misuse of GENs - but I expect it to work with long long too. Enjoy, Ilya diff -pru pari-word-new2/src/basemath/alglin1.c pari-word-new1/src/basemath/alglin1.c --- pari-word-new2/src/basemath/alglin1.c Sun Nov 10 01:03:48 2002 +++ pari-word-new1/src/basemath/alglin1.c Sun Nov 10 00:26:24 2002 @@ -777,13 +777,14 @@ isscalarmat(GEN x, GEN s) for (j=1; j<=nco; j++) { - GEN *col = (GEN*) x[j]; + GEN col = VEC_elt(x,j); + for (i=1; i<=nco; i++) if (i == j) { - if (!gegal(col[i],s)) return 0; + if (!gegal(VEC_elt(col, i),s)) return 0; } - else if (!gcmp0(col[i])) return 0; + else if (!gcmp0(VEC_elt(col,i))) return 0; } return 1; } @@ -799,9 +800,9 @@ isdiagonal(GEN x) for (j=1; j<=nco; j++) { - GEN *col = (GEN*) x[j]; + GEN col = VEC_elt(x,j); for (i=1; i<=nco; i++) - if (i!=j && !gcmp0(col[i])) return 0; + if (i!=j && !gcmp0(VEC_elt(col,i))) return 0; } return 1; } @@ -1928,7 +1929,7 @@ deplin(GEN x0) { pari_sp av = avma; PARI_word i,j,k,t,nc,nl; - GEN x,y,piv,q,c,l,*d,*ck,*cj; + GEN x,y,piv,q,c,l,d,ck,cj; t = typ(x0); if (t == t_MAT) x = dummycopy(x0); @@ -1939,22 +1940,22 @@ deplin(GEN x0) } nc = lg(x)-1; if (!nc) err(talker,"empty matrix in deplin"); nl = lg(x[1])-1; - d = (GEN*)cgetg(nl+1,t_VEC); /* pivot list */ + d = cgetg(nl+1,t_VEC); /* pivot list */ c = cgetg(nl+1, t_VECSMALL); l = cgetg(nc+1, t_VECSMALL); /* not initialized */ - for (i=1; i<=nl; i++) { d[i] = gun; c[i] = 0; } + for (i=1; i<=nl; i++) { d[i] = un; c[i] = 0; } ck = NULL; /* gcc -Wall */ for (k=1; k<=nc; k++) { - ck = (GEN*)x[k]; + ck = VEC_elt(x,k); for (j=1; j<k; j++) { - cj = (GEN*)x[j]; piv = d[j]; q = gneg(ck[l[j]]); + cj = VEC_elt(x,j); piv = VEC_elt(d,j); q = gneg(VEC_elt(ck,l[j])); for (i=1; i<=nl; i++) - if (i != l[j]) ck[i] = gadd(gmul(piv, ck[i]), gmul(q, cj[i])); + if (i != l[j]) ck[i] = ladd(gmul(piv, VEC_elt(ck,i)), gmul(q, VEC_elt(cj,i))); } - i = gauss_get_pivot_NZ((GEN)ck, NULL, c, 1); + i = gauss_get_pivot_NZ(ck, NULL, c, 1); if (i > nl) break; d[k] = ck[i]; @@ -1963,11 +1964,11 @@ deplin(GEN x0) if (k > nc) { avma = av; return zerocol(nc); } if (k == 1) { avma = av; return gscalcol_i(gun,nc); } y = cgetg(nc+1,t_COL); - y[1] = (PARI_word)ck[ l[1] ]; - for (q=d[1],j=2; j<k; j++) + y[1] = ck[ l[1] ]; + for (q=VEC_elt(d,1),j=2; j<k; j++) { - y[j] = lmul(ck[ l[j] ], q); - q = gmul(q, d[j]); + y[j] = lmul(VEC_elt(ck, l[j]), q); + q = gmul(q, VEC_elt(d,j)); } y[j] = lneg(q); for (j++; j<=nc; j++) y[j] = zero; @@ -3152,7 +3153,7 @@ det(GEN a) a = dummycopy(a); s = 1; for (pprec=gun,i=1; i<nbco; i++,pprec=p) { - GEN *ci, *ck, m, p1; + GEN ci, ck, m, p1; int diveuc = (gcmp1(pprec)==0); p = gcoeff(a,i,i); @@ -3163,10 +3164,10 @@ det(GEN a) swap(a[k], a[i]); s = -s; p = gcoeff(a,i,i); } - ci = (GEN*)a[i]; + ci = VEC_elt(a,i); for (k=i+1; k<=nbco; k++) { - ck = (GEN*)a[k]; m = (GEN)ck[i]; + ck = VEC_elt(a,k); m = VEC_elt(ck,i); if (gcmp0(m)) { if (gcmp1(p)) @@ -3177,9 +3178,9 @@ det(GEN a) else for (j=i+1; j<=nbco; j++) { - p1 = gmul(p,ck[j]); + p1 = gmul(p,VEC_elt(ck,j)); if (diveuc) p1 = mydiv(p1,pprec); - ck[j] = p1; + VEC_elt_set(ck,j, p1); } } else @@ -3187,16 +3188,16 @@ det(GEN a) m = gneg_i(m); for (j=i+1; j<=nbco; j++) { - p1 = gadd(gmul(p,ck[j]), gmul(m,ci[j])); + p1 = gadd(gmul(p,VEC_elt(ck,j)), gmul(m,VEC_elt(ci,j))); if (diveuc) p1 = mydiv(p1,pprec); - ck[j] = p1; + VEC_elt_set(ck, j, p1); } } if (low_stack(lim,stack_lim(av,2))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&pprec; if(DEBUGMEM>1) err(warnmem,"det. col = %"IWdf,i); - gerepilemany(av,gptr,2); p = gcoeff(a,i,i); ci = (GEN*)a[i]; + gerepilemany(av,gptr,2); p = gcoeff(a,i,i); ci = VEC_elt(a,i); } } if (DEBUGLEVEL > 7) msgtimer("det, col %"IWdf" / %"IWdf,i,nbco-1); @@ -3210,7 +3211,7 @@ det(GEN a) * If ptu1 != NULL, put in *ptu1 a Z-basis of the homogeneous system */ static GEN -gaussmoduloall(GEN M, GEN D, GEN Y, GEN *ptu1) +gaussmoduloall(GEN M, GEN D, GEN Y, GEN ptu1) { pari_sp av = avma, tetpil; PARI_word n,m,i,j,lM; @@ -3262,7 +3263,9 @@ gaussmoduloall(GEN M, GEN D, GEN Y, GEN else { GEN *gptr[2]; - *ptu1=gcopy(u1); gptr[0]=ptu1; gptr[1]=&x; + *ptu1=lcopy(u1); + /* XXXX This pointer conversion assumes low-endian! */ + gptr[0]=(GEN*)ptu1; gptr[1]=&x; gerepilemanysp(av,tetpil,gptr,2); } return x; @@ -3277,7 +3280,7 @@ matsolvemod0(GEN M, GEN D, GEN Y, PARI_w if (!flag) return gaussmoduloall(M,D,Y,NULL); av=avma; y = cgetg(3,t_VEC); - p1 = gaussmoduloall(M,D,Y, (GEN*)y+2); + p1 = gaussmoduloall(M,D,Y, y+2); if (p1==gzero) { avma=av; return gzero; } y[1] = (PARI_word)p1; return y; } diff -pru pari-word-new2/src/basemath/alglin2.c pari-word-new1/src/basemath/alglin2.c --- pari-word-new2/src/basemath/alglin2.c Sun Nov 10 01:03:48 2002 +++ pari-word-new1/src/basemath/alglin2.c Sun Nov 10 00:26:24 2002 @@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place - Suit /*******************************************************************/ GEN -charpoly0(GEN x, int v, PARI_word flag) +charpoly0(GEN x, PARI_word v, PARI_word flag) { if (v<0) v = 0; switch(flag) @@ -2246,9 +2246,9 @@ mynegi(GEN x) } static void -Minus(PARI_word j, GEN **lambda) +Minus(PARI_word j, PARI_word n, GEN **lambda) { - PARI_word k, n = lg(lambda); + PARI_word k; for (k=1 ; k<j; k++) lambda[j][k] = mynegi(lambda[j][k]); for (k=j+1; k<n; k++) lambda[k][j] = mynegi(lambda[k][j]); @@ -2296,25 +2296,25 @@ findi(GEN M) } static PARI_word -findi_normalize(GEN Aj, GEN B, PARI_word j, GEN **lambda) +findi_normalize(GEN Aj, GEN B, PARI_word j, PARI_word n, GEN **lambda) { PARI_word r = findi(Aj); if (r && signe(Aj[r]) < 0) { neg_col(Aj); if (B) neg_col((GEN)B[j]); - Minus(j,lambda); + Minus(j,n,lambda); } return r; } static void -reduce2(GEN A, GEN B, PARI_word k, PARI_word j, PARI_word *row, GEN **lambda, GEN *D) +reduce2(GEN A, GEN B, PARI_word k, PARI_word j, PARI_word n, PARI_word *row, GEN **lambda, GEN *D) { GEN q; PARI_word i, row0, row1; - row[0] = row0 = findi_normalize((GEN)A[j], B,j,lambda); - row[1] = row1 = findi_normalize((GEN)A[k], B,k,lambda); + row[0] = row0 = findi_normalize((GEN)A[j], B,j,n,lambda); + row[1] = row1 = findi_normalize((GEN)A[k], B,k,n,lambda); if (row0) q = truedvmdii(gcoeff(A,row0,k), gcoeff(A,row0,j), NULL); else if (absi_cmp(shifti(lambda[k][j], 1), D[j]) > 0) @@ -2399,20 +2399,24 @@ hnflll_i(GEN A, GEN *ptB, int remove) pari_sp av = avma, lim = stack_lim(av,3); PARI_word m1 = 1, n1 = 1; /* alpha = m1/n1. Maybe 3/4 here ? */ PARI_word row[2], do_swap,i,n,k; - GEN z,B, **lambda, *D; + GEN z,B, lambda1, D1, **lambda, *D; if (typ(A) != t_MAT) err(typeer,"hnflll"); n = lg(A); A = ZM_copy(fix_rows(A)); B = ptB? idmat(n-1): NULL; - D = (GEN*)cgetg(n+1,t_VEC); lambda = (GEN**) cgetg(n,t_MAT); - D++; + D1 = cgetg(n+1,t_VEC); lambda1 = cgetg(n,t_MAT); + D = (GEN*)(D1+1); + lambda = ((GEN**)(lambda1+1))-1; for (i=0; i<n; i++) D[i] = gun; - for (i=1; i<n; i++) lambda[i] = (GEN*)zerocol(n-1); + for (i=1; i<n; i++) { + lambda[i] = ((GEN*)(cgetg(n,t_COL)+1))-1; + for (k=1; k<n; k++) lambda[i][k]=gzero; + } k = 2; while (k < n) { - reduce2(A,B,k,k-1,row,lambda,D); + reduce2(A,B,k,k-1,n,row,lambda,D); if (row[0]) do_swap = (!row[1] || row[0] <= row[1]); else if (!row[1]) @@ -2433,7 +2437,7 @@ hnflll_i(GEN A, GEN *ptB, int remove) { for (i=k-2; i; i--) { - reduce2(A,B,k,i,row,lambda,D); + reduce2(A,B,k,i,n,row,lambda,D); if (low_stack(lim, stack_lim(av,3))) { GEN b = (GEN)(D-1); @@ -2453,7 +2457,7 @@ hnflll_i(GEN A, GEN *ptB, int remove) } } /* handle trivial case: return negative diag coeff otherwise */ - if (n == 2) (void)findi_normalize((GEN)A[1], B,1,lambda); + if (n == 2) (void)findi_normalize((GEN)A[1], B,1,n,lambda); A = fix_rows(A); if (remove) { diff -pru pari-word-new2/src/basemath/arith2.c pari-word-new1/src/basemath/arith2.c --- pari-word-new2/src/basemath/arith2.c Sun Nov 10 01:03:48 2002 +++ pari-word-new1/src/basemath/arith2.c Sun Nov 10 00:26:26 2002 @@ -1032,7 +1032,7 @@ divisors(GEN n) { pari_sp tetpil,av=avma; PARI_word i,j,l; - GEN *d,*t,*t1,*t2,*t3, nbdiv,e; + GEN d, t, t1, t2, t3, nbdiv,e; if (typ(n) != t_MAT || lg(n) != 3) n = auxdecomp(n,1); @@ -1046,13 +1046,13 @@ divisors(GEN n) } if (is_bigint(nbdiv) || (itos(nbdiv) & ~LGBITS)) err(talker, "too many divisors (more than %"IWdf")", LGBITS - 1); - d = t = (GEN*) cgetg(itos(nbdiv)+1,t_VEC); + d = t = cgetg(itos(nbdiv)+1,t_VEC); *++d = gun; for (i=1; i<l; i++) for (t1=t,j=e[i]; j; j--,t1=t2) for (t2=d,t3=t1; t3<t2; ) - *++d = mulii(*++t3, (GEN)n[i]); - tetpil=avma; return gerepile(av,tetpil,sort((GEN)t)); + *++d = (PARI_word)mulii((GEN)*++t3, (GEN)n[i]); + tetpil=avma; return gerepile(av,tetpil,sort(t)); } static GEN diff -pru pari-word-new2/src/basemath/bibli1.c pari-word-new1/src/basemath/bibli1.c --- pari-word-new2/src/basemath/bibli1.c Sun Nov 10 01:03:48 2002 +++ pari-word-new1/src/basemath/bibli1.c Sun Nov 10 00:26:26 2002 @@ -340,19 +340,19 @@ lll_finish(GEN h,GEN fl,PARI_word flag) static void Zupdate_col(PARI_word k, PARI_word l, GEN q, PARI_word K, GEN h) { - GEN *hl, *hk; + GEN hl, hk; PARI_word i; if (!h) return; - hl = (GEN*)h[l]; hk = (GEN*)h[k]; + hl = VEC_elt(h,l); hk = VEC_elt(h,k); if (is_pm1(q)) { if (signe(q) > 0) - for (i=1;i<=K;i++) { if (signe(hl[i])) hk[i] = addii(hk[i],hl[i]); } + for (i=1;i<=K;i++) { if (signe(hl[i])) hk[i] = laddii(VEC_elt(hk,i),VEC_elt(hl,i)); } else - for (i=1;i<=K;i++) { if (signe(hl[i])) hk[i] = subii(hk[i],hl[i]); } + for (i=1;i<=K;i++) { if (signe(hl[i])) hk[i] = lsubii(VEC_elt(hk,i),VEC_elt(hl,i)); } } else - for (i=1;i<=K;i++) if (signe(hl[i])) hk[i] = addii(hk[i],mulii(q,hl[i])); + for (i=1;i<=K;i++) if (signe(hl[i])) hk[i] = laddii(VEC_elt(hk,i),mulii(q,VEC_elt(hl,i))); } /* L[k,] += q * L[l,], l < k */ diff -pru pari-word-new2/src/basemath/bibli2.c pari-word-new1/src/basemath/bibli2.c --- pari-word-new2/src/basemath/bibli2.c Sun Nov 10 01:03:48 2002 +++ pari-word-new1/src/basemath/bibli2.c Sun Nov 10 00:26:26 2002 @@ -79,7 +79,7 @@ grando0(GEN x, PARI_word n, PARI_word do /** **/ /*******************************************************************/ #ifdef LONG_IS_64BIT -# define SQRTVERYBIGINT 3037000500 /* ceil(sqrt(VERYBIGINT)) */ +# define SQRTVERYBIGINT as_UWORD(3037000500) /* ceil(sqrt(VERYBIGINT)) */ #else # define SQRTVERYBIGINT 46341 #endif @@ -533,13 +533,13 @@ GEN vecbinome(PARI_word n) { PARI_word d = (n + 1)/2, k; - GEN bin = cgetg(n+2, t_VEC), *C; - C = (GEN*)(bin + 1); /* C[k] = binomial(n, k) */ - C[0] = gun; + GEN bin = cgetg(n+2, t_VEC), C; + C = bin + 1; /* C[k] = binomial(n, k) */ + C[0] = un; for (k=1; k <= d; k++) { pari_sp av = avma; - C[k] = gerepileuptoint(av, diviiexact(mulsi(n-k+1, C[k-1]), stoi(k))); + VEC_elt_set(C, k, gerepileuptoint(av, diviiexact(mulsi(n-k+1, VEC_elt(C,k-1)), stoi(k)))); } for ( ; k <= n; k++) C[k] = C[n - k]; return bin; diff -pru pari-word-new2/src/basemath/gen2.c pari-word-new1/src/basemath/gen2.c --- pari-word-new2/src/basemath/gen2.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/basemath/gen2.c Sun Nov 10 00:26:26 2002 @@ -424,6 +424,12 @@ lexcmp_vec_mat(GEN x, GEN y) return lexcmp_scal_vec(x,y); } +PARI_word +lexcmp_l(GEN x, GEN y) +{ + return lexcmp(x, y); +} + /* as gcmp for vector/matrices, using lexicographic ordering on components */ int lexcmp(GEN x, GEN y) diff -pru pari-word-new2/src/basemath/polarit1.c pari-word-new1/src/basemath/polarit1.c --- pari-word-new2/src/basemath/polarit1.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/basemath/polarit1.c Sun Nov 10 00:40:26 2002 @@ -694,62 +694,62 @@ try_pow(GEN w0, GEN pol, GEN p, GEN q, P * t[0],t[1]...t[k-1] the k factors, normalized */ static void -split(PARI_word m, GEN *t, PARI_word d, GEN p, GEN q, PARI_word r, GEN S) +split(PARI_word m, GEN t, PARI_word d, GEN p, GEN q, PARI_word r, GEN S) { PARI_word ps, l, v, dv; pari_sp av0, av; GEN w,w0; - dv=degpol(*t); if (dv==d) return; + dv=degpol((PARI_word2GEN)*t); if (dv==d) return; v=varn(*t); av0=avma; ps = p[2]; for(av=avma;;avma=av) { if (ps==2) { - w0 = w = FpXQ_pow(polx[v], stoi(m-1), *t, gdeux); m += 2; + w0 = w = FpXQ_pow(polx[v], stoi(m-1), (PARI_word2GEN)*t, gdeux); m += 2; for (l=1; l<d; l++) w = gadd(w0, spec_FpXQ_pow(w, p, S)); } else { - w = FpX_res(stopoly(m,ps,v),*t, p); - m++; w = try_pow(w,*t,p,q,r); + w = FpX_res(stopoly(m,ps,v),(PARI_word2GEN)*t, p); + m++; w = try_pow(w,(PARI_word2GEN)*t,p,q,r); if (!w) continue; w = ZX_s_add(w, -1); } - w = FpX_gcd(*t,w, p); + w = FpX_gcd((PARI_word2GEN)*t,w, p); l = degpol(w); if (l && l!=dv) break; } w = FpX_normalize(w, p); w = gerepileupto(av0, w); - l /= d; t[l]=FpX_div(*t,w,p); *t=w; + l /= d; t[l]=(GEN2PARI_word)FpX_div((PARI_word2GEN)*t,w,p); *t=(GEN2PARI_word)w; split(m,t+l,d,p,q,r,S); split(m,t, d,p,q,r,S); } static void -splitgen(GEN m, GEN *t, PARI_word d, GEN p, GEN q, PARI_word r) +splitgen(GEN m, GEN t, PARI_word d, GEN p, GEN q, PARI_word r) { PARI_word l, v, dv; pari_sp av; GEN w; - dv=degpol(*t); if (dv==d) return; - v=varn(*t); m=setloop(m); m=incpos(m); + dv=degpol((PARI_word2GEN)*t); if (dv==d) return; + v=varn((PARI_word2GEN)*t); m=setloop(m); m=incpos(m); av=avma; for(;; avma=av, m=incpos(m)) { - w = FpX_res(stopoly_gen(m,p,v),*t, p); - w = try_pow(w,*t,p,q,r); + w = FpX_res(stopoly_gen(m,p,v),(PARI_word2GEN)*t, p); + w = try_pow(w,(PARI_word2GEN)*t,p,q,r); if (!w) continue; w = ZX_s_add(w,-1); - w = FpX_gcd(*t,w, p); l=degpol(w); + w = FpX_gcd((PARI_word2GEN)*t,w, p); l=degpol(w); if (l && l!=dv) break; } w = FpX_normalize(w, p); w = gerepileupto(av, w); - l /= d; t[l]=FpX_div(*t,w,p); *t=w; + l /= d; t[l]=(GEN2PARI_word)FpX_div((PARI_word2GEN)*t,w,p); *t=(GEN2PARI_word)w; splitgen(m,t+l,d,p,q,r); splitgen(m,t, d,p,q,r); } @@ -809,11 +809,11 @@ factcantor0(GEN f, GEN pp, PARI_word fla PARI_word i, j, k, d, e, vf, p, nbfact; pari_sp tetpil, av = avma; GEN ex,y,f2,g,g1,u,v,pd,q; - GEN *t; + GEN t; if (!(d = factmod_init(&f, pp, &p))) { avma=av; return trivfact(); } /* to hold factors and exponents */ - t = (GEN*)cgetg(d+1,t_VEC); ex = new_chunk(d+1); + t = cgetg(d+1,t_VEC); ex = new_chunk(d+1); vf=varn(f); e = nbfact = 1; for(;;) { @@ -852,13 +852,13 @@ factcantor0(GEN f, GEN pp, PARI_word fla if (flag) { if (flag > 1) return NULL; - for ( ; nbfact<j; nbfact++) { t[nbfact]=(GEN)d; ex[nbfact]=e*k; } + for ( ; nbfact<j; nbfact++) { t[nbfact]=d; ex[nbfact]=e*k; } } else { PARI_word r; g = FpX_normalize(g, pp); - t[nbfact]=g; q = subis(pd,1); /* also ok for p=2: unused */ + VEC_elt_set(t, nbfact, g); q = subis(pd,1); /* also ok for p=2: unused */ r = vali(q); q = shifti(q,-r); /* le premier parametre est un entier variable m qui sera * converti en un polynome w dont les coeff sont ses digits en @@ -877,7 +877,8 @@ factcantor0(GEN f, GEN pp, PARI_word fla } if (du) { - t[nbfact] = flag? (GEN)du: FpX_normalize(u, pp); + /* XXXX VEC_elt_set() ??? A horrible mix... */ + t[nbfact] = flag? du: (GEN2PARI_word)FpX_normalize(u, pp); ex[nbfact++]=e*k; } } @@ -898,13 +899,14 @@ factcantor0(GEN f, GEN pp, PARI_word fla if (flag) for (j=1; j<nbfact; j++) { - u[j] = lstoi((PARI_word)t[j]); + /* XXXX VEC_elt_set() ??? A horrible mix... */ + u[j] = lstoi(t[j]); v[j] = lstoi(ex[j]); } else for (j=1; j<nbfact; j++) { - u[j] = (PARI_word)FpX(t[j], pp); + VEC_elt_set(u,j, FpX(VEC_elt(t,j), pp)); v[j] = lstoi(ex[j]); } return gerepile(av,tetpil,y); @@ -1175,11 +1177,12 @@ FqX_rand(PARI_word d1, PARI_word v, GEN } #define set_irred(i) { if ((i)>ir) swap(t[i],t[ir]); ir++;} +#define lset_irred(i) { if ((i)>ir) lswap(t[i],t[ir]); ir++;} PARI_word -FpX_split_berlekamp(GEN *t, GEN p) +FpX_split_berlekamp(GEN t, GEN p) { - GEN u = *t, a,b,po2,vker,pol; + GEN u = (PARI_word2GEN)*t, a,b,po2,vker,pol; PARI_word N = degpol(u), d, i, ir, L, la, lb, ps, vu = varn(u); pari_sp av0 = avma; @@ -1218,17 +1221,17 @@ FpX_split_berlekamp(GEN *t, GEN p) } for (i=ir; i<L && L<d; i++) { - a = t[i]; la = degpol(a); - if (la == 1) { set_irred(i); } + a = (PARI_word2GEN)t[i]; la = degpol(a); + if (la == 1) { lset_irred(i); } else if (la == 2) { GEN r = quadsolvemod(a,p,1); if (r) { - t[i] = deg1pol_i(gun, subii(p,r), vu); r = otherroot(a,r,p); - t[L] = deg1pol_i(gun, subii(p,r), vu); L++; + t[i] = (GEN2PARI_word)deg1pol_i(gun, subii(p,r), vu); r = otherroot(a,r,p); + t[L] = (GEN2PARI_word)deg1pol_i(gun, subii(p,r), vu); L++; } - set_irred(i); + lset_irred(i); } else { @@ -1240,8 +1243,8 @@ FpX_split_berlekamp(GEN *t, GEN p) if (lb && lb < la) { b = FpX_normalize(b, p); - t[L] = FpX_div(a,b,p); - t[i]= b; L++; + t[L] = (GEN2PARI_word)FpX_div(a,b,p); + t[i] = (GEN2PARI_word)b; L++; } else avma = av; } @@ -1325,11 +1328,11 @@ factmod0(GEN f, GEN pp) { PARI_word i, j, k, e, p, N, nbfact, d; pari_sp av = avma, tetpil; - GEN pps2,ex,y,f2,p1,g1,u, *t; + GEN pps2,ex,y,f2,p1,g1,u, t; if (!(d = factmod_init(&f, pp, &p))) { avma=av; return trivfact(); } /* to hold factors and exponents */ - t = (GEN*)cgetg(d+1,t_VEC); ex = cgetg(d+1,t_VECSMALL); + t = cgetg(d+1,t_VEC); ex = cgetg(d+1,t_VECSMALL); e = nbfact = 1; pps2 = shifti(pp,-1); @@ -1351,7 +1354,7 @@ factmod0(GEN f, GEN pp) N = degpol(u); if (N) { - t[nbfact] = FpX_normalize(u,pp); + VEC_elt_set(t, nbfact, FpX_normalize(u,pp)); d = (N==1)? 1: FpX_split_berlekamp(t+nbfact, pp); for (j=0; j<d; j++) ex[nbfact+j] = e*k; nbfact += d; @@ -1364,13 +1367,14 @@ factmod0(GEN f, GEN pp) for (i=2; i<j; i++) f[i] = f2[p*(i-2)+2]; } tetpil=avma; y=cgetg(3,t_VEC); - setlg((GEN)t, nbfact); + setlg(t, nbfact); setlg(ex, nbfact); - y[1]=lcopy((GEN)t); + y[1]=lcopy(t); y[2]=lcopy(ex); (void)sort_factor(y,cmpii); return gerepile(av,tetpil,y); } + GEN factmod(GEN f, GEN pp) { diff -pru pari-word-new2/src/basemath/polarit2.c pari-word-new1/src/basemath/polarit2.c --- pari-word-new2/src/basemath/polarit2.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/basemath/polarit2.c Sun Nov 10 00:26:26 2002 @@ -625,7 +625,7 @@ Mignotte_bound(GEN S) p1 = N2; if (gcmp(C, p1) < 0) C = p1; for (i = 1; i < d; i++) { - p1 = gadd(gmul((GEN)bin[i], N2), (GEN)binlS[i+1]); + p1 = gadd(gmul(VEC_elt(bin,i), N2), VEC_elt(binlS, i+1)); if (gcmp(C, p1) < 0) C = p1; } return C; diff -pru pari-word-new2/src/basemath/trans1.c pari-word-new1/src/basemath/trans1.c --- pari-word-new2/src/basemath/trans1.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/basemath/trans1.c Sun Nov 10 00:26:26 2002 @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suit #ifdef LONG_IS_64BIT # define C31 (9223372036854775808.0) /* VERYBIGINT * 1.0 */ -# define SQRTVERYBIGINT 3037000500 /* ceil(sqrt(VERYBIGINT)) */ +# define SQRTVERYBIGINT as_UWORD(3037000500) /* ceil(sqrt(VERYBIGINT)) */ # define CBRTVERYBIGINT 2097152 /* ceil(cbrt(VERYBIGINT)) */ #else # define C31 (2147483648.0) diff -pru pari-word-new2/src/headers/paricast.h pari-word-new1/src/headers/paricast.h --- pari-word-new2/src/headers/paricast.h Sun Nov 10 01:03:28 2002 +++ pari-word-new1/src/headers/paricast.h Sun Nov 10 00:26:26 2002 @@ -17,229 +17,244 @@ Foundation, Inc., 59 Temple Place - Suit # undef lround #endif -#define mael(ma,x1,x2) ( ((GEN) ((GEN)(ma))[x1]) [x2]) -#define mael2 mael -#define mael3(ma,x1,x2,x3) ( ((GEN) mael2((ma),(x1),(x2))) [x3]) -#define mael4(ma,x1,x2,x3,x4) ( ((GEN) mael3((ma),(x1),(x2),(x3))) [x4]) -#define mael5(ma,x1,x2,x3,x4,x5) (\ - ((GEN) mael4((ma),(x1),(x2),(x3),(x4))) [x5] \ -) -#define gmael (GEN) mael -#define gmael2 (GEN) mael -#define gmael3 (GEN) mael3 -#define gmael4 (GEN) mael4 -#define gmael5 (GEN) mael5 - -#define coeff(a,i,j) ( ( (GEN) ( (GEN) (a))[j]) [i]) -#define gcoeff(a,i,j) ((GEN)coeff((a),(i),(j))) - -#define labsi (PARI_word)absi -#define labsr (PARI_word)absr -#define lach (PARI_word)gach -#define lacos (PARI_word)gacos -#define ladd (PARI_word)gadd -#define laddii (PARI_word)addii -#define laddir (PARI_word)addir -#define laddis (PARI_word)addis -#define laddmat (PARI_word)gaddmat -#define laddrr (PARI_word)addrr -#define laddrs (PARI_word)addrs -#define laddsi (PARI_word)addsi -#define laddsmat (PARI_word)gaddsmat -#define laddsr (PARI_word)addsr -#define ladj (PARI_word)adj -#define larg (PARI_word)garg -#define lash (PARI_word)gash -#define lasin (PARI_word)gasin -#define lassmat (PARI_word)assmat -#define latan (PARI_word)gatan -#define lath (PARI_word)gath -#define lbezout (PARI_word)bezout -#define lbinome (PARI_word)binome -#define lcaract (PARI_word)caract -#define lcaradj (PARI_word)caradj -#define lceil (PARI_word)gceil -#define lch (PARI_word)gch -#define lchangevar (PARI_word)changevar -#define lclone (PARI_word)gclone -#define lco8 (PARI_word)co8 -#define lconcat (PARI_word)concat -#define lconj (PARI_word)gconj -#define lcontent (PARI_word)content -#define lcopy (PARI_word)gcopy -#define lcos (PARI_word)gcos -#define lcvtoi (PARI_word)gcvtoi -#define lderiv (PARI_word)deriv -#define ldet (PARI_word)det -#define ldet2 (PARI_word)det2 -#define ldeuc (PARI_word)gdeuc -#define ldiscsr (PARI_word)discsr +/* These four assume that v is of type GEN; n n1 n2 are 1-based indices */ +#define VEC_elt(v,n) ((PARI_word2GEN) ((v)[n])) +#define MAT_elt(v,n1,n2) VEC_elt( VEC_elt((v),(n1)), (n2) ) +#define VEC_elt_set(v,n,g) ((v)[n] = (GEN2PARI_word)(g)) +#define MAT_elt_set(v,n1,n2,g) VEC_elt_set( VEC_elt((v),(n1)), (n2), (g) ) + +/* These two assume that v may be of a type PARI_word too */ +#define VEC_elt_conv(v,n) VEC_elt((PARI_word2GEN)(v), (n)) +#define MAT_elt_conv(v,n1,n2) MAT_elt((PARI_word2GEN)(v), (n1), (n2)) + +/* Deep accessors with analogues which return PARI_word */ +#define gmael MAT_elt_conv +#define mael(ma,x1,x2) (VEC_elt_conv(ma,x1)[x2]) + +/* More synonims... */ +#define mael2 mael +#define gmael2 MAT_elt_conv + +#define coeff(v,n1,n2) mael((v),(n2),(n1)) +#define gcoeff(v,n1,n2) MAT_elt_conv((v),(n2),(n1)) + +#define mael3(ma,x1,x2,x3) (MAT_elt_conv((ma),(x1),(x2))[x3]) +#define gmael3(ma,x1,x2,x3) VEC_elt( MAT_elt_conv((ma),(x1),(x2)), (x3) ) + + +#define mael4(ma,x1,x2,x3,x4) gmael3((ma),(x1),(x2),(x3))[x4] +#define gmael4(ma,x1,x2,x3,x4) VEC_elt( gmael3((ma),(x1),(x2),(x3)), x4) + +#define mael5(ma,x1,x2,x3,x4,x5) gmael4((ma),(x1),(x2),(x3),(x4))[x5] +#define gmael5(m,x1,x2,x3,x4,x5) VEC_elt( gmael4((m),(x1),(x2),(x3),(x4)), x5) + +#define labsi (GEN2PARI_word)absi +#define labsr (GEN2PARI_word)absr +#define lach (GEN2PARI_word)gach +#define lacos (GEN2PARI_word)gacos +#define ladd (GEN2PARI_word)gadd +#define laddii (GEN2PARI_word)addii +#define laddir (GEN2PARI_word)addir +#define laddis (GEN2PARI_word)addis +#define laddmat (GEN2PARI_word)gaddmat +#define laddrr (GEN2PARI_word)addrr +#define laddrs (GEN2PARI_word)addrs +#define laddsi (GEN2PARI_word)addsi +#define laddsmat (GEN2PARI_word)gaddsmat +#define laddsr (GEN2PARI_word)addsr +#define ladj (GEN2PARI_word)adj +#define larg (GEN2PARI_word)garg +#define lash (GEN2PARI_word)gash +#define lasin (GEN2PARI_word)gasin +#define lassmat (GEN2PARI_word)assmat +#define latan (GEN2PARI_word)gatan +#define lath (GEN2PARI_word)gath +#define lbezout (GEN2PARI_word)bezout +#define lbinome (GEN2PARI_word)binome +#define lcaract (GEN2PARI_word)caract +#define lcaradj (GEN2PARI_word)caradj +#define lceil (GEN2PARI_word)gceil +#define lch (GEN2PARI_word)gch +#define lchangevar (GEN2PARI_word)changevar +#define lclone (GEN2PARI_word)gclone +#define lco8 (GEN2PARI_word)co8 +#define lconcat (GEN2PARI_word)concat +#define lconj (GEN2PARI_word)gconj +#define lcontent (GEN2PARI_word)content +#define lcopy (GEN2PARI_word)gcopy +#define lcos (GEN2PARI_word)gcos +#define lcvtoi (GEN2PARI_word)gcvtoi +#define lderiv (GEN2PARI_word)deriv +#define ldet (GEN2PARI_word)det +#define ldet2 (GEN2PARI_word)det2 +#define ldeuc (GEN2PARI_word)gdeuc +#define ldiscsr (GEN2PARI_word)discsr /* ldiv is a predefined macro on some AIX versions --GN1997Jan27 */ #ifdef ldiv #undef ldiv #endif -#define ldiv (PARI_word)gdiv +#define ldiv (GEN2PARI_word)gdiv + +#define ldivgs (GEN2PARI_word)gdivgs +#define ldivii (GEN2PARI_word)divii +#define ldivir (GEN2PARI_word)divir +#define ldivis (GEN2PARI_word)divis +#define ldivmod (GEN2PARI_word)gdivmod +#define ldivres (GEN2PARI_word)poldivres +#define ldivri (GEN2PARI_word)divri +#define ldivrr (GEN2PARI_word)divrr +#define ldivrs (GEN2PARI_word)divrs +#define ldivsi (GEN2PARI_word)divsi +#define ldivsr (GEN2PARI_word)divsr +#define ldvmdii (GEN2PARI_word)dvmdii +#define ldvmdis (GEN2PARI_word)dvmdis +#define ldvmdsi (GEN2PARI_word)dvmdsi +#define lexp (GEN2PARI_word)gexp +#define lfibo (GEN2PARI_word)fibo +#define lfloor (GEN2PARI_word)gfloor +#define lfrac (GEN2PARI_word)gfrac +#define lgamd (GEN2PARI_word)ggamd +#define lgamma (GEN2PARI_word)ggamma +#define lgauss (GEN2PARI_word)gauss +#define lgcd (GEN2PARI_word)ggcd +#define lgetg (GEN2PARI_word)cgetg +#define lgeti (GEN2PARI_word)cgeti +#define lgetp (GEN2PARI_word)cgetp +#define lgetr (GEN2PARI_word)cgetr +#define lgreffe (GEN2PARI_word)greffe +#define lhilb (GEN2PARI_word)hilb +#define licopy (GEN2PARI_word)icopy +#define limag (GEN2PARI_word)gimag +#define linteg (GEN2PARI_word)integ +#define linv (GEN2PARI_word)ginv +#define linvmat (GEN2PARI_word)invmat +#define linvmod (GEN2PARI_word)ginvmod +#define linvmulmat (GEN2PARI_word)invmulmat +#define llegendre (GEN2PARI_word)legendre +#define llift (GEN2PARI_word)lift +#define llngamma (GEN2PARI_word)glngamma +#define llog (GEN2PARI_word)glog +#define lmax (GEN2PARI_word)gmax +#define lmin (GEN2PARI_word)gmin +#define lmod (GEN2PARI_word)gmod +#define lmodii (GEN2PARI_word)modii +#define lmodsi (GEN2PARI_word)modsi +#define lmodulcp (GEN2PARI_word)gmodulcp +#define lmodulo (GEN2PARI_word)gmodulo +#define lmpabs (GEN2PARI_word)mpabs +#define lmpach (GEN2PARI_word)mpach +#define lmpacos (GEN2PARI_word)mpacos +#define lmpadd (GEN2PARI_word)mpadd +#define lmpash (GEN2PARI_word)mpash +#define lmpasin (GEN2PARI_word)mpasin +#define lmpatan (GEN2PARI_word)mpatan +#define lmpath (GEN2PARI_word)mpath +#define lmpaut (GEN2PARI_word)mpaut +#define lmpch (GEN2PARI_word)mpch +#define lmpcos (GEN2PARI_word)mpcos +#define lmpdiv (GEN2PARI_word)mpdiv +#define lmpent (GEN2PARI_word)mpent +#define lmpeuler (GEN2PARI_word)mpeuler +#define lmpexp (GEN2PARI_word)mpexp +#define lmpexp1 (GEN2PARI_word)mpexp1 +#define lmpfact (GEN2PARI_word)mpfact +#define lmpgamd (GEN2PARI_word)mpgamd +#define lmpgamma (GEN2PARI_word)mpgamma +#define lmpinvmod (GEN2PARI_word)mpinvmod +#define lmplngamma (GEN2PARI_word)mplngamma +#define lmplog (GEN2PARI_word)mplog +#define lmpmul (GEN2PARI_word)mpmul +#define lmpneg (GEN2PARI_word)mpneg +#define lmppgcd (GEN2PARI_word)mppgcd +#define lmppi (GEN2PARI_word)mppi +#define lmppsi (GEN2PARI_word)mppsi +#define lmpsc1 (GEN2PARI_word)mpsc1 +#define lmpsh (GEN2PARI_word)mpsh +#define lmpshift (GEN2PARI_word)mpshift +#define lmpsin (GEN2PARI_word)mpsin +#define lmpsqrt (GEN2PARI_word)mpsqrt +#define lmpsub (GEN2PARI_word)mpsub +#define lmptan (GEN2PARI_word)mptan +#define lmpth (GEN2PARI_word)mpth +#define lmptrunc (GEN2PARI_word)mptrunc +#define lmul (GEN2PARI_word)gmul +#define lmul2n (GEN2PARI_word)gmul2n +#define lmulii (GEN2PARI_word)mulii +#define lmulir (GEN2PARI_word)mulir +#define lmulis (GEN2PARI_word)mulis +#define lmulri (GEN2PARI_word)mulri +#define lmulrr (GEN2PARI_word)mulrr +#define lmulrs (GEN2PARI_word)mulrs +#define lmulsg (GEN2PARI_word)gmulsg +#define lmulsi (GEN2PARI_word)mulsi +#define lmulsr (GEN2PARI_word)mulsr +#define lmulss (GEN2PARI_word)mulss +#define lneg (GEN2PARI_word)gneg +#define lnegi (GEN2PARI_word)negi +#define lnegr (GEN2PARI_word)negr +#define lnorm (GEN2PARI_word)gnorm +#define lnorml2 (GEN2PARI_word)gnorml2 +#define lopgs2 (GEN2PARI_word)gopgs2 +#define lopsg2 (GEN2PARI_word)gopsg2 +#define lpasc (GEN2PARI_word)pasc +#define lpile (GEN2PARI_word)gerepile +#define lpilecopy (GEN2PARI_word)gerepilecopy +#define lpileupto (GEN2PARI_word)gerepileupto +#define lpileuptoint (GEN2PARI_word)gerepileuptoint +#define lpoleval (GEN2PARI_word)poleval +#define lpolgcd (GEN2PARI_word)polgcd +#define lpowgs (GEN2PARI_word)gpowgs +#define lprec (GEN2PARI_word)gprec +#define lprimpart (GEN2PARI_word)primpart +#define lpsi (GEN2PARI_word)gpsi +#define lpui (GEN2PARI_word)gpui +#define lpuigs (GEN2PARI_word)gpuigs +#define lpuissmodulo (GEN2PARI_word)puissmodulo +#define lquadgen (GEN2PARI_word)quadgen +#define lquadpoly (GEN2PARI_word)quadpoly +#define lracine (GEN2PARI_word)racine +#define lrcopy (GEN2PARI_word)rcopy +#define lreal (GEN2PARI_word)greal +#define lrecip (GEN2PARI_word)recip +#define lred (GEN2PARI_word)gred +#define lres (GEN2PARI_word)gres +#define lresii (GEN2PARI_word)resii +#define lrndtoi (GEN2PARI_word)grndtoi +#define lroots (GEN2PARI_word)roots +#define lround (GEN2PARI_word)ground +#define lscalmat (GEN2PARI_word)gscalmat +#define lscalsmat (GEN2PARI_word)gscalsmat +#define lsh (GEN2PARI_word)gsh +#define lshift (GEN2PARI_word)gshift +#define lshifti (GEN2PARI_word)shifti +#define lshiftr (GEN2PARI_word)shiftr +#define lsin (GEN2PARI_word)gsin +#define lsqr (GEN2PARI_word)gsqr +#define lsqri (GEN2PARI_word)sqri +#define lsqrt (GEN2PARI_word)gsqrt +#define lstoi (GEN2PARI_word)stoi +#define lsub (GEN2PARI_word)gsub +#define lsubii (GEN2PARI_word)subii +#define lsubir (GEN2PARI_word)subir +#define lsubis (GEN2PARI_word)subis +#define lsubres (GEN2PARI_word)subres +#define lsubri (GEN2PARI_word)subri +#define lsubrr (GEN2PARI_word)subrr +#define lsubrs (GEN2PARI_word)subrs +#define lsubsi (GEN2PARI_word)subsi +#define lsubsr (GEN2PARI_word)subsr +#define lsubst (GEN2PARI_word)gsubst +#define ltan (GEN2PARI_word)gtan +#define ltchebi (GEN2PARI_word)tchebi +#define lth (GEN2PARI_word)gth +#define ltrace (GEN2PARI_word)gtrace +#define ltrans (GEN2PARI_word)gtrans +#define ltrunc (GEN2PARI_word)gtrunc -#define ldivgs (PARI_word)gdivgs -#define ldivii (PARI_word)divii -#define ldivir (PARI_word)divir -#define ldivis (PARI_word)divis -#define ldivmod (PARI_word)gdivmod -#define ldivres (PARI_word)poldivres -#define ldivri (PARI_word)divri -#define ldivrr (PARI_word)divrr -#define ldivrs (PARI_word)divrs -#define ldivsi (PARI_word)divsi -#define ldivsr (PARI_word)divsr -#define ldvmdii (PARI_word)dvmdii -#define ldvmdis (PARI_word)dvmdis -#define ldvmdsi (PARI_word)dvmdsi -#define lexp (PARI_word)gexp -#define lfibo (PARI_word)fibo -#define lfloor (PARI_word)gfloor -#define lfrac (PARI_word)gfrac -#define lgamd (PARI_word)ggamd -#define lgamma (PARI_word)ggamma -#define lgauss (PARI_word)gauss -#define lgcd (PARI_word)ggcd -#define lgetg (PARI_word)cgetg -#define lgeti (PARI_word)cgeti -#define lgetp (PARI_word)cgetp -#define lgetr (PARI_word)cgetr -#define lgreffe (PARI_word)greffe -#define lhilb (PARI_word)hilb -#define licopy (PARI_word)icopy -#define limag (PARI_word)gimag -#define linteg (PARI_word)integ -#define linv (PARI_word)ginv -#define linvmat (PARI_word)invmat -#define linvmod (PARI_word)ginvmod -#define linvmulmat (PARI_word)invmulmat -#define llegendre (PARI_word)legendre -#define llift (PARI_word)lift -#define llngamma (PARI_word)glngamma -#define llog (PARI_word)glog -#define lmax (PARI_word)gmax -#define lmin (PARI_word)gmin -#define lmod (PARI_word)gmod -#define lmodii (PARI_word)modii -#define lmodsi (PARI_word)modsi -#define lmodulcp (PARI_word)gmodulcp -#define lmodulo (PARI_word)gmodulo -#define lmpabs (PARI_word)mpabs -#define lmpach (PARI_word)mpach -#define lmpacos (PARI_word)mpacos -#define lmpadd (PARI_word)mpadd -#define lmpash (PARI_word)mpash -#define lmpasin (PARI_word)mpasin -#define lmpatan (PARI_word)mpatan -#define lmpath (PARI_word)mpath -#define lmpaut (PARI_word)mpaut -#define lmpch (PARI_word)mpch -#define lmpcos (PARI_word)mpcos -#define lmpdiv (PARI_word)mpdiv -#define lmpent (PARI_word)mpent -#define lmpeuler (PARI_word)mpeuler -#define lmpexp (PARI_word)mpexp -#define lmpexp1 (PARI_word)mpexp1 -#define lmpfact (PARI_word)mpfact -#define lmpgamd (PARI_word)mpgamd -#define lmpgamma (PARI_word)mpgamma -#define lmpinvmod (PARI_word)mpinvmod -#define lmplngamma (PARI_word)mplngamma -#define lmplog (PARI_word)mplog -#define lmpmul (PARI_word)mpmul -#define lmpneg (PARI_word)mpneg -#define lmppgcd (PARI_word)mppgcd -#define lmppi (PARI_word)mppi -#define lmppsi (PARI_word)mppsi -#define lmpsc1 (PARI_word)mpsc1 -#define lmpsh (PARI_word)mpsh -#define lmpshift (PARI_word)mpshift -#define lmpsin (PARI_word)mpsin -#define lmpsqrt (PARI_word)mpsqrt -#define lmpsub (PARI_word)mpsub -#define lmptan (PARI_word)mptan -#define lmpth (PARI_word)mpth -#define lmptrunc (PARI_word)mptrunc -#define lmul (PARI_word)gmul -#define lmul2n (PARI_word)gmul2n -#define lmulii (PARI_word)mulii -#define lmulir (PARI_word)mulir -#define lmulis (PARI_word)mulis -#define lmulri (PARI_word)mulri -#define lmulrr (PARI_word)mulrr -#define lmulrs (PARI_word)mulrs -#define lmulsg (PARI_word)gmulsg -#define lmulsi (PARI_word)mulsi -#define lmulsr (PARI_word)mulsr -#define lmulss (PARI_word)mulss -#define lneg (PARI_word)gneg -#define lnegi (PARI_word)negi -#define lnegr (PARI_word)negr -#define lnorm (PARI_word)gnorm -#define lnorml2 (PARI_word)gnorml2 -#define lopgs2 (PARI_word)gopgs2 -#define lopsg2 (PARI_word)gopsg2 -#define lpasc (PARI_word)pasc -#define lpile (PARI_word)gerepile -#define lpilecopy (PARI_word)gerepilecopy -#define lpileupto (PARI_word)gerepileupto -#define lpileuptoint (PARI_word)gerepileuptoint -#define lpoleval (PARI_word)poleval -#define lpolgcd (PARI_word)polgcd -#define lpowgs (PARI_word)gpowgs -#define lprec (PARI_word)gprec -#define lprimpart (PARI_word)primpart -#define lpsi (PARI_word)gpsi -#define lpui (PARI_word)gpui -#define lpuigs (PARI_word)gpuigs -#define lpuissmodulo (PARI_word)puissmodulo -#define lquadgen (PARI_word)quadgen -#define lquadpoly (PARI_word)quadpoly -#define lracine (PARI_word)racine -#define lrcopy (PARI_word)rcopy -#define lreal (PARI_word)greal -#define lrecip (PARI_word)recip -#define lred (PARI_word)gred -#define lres (PARI_word)gres -#define lresii (PARI_word)resii -#define lrndtoi (PARI_word)grndtoi -#define lroots (PARI_word)roots -#define lround (PARI_word)ground -#define lscalmat (PARI_word)gscalmat -#define lscalsmat (PARI_word)gscalsmat -#define lsh (PARI_word)gsh -#define lshift (PARI_word)gshift -#define lshifti (PARI_word)shifti -#define lshiftr (PARI_word)shiftr -#define lsin (PARI_word)gsin -#define lsqr (PARI_word)gsqr -#define lsqri (PARI_word)sqri -#define lsqrt (PARI_word)gsqrt -#define lstoi (PARI_word)stoi -#define lsub (PARI_word)gsub -#define lsubii (PARI_word)subii -#define lsubir (PARI_word)subir -#define lsubis (PARI_word)subis -#define lsubres (PARI_word)subres -#define lsubri (PARI_word)subri -#define lsubrr (PARI_word)subrr -#define lsubrs (PARI_word)subrs -#define lsubsi (PARI_word)subsi -#define lsubsr (PARI_word)subsr -#define lsubst (PARI_word)gsubst -#define ltan (PARI_word)gtan -#define ltchebi (PARI_word)tchebi -#define lth (PARI_word)gth -#define ltrace (PARI_word)gtrace -#define ltrans (PARI_word)gtrans -#define ltrunc (PARI_word)gtrunc - -#define zero (PARI_word)gzero -#define un (PARI_word)gun -#define deux (PARI_word)gdeux -#define lhalf (PARI_word)ghalf -#define lpolx (PARI_word)polx -#define lpolun (PARI_word)polun +#define zero (GEN2PARI_word)gzero +#define un (GEN2PARI_word)gun +#define deux (GEN2PARI_word)gdeux +#define lhalf (GEN2PARI_word)ghalf +#define lpolx (GEN2PARI_word)polx +#define lpolun (GEN2PARI_word)polun diff -pru pari-word-new2/src/headers/paricom.h pari-word-new1/src/headers/paricom.h --- pari-word-new2/src/headers/paricom.h Sun Nov 10 01:03:34 2002 +++ pari-word-new1/src/headers/paricom.h Sun Nov 10 00:26:26 2002 @@ -30,6 +30,17 @@ Foundation, Inc., 59 Temple Place - Suit * [ avoid "dangling else" problem in macros ] */ #define STMT_START do #define STMT_END while (0) + +#ifndef PeRl_CaTiFy +# define PeRl_CaTiFy(a, b) a ## b +# define PeRl_StGiFy(a) #a +/* the additional level of indirection enables these macros to be + * used as arguments to other macros. See K&R 2nd ed., page 231. */ +# define CAT2(a,b) PeRl_CaTiFy(a,b) +# define StGiFy(a) PeRl_StGiFy(a) +# define STRINGIFY(a) PeRl_StGiFy(a) +#endif + /*=====================================================================*/ /* CATCH(numer) { * recovery @@ -118,12 +129,12 @@ extern int new_galois_format; #endif #ifdef LONG_IS_64BIT -# define VERYBIGINT (as_WORD(9223372036854775807)) /* 2^63-1 */ -# define EXP220 (as_WORD(1099511627776)) /* 2^40 */ +# define VERYBIGINT as_WORD(9223372036854775807) /* 2^63-1 */ +# define EXP220 as_WORD(1099511627776) /* 2^40 */ # define BIGINT (2147483647) /* 2^31-1 */ #else -# define VERYBIGINT (as_WORD(2147483647)) /* 2^31-1 */ -# define EXP220 (as_WORD(1048576)) /* 2^20 */ +# define VERYBIGINT as_WORD(2147483647) /* 2^31-1 */ +# define EXP220 as_WORD(1048576) /* 2^20 */ # define BIGINT (32767) /* 2^15-1 */ #endif diff -pru pari-word-new2/src/headers/paridecl.h pari-word-new1/src/headers/paridecl.h --- pari-word-new2/src/headers/paridecl.h Sun Nov 10 01:03:28 2002 +++ pari-word-new1/src/headers/paridecl.h Sun Nov 10 00:26:26 2002 @@ -115,7 +115,7 @@ GEN caract2(GEN p, GEN x, int v); GEN caradj(GEN x, PARI_word v, GEN *py); GEN caradj0(GEN x, PARI_word v); GEN carhess(GEN x, PARI_word v); -GEN charpoly0(GEN x, int v,PARI_word flag); +GEN charpoly0(GEN x, PARI_word v,PARI_word flag); GEN conjvec(GEN x,PARI_word prec); GEN gconj(GEN x); GEN gnorm(GEN x); @@ -884,6 +884,7 @@ int gsigne(GEN x); GEN gtolist(GEN x); PARI_word gtolong(GEN x); int lexcmp(GEN x, GEN y); +PARI_word lexcmp_l(GEN x, GEN y); GEN listconcat(GEN list1, GEN list2); GEN listcreate(PARI_word n); GEN listinsert(GEN list, GEN object, PARI_word index); @@ -1029,7 +1030,7 @@ void freeall(void); GEN gcopy(GEN x); GEN gcopy_i(GEN x, PARI_word lx); GEN gerepile(pari_sp ltop, pari_sp lbot, GEN q); -void gerepileall(PARI_uword av, int n, ...); +void gerepileall(pari_sp av, int n, ...); GEN gerepilecopy(pari_sp av, GEN x); void gerepilemany(pari_sp av, GEN* g[], int n); void gerepilemanycoeffs(pari_sp av, GEN x, int n); diff -pru pari-word-new2/src/headers/parigen.h pari-word-new1/src/headers/parigen.h --- pari-word-new2/src/headers/parigen.h Sun Nov 10 01:03:34 2002 +++ pari-word-new1/src/headers/parigen.h Sun Nov 10 00:26:26 2002 @@ -19,7 +19,7 @@ typedef PARI_word *GEN; typedef int (*QSCOMP)(const void *, const void *); #ifdef ULONG_NOT_DEFINED - typedef PARI_uword PARI_uword; + typedef PARI_uword PARI_uword_t; #endif #ifdef __M68K__ @@ -90,8 +90,8 @@ typedef int (*QSCOMP)(const void *, cons #define SIGNSHIFT (LGEFnumBITS+VARNnumBITS) #define EXPOBITS ((as_UWORD(1)<<EXPOnumBITS)-1) -#define SIGNBITS (0xffffUL << SIGNSHIFT) -#define TYPBITS (0xffffUL << TYPSHIFT) +#define SIGNBITS (as_UWORD(0xffff) << SIGNSHIFT) +#define TYPBITS (as_UWORD(0xffff) << TYPSHIFT) #define PRECPBITS (~VALPBITS) #define LGBITS ((as_UWORD(1)<<LGnumBITS)-1) #define LGEFINTBITS LGBITS @@ -113,44 +113,44 @@ typedef int (*QSCOMP)(const void *, cons #define _evallg(x) (x) #define _evallgef(x) (x) -#define typ(x) ((((PARI_uword)(x))&1)? (PARI_word)t_SMALL: (PARI_word)(((PARI_uword) ((GEN) (x))[0]) >> TYPSHIFT)) +#define typ(x) ((((GEN2PARI_uword)(x))&1)? (PARI_word)t_SMALL: (PARI_word)(((PARI_uword) ((PARI_word2GEN) (x))[0]) >> TYPSHIFT)) #define settyp(x,s) (((GEN)(x))[0]=\ (((GEN)(x))[0]&(~TYPBITS)) | evaltyp(s)) -#define smalltos(x) (((PARI_word)(x))>>1) +#define smalltos(x) (((PARI_uword)(x))>>1) -#define isclone(x) (((GEN) (x))[0] & CLONEBIT) +#define isclone(x) (((PARI_word2GEN) (x))[0] & CLONEBIT) #define setisclone(x) (((GEN) (x))[0] |= CLONEBIT) #define unsetisclone(x) (((GEN) (x))[0] &= (~CLONEBIT)) -#define lg(x) ((((PARI_uword)(x))&1)?as_WORD(1): ((PARI_word) (((GEN) (x))[0] & LGBITS))) -#define setlg(x,s) (((GEN)(x))[0]=\ - (((GEN)(x))[0]&(~LGBITS)) | evallg(s)) - -#define signe(x) (((PARI_word) ((GEN) (x))[1]) >> SIGNSHIFT) -#define setsigne(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~SIGNBITS)) | evalsigne(s)) - -#define lgef(x) (((GEN) (x))[1] & LGEFBITS) -#define setlgef(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~LGEFBITS)) | evallgef(s)) - -#define lgefint(x) (((GEN) (x))[1] & LGEFINTBITS) -#define setlgefint(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~LGEFINTBITS)) | evallgefint(s)) - -#define expo(x) ((PARI_word) ((((GEN) (x))[1] & EXPOBITS) - HIGHEXPOBIT)) -#define setexpo(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~EXPOBITS)) | evalexpo(s)) - -#define valp(x) ((PARI_word) ((((GEN)(x))[1] & VALPBITS) - HIGHVALPBIT)) -#define setvalp(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~VALPBITS)) | evalvalp(s)) - -#define precp(x) ((PARI_word) (((PARI_uword) ((GEN) (x))[1]) >> PRECPSHIFT)) -#define setprecp(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~PRECPBITS)) | evalprecp(s)) - -#define varn(x) ((((GEN) (x))[1]&VARNBITS) >> VARNSHIFT) -#define setvarn(x,s) (((GEN)(x))[1]=\ - (((GEN)(x))[1]&(~VARNBITS)) | evalvarn(s)) +#define lg(x) ((((GEN2PARI_uword)(x))&1)?as_WORD(1): ((PARI_word) (((PARI_word2GEN) (x))[0] & LGBITS))) +#define setlg(x,s) (((PARI_word2GEN)(x))[0]=\ + (((PARI_word2GEN)(x))[0]&(~LGBITS)) | evallg(s)) + +#define signe(x) (((PARI_word) ((PARI_word2GEN) (x))[1]) >> SIGNSHIFT) +#define setsigne(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~SIGNBITS)) | evalsigne(s)) + +#define lgef(x) (((PARI_word2GEN) (x))[1] & LGEFBITS) +#define setlgef(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~LGEFBITS)) | evallgef(s)) + +#define lgefint(x) (((PARI_word2GEN) (x))[1] & LGEFINTBITS) +#define setlgefint(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~LGEFINTBITS)) | evallgefint(s)) + +#define expo(x) ((PARI_word) ((((PARI_word2GEN) (x))[1] & EXPOBITS) - HIGHEXPOBIT)) +#define setexpo(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~EXPOBITS)) | evalexpo(s)) + +#define valp(x) ((PARI_word) ((((PARI_word2GEN)(x))[1] & VALPBITS) - HIGHVALPBIT)) +#define setvalp(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~VALPBITS)) | evalvalp(s)) + +#define precp(x) ((PARI_word) (((PARI_uword) ((PARI_word2GEN) (x))[1]) >> PRECPSHIFT)) +#define setprecp(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~PRECPBITS)) | evalprecp(s)) + +#define varn(x) ((((PARI_word2GEN) (x))[1]&VARNBITS) >> VARNSHIFT) +#define setvarn(x,s) (((PARI_word2GEN)(x))[1]=\ + (((PARI_word2GEN)(x))[1]&(~VARNBITS)) | evalvarn(s)) diff -pru pari-word-new2/src/headers/paristio.h pari-word-new1/src/headers/paristio.h --- pari-word-new2/src/headers/paristio.h Sun Nov 10 01:03:28 2002 +++ pari-word-new1/src/headers/paristio.h Sun Nov 10 00:26:26 2002 @@ -20,7 +20,7 @@ typedef struct { } pari_timer; typedef unsigned char *byteptr; -typedef PARI_uword pari_sp; +typedef unsigned long pari_sp; typedef struct stackzone { @@ -68,9 +68,9 @@ extern char *errmessage[], *current_p #define is_universal_constant(x) ((GEN)(x) >= gzero && (GEN)(x) <= gi) #define copyifstack(x,y) STMT_START {pari_sp _t=(pari_sp)(x); \ - (y)=(_t>=bot &&_t<top)? lcopy((GEN)_t): (PARI_word)_t;} STMT_END + (y)=(_t>=bot &&_t<top)? lcopy((GEN)_t): (GEN2PARI_word)_t;} STMT_END #define icopyifstack(x,y) STMT_START {pari_sp _t=(pari_sp)(x); \ - (y)=(_t>=bot &&_t<top)? licopy((GEN)_t): (PARI_word)_t;} STMT_END + (y)=(_t>=bot &&_t<top)? licopy((GEN)_t): (GEN2PARI_word)_t;} STMT_END #define isonstack(x) ((pari_sp)(x)>=bot && (pari_sp)(x)<top) /* Define this to (1) locally (in a given file, NOT here) to check diff -pru pari-word-new2/src/headers/parisys.h pari-word-new1/src/headers/parisys.h --- pari-word-new2/src/headers/parisys.h Sat Jun 8 17:22:42 2002 +++ pari-word-new1/src/headers/parisys.h Sun Nov 10 00:26:26 2002 @@ -15,6 +15,18 @@ Foundation, Inc., 59 Temple Place - Suit /* This files contains macros depending on system and compiler */ +#if defined(PARIWORD_IS_LONG_LONG) +# include <machine/endian.h> +/* How to convert 'L'-type function argument to 2 'G'-type arguments */ +# if BYTE_ORDER == LITTLE_ENDIAN +# define WORD_TO_GENs_LOWER 0 +# define WORD_TO_GENs_UPPER 1 +# else +# define WORD_TO_GENs_LOWER 1 +# define WORD_TO_GENs_UPPER 2 +# endif +#endif + #ifndef LITTLE_ENDIAN_64 # define LITTLE_ENDIAN_64 12345678 #endif diff -pru pari-word-new2/src/headers/paritype.h pari-word-new1/src/headers/paritype.h --- pari-word-new2/src/headers/paritype.h Tue Mar 19 04:11:48 2002 +++ pari-word-new1/src/headers/paritype.h Sun Nov 10 00:26:26 2002 @@ -13,6 +13,64 @@ Check the License for details. You shoul with the package; see the file 'COPYING'. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +/* IWdf: + * This symbol defines the format string used for printing a WORD + * as a signed decimal integer. + */ +/* UWuf: + * This symbol defines the format string used for printing a UWORD + * as an unsigned decimal integer. + */ +/* UWof: + * This symbol defines the format string used for printing a UWORD + * as an unsigned octal integer. + */ +/* UWxf: + * This symbol defines the format string used for printing a UWORD + * as an unsigned hexadecimal integer in lowercase abcdef. + */ +/* UWXf: + * This symbol defines the format string used for printing a UWORD + * as an unsigned hexadecimal integer in uppercase ABCDEF. + */ + +#ifndef PARIWORD_IS_LONG_LONG +typedef long PARI_word; +typedef unsigned long PARI_uword; +#define as_WORD_suf L +#define as_UWORD_suf UL +#define GEN2PARI_word PARI_word +#define GEN2PARI_uword PARI_uword +#define PARI_word2GEN GEN /* May be used with GEN and PARI_word */ + +#define IWdf "ld" /**/ +#define UWuf "lu" /**/ +#define UWof "lo" /**/ +#define UWxf "lx" /**/ +#define UWXf "lX" /**/ + +#else +typedef long long PARI_word; +typedef unsigned long long PARI_uword; +#define LONG_IS_64BIT +#define as_WORD_suf LL +#define as_UWORD_suf ULL +/* These symbols may be put inside () to perform a sensible conversion */ +#define GEN2PARI_word PARI_word)(long +#define GEN2PARI_uword PARI_uword)(long +#define PARI_word2GEN GEN)(long /* May be used with GEN and PARI_word */ + +#define IWdf "Ld" /**/ +#define UWuf "Lu" /**/ +#define UWof "Lo" /**/ +#define UWxf "Lx" /**/ +#define UWXf "LX" /**/ + +#endif + +#define as_WORD(val) CAT2(val,as_WORD_suf) +#define as_UWORD(val) CAT2(val,as_UWORD_suf) + /* DO NOT REORDER THESE * actual values can be changed, but don't forget to adapt * - lontyp/lontyp2 in gen2.c diff -pru pari-word-new2/src/language/anal.c pari-word-new1/src/language/anal.c --- pari-word-new2/src/language/anal.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/language/anal.c Sun Nov 10 00:26:26 2002 @@ -1395,11 +1395,12 @@ readstring_i(char *s, char **ptbuf, char return s; } -static GEN +static GEN* any_string() { PARI_word n = 0, len = 16; - GEN res = new_chunk(len + 1); + GEN r = new_chunk(len + 1); + GEN* res = (GEN*)r; while (*analyseur) { @@ -1408,15 +1409,17 @@ any_string() analyseur++; else { - res[n++] = (PARI_word)expr(); + res[n++] = expr(); if (br_status) err(breaker,"here (print)"); } if (n == len) { PARI_word newlen = len << 1; GEN p1 = new_chunk(newlen + 1); - for (n = 0; n < len; n++) p1[n] = res[n]; - res = p1; len = newlen; + GEN *pp = (GEN*)p1; + + for (n = 0; n < len; n++) pp[n] = res[n]; + res = pp; len = newlen; } } res[n] = 0; /* end the sequence with NULL */ @@ -1710,10 +1713,26 @@ num_derivU(GEN p, GEN *arg, gp_args *f) return gerepileupto(av, gmul(gsub(b,a), eps)); } -#define DFT_VAR (GEN)-as_WORD(1) +#define DFT_VAR -as_WORD(1) #define DFT_GEN (GEN)NULL #define _ARGS_ argvec[0], argvec[1], argvec[2], argvec[3],\ - argvec[4], argvec[5], argvec[6], argvec[7], argvec[8] + argvec[4], argvec[5], argvec[6], argvec[7], argvec[8] _ARGS_EXTRA + +#ifndef PARIWORD_IS_LONG_LONG +# define WORD_2ARGVECT_inc_ind(argvec,i,w) ((argvec)[(i)++] = (GEN)(w)) +# define _ARGS_EXTRA +# define _ARGS_C 9 +#else +# define WORD_2ARGVECT_inc_ind(argvec,i,w) \ + STMT_START { \ + PARI_word _w = w; \ + ((argvec)[(i)+WORD_TO_GENs_LOWER] = (PARI_word2GEN)((_w)&LOWMASK)); \ + ((argvec)[(i)+WORD_TO_GENs_UPPER] = (PARI_word2GEN)((_w)>>BITS_IN_HALFULONG)); \ + i += 2; \ + } STMT_END +# define _ARGS_EXTRA , argvec[9], argvec[10], argvec[11], argvec[12] +# define _ARGS_C 14 /* 4 more args for 4 PARI_words */ +#endif static GEN identifier(void) @@ -1785,8 +1804,8 @@ identifier(void) unsigned int ret, noparen, has_pointer=0; PARI_word fake; void *call = ep->value; - GEN argvec[9]; - matcomp *init[9]; + GEN argvec[_ARGS_C]; + matcomp *init[_ARGS_C]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; @@ -1816,7 +1835,7 @@ identifier(void) argvec[i++] = expr(); if (br_status) err(breaker,"here (argument reading)"); } - if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } + if (*s == 'p') { WORD_2ARGVECT_inc_ind(argvec, i, prec); s++; } while (*s && *s != '\n') switch (*s++) @@ -1827,10 +1846,10 @@ identifier(void) break; case 'L': /* PARI_word */ - match_comma(); argvec[i++] = (GEN) readlong(); break; + match_comma(); WORD_2ARGVECT_inc_ind(argvec, i, readlong()); break; case 'n': /* var number */ - match_comma(); argvec[i++] = (GEN) readvar(); break; + match_comma(); WORD_2ARGVECT_inc_ind(argvec, i, readvar()); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; @@ -1898,19 +1917,19 @@ identifier(void) if (!flags) err(talker, "not enough flags in string function signature"); flags++; - argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), - flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, - NULL, NULL); + WORD_2ARGVECT_inc_ind(argvec, i, + parse_option_string((char*)(argvec[i] + 1), + flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, + NULL, NULL)); } else - argvec[i] = (GEN)itos(argvec[i]); - i++; + WORD_2ARGVECT_inc_ind(argvec, i, itos(argvec[i])); break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { - argvec[i++] = any_string(); + argvec[i++] = (GEN)any_string(); s++; break; } @@ -1924,7 +1943,7 @@ identifier(void) break; case 'p': /* precision */ - argvec[i++] = (GEN) prec; break; + WORD_2ARGVECT_inc_ind(argvec, i, prec); break; case '=': match('='); matchcomma = 0; break; @@ -1937,7 +1956,7 @@ identifier(void) case '&': case 'I': case 'V': argvec[i++]=DFT_GEN; s++; break; - case 'n': argvec[i++]=DFT_VAR; s++; break; + case 'n': WORD_2ARGVECT_inc_ind(argvec, i, DFT_VAR); s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; @@ -1957,7 +1976,7 @@ identifier(void) break; case 'P': /* series precision */ - argvec[i++] = (GEN) precdl; break; + WORD_2ARGVECT_inc_ind(argvec, i, precdl); break; case 'f': /* Fake *PARI_word argument */ argvec[i++] = (GEN) &fake; break; @@ -1975,7 +1994,7 @@ identifier(void) default: err(bugparier,"identifier (unknown code)"); } #if 0 /* uncomment if using purify: unitialized read otherwise */ - for ( ; i<9; i++) argvec[i]=NULL; + for ( ; i<_ARGS_C; i++) argvec[i]=NULL; #endif if (deriv) { diff -pru pari-word-new2/src/language/anal.h pari-word-new1/src/language/anal.h --- pari-word-new2/src/language/anal.h Sun Nov 10 01:03:46 2002 +++ pari-word-new1/src/language/anal.h Sun Nov 10 00:26:26 2002 @@ -40,7 +40,7 @@ typedef struct GENbin { GEN x; /* binary copy of x */ GEN base; /* base address of p->x */ } GENbin; -#define GENbase(p) ((GEN)p+3) +#define GENbase(p) ((GEN)(p+1)) void shiftaddress(GEN x, PARI_word dec); GENbin* copy_bin(GEN x); @@ -161,7 +161,7 @@ extern void *PARI_stack_limit; #define EpNEW 101 #define EpUSER 100 -#define NOT_CREATED_YET ((entree *)as_WORD(0x1)) /* for check_new_fun */ +#define NOT_CREATED_YET ((entree *)0x1L) /* for check_new_fun */ #define initial_value(ep) ((ep)+1) /* blocs */ diff -pru pari-word-new2/src/language/es.c pari-word-new1/src/language/es.c --- pari-word-new2/src/language/es.c Sun Nov 10 01:03:50 2002 +++ pari-word-new1/src/language/es.c Sun Nov 10 00:26:26 2002 @@ -277,7 +277,7 @@ vpariputs(char* format, va_list args) if (l < 0) l = bufsize<<1; else if (l < bufsize) break; free(buf); bufsize++; } - buf[bufsize] = 0; /* just in case */ + buf[bufsize-1] = 0; /* just in case */ #else buf = gpmalloc(bufsize); (void)vsprintf(buf,str,args); /* pray it does fit */ diff -pru pari-word-new2/src/language/init.c pari-word-new1/src/language/init.c --- pari-word-new2/src/language/init.c Sun Nov 10 01:03:52 2002 +++ pari-word-new1/src/language/init.c Sun Nov 10 00:26:26 2002 @@ -1428,6 +1428,9 @@ shiftaddress(GEN x, PARI_word dec) else { x[i] += dec; +#ifdef PARIWORD_IS_LONG_LONG + x[i] = (GEN2PARI_word)(PARI_word2GEN)(x[i]); +#endif shiftaddress((GEN)x[i], dec); } } @@ -1452,12 +1455,15 @@ bin_copy(GENbin *p) { GEN x,y,base; PARI_word dx,len; + long shift; x = p->x; if (!x) { free(p); return gzero; } len = p->len; base= p->base; dx = x - base; y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbase(p), len*sizeof(PARI_word)); - y += dx; shiftaddress(y, (y-x)*sizeof(PARI_word)); + y += dx; + shift = (y-x)*sizeof(PARI_word); /* Cannot use long long: gcc 2.8.1... */ + shiftaddress(y, ((char*)y) - ((char*)x)); free(p); return y; } @@ -1644,7 +1650,7 @@ gerepile(pari_sp av, pari_sp tetpil, GEN GEN ll,a,b; if (dec==0) return q; - if ((PARI_word)dec<0) err(talker,"lbot>ltop in gerepile"); + if (av < tetpil) err(talker,"lbot>ltop in gerepile"); if ((pari_sp)q >= avma && (pari_sp)q < tetpil) q = (GEN) (((pari_sp)q) + dec); @@ -2165,7 +2171,7 @@ entree functions_basic[]={ {"kronecker",2,(void*)gkronecker,4,"GG"}, {"lcm",99,(void*)glcm0,4,"GDG"}, {"length",10,(void*)glength,2,"lG"}, -{"lex",20,(void*)lexcmp,1,"lGG"}, +{"lex",20,(void*)lexcmp_l,1,"lGG"}, {"lift",99,(void*)lift0,2,"GDn"}, {"lindep",99,(void*)lindep0,8,"GD0,L,p"}, {"listcreate",11,(void*)listcreate,8,"L"}, diff -pru pari-word-new2/src/language/sumiter.c pari-word-new1/src/language/sumiter.c --- pari-word-new2/src/language/sumiter.c Sun Nov 10 01:03:30 2002 +++ pari-word-new1/src/language/sumiter.c Sun Nov 10 00:39:46 2002 @@ -202,7 +202,7 @@ fordiv(GEN a, entree *ep, char *ch) * fl = 2: a1 < ... < an */ typedef struct { - GEN *a, *m, *M; + GEN a, *m, *M; PARI_word n,fl; char *ch; } fvdat; @@ -211,28 +211,28 @@ typedef struct { static void fvloop(PARI_word i, fvdat *d) { - d->a[i] = d->m[i]; + VEC_elt_set(d->a, i, d->m[i]); if (d->fl && i > 1) { - GEN p1 = gsub(d->a[i], d->a[i-1]); + GEN p1 = gsub(VEC_elt(d->a, i), VEC_elt(d->a, i-1)); if (gsigne(p1) < 0) - d->a[i] = gadd(d->a[i], gceil(gneg_i(p1))); - if (d->fl == 2 && gegal(d->a[i], d->a[i-1])) - d->a[i] = gadd(d->a[i], gun); + VEC_elt_set(d->a,i, gadd(VEC_elt(d->a,i), gceil(gneg_i(p1)))); + if (d->fl == 2 && gegal(VEC_elt(d->a, i), VEC_elt(d->a, i-1))) + VEC_elt_set(d->a, i, gadd(VEC_elt(d->a, i), gun)); } if (i+1 == d->n) - while (gcmp(d->a[i], d->M[i]) <= 0) + while (gcmp(VEC_elt(d->a,i), d->M[i]) <= 0) { pari_sp av = avma; (void)lisseq(d->ch); avma = av; if (loop_break()) { d->n = 0; return; } - d->a[i] = gadd(d->a[i], gun); + VEC_elt_set(d->a, i, gadd(VEC_elt(d->a,i), gun)); } else - while (gcmp(d->a[i], d->M[i]) <= 0) + while (gcmp(VEC_elt(d->a,i), d->M[i]) <= 0) { pari_sp av = avma; fvloop(i+1, d); avma = av; if (!d->n) return; - d->a[i] = gadd(d->a[i], gun); + VEC_elt_set(d->a, i, gadd(VEC_elt(d->a,i), gun)); } } @@ -240,31 +240,31 @@ fvloop(PARI_word i, fvdat *d) static void fvloop_i(PARI_word i, fvdat *d) { - d->a[i] = setloop(d->m[i]); + VEC_elt_set(d->a, i, setloop(d->m[i])); if (d->fl && i > 1) { - int c = cmpii(d->a[i], d->a[i-1]); + int c = cmpii(VEC_elt(d->a,i), VEC_elt(d->a, i-1)); if (c < 0) { - d->a[i] = setloop(d->a[i-1]); + VEC_elt_set(d->a, i, setloop(VEC_elt(d->a, i-1))); c = 0; } if (c == 0 && d->fl == 2) - d->a[i] = incloop(d->a[i]); + VEC_elt_set(d->a, i, incloop(VEC_elt(d->a, i))); } if (i+1 == d->n) - while (gcmp(d->a[i], d->M[i]) <= 0) + while (gcmp(VEC_elt(d->a, i), d->M[i]) <= 0) { pari_sp av = avma; (void)lisseq(d->ch); avma = av; if (loop_break()) { d->n = 0; return; } - d->a[i] = incloop(d->a[i]); + VEC_elt_set(d->a, i, incloop(VEC_elt(d->a,i))); } else - while (gcmp(d->a[i], d->M[i]) <= 0) + while (gcmp(VEC_elt(d->a, i), d->M[i]) <= 0) { pari_sp av = avma; fvloop_i(i+1, d); avma = av; if (!d->n) return; - d->a[i] = incloop(d->a[i]); + VEC_elt_set(d->a, i, incloop(VEC_elt(d->a,i))); } } @@ -279,7 +279,7 @@ forvec(entree *ep, GEN x, char *c, PARI_ if (flag<0 || flag>2) err(flagerr); d->n = lg(x); d->ch = c; - d->a = (GEN*)cgetg(d->n,t_VEC); push_val(ep, (GEN)d->a); + d->a = cgetg(d->n,t_VEC); push_val(ep, d->a); if (d->n == 1) (void)lisseq(d->ch); else { @@ -289,15 +289,15 @@ forvec(entree *ep, GEN x, char *c, PARI_ d->M = (GEN*)cgetg(d->n,t_VEC); for (i=1; i<d->n; i++) { - GEN *e = (GEN*) x[i]; + GEN e = VEC_elt(x, i); tx = typ(e); if (! is_vec_t(tx) || lg(e)!=3) err(talker,"not a vector of two-component vectors in forvec"); - if (gcmp(e[1],e[2]) > 0) d->n = 0; + if (gcmp(VEC_elt(e, 1), VEC_elt(e,2)) > 0) d->n = 0; if (typ(e[1]) != t_INT) t = t_REAL; /* in case x is an ep->value and lisexpr(d->ch) kills it, have to copy */ - d->m[i] = gcopy(e[1]); - d->M[i] = gcopy(e[2]); + d->m[i] = gcopy(VEC_elt(e,1)); + d->M[i] = gcopy(VEC_elt(e,2)); } if (t == t_INT) fvloop_i(1, d); else fvloop(1, d); } diff -pru pari-word-new2/src/modules/elliptic.c pari-word-new1/src/modules/elliptic.c --- pari-word-new2/src/modules/elliptic.c Sun Nov 10 01:03:42 2002 +++ pari-word-new1/src/modules/elliptic.c Sun Nov 10 00:26:26 2002 @@ -1979,7 +1979,7 @@ apell(GEN e, GEN p) # define TEMPC 46337 # define TEMPMAX as_UWORD(16777215) #else -# define TEMPC 3037000493 +# define TEMPC as_UWORD(3037000493) # define TEMPMAX as_UWORD(4294967295) #endif diff -pru pari-word-new2/src/modules/subfield.c pari-word-new1/src/modules/subfield.c --- pari-word-new2/src/modules/subfield.c Sun Nov 10 01:03:52 2002 +++ pari-word-new1/src/modules/subfield.c Sun Nov 10 00:26:26 2002 @@ -507,22 +507,22 @@ GEN TR_pol(GEN P, GEN c) { pari_sp av = avma, lim; - GEN Q, *R; + GEN Q, R; PARI_word i, k, n; if (!signe(P) || gcmp0(c)) return gcopy(P); Q = dummycopy(P); - R = (GEN*)(Q+2); n = degpol(P); + R = Q+2; n = degpol(P); lim = stack_lim(av, 2); if (gcmp1(c)) { for (i=1; i<=n; i++) { - for (k=n-i; k<n; k++) R[k] = gadd(R[k], R[k+1]); + for (k=n-i; k<n; k++) VEC_elt_set(R, k, gadd(VEC_elt(R,k), VEC_elt(R,k+1))); if (low_stack(lim, stack_lim(av,2))) { if(DEBUGMEM>1) err(warnmem,"TR_POL(1), i = %"IWdf"/%"IWdf, i,n); - Q = gerepilecopy(av, Q); R = (GEN*)Q+2; + Q = gerepilecopy(av, Q); R = Q+2; } } } @@ -530,11 +530,11 @@ TR_pol(GEN P, GEN c) { for (i=1; i<=n; i++) { - for (k=n-i; k<n; k++) R[k] = gsub(R[k], R[k+1]); + for (k=n-i; k<n; k++) VEC_elt_set(R, k, gsub(VEC_elt(R,k), VEC_elt(R,k+1))); if (low_stack(lim, stack_lim(av,2))) { if(DEBUGMEM>1) err(warnmem,"TR_POL(-1), i = %"IWdf"/%"IWdf, i,n); - Q = gerepilecopy(av, Q); R = (GEN*)Q+2; + Q = gerepilecopy(av, Q); R = Q+2; } } } @@ -542,11 +542,11 @@ TR_pol(GEN P, GEN c) { for (i=1; i<=n; i++) { - for (k=n-i; k<n; k++) R[k] = gadd(R[k], gmul(c, R[k+1])); + for (k=n-i; k<n; k++) VEC_elt_set(R, k, gadd(VEC_elt(R, k), gmul(c, VEC_elt(R, k+1)))); if (low_stack(lim, stack_lim(av,2))) { if(DEBUGMEM>1) err(warnmem,"TR_POL, i = %"IWdf"/%"IWdf, i,n); - Q = gerepilecopy(av, Q); R = (GEN*)Q+2; + Q = gerepilecopy(av, Q); R = Q+2; } } }