File: [local] / OpenXM_contrib / pari-2.2 / src / test / Attic / kerntest.c (download)
Revision 1.2, Wed Sep 11 07:27:08 2002 UTC (21 years, 11 months ago) by noro
Branch: MAIN
CVS Tags: RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2 Changes since 1.1: +8 -7
lines
Upgraded pari-2.2 to pari-2.2.4.
|
#include <pari.h>
#include <anal.h>
GEN gzero, gun, gdeux;
gpmem_t top, bot, avma;
size_t memused = 0;
long DEBUGLEVEL,DEBUGMEM = 0;
void specinit()
{
long size = 100000L;
bot = (gpmem_t)malloc(size);
top = avma = bot + size;
gzero = malloc(2);
gzero[0] = evaltyp(t_INT)|evallg(2);
gzero[1] = evallgefint(2);
gun = stoi(1);
gdeux = stoi(2);
}
void pari_err(long x, ...) { exit (0); }
GEN gerepileuptoint(gpmem_t av, GEN q){ return q; }
void gerepilemanysp(gpmem_t av, gpmem_t tetpil, GEN* gptr[], long n){}
void gerepilemany(gpmem_t av, GEN* gptr[], long n){}
void sorstring(char* b, long x)
{
#ifdef LONG_IS_64BIT
printf(b,(ulong)x>>32,x & MAXHALFULONG);
#else
printf(b,x);
#endif
}
void _voir(GEN x)
{
long tx = typ(x), lx = lg(x),i;
sorstring(VOIR_STRING2,x[0]);
if (tx==t_INT) lx = lgefint(x);
for (i=1; i < lx; i++) sorstring(VOIR_STRING2,x[i]);
printf("\n");
}
int main()
{
GEN x,y,r,z, xr,yr;
specinit();
x = stoi(187654321L);
y = stoi(-12345678L);
printf("INT: %ld\n", itos(x));
printf("conv:"); _voir(x);
printf("+:"); _voir(addii(x,y));
printf("-:"); _voir(subii(x,y));
printf("*:"); _voir(mulii(x,y));
printf("/:"); _voir(dvmdii(x,y, &z));
printf("rem:"); _voir(z);
printf("pow:\n");
z = mulii(x,x); _voir(z);
z = mulii(z,z); _voir(z);
z = mulii(z,z); _voir(z);
z = mulii(z,z); _voir(z);
z = mulii(z,z); _voir(z);
printf("invmod:"); invmod(y,z,&r); _voir(r);
xr = itor(x, DEFAULTPREC);
yr = itor(y, DEFAULTPREC);
printf("\nREAL: %f\n", rtodbl(xr));
printf("conv1:"); _voir(xr);
printf("conv2:"); _voir(dbltor(rtodbl(xr)));
printf("+:"); _voir(addrr(xr,yr));
printf("-:"); _voir(subrr(xr,yr));
printf("*:"); _voir(mulrr(xr,yr));
printf("/:"); _voir(divrr(xr,yr));
printf("gcc bug?:"); _voir(divrs(dbltor(3.),2));
return 0;
}