Annotation of OpenXM_contrib/pari-2.2/src/test/kerntest.c, Revision 1.2
1.1 noro 1: #include <pari.h>
2: #include <anal.h>
3:
4: GEN gzero, gun, gdeux;
1.2 ! noro 5: gpmem_t top, bot, avma;
! 6: size_t memused = 0;
1.1 noro 7: long DEBUGLEVEL,DEBUGMEM = 0;
8:
9: void specinit()
10: {
11: long size = 100000L;
1.2 ! noro 12: bot = (gpmem_t)malloc(size);
1.1 noro 13: top = avma = bot + size;
14: gzero = malloc(2);
15: gzero[0] = evaltyp(t_INT)|evallg(2);
16: gzero[1] = evallgefint(2);
17: gun = stoi(1);
18: gdeux = stoi(2);
19: }
20:
21: void pari_err(long x, ...) { exit (0); }
1.2 ! noro 22: GEN gerepileuptoint(gpmem_t av, GEN q){ return q; }
! 23: void gerepilemanysp(gpmem_t av, gpmem_t tetpil, GEN* gptr[], long n){}
! 24: void gerepilemany(gpmem_t av, GEN* gptr[], long n){}
1.1 noro 25:
26: void sorstring(char* b, long x)
27: {
28: #ifdef LONG_IS_64BIT
29: printf(b,(ulong)x>>32,x & MAXHALFULONG);
30: #else
31: printf(b,x);
32: #endif
33: }
34:
35: void _voir(GEN x)
36: {
37: long tx = typ(x), lx = lg(x),i;
38: sorstring(VOIR_STRING2,x[0]);
39: if (tx==t_INT) lx = lgefint(x);
40: for (i=1; i < lx; i++) sorstring(VOIR_STRING2,x[i]);
41: printf("\n");
42: }
43:
44: int main()
45: {
46: GEN x,y,r,z, xr,yr;
47: specinit();
48: x = stoi(187654321L);
49: y = stoi(-12345678L);
50: printf("INT: %ld\n", itos(x));
51: printf("conv:"); _voir(x);
52: printf("+:"); _voir(addii(x,y));
53: printf("-:"); _voir(subii(x,y));
54: printf("*:"); _voir(mulii(x,y));
55: printf("/:"); _voir(dvmdii(x,y, &z));
56: printf("rem:"); _voir(z);
57: printf("pow:\n");
58: z = mulii(x,x); _voir(z);
59: z = mulii(z,z); _voir(z);
60: z = mulii(z,z); _voir(z);
61: z = mulii(z,z); _voir(z);
62: z = mulii(z,z); _voir(z);
63: printf("invmod:"); invmod(y,z,&r); _voir(r);
1.2 ! noro 64: xr = itor(x, DEFAULTPREC);
! 65: yr = itor(y, DEFAULTPREC);
1.1 noro 66: printf("\nREAL: %f\n", rtodbl(xr));
67: printf("conv1:"); _voir(xr);
68: printf("conv2:"); _voir(dbltor(rtodbl(xr)));
69: printf("+:"); _voir(addrr(xr,yr));
70: printf("-:"); _voir(subrr(xr,yr));
71: printf("*:"); _voir(mulrr(xr,yr));
72: printf("/:"); _voir(divrr(xr,yr));
73: printf("gcc bug?:"); _voir(divrs(dbltor(3.),2));
74: return 0;
75: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>