[BACK]Return to init.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / pari / src / language

Annotation of OpenXM_contrib/pari/src/language/init.c, Revision 1.1.1.1

1.1       maekawa     1: /*******************************************************************/
                      2: /*                                                                 */
                      3: /*                INITIALIZING THE SYSTEM, ERRORS                  */
                      4: /*                                                                 */
                      5: /*******************************************************************/
                      6: /* $Id: init.c,v 1.3 1999/09/24 15:28:35 karim Exp $ */
                      7: #include <string.h>
                      8: #include "pari.h"
                      9: #include "anal.h"
                     10: #ifdef _WIN32
                     11: #  ifndef WINCE
                     12: #    include <process.h>
                     13: #  endif
                     14: #endif
                     15:
                     16: /*      Variables statiques communes :         */
                     17: FILE    *pari_outfile, *errfile, *logfile, *infile;
                     18: GEN     *polun, *polx;
                     19: GEN     gnil, gzero, gun, gdeux, ghalf, polvar, gi;
                     20: GEN     gpi=NULL, geuler=NULL, bernzone=NULL;
                     21: GEN     primetab; /* private primetable */
                     22: byteptr diffptr;
                     23: char    *current_logfile, *current_psfile;
                     24: int     gp_colors[c_LAST];
                     25: int     disable_color = 1, added_newline = 1, under_emacs = 0;
                     26:
                     27: int     functions_tblsz = 135; /* size of functions_hash          */
                     28: entree  **varentries;
                     29:
                     30: jmp_buf environnement;
                     31: long    *ordvar;
                     32: long    DEBUGFILES,DEBUGLEVEL,DEBUGMEM,compatible;
                     33: long    prec,precdl;
                     34: ulong   init_opts = INIT_JMPm | INIT_SIGm;
                     35: ulong   top, bot, avma, memused;
                     36:
                     37: void *foreignHandler;                /* Handler for foreign commands.   */
                     38: char foreignExprSwitch = 3;          /* Just some unprobable char.      */
                     39: GEN  (*foreignExprHandler)(char*);    /* Handler for foreign expressions.*/
                     40: entree * (*foreignAutoload)(char*, long); /* Autoloader                      */
                     41: void (*foreignFuncFree)(entree *);    /* How to free external entree.    */
                     42:
                     43: GEN  (*gp_history_fun)(long, long, char *, char *);
                     44: int  (*whatnow_fun)(char *, int);
                     45:
                     46: void  initout(void);
                     47: int   term_width(void);
                     48:
                     49: /*********************************************************************/
                     50: /*                                                                   */
                     51: /*                     INITIALISATION DU SYSTEME                     */
                     52: /*                                                                   */
                     53: /*********************************************************************/
                     54: static int var_not_changed; /* altered in reorder() */
                     55: static int try_to_recover = 0;
                     56: static long next_bloc;
                     57: static GEN cur_bloc=NULL; /* current bloc in bloc list */
                     58: static long *universal_constants;
                     59:
                     60: #ifdef WINCE
                     61: #else
                     62: static void
                     63: pari_sighandler(int sig)
                     64: {
                     65:   char *msg;
                     66:   switch(sig)
                     67:   {
                     68:     case SIGINT:
                     69: #ifdef _WIN32
                     70: # ifdef SIGBREAK
                     71:     case SIGBREAK:
                     72: # endif
                     73:       if (++win32ctrlc >= 5) _exit(3);
                     74:       signal(sig,pari_sighandler);
                     75:       return;
                     76: #endif
                     77:       msg="user interrupt";
                     78:       break;
                     79:
                     80:     case SIGSEGV:
                     81:       msg="segmentation fault: bug in PARI or calling program";
                     82:       break;
                     83:
                     84: #ifdef SIGBUS
                     85:     case SIGBUS:
                     86:       msg="bus error: bug in PARI or calling program";
                     87:       break;
                     88: #endif
                     89:   }
                     90:   signal(sig,pari_sighandler);
                     91:   err(talker,msg);
                     92: }
                     93: #endif
                     94:
                     95: #ifdef _WIN32
                     96: int win32ctrlc = 0;
                     97:
                     98: void
                     99: dowin32ctrlc()
                    100: {
                    101:    win32ctrlc = 0;
                    102:    err(talker,"user interrupt");
                    103: }
                    104: #endif
                    105:
                    106: /* Initialize hashtable */
                    107: static void
                    108: init_hashtable(entree **table, int tblsz)
                    109: {
                    110:   entree *ep, *ep1, *last;
                    111:   long i, v;
                    112:
                    113:   for (i = 0; i < tblsz; i++)
                    114:   {
                    115:     last = NULL; ep = table[i]; table[i] = NULL;
                    116:     for ( ; ep; ep = ep1)
                    117:     {
                    118:       ep1 = ep->next; v = EpVALENCE(ep);
                    119:       if (v == EpVAR || v == EpINSTALL) /* keep this one */
                    120:       {
                    121:         if (last)
                    122:           last->next = ep;
                    123:         else
                    124:           table[i] = ep;
                    125:         last = ep; last->next = NULL;
                    126:       }
                    127:       else freeep(ep);
                    128:     }
                    129:   }
                    130: }
                    131:
                    132: static void
                    133: fill_hashtable(entree **table, entree *ep, char **helpmessage)
                    134: {
                    135:   long n;
                    136:
                    137:   for ( ; ep->name; ep++)
                    138:   {
                    139:     EpSETSTATIC(ep);
                    140:     ep->help = helpmessage? *helpmessage++: NULL;
                    141:     n = hashvalue(ep->name);
                    142:     ep->next = table[n]; table[n] = ep;
                    143:     ep->args = NULL;
                    144:   }
                    145: }
                    146:
                    147: void
                    148: init_defaults(int force)
                    149: {
                    150:   static int done=0;
                    151:
                    152:   if (done && !force) return;
                    153:   done = 1;
                    154:
                    155: #ifdef LONG_IS_64BIT
                    156:   prec=4;
                    157: #else
                    158:   prec=5;
                    159: #endif
                    160:
                    161:   precdl = 16;
                    162:   compatible = NONE;
                    163:   DEBUGFILES = DEBUGLEVEL = DEBUGMEM = 0;
                    164:
                    165:   current_psfile = pari_strdup("pari.ps");
                    166:   current_logfile= pari_strdup("pari.log");
                    167:   logfile = NULL;
                    168:   infile = stdin; pari_outfile = stdout; errfile = stderr;
                    169:   initout(); next_bloc=0;
                    170: }
                    171:
                    172: /* does elt belong to list, after position start (excluded) ? */
                    173: static int
                    174: list_isin(void **list, void *elt, int start)
                    175: {
                    176:   long indelt=0;
                    177:
                    178:   if (list)
                    179:   {
                    180:     while (*list)
                    181:     {
                    182:       if (indelt>start && *list==elt) return indelt;
                    183:       list++; indelt++;
                    184:     }
                    185:   }
                    186:   return -1;
                    187: }
                    188:
                    189: static void
                    190: list_prepend(void ***listptr, void *elt)
                    191: {
                    192:   void **list=*listptr;
                    193:   long nbelt=0;
                    194:
                    195:   if (list)
                    196:     while (list[nbelt]) nbelt++;
                    197:   list = (void **) gpmalloc(sizeof(void *)*(nbelt+2));
                    198:   list[0]=elt;
                    199:   if (nbelt)
                    200:   {
                    201:     memcpy(list+1,*listptr,nbelt*sizeof(void *));
                    202:     free(*listptr);
                    203:   }
                    204:   list[nbelt+1]=NULL; *listptr=list;
                    205: }
                    206:
                    207: /* Load modlist in hashtable hash. If force == 0, do not load twice the
                    208:  * same list in the same hashtable, which would only destroy user variables.
                    209:  * As it stands keep a complete history (instead of most recent changes).
                    210:  */
                    211: int
                    212: gp_init_entrees(module *modlist, entree **hash, int force)
                    213: {
                    214:   static void **oldmodlist=NULL, **oldhash=NULL;
                    215:
                    216:   if (!force)
                    217:   {
                    218:     const long indhash = list_isin(oldhash,(void *)hash,-1);
                    219:     if (indhash != -1 && oldmodlist[indhash]==modlist) return 0;
                    220:   }
                    221:   /* record the new pair (hash,modlist) */
                    222:   list_prepend(&oldmodlist,(void *)modlist);
                    223:   list_prepend(&oldhash,(void *)hash);
                    224:
                    225:   init_hashtable(hash,functions_tblsz);
                    226:   while (modlist && modlist->func)
                    227:   {
                    228:     fill_hashtable(hash, modlist->func, modlist->help);
                    229:     modlist++;
                    230:   }
                    231:   return (hash == functions_hash);
                    232: }
                    233:
                    234: module *pari_modules    = NULL;
                    235: module *pari_oldmodules = NULL;
                    236: module *pari_membermodules = NULL;
                    237: entree **functions_hash = NULL;
                    238: entree **funct_old_hash = NULL;
                    239: entree **members_hash   = NULL;
                    240:
                    241: /* add to modlist the functions in func, with helpmsg help */
                    242: void
                    243: pari_addfunctions(module **modlist_p, entree *func, char **help)
                    244: {
                    245:   module *modlist = *modlist_p;
                    246:   int nbmodules = 0;
                    247:
                    248:   while (modlist && modlist->func) { nbmodules++; modlist++; }
                    249:   modlist = *modlist_p;
                    250:   *modlist_p = (module*) gpmalloc(sizeof(module)*(nbmodules+2));
                    251:   if (nbmodules)
                    252:   {
                    253:     memcpy(1+ *modlist_p, modlist, sizeof(module)*nbmodules);
                    254:     free(modlist);
                    255:   }
                    256:   modlist = *modlist_p;
                    257:   modlist->func = func;
                    258:   modlist->help = help;
                    259:
                    260:   modlist += nbmodules+1;
                    261:   modlist->func = NULL;
                    262:   modlist->help = NULL;
                    263: }
                    264:
                    265: static long
                    266: fix_size(long a)
                    267: {
                    268:   /* BYTES_IN_LONG*ceil(a/BYTES_IN_LONG) */
                    269:   ulong b = a+BYTES_IN_LONG - (((a-1) & (BYTES_IN_LONG-1)) + 1);
                    270:   if (b > VERYBIGINT) err(talker,"stack too large");
                    271:   return b;
                    272: }
                    273:
                    274: void
                    275: pari_sig_init(void (*f)(int))
                    276: {
                    277: #ifdef WINCE
                    278: #else
                    279: #ifdef SIGBUS
                    280:   signal(SIGBUS,f);
                    281: #endif
                    282:   signal(SIGINT,f);
                    283: #ifdef SIGBREAK
                    284:   signal(SIGBREAK,f);
                    285: #endif
                    286:   signal(SIGSEGV,f);
                    287: #endif
                    288: }
                    289:
                    290: /* initialise les donnees de la bibliotheque PARI. Peut être précédée d'un
                    291:  * appel à pari_addfunctions si on ajoute d'autres fonctions au pool de base.
                    292:  */
                    293: void
                    294: pari_init(long parisize, long maxprime)
                    295: {
                    296:   long n;
                    297:   GEN p;
                    298:
                    299:   init_defaults(0);
                    300:   if (INIT_JMP && setjmp(environnement))
                    301:   {
                    302:     fprintferr("  ***   Error in the PARI system. End of program.\n");
                    303:     exit(1);
                    304:   }
                    305: #ifndef WINCE
                    306:   if (INIT_SIG) pari_sig_init(pari_sighandler);
                    307: #endif
                    308:   parisize = fix_size(parisize);
                    309: #if __MWERKS__
                    310:   {
                    311:     OSErr resultCode;
                    312:     Handle newHand = TempNewHandle(parisize,&resultCode);
                    313:
                    314:     if (!newHand) err(memer);
                    315:     HLock(newHand);
                    316:     bot = (long)*newHand;
                    317:   }
                    318: #else
                    319:   bot = (long) gpmalloc(parisize);
                    320: #endif
                    321:   top = avma = memused = bot+parisize;
                    322:   diffptr = initprimes(maxprime);
                    323:
                    324:   varentries = (entree**) gpmalloc((MAXVARN+1)*sizeof(entree*));
                    325:   polvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long));
                    326:   ordvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long));
                    327:   polx  = (GEN*) gpmalloc((MAXVARN+1)*sizeof(GEN));
                    328:   polun = (GEN*) gpmalloc((MAXVARN+1)*sizeof(GEN));
                    329:   polvar[0] = evaltyp(t_VEC) | evallg(1);
                    330:   for (n=0; n <= MAXVARN; n++) ordvar[n] = n;
                    331:
                    332:   /* 2 (gnil) + 2 (gzero) + 3 (gun) + 3 (gdeux) + 3 (half) + 3 (gi) */
                    333:   p = universal_constants = (long *) gpmalloc(16*sizeof(long));
                    334:
                    335:   gzero = p; p+=2; gnil = p; p+=2;
                    336:   gzero[0] = gnil[0] = evaltyp(t_INT) | evallg(2);
                    337:   gzero[1] = gnil[1] = evallgefint(2);
                    338:
                    339:   gun = p; p+=3; gdeux = p; p+=3;
                    340:   gun[0] = gdeux[0] = evaltyp(t_INT) | evallg(3);
                    341:   gun[1] = gdeux[1] = evalsigne(1) | evallgefint(3);
                    342:   gun[2] = 1; gdeux[2]= 2;
                    343:
                    344:   ghalf = p; p+=3; gi = p; p+=3;
                    345:   ghalf[0] = evaltyp(t_FRAC) | evallg(3);
                    346:   ghalf[1] = un;
                    347:   ghalf[2] = deux;
                    348:   gi[0] = evaltyp(t_COMPLEX) | evallg(3);
                    349:   gi[1] = zero;
                    350:   gi[2] = un;
                    351:   fetch_var(); /* create polx/polun[MAXVARN] */
                    352:   primetab = (GEN) gpmalloc((NUMPRTBELT+2)*sizeof(long));
                    353:   primetab[0] = evaltyp(t_VEC) | evallg(1);
                    354:
                    355:   pari_addfunctions(&pari_modules, functions_basic,helpmessages_basic);
                    356:   functions_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    357:   for (n = 0; n < functions_tblsz; n++) functions_hash[n] = NULL;
                    358:
                    359:   pari_addfunctions(&pari_oldmodules, oldfonctions,oldhelpmessage);
                    360:   funct_old_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    361:   for (n = 0; n < functions_tblsz; n++) funct_old_hash[n] = NULL;
                    362:   gp_init_entrees(pari_oldmodules, funct_old_hash, 1);
                    363:
                    364:   if (new_fun_set)
                    365:     gp_init_entrees(pari_modules, functions_hash, 1);
                    366:   else
                    367:     gp_init_entrees(pari_oldmodules, functions_hash, 1);
                    368:
                    369:   pari_addfunctions(&pari_membermodules, gp_member_list, NULL);
                    370:   members_hash = (entree **) gpmalloc(sizeof(entree*)*functions_tblsz);
                    371:   for (n = 0; n < functions_tblsz; n++) members_hash[n] = NULL;
                    372:   gp_init_entrees(pari_membermodules, members_hash, 1);
                    373:
                    374:   gp_history_fun = NULL;
                    375:   whatnow_fun = NULL;
                    376:   manage_var(2,NULL); /* init nvar */
                    377:   var_not_changed = 1; fetch_named_var("x", 0);
                    378:   try_to_recover=1;
                    379: }
                    380:
                    381: void
                    382: freeall()
                    383: {
                    384:   long i;
                    385:   entree *ep,*ep1;
                    386:
                    387:   while (delete_var()) /* empty */;
                    388:   for (i = 0; i < functions_tblsz; i++)
                    389:   {
                    390:     for (ep = functions_hash[i]; ep; ep = ep1)
                    391:     {
                    392:       ep1 = ep->next; freeep(ep);
                    393:     }
                    394:     for (ep = members_hash[i]; ep; ep = ep1)
                    395:     {
                    396:       ep1 = ep->next; freeep(ep);
                    397:     }
                    398:   }
                    399:   free((void*)varentries); free((void*)ordvar); free((void*)polvar);
                    400:   free((void*)polx[MAXVARN]); free((void*)polx); free((void*)polun);
                    401:   free((void*)primetab);
                    402:   free((void*)universal_constants);
                    403:
                    404:   /* set first cell to 0 to inhibit recursion in all cases */
                    405:   while (cur_bloc) { *cur_bloc=0; killbloc(cur_bloc); }
                    406:   killallfiles(1);
                    407:   free((void *)functions_hash);
                    408:   free((void *)bot); free((void *)diffptr);
                    409:   free(current_logfile);
                    410:   free(current_psfile);
                    411:
                    412:   if (gp_history_fun)
                    413:     gp_history_fun(0,-1,NULL,NULL);
                    414: }
                    415:
                    416: GEN
                    417: getheap()
                    418: {
                    419:   long m=0,l=0;
                    420:   GEN x;
                    421:
                    422:   for (x = cur_bloc; x; x = (GEN)bl_prev(x))
                    423:   {
                    424:     m++; l+=4;
                    425:     if (! x[0]) /* user function */
                    426:       l += (strlen((char *)(x+sizeof(entree*)))) / sizeof(long);
                    427:     else if (x==bernzone)
                    428:       l += x[0];
                    429:     else /* GEN */
                    430:       l += taille(x);
                    431:   }
                    432:   x=cgetg(3,t_VEC); x[1]=lstoi(m); x[2]=lstoi(l);
                    433:   return x;
                    434: }
                    435:
                    436: /* Return x, where:
                    437:  * x[-3]: adress of next bloc
                    438:  * x[-2]: adress of preceding bloc.
                    439:  * x[-1]: number of allocated blocs.
                    440:  * x[0..n-1]: malloc-ed memory.
                    441:  */
                    442: GEN
                    443: newbloc(long n)
                    444: {
                    445:   long *x = (long *) gpmalloc((n + BL_HEAD)*sizeof(long)) + BL_HEAD;
                    446:
                    447:   bl_next(x) = 0; /* the NULL address */
                    448:   bl_prev(x) = (long)cur_bloc;
                    449:   bl_num(x)  = next_bloc++;
                    450:   if (n) *x = 0; /* initialize first cell to 0. See killbloc */
                    451:   if (cur_bloc) bl_next(cur_bloc) = (long)x;
                    452:   if (DEBUGMEM)
                    453:   {
                    454:     if (!n) err(warner,"mallocing NULL object in newbloc");
                    455:     if (DEBUGMEM > 2)
                    456:       fprintferr("new bloc, size %6ld (no %ld): %08lx\n", n, next_bloc-1, x);
                    457:   }
                    458:   return cur_bloc = x;
                    459: }
                    460:
                    461: void
                    462: killbloc0(GEN x, int inspect)
                    463: {
                    464:   long tx,lx,l,i,j;
                    465:   GEN p1;
                    466:
                    467:   if (!x || isonstack(x)) return;
                    468:   if (bl_next(x)) bl_prev(bl_next(x)) = bl_prev(x);
                    469:   else
                    470:   {
                    471:     cur_bloc = (GEN)bl_prev(x);
                    472:     next_bloc = bl_num(x);
                    473:   }
                    474:   if (bl_prev(x)) bl_next(bl_prev(x)) = bl_next(x);
                    475:   if (DEBUGMEM > 2)
                    476:     fprintferr("killing bloc (no %ld): %08lx\n", bl_num(x), x);
                    477:   if (inspect)
                    478:   {
                    479:     /* FIXME: SIGINT should be blocked at this point */
                    480:     tx=typ(x); /* if x is not a GEN, we will have tx=0 */
                    481:     if (is_vec_t(tx))
                    482:     {
                    483:       lx = lg(x);
                    484:       for (i=1;i<lx;i++)
                    485:       {
                    486:         p1=(GEN)x[i];
                    487:         if (isclone(p1)) killbloc(p1);
                    488:       }
                    489:     }
                    490:     else if (tx==t_MAT)
                    491:     {
                    492:       lx = lg(x);
                    493:       if (lx>1)
                    494:       {
                    495:         l=lg(x[1]);
                    496:         if (l>1)
                    497:           for (i=1;i<lx;i++)
                    498:             for (j=1;j<l;j++)
                    499:             {
                    500:               p1=gmael(x,i,j);
                    501:               if (isclone(p1)) killbloc(p1);
                    502:             }
                    503:       }
                    504:     }
                    505:     else if (tx==t_LIST)
                    506:     {
                    507:       lx = lgef(x);
                    508:       for (i=2;i<lx;i++)
                    509:       {
                    510:         p1=(GEN)x[i];
                    511:         if (isclone(p1)) killbloc(p1);
                    512:       }
                    513:     }
                    514:     unsetisclone(x);
                    515:     /* FIXME: SIGINT should be released here */
                    516:   }
                    517:   free((void *)bl_base(x));
                    518: }
                    519: void
                    520: killbloc(GEN x) { killbloc0(x,1); }
                    521: void
                    522: gunclone(GEN x) { killbloc0(x,0); }
                    523:
                    524: /********************************************************************/
                    525: /**                                                                **/
                    526: /**                       VARIABLE ORDERING                        **/
                    527: /**                                                                **/
                    528: /********************************************************************/
                    529:
                    530: /* Substitution globale des composantes du vecteur y aux variables de x */
                    531: GEN
                    532: changevar(GEN x, GEN y)
                    533: {
                    534:   long tx,ty,lx,vx,vy,i,av,tetpil;
                    535:   GEN  p1,p2,z;
                    536:
                    537:   if (var_not_changed && y==polvar) return x;
                    538:   tx=typ(x); if (!is_recursive_t(tx)) return gcopy(x);
                    539:   ty=typ(y); if (! is_vec_t(ty)) err(changer1);
                    540:   if (is_scalar_t(tx))
                    541:   {
                    542:     if (tx!=t_POLMOD) return gcopy(x);
                    543:     av=avma;
                    544:     p1=changevar((GEN)x[1],y);
                    545:     p2=changevar((GEN)x[2],y); tetpil=avma;
                    546:     return gerepile(av,tetpil, gmodulcp(p2,p1));
                    547:   }
                    548:   if (is_rfrac_t(tx))
                    549:   {
                    550:     av=avma;
                    551:     p1=changevar((GEN)x[1],y);
                    552:     p2=changevar((GEN)x[2],y); tetpil=avma;
                    553:     return gerepile(av,tetpil, gdiv(p1,p2));
                    554:   }
                    555:
                    556:   lx = (tx==t_POL)? lgef(x): lg(x);
                    557:   if (tx == t_POL || tx == t_SER)
                    558:   {
                    559:     vx=varn(x)+1; if (vx>=lg(y)) return gcopy(x);
                    560:     p1=(GEN)y[vx];
                    561:     if (!signe(x))
                    562:     {
                    563:       vy=gvar(p1); if (vy>MAXVARN) err(changer1);
                    564:       z=gcopy(x); setvarn(z,vy); return z;
                    565:     }
                    566:     av=avma; p2=changevar((GEN)x[lx-1],y);
                    567:     for (i=lx-2; i>=2; i--)
                    568:     {
                    569:       p2 = gmul(p2,p1);
                    570:       p2 = gadd(p2, changevar((GEN)x[i],y));
                    571:     }
                    572:     if (tx==t_SER)
                    573:     {
                    574:       p2 = gadd(p2, ggrando(p1,lx-2));
                    575:       if (valp(x))
                    576:         p2 = gmul(gpuigs(p1,valp(x)), p2);
                    577:     }
                    578:     return gerepileupto(av,p2);
                    579:   }
                    580:   z=cgetg(lx,tx);
                    581:   for (i=1; i<lx; i++) z[i]=lchangevar((GEN)x[i],y);
                    582:   return z;
                    583: }
                    584:
                    585: GEN
                    586: reorder(GEN x)
                    587: {
                    588:   long tx,lx,i,n, nvar = manage_var(3,NULL);
                    589:   int *var,*varsort,*t1;
                    590:
                    591:   if (!x) return polvar;
                    592:   tx=typ(x); lx=lg(x)-1;
                    593:   if (! is_vec_t(tx)) err(typeer,"reorder");
                    594:   if (! lx) return polvar;
                    595:
                    596:   varsort = (int *) gpmalloc(lx*sizeof(int));
                    597:   var = (int *) gpmalloc(lx*sizeof(int));
                    598:   t1 = (int *) gpmalloc(nvar*sizeof(int));
                    599:
                    600:   for (n=0; n<nvar; n++) t1[n] = 0;
                    601:   for (n=0; n<lx; n++)
                    602:   {
                    603:     var[n] = i = gvar((GEN)x[n+1]);
                    604:     varsort[n] = ordvar[var[n]]; /* position in polvar */
                    605:     if (i >= nvar) err(talker,"variable out of range in reorder");
                    606:     /* check if x is a permutation */
                    607:     if (t1[i]) err(talker,"duplicated indeterminates in reorder");
                    608:     t1[i] = 1;
                    609:   }
                    610:   qsort(varsort,lx,sizeof(int),(QSCOMP)pari_compare_int);
                    611:
                    612:   for (n=0; n<lx; n++)
                    613:   {
                    614:     /* variables are numbered 0,1 etc... while polvar starts at 1. */
                    615:     polvar[varsort[n]+1] = lpolx[var[n]];
                    616:     ordvar[var[n]] = varsort[n];
                    617:   }
                    618:
                    619:   var_not_changed=1;
                    620:   for (i=0; i<nvar; i++)
                    621:     if (ordvar[i]!=i) { var_not_changed=0; break; }
                    622:
                    623:   free(t1); free(var); free(varsort);
                    624:   return polvar;
                    625: }
                    626:
                    627: /*******************************************************************/
                    628: /*                                                                 */
                    629: /*                         ERROR RECOVERY                          */
                    630: /*                                                                 */
                    631: /*******************************************************************/
                    632: int pop_val_if_newer(entree *ep, long loc);
                    633: void kill_from_hashlist(entree *ep);
                    634:
                    635: /* if flag = 0: record address of next bloc allocated.
                    636:  * if flag = 1: (after an error) recover all memory allocated since last call
                    637:  */
                    638: void
                    639: recover(int flag)
                    640: {
                    641:   static long listloc;
                    642:   long n;
                    643:   entree *ep, *epnext;
                    644: #ifndef WINCE
                    645:   void (*sigfun)(int);
                    646: #endif
                    647:
                    648:   if (!flag) { listloc = next_bloc; return; }
                    649:
                    650:  /* disable recover() and SIGINT. Better: sigint_[block|release] as in
                    651:   * readline/rltty.c ? */
                    652:   try_to_recover=0;
                    653: #ifndef WINCE
                    654:   sigfun = signal(SIGINT, SIG_IGN);
                    655: #endif
                    656:
                    657:   for (n = 0; n < functions_tblsz; n++)
                    658:     for (ep = functions_hash[n]; ep; ep = epnext)
                    659:     {
                    660:       epnext = ep->next;
                    661:       switch(EpVALENCE(ep))
                    662:       {
                    663:         case EpVAR:
                    664:           while (pop_val_if_newer(ep,listloc)) /* empty */;
                    665:           break;
                    666:         case EpNEW:
                    667:           kill_from_hashlist(ep);
                    668:           break;
                    669:         case EpUSER:
                    670:         case EpALIAS:
                    671:         case EpMEMBER:
                    672:           if (bl_num(ep->value) >= listloc)
                    673:           {
                    674:             gunclone((GEN)ep->value);
                    675:             ep->value = (void*)initial_value(ep);
                    676:             kill_from_hashlist(ep);
                    677:           }
                    678:       }
                    679:     }
                    680: #if 0
                    681:  /* This causes SEGV on lists and GP-2.0 vectors: internal component is
                    682:   * destroyed while global object is not updated. Two solutions:
                    683:   *  - comment it out: should not be a big memory problem except for huge
                    684:   *  vec. components. Has the added advantadge that the results computed so
                    685:   *  far are not lost.
                    686:   *
                    687:   *  - tag every variable whose component has been modified in the last
                    688:   *  cycle. Untag it at the begining of each cycle. Maybe this should be
                    689:   *  done. But do we really want to destroy a huge global vector if one of
                    690:   *  its components was modified before the error ? (we don't copy the whole
                    691:   *  thing anymore). K.B.
                    692:   */
                    693:   {
                    694:     GEN y;
                    695:     for (x = cur_bloc; x && bl_num(x) >= listloc; x = y)
                    696:     {
                    697:       y = (GEN)bl_prev(x);
                    698:       if (x != gpi && x != geuler && x != bernzone) killbloc(x);
                    699:     }
                    700:   }
                    701: #endif
                    702:   try_to_recover=1;
                    703: #ifndef WINCE
                    704:   signal(SIGINT, sigfun);
                    705: #endif
                    706: }
                    707:
                    708: void
                    709: disable_dbg(long val)
                    710: {
                    711:   static long oldval = -1;
                    712:   if (val < 0)
                    713:   {
                    714:     if (oldval >= 0) { DEBUGLEVEL = oldval; oldval = -1; }
                    715:   }
                    716:   else if (DEBUGLEVEL)
                    717:     { oldval = DEBUGLEVEL; DEBUGLEVEL = val; }
                    718: }
                    719:
                    720: void
                    721: err_recover(long numerr)
                    722: {
                    723:   pari_outfile=stdout; errfile=stderr;
                    724:   disable_dbg(-1);
                    725:   if (pariErr->die) pariErr->die();    /* Caller wants to catch exceptions? */
                    726:   fprintferr("\n"); flusherr();
                    727:   if (!environnement) exit(1);
                    728:
                    729:   /* reclaim memory stored in "blocs" */
                    730:   if (try_to_recover) recover(1);
                    731:   /* allocate _after_ recover (otherwise we may inspect freed memory) */
                    732:   if (numerr==errpile) (void)allocatemoremem(0);
                    733:   longjmp(environnement, numerr);
                    734: }
                    735:
                    736: #define MAX_PAST 25
                    737: #define STR_LEN 20
                    738: /* Outputs a beautiful error message
                    739:  *   msg is errmessage to print.
                    740:  *   s points to the offending chars.
                    741:  *   entry tells how much we can go back from s[0].
                    742:  */
                    743: static void
                    744: errcontext(char *msg, char *s, char *entry)
                    745: {
                    746:   char *prefix = "  ***   ";
                    747:   int past = (s-entry);
                    748:   char str[STR_LEN + 2];
                    749:   char *buf = gpmalloc(strlen(msg) + MAX_PAST + 5), *t = buf;
                    750:
                    751:   sprintf(t,"%s: ", msg);
                    752:   if (past <= 0) past = 0;
                    753:   else
                    754:   {
                    755:     t += strlen(t);
                    756:     if (past > MAX_PAST) { past=MAX_PAST; strcpy(t, "..."); t += 3; }
                    757:     strncpy(t, s - past, past); t[past] = 0;
                    758:   }
                    759:
                    760:   t = str; if (!past) *t++ = ' ';
                    761:   strncpy(t, s, STR_LEN); t[STR_LEN] = 0;
                    762:   print_prefixed_text(buf, prefix, str); free(buf);
                    763: }
                    764:
                    765: #define op_err(ap, op) {\
                    766:   long _x = va_arg(ap, long);\
                    767:   long _y = va_arg(ap, long);\
                    768:   (pariputsf(" %s %s %s.",type_name(_x),(op),type_name(_y)));\
                    769: }
                    770:
                    771: VOLATILE void
                    772: err(long numerr, ...)
                    773: {
                    774:   char s[128], *ch1, ret = 0;
                    775:   PariOUT *out = pariOut;
                    776:   va_list ap;
                    777:
                    778:   va_start(ap,numerr);
                    779:   if (!added_newline) { pariputc('\n'); added_newline=1; }
                    780:   pariflush(); pariOut = pariErr;
                    781:   pariflush(); term_color(c_ERR);
                    782:
                    783:   if (numerr < talker)
                    784:   {
                    785:     strcpy(s, errmessage[numerr]);
                    786:     switch (numerr)
                    787:     {
                    788:       case obsoler:
                    789:         ch1 = va_arg(ap,char *);
                    790:         errcontext(s,ch1,va_arg(ap,char *));
                    791:         if (whatnow_fun)
                    792:         {
                    793:           print_text("For full compatibility with GP 1.39, type \"default(compatible,3)\" (you can also set \"compatible = 3\" in your GPRC file)");
                    794:           pariputc('\n');
                    795:           term_color(c_NONE); ch1 = va_arg(ap,char *);
                    796:           whatnow_fun(ch1, - va_arg(ap,int));
                    797:         }
                    798:         break;
                    799:
                    800:       case openfiler:
                    801:         sprintf(s+strlen(s), "%s file", va_arg(ap,char*));
                    802:         ch1 = va_arg(ap,char *);
                    803:         errcontext(s,ch1,ch1); break;
                    804:
                    805:       case talker2:
                    806:       case member:
                    807:         strcat(s,va_arg(ap, char*)); /* fall through */
                    808:       default:
                    809:         ch1 = va_arg(ap,char *);
                    810:         errcontext(s,ch1,va_arg(ap,char *));
                    811:     }
                    812:   }
                    813:   else
                    814:   {
                    815:     pariputsf("  ***   %s", errmessage[numerr]);
                    816:     switch (numerr)
                    817:     {
                    818:       case talker:
                    819:         ch1=va_arg(ap, char*);
                    820:         vpariputs(ch1,ap); pariputs(".\n"); break;
                    821:
                    822:       case impl:
                    823:         ch1=va_arg(ap, char*);
                    824:         pariputsf(" %s is not yet implemented.",ch1); break;
                    825:
                    826:       case breaker: case typeer: case mattype1: case overwriter:
                    827:       case accurer: case infprecer: case negexper: case polrationer:
                    828:       case funder2: case constpoler: case notpoler: case redpoler:
                    829:       case zeropoler: case consister: case flagerr:
                    830:         pariputsf(" %s.",va_arg(ap, char*)); break;
                    831:
                    832:       case bugparier:
                    833:         pariputsf(" %s, please report",va_arg(ap, char*)); break;
                    834:
                    835:       case assigneri: case assignerf:
                    836:         op_err(ap, "-->"); break;
                    837:       case gadderi: case gadderf:
                    838:         op_err(ap, "+"); break;
                    839:       case gmuleri: case gmulerf:
                    840:         op_err(ap, "*"); break;
                    841:       case gdiveri: case gdiverf:
                    842:         op_err(ap, "/"); break;
                    843:
                    844:       /* the following 4 are only warnings (they return) */
                    845:       case warnmem: case warner:
                    846:         pariputc(' '); ch1=va_arg(ap, char*);
                    847:         vpariputs(ch1,ap); pariputs(".\n");
                    848:         ret = 1; break;
                    849:
                    850:       case warnprec:
                    851:         vpariputs(" %s; new prec = %ld\n",ap);
                    852:         ret = 1; break;
                    853:
                    854:       case warnfile:
                    855:         ch1=va_arg(ap, char*);
                    856:         pariputsf(" %s: %s", ch1, va_arg(ap, char*));
                    857:     }
                    858:   }
                    859:   term_color(c_NONE); va_end(ap);
                    860:   pariOut = out; if (ret) { flusherr(); return; }
                    861:   err_recover(numerr); exit(1); /* not reached */
                    862: }
                    863: #undef op_err
                    864:
                    865: /*******************************************************************/
                    866: /*                                                                 */
                    867: /*                         STACK MANAGEMENT                        */
                    868: /*                                                                 */
                    869: /*******************************************************************/
                    870: /* Inhibit some area gerepile-wise: declare it to be a non recursive
                    871:  * type, of length l. Thus gerepile won't inspect the zone, just copy it.
                    872:  * For the following situation:
                    873:  *   z = cgetg(t,a); garbage of length l;
                    874:  *   for (i=1; i<HUGE; i++) z[i] = ...
                    875:  *   stackdummy(z,l); z += l; We lose l words but save a costly gerepile.
                    876:  */
                    877: void
                    878: stackdummy(GEN z, long l)
                    879: {
                    880:   z[0] = evaltyp(t_STR) | evallg(l);
                    881: }
                    882:
                    883: /* Takes an array of pointers to GENs, of length n. Copies all
                    884:  * objects to contiguous locations and cleans up the stack between
                    885:  * av and avma.
                    886:  */
                    887: void
                    888: gerepilemany(long av, GEN* gptr[], long n)
                    889: {
                    890:   GEN *l = (GEN*)gpmalloc(n*sizeof(GEN));
                    891:   long i;
                    892:
                    893:   /* copy objects */
                    894:   for (i=0; i<n; i++) l[i] = gclone(*(gptr[i]));
                    895:   avma = av;
                    896:   /* copy them back, kill clones */
                    897:   for (--i; i>=0; i--)
                    898:   {
                    899:     *(gptr[i]) = forcecopy(l[i]);
                    900:     gunclone(l[i]);
                    901:   }
                    902:   free(l);
                    903: }
                    904:
                    905: void
                    906: gerepilemanycoeffs(long av, GEN x, long n)
                    907: {
                    908:   long i;
                    909:
                    910:   /* copy objects */
                    911:   for (i=0; i<n; i++) x[i] = lclone((GEN)x[i]);
                    912:   avma = av;
                    913:   /* copy them back, kill clones */
                    914:   for (--i; i>=0; i--)
                    915:   {
                    916:     GEN p1 = (GEN)x[i];
                    917:     x[i] = (long)forcecopy(p1); gunclone(p1);
                    918:   }
                    919: }
                    920:
                    921: /* Takes an array of pointers to GENs, of length n.
                    922:  * Cleans up the stack between av and tetpil, updating those GENs.
                    923:  */
                    924: void
                    925: gerepilemanysp(long av, long tetpil, GEN* gptr[], long n)
                    926: {
                    927:   const long av2 = avma, dec = av-tetpil;
                    928:   long i;
                    929:
                    930:   (void)gerepile(av,tetpil,NULL);
                    931:   for (i=0; i<n; i++)
                    932:   {
                    933:     ulong *g1 = (ulong*) gptr[i];
                    934:     if (*g1 < (ulong)tetpil)
                    935:     {
                    936:       if (*g1 >= (ulong)av2) *g1 += dec; /* Update address if in stack */
                    937:       else if (*g1 >=(ulong)av) err(gerper);
                    938:     }
                    939:   }
                    940: }
                    941:
                    942: /* Takes an array of GENs (casted to longs), of length n. Cleans up the
                    943:  * stack between av and tetpil, and update those GENs.
                    944:  */
                    945: void
                    946: gerepilemanyvec(long av, long tetpil, long *g, long n)
                    947: {
                    948:   const long av2 = avma, dec = av-tetpil;
                    949:   long i;
                    950:
                    951:   (void)gerepile(av,tetpil,NULL);
                    952:   for (i=0; i<n; i++,g++)
                    953:     if ((ulong)*g < (ulong)tetpil)
                    954:     {
                    955:       if ((ulong)*g >= (ulong)av2) *g += dec;/* Update addresses if in stack */
                    956:       else if ((ulong)*g >= (ulong)av) err(gerper);
                    957:     }
                    958: }
                    959:
                    960: GEN
                    961: gerepileupto(long av, GEN q)
                    962: {
                    963:   if (!isonstack(q)) { avma=av; return q; } /* universal object */
                    964:   /* empty garbage */
                    965:   if ((ulong)av <= (ulong)q) return q;
                    966:   /* The garbage is only empty when av==q. It's probably a mistake if
                    967:    * av < q. But "temporary variables" from sumiter are a problem since
                    968:    * ep->values are returned as-is by identifier() and they can be in the
                    969:    * stack: if we put a gerepileupto in lisseq(), we get an error. Maybe add,
                    970:    * if (DEBUGMEM) err(warner,"av>q in gerepileupto") ???
                    971:    */
                    972:
                    973:   /* Beware: (long)(q+i) --> ((long)q)+i*sizeof(long) */
                    974:   return gerepile(av, (long) (q+lg(q)), q);
                    975: }
                    976:
                    977: /* internal */
                    978: GEN
                    979: gerepileuptoleaf(long av, GEN q)
                    980: {
                    981:   long i;
                    982:   GEN q0;
                    983:
                    984:   if (!isonstack(q) || av==(long)q) { avma=av; return q; }
                    985:   i=lg(q); avma = (long)(((GEN)av) -  i);
                    986:   q0 = (GEN)avma; while (--i >= 0) q0[i]=q[i];
                    987:   return q0;
                    988: }
                    989: /* internal */
                    990: GEN
                    991: gerepileuptoint(long av, GEN q)
                    992: {
                    993:   if (!isonstack(q) || av==(long)q) { avma=av; return q; }
                    994:   avma = (long)icopy_av(q, (GEN)av);
                    995:   return (GEN)avma;
                    996: }
                    997:
                    998: /* check that x and all its components are out of stack, or have been
                    999:  * created after av */
                   1000: int
                   1001: ok_for_gerepileupto(long r, GEN x)
                   1002: {
                   1003:   long i,lx = lg(x),tx = typ(x);
                   1004:   if (! is_recursive_t(tx))
                   1005:     return !isonstack(x) || x <= (GEN)r;
                   1006:   if (x > (GEN)r)
                   1007:   {
                   1008:     err(warner,"bad object %Z\n",x);
                   1009:     return 0;
                   1010:   }
                   1011:
                   1012:   lx = lg(x);
                   1013:   if (tx==t_POL || tx==t_LIST) lx = lgef(x);
                   1014:   for (i=lontyp[tx]; i<lx; i++)
                   1015:     if (!ok_for_gerepileupto(r, (GEN)x[i]))
                   1016:     {
                   1017:       err(warner,"bad component %ld in object %Z\n",i,x);
                   1018:       return 0;
                   1019:     }
                   1020:   return 1;
                   1021: }
                   1022:
                   1023: GEN
                   1024: gerepile(long av, long tetpil, GEN q)
                   1025: {
                   1026:   long avmb, dec = av - tetpil;
                   1027:   GEN ll,a,b;
                   1028:
                   1029:   if (dec==0) return q;
                   1030:   if (dec<0) err(talker,"lbot>ltop in gerepile");
                   1031:
                   1032:   if ((ulong)q>=(ulong)avma && (ulong)q<(ulong)tetpil)
                   1033:     q = (GEN) (((long)q) + dec);
                   1034:
                   1035: #if 1
                   1036:   for (ll=(GEN)av, a=(GEN)tetpil; a > (GEN)avma; ) *--ll= *--a;
                   1037:   avmb = (long)ll;
                   1038: #else /* slower */
                   1039:   ll = (GEN)(avmb=avma+dec); a = (GEN)avma;
                   1040:   for (i=((tetpil-avma)>>TWOPOTBYTES_IN_LONG)-1; i>=0; i--) ll[i] = a[i];
                   1041: #endif
                   1042:
                   1043:   while (ll < (GEN)av)
                   1044:   {
                   1045:     const long tl=typ(ll);
                   1046:
                   1047:     if (! is_recursive_t(tl)) { ll+=lg(ll); continue; }
                   1048:     a = ll+lontyp[tl];
                   1049:     if (tl==t_POL) { b=ll+lgef(ll); ll+=lg(ll); } else { ll+=lg(ll); b=ll; }
                   1050:     for (  ; a<b; a++)
                   1051:       if ((ulong)*a < (ulong)av && (ulong)*a >= (ulong)avma)
                   1052:       {
                   1053:        if ((ulong)*a < (ulong)tetpil) *a += dec; else err(gerper);
                   1054:       }
                   1055:   }
                   1056:   avma = avmb; return q;
                   1057: }
                   1058:
                   1059: long
                   1060: allocatemoremem(ulong newsize)
                   1061: {
                   1062:   long sizeold = top - bot, newbot;
                   1063:
                   1064:   if (!newsize)
                   1065:   {
                   1066:     newsize = sizeold << 1;
                   1067:     err(warner,"doubling stack size; new stack = %lu",newsize);
                   1068:   }
                   1069:   else if ((long)newsize < 0)
                   1070:     err(talker,"required stack memory too small");
                   1071:   /* can't do bot = malloc directly, in case we lack memory */
                   1072:   newsize = fix_size(newsize);
                   1073:   newbot = (long) gpmalloc(newsize);
                   1074:   free((void*)bot); bot = newbot;
                   1075:   memused = avma = top = bot + newsize;
                   1076:   return newsize;
                   1077: }
                   1078:
                   1079: /* alternate stack management routine */
                   1080: stackzone *
                   1081: switch_stack(stackzone *z, long n)
                   1082: {
                   1083:   if (!z)
                   1084:   { /* create parallel stack */
                   1085:     long size = n*sizeof(long) + sizeof(stackzone);
                   1086:     z = (stackzone*) gpmalloc(size);
                   1087:     z->zonetop = ((long)z) + size;
                   1088:     return z;
                   1089:   }
                   1090:
                   1091:   if (n)
                   1092:   { /* switch to parallel stack */
                   1093:     z->bot     = bot;
                   1094:     z->top     = top;
                   1095:     z->avma    = avma;
                   1096:     z->memused = memused;
                   1097:     bot     = (long) (z+1);
                   1098:     top     = z->zonetop;
                   1099:     avma    = top;
                   1100:     memused = (ulong)-1;
                   1101:   }
                   1102:   else
                   1103:   { /* back to normalcy */
                   1104:     bot     = z->bot;
                   1105:     top     = z->top;
                   1106:     avma    = z->avma;
                   1107:     memused = z->memused;
                   1108:   }
                   1109:   return NULL;
                   1110: }
                   1111:
                   1112: #if 0 /* for a specific broken machine (readline not correctly installed) */
                   1113: char *xmalloc(long x) { return malloc(x); }
                   1114: char *xrealloc(char *c,long x) { return realloc(c,x); }
                   1115: #endif
                   1116:
                   1117: char*
                   1118: gpmalloc(size_t bytes)
                   1119: {
                   1120:   char *tmp;
                   1121:
                   1122:   if (bytes)
                   1123:   {
                   1124:     tmp = (char *) malloc(bytes);
                   1125:     if (!tmp) err(memer);
                   1126:     return tmp;
                   1127:   }
                   1128:   if (DEBUGMEM)
                   1129:     err(warner,"mallocing NULL object");
                   1130:   return NULL;
                   1131: }
                   1132:
                   1133: #if __MWERKS__
                   1134: static void *
                   1135: macrealloc(void *p, size_t newsize, size_t oldsize)
                   1136: {
                   1137:   char *q = gpmalloc(newsize), *qq = q, *pp = p;
                   1138:   int l = newsize > oldsize ? oldsize : newsize;
                   1139:
                   1140:   while (l--) *qq++ = *pp++;
                   1141:   free(p); return q;
                   1142: }
                   1143: #endif
                   1144:
                   1145: char*
                   1146: gprealloc(void *pointer, size_t newsize, size_t oldsize)
                   1147: {
                   1148:   char *tmp;
                   1149:
                   1150:   if (!pointer) tmp = (char *) malloc(newsize);
                   1151: #if __MWERKS__
                   1152:   else tmp = (char *) macrealloc(pointer,newsize,oldsize);
                   1153: #else
                   1154:   else tmp = (char *) realloc(pointer,newsize);
                   1155: #endif
                   1156:   if (!tmp) err(memer,oldsize);
                   1157:   return tmp;
                   1158: }
                   1159:
                   1160: #ifdef MEMSTEP
                   1161: void
                   1162: checkmemory(GEN z)
                   1163: {
                   1164:   if (DEBUGMEM && memused != (ulong)-1 &&
                   1165:        ((GEN)memused > z + MEMSTEP || z > (GEN)memused + MEMSTEP))
                   1166:   {
                   1167:     memused=(ulong)z;
                   1168: #if MEMSTEP >= 1048576
                   1169:     fprintferr("...%4.0lf Mbytes used\n",(top-memused)/1048576.);
                   1170: #else
                   1171:     fprintferr("...%5.1lf Mbytes used\n",(top-memused)/1048576.);
                   1172: #endif
                   1173:   }
                   1174: }
                   1175: #endif
                   1176:
                   1177: /*******************************************************************/
                   1178: /*                                                                 */
                   1179: /*                               TIMER                             */
                   1180: /*                                                                 */
                   1181: /*******************************************************************/
                   1182: #define MAX_TIMER 3
                   1183:
                   1184: #ifdef WINCE
                   1185: static long
                   1186: timer_proto(int i)
                   1187: {
                   1188:        static DWORD oldticks[MAX_TIMER];
                   1189:        DWORD ticks = GetTickCount();
                   1190:        DWORD delay = ticks - oldticks[i];
                   1191:        oldticks[i] = ticks;
                   1192:        return delay;
                   1193:
                   1194: }
                   1195: #elif defined(macintosh)
                   1196: # include <Events.h>
                   1197:   static long
                   1198:   timer_proto(int i)
                   1199:   {
                   1200:     static long oldticks[MAX_TIMER];
                   1201:     long ticks = TickCount(), delay = ticks - oldticks[i];
                   1202:
                   1203:     oldticks[i] = ticks;
                   1204:     return 50 * delay / 3;
                   1205:   }
                   1206: #elif USE_TIMES
                   1207:
                   1208: # include <sys/times.h>
                   1209: # include <sys/time.h>
                   1210:   static long
                   1211:   timer_proto(int i)
                   1212:   {
                   1213:     static clock_t oldticks[MAX_TIMER];
                   1214:     struct tms t;
                   1215:     long delay;
                   1216:
                   1217:     times(&t);
                   1218:     delay = (long)((t.tms_utime - oldticks[i]) * (1000. / CLK_TCK));
                   1219:     oldticks[i] = t.tms_utime;
                   1220:     return delay;
                   1221:   }
                   1222: #elif USE_GETRUSAGE
                   1223:
                   1224: # include <sys/time.h>
                   1225: # include <sys/resource.h>
                   1226:   static long
                   1227:   timer_proto(int i)
                   1228:   {
                   1229:     static long oldmusec[MAX_TIMER],oldsec[MAX_TIMER];
                   1230:     struct rusage r;
                   1231:     struct timeval t;
                   1232:     long delay;
                   1233:
                   1234:     getrusage(0,&r); t=r.ru_utime;
                   1235:     delay = 1000 * (t.tv_sec - oldsec[i]) + (t.tv_usec - oldmusec[i]) / 1000;
                   1236:     oldmusec[i] = t.tv_usec; oldsec[i] = t.tv_sec;
                   1237:     return delay;
                   1238:   }
                   1239: #elif USE_FTIME
                   1240:
                   1241: # include <sys/timeb.h>
                   1242:   static long
                   1243:   timer_proto(int i)
                   1244:   {
                   1245:     static long oldmsec[MAX_TIMER],oldsec[MAX_TIMER];
                   1246:     struct timeb t;
                   1247:     long delay;
                   1248:
                   1249:     ftime(&t);
                   1250:     delay = 1000 * (t.time - oldsec[i]) + (t.millitm - oldmsec[i]);
                   1251:     oldmsec[i] = t.millitm; oldsec[i] = t.time;
                   1252:     return delay;
                   1253:   }
                   1254: #else
                   1255:
                   1256: # include <time.h>
                   1257: # ifndef CLOCKS_PER_SEC
                   1258: #   define CLOCKS_PER_SEC 1000000 /* may be false on YOUR system */
                   1259: # endif
                   1260:   static long
                   1261:   timer_proto(int i)
                   1262:   {
                   1263:     static clock_t oldclocks[MAX_TIMER];
                   1264:     clock_t t = clock();
                   1265:     long delay = (long)((t-oldclocks[i]) * 1000. / CLOCKS_PER_SEC);
                   1266:
                   1267:     oldclocks[i] = t;
                   1268:     return delay;
                   1269:   }
                   1270: #endif
                   1271:
                   1272: long
                   1273: gptimer() { return timer_proto(0); }
                   1274: long
                   1275: timer() { return timer_proto(1); }
                   1276: long
                   1277: timer2() { return timer_proto(2); }
                   1278:
                   1279: void
                   1280: msgtimer(char *format, ...)
                   1281: {
                   1282:   va_list args;
                   1283:   PariOUT *out = pariOut; pariOut = pariErr;
                   1284:
                   1285:   pariputs("Time "); va_start(args, format);
                   1286:   vpariputs(format,args); va_end(args);
                   1287:   pariputsf(": %ld\n",timer2()); pariflush();
                   1288:   pariOut = out;
                   1289: }
                   1290:
                   1291: /*******************************************************************/
                   1292: /*                                                                 */
                   1293: /*                   FUNCTIONS KNOWN TO THE ANALYZER               */
                   1294: /*                                                                 */
                   1295: /*******************************************************************/
                   1296: void alias0(char *s, char *old);
                   1297: GEN break0(long n);
                   1298: GEN next0(long n);
                   1299: GEN return0(GEN x);
                   1300:
                   1301: GEN
                   1302: geni(void) { return gi; }
                   1303:
                   1304: /* List of GP functions:
                   1305:  * ---------------------
                   1306:  * Format (struct entree) :
                   1307:  *   char *name    : name (under GP).
                   1308:  *   ulong valence : used to form arg list, now often handled by code.
                   1309:  *   void *value   : For PREDEFINED FUNCTIONS: C function to call.
                   1310:  *                   For USER FUNCTIONS: pointer to defining data (bloc) =
                   1311:  *                    entree*: NULL, list of entree (arguments), NULL
                   1312:  *                    char*  : function text
                   1313:  *   long menu     : which help section do we belong (See below).
                   1314:  *   char *code    : argument list (See below).
                   1315:  *   entree *next  : next entree (init to NULL, used in hashing code).
                   1316:  *   char *help    : short help text (init to NULL).
                   1317:  *   void *args    : For USER FUNCTIONS: default arguments (NULL terminated).
                   1318:  *                   For VARIABLES: (esp. loop indexes): push_val history.
                   1319:  *                   (while processing a loop, ep->value may not be a bloc)
                   1320:  * menu:
                   1321:  * -----
                   1322:  *  1: Standard monadic or dyadic OPERATORS
                   1323:  *  2: CONVERSIONS and similar elementary functions
                   1324:  *  3: TRANSCENDENTAL functions
                   1325:  *  4: NUMBER THEORETICAL functions
                   1326:  *  5: Functions related to ELLIPTIC CURVES
                   1327:  *  6: Functions related to general NUMBER FIELDS
                   1328:  *  7: POLYNOMIALS and power series
                   1329:  *  8: Vectors, matrices, LINEAR ALGEBRA and sets
                   1330:  *  9: SUMS, products, integrals and similar functions
                   1331:  *  10: GRAPHIC functions
                   1332:  *  11: PROGRAMMING under GP
                   1333:  *
                   1334:  * code: describe function prototype. NULL = use valence instead.
                   1335:  * -----
                   1336:  * Arguments:
                   1337:  *  I  input position (to be processed with lisexpr or lisseq).
                   1338:  *  G  GEN
                   1339:  *  L  long
                   1340:  *  S  symbol (i.e GP function name)
                   1341:  *  V  variable (same as S, but valence must equal EpVAR/EpGVAR)
                   1342:  *  n  variable number
                   1343:  *  &  *GEN
                   1344:  *  F  Fake *GEN (function requires a *GEN, but we don't use the resulting GEN)
                   1345:  *  f  Fake *long
                   1346:  *  p  real precision (prec for the C library)
                   1347:  *  P  series precision (precdl dor the C library)
                   1348:  *  r  raw input (treated as a string without quotes).
                   1349:  *     Quoted args are copied as strings. Stops at first unquoted ')' or ','.
                   1350:  *     Special chars can be quoted using '\'.  Ex : aa"b\n)"c => "aab\n)c".
                   1351:  *  s  expanded string. Example: pi"x"2 yields "3.142x2".
                   1352:  *     The unquoted components can be of any pari type (converted according to
                   1353:  *     the current output format)
                   1354:  *  s* any number of strings (see s)
                   1355:  *  s*p idem, setting prettyp=1
                   1356:  *  s*t idem, in TeX format.
                   1357:  *  D  Has a default value. Format is "Dvalue,type," (the ending comma is
                   1358:  *     mandatory). Ex: D0,L, (arg is long, 0 by default).
                   1359:  *     Special syntax:
                   1360:  *       if type = G, &, I or V:  D[G&IV] all send NULL.
                   1361:  *       if type = v: Dn sends -1.
                   1362:  *
                   1363:  *     The user-given args are read first, then completed by the defaults
                   1364:  *
                   1365:  * Return type (first char or immediately after 'x'): GEN by default, otherwise
                   1366:  *  l Return long
                   1367:  *  v Return void
                   1368:  *
                   1369:  * Syntax requirements:
                   1370:  *  = Separator '=' required.
                   1371:  *
                   1372:  * Origin:
                   1373:  *  x Installed foreign function. Put the ep of the function as the
                   1374:  *       first argument, fill the rest with PARI arguments,
                   1375:  *       then call installedHandler with these arguments.
                   1376:  *       Should be the first char in the code.
                   1377:  *
                   1378:  ****************************************************************************
                   1379:  * If new codes are added, change identifier and skipidentifier.
                   1380:  *
                   1381:  * Currently the following functions have no code word:
                   1382:  * 'O' 50, 'if' 80, 'until' 82, 'while' 81, 'global' 88,
                   1383:  *
                   1384:  * Valence 0 reserved for functions without mandatory args.
                   1385:  * Valence 99 reserved for codes which do not correspond 1-to-1 to valences.
                   1386:  * Any other valence (what to do with 0?) should correspond to exactly
                   1387:  *  one code.
                   1388:  */
                   1389:
                   1390: entree functions_basic[]={
                   1391: {"Euler",0,(void*)mpeuler,3,"p"},
                   1392: {"I",0,(void*)geni,2,""},
                   1393: {"List",0,(void*)gtolist,2,"DG"},
                   1394: {"Mat",0,(void*)gtomat,2,"DG"},
                   1395: {"Mod",25,(void*)Mod0,2,"GGD0,L,"},
                   1396: {"O",50,NULL,7,NULL},
                   1397: {"Pi",0,(void*)mppi,3,"p"},
                   1398: {"Pol",14,(void*)gtopoly,2,"GDn"},
                   1399: {"Polrev",14,(void*)gtopolyrev,2,"GDn"},
                   1400: {"Qfb",99,(void*)Qfb0,2,"GGGDGp"},
                   1401: {"Ser",14,(void*)gtoser,2,"GDn"},
                   1402: {"Set",0,(void*)gtoset,2,"DG"},
                   1403: {"Str",0,(void*)strtoGENstr,2,"D\"\",s,D0,L,"},
                   1404: {"Vec",0,(void*)gtovec,2,"DG"},
                   1405: {"abs",1,(void*)gabs,3,"Gp"},
                   1406: {"acos",1,(void*)gacos,3,"Gp"},
                   1407: {"acosh",1,(void*)gach,3,"Gp"},
                   1408: {"addprimes",0,(void*)addprimes,4,"DG"},
                   1409: {"agm",29,(void*)agm,3,"GGp"},
                   1410: {"algdep",99,(void*)algdep0,8,"GLD0,L,p"},
                   1411: {"alias",99,(void*)alias0,11,"vrr"},
                   1412: {"arg",1,(void*)garg,3,"Gp"},
                   1413: {"asin",1,(void*)gasin,3,"Gp"},
                   1414: {"asinh",1,(void*)gash,3,"Gp"},
                   1415: {"atan",1,(void*)gatan,3,"Gp"},
                   1416: {"atanh",1,(void*)gath,3,"Gp"},
                   1417: {"bernfrac",11,(void*)bernfrac,3,"L"},
                   1418: {"bernreal",99,(void*)bernreal,3,"Lp"},
                   1419: {"bernvec",11,(void*)bernvec,3,"L"},
                   1420: {"besseljh",29,(void*)jbesselh,3,"GGp"},
                   1421: {"besselk",99,(void*)kbessel0,3,"GGD0,L,p"},
                   1422: {"bestappr",2,(void*)bestappr,4,"GG"},
                   1423: {"bezout",2,(void*)vecbezout,4,"GG"},
                   1424: {"bezoutres",2,(void*)vecbezoutres,4,"GG"},
                   1425: {"bigomega",18,(void*)gbigomega,4,"G"},
                   1426: {"binary",18,(void*)binaire,2,"G"},
                   1427: {"binomial",21,(void*)binome,4,"GL"},
                   1428: {"bittest",2,(void*)gbittest,2,"GG"},
                   1429: {"bnfcertify",10,(void*)certifybuchall,6,"lG"},
                   1430: {"bnfclassunit",99,(void*)bnfclassunit0,6,"GD0,L,DGp"},
                   1431: {"bnfclgp",99,(void*)classgrouponly,6,"GDGp"},
                   1432: {"bnfdecodemodule",2,(void*)decodemodule,6,"GG"},
                   1433: {"bnfinit",91,(void*)bnfinit0,6,"GD0,L,DGp"},
                   1434: {"bnfisintnorm",99,(void*)bnfisintnorm,6,"GG"},
                   1435: {"bnfisnorm",99,(void*)bnfisnorm,6,"GGD1,L,p"},
                   1436: {"bnfisprincipal",99,(void*)isprincipalall,6,"GGD1,L,"},
                   1437: {"bnfissunit",99,(void*)bnfissunit,6,"GGG"},
                   1438: {"bnfisunit",2,(void*)isunit,6,"GG"},
                   1439: {"bnfmake",1,(void*)bnfmake,6,"Gp"},
                   1440: {"bnfnarrow",18,(void*)buchnarrow,6,"G"},
                   1441: {"bnfreg",99,(void*)regulator,6,"GDGp"},
                   1442: {"bnfsignunit",18,(void*)signunits,6,"G"},
                   1443: {"bnfsunit",99,(void*)bnfsunit,6,"GGp"},
                   1444: {"bnfunit",1,(void*)buchfu,6,"Gp"},
                   1445: {"bnrL1",99,(void*)bnrL1,6,"GD0,L,p"},
                   1446: {"bnrclass",99,(void*)bnrclass0,6,"GGD0,L,p"},
                   1447: {"bnrclassno",2,(void*)rayclassno,6,"GG"},
                   1448: {"bnrclassnolist",2,(void*)rayclassnolist,6,"GG"},
                   1449: {"bnrconductor",62,(void*)bnrconductor,6,"GDGDGD0,L,p"},
                   1450: {"bnrconductorofchar",29,(void*)bnrconductorofchar,6,"GGp"},
                   1451: {"bnrdisc",62,(void*)bnrdisc0,6,"GDGDGD0,L,p"},
                   1452: {"bnrdisclist",99,(void*)bnrdisclist0,6,"GGDGD0,L,"},
                   1453: {"bnrinit",99,(void*)bnrinit0,6,"GGD0,L,p"},
                   1454: {"bnrisconductor",99,(void*)bnrisconductor,6,"lGDGDGp"},
                   1455: {"bnrisprincipal",99,(void*)isprincipalrayall,6,"GGD1,L,"},
                   1456: {"bnrrootnumber",99,(void*)bnrrootnumber,6,"GGD0,L,p"},
                   1457: {"bnrstark",99,(void*)bnrstark,6,"GGD0,L,p"},
                   1458: {"break",0,(void*)break0,11,"D1,L,"},
                   1459: {"ceil",18,(void*)gceil,2,"G"},
                   1460: {"centerlift",99,(void*)centerlift0,2,"GDn"},
                   1461: {"changevar",2,(void*)changevar,2,"GG"},
                   1462: {"charpoly",99,(void*)charpoly0,8,"GDnD0,L,"},
                   1463: {"chinese",2,(void*)chinois,4,"GG"},
                   1464: {"component",21,(void*)compo,2,"GL"},
                   1465: {"concat",99,(void*)concat,8,"GDG"},
                   1466: {"conj",18,(void*)gconj,2,"G"},
                   1467: {"conjvec",1,(void*)conjvec,2,"Gp"},
                   1468: {"content",18,(void*)content,4,"G"},
                   1469: {"contfrac",99,(void*)sfcont0,4,"GDGD0,L,"},
                   1470: {"contfracpnqn",18,(void*)pnqn,4,"G"},
                   1471: {"core",99,(void*)core0,4,"GD0,L,"},
                   1472: {"coredisc",99,(void*)coredisc0,4,"GD0,L,"},
                   1473: {"cos",1,(void*)gcos,3,"Gp"},
                   1474: {"cosh",1,(void*)gch,3,"Gp"},
                   1475: {"cotan",1,(void*)gcotan,3,"Gp"},
                   1476: {"denominator",18,(void*)denom,2,"G"},
                   1477: {"deriv",14,(void*)deriv,7,"GDn"},
                   1478: {"dilog",1,(void*)dilog,3,"Gp"},
                   1479: {"dirdiv",2,(void*)dirdiv,7,"GG"},
                   1480: {"direuler",99,(void*)direuler,7,"V=GGI"},
                   1481: {"dirmul",2,(void*)dirmul,7,"GG"},
                   1482: {"dirzetak",2,(void*)dirzetak,6,"GG"},
                   1483: {"divisors",18,(void*)divisors,4,"G"},
                   1484: {"divrem",2,(void*)gdiventres,1,"GG"},
                   1485: {"eint1",99,(void*)veceint1,3,"GDGp"},
                   1486: {"elladd",3,(void*)addell,5,"GGG"},
                   1487: {"ellak",2,(void*)akell,5,"GG"},
                   1488: {"ellan",23,(void*)anell,5,"GL"},
                   1489: {"ellap",25,(void*)ellap0,5,"GGD0,L,"},
                   1490: {"ellbil",99,(void*)bilhell,5,"GGGp"},
                   1491: {"ellchangecurve",2,(void*)coordch,5,"GG"},
                   1492: {"ellchangepoint",2,(void*)pointch,5,"GG"},
                   1493: {"elleisnum",99,(void*)elleisnum,5,"GLD0,L,p"},
                   1494: {"elleta",1,(void*)elleta,5,"Gp"},
                   1495: {"ellglobalred",18,(void*)globalreduction,5,"G"},
                   1496: {"ellheight",99,(void*)ellheight0,5,"GGD0,L,p"},
                   1497: {"ellheightmatrix",29,(void*)mathell,5,"GGp"},
                   1498: {"ellinit",99,(void*)ellinit0,5,"GD0,L,p"},
                   1499: {"ellisoncurve",20,(void*)oncurve,5,"lGG"},
                   1500: {"ellj",1,(void*)jell,5,"Gp"},
                   1501: {"elllocalred",2,(void*)localreduction,5,"GG"},
                   1502: {"elllseries",99,(void*)lseriesell,5,"GGDGp"},
                   1503: {"ellorder",2,(void*)orderell,5,"GG"},
                   1504: {"ellordinate",29,(void*)ordell,5,"GGp"},
                   1505: {"ellpointtoz",29,(void*)zell,5,"GGp"},
                   1506: {"ellpow",99,(void*)powell,5,"GGGp"},
                   1507: {"ellrootno",99,(void*)ellrootno,5,"lGDG"},
                   1508: {"ellsigma",99,(void*)ellsigma,5,"GGD0,L,p"},
                   1509: {"ellsub",99,(void*)subell,5,"GGGp"},
                   1510: {"elltaniyama",1,(void*)taniyama,5,"Gp"},
                   1511: {"elltors",99,(void*)elltors0,5,"GD0,L,p"},
                   1512: {"ellwp",99,(void*)ellwp0,5,"GDGD0,L,pP"},
                   1513: {"ellzeta",99,(void*)ellzeta,5,"GGp"},
                   1514: {"ellztopoint",29,(void*)pointell,5,"GGp"},
                   1515: {"erfc",1,(void*)gerfc,3,"Gp"},
                   1516: {"eta",99,(void*)eta0,3,"GD0,L,p"},
                   1517: {"eulerphi",18,(void*)gphi,4,"G"},
                   1518: {"eval",18,(void*)geval,7,"G"},
                   1519: {"exp",1,(void*)gexp,3,"Gp"},
                   1520: {"factor",99,(void*)factor0,4,"GD-1,L,"},
                   1521: {"factorback",99,(void*)factorback,4,"GDG"},
                   1522: {"factorcantor",2,(void*)factcantor,4,"GG"},
                   1523: {"factorff",3,(void*)factmod9,4,"GGG"},
                   1524: {"factorial",99,(void*)mpfactr,4,"Lp"},
                   1525: {"factorint",99,(void*)factorint,4,"GD0,L,"},
                   1526: {"factormod",25,(void*)factormod0,4,"GGD0,L,"},
                   1527: {"factornf",2,(void*)polfnf,6,"GG"},
                   1528: {"factorpadic",99,(void*)factorpadic0,7,"GGLD0,L,"},
                   1529: {"ffinit",99,(void*)ffinit,4,"GLDn"},
                   1530: {"fibonacci",11,(void*)fibo,4,"L"},
                   1531: {"floor",18,(void*)gfloor,2,"G"},
                   1532: {"for",83,(void*)forpari,11,"vV=GGI"},
                   1533: {"fordiv",84,(void*)fordiv,11,"vGVI"},
                   1534: {"forprime",83,(void*)forprime,11,"vV=GGI"},
                   1535: {"forstep",86,(void*)forstep,11,"vV=GGGI"},
                   1536: {"forsubgroup",99,(void*)forsubgroup,11,"vV=GD0,L,I"},
                   1537: {"forvec",87,(void*)forvec,11,"vV=GID0,L,"},
                   1538: {"frac",18,(void*)gfrac,2,"G"},
                   1539: {"galoisfixedfield",99,(void*)galoisfixedfield,6,"GGDG"},
                   1540: {"galoisinit",99,(void*)galoisinit,6,"GDG,"},
                   1541: {"galoispermtopol",2,(void*)galoispermtopol,6,"GG"},
                   1542: {"gamma",1,(void*)ggamma,3,"Gp"},
                   1543: {"gammah",1,(void*)ggamd,3,"Gp"},
                   1544: {"gcd",25,(void*)gcd0,4,"GGD0,L,"},
                   1545: {"getheap",0,(void*)getheap,11,""},
                   1546: {"getrand",0,(void*)getrand,11,"l"},
                   1547: {"getstack",0,(void*)getstack,11,"l"},
                   1548: {"gettime",0,(void*)gettime,11,"l"},
                   1549: {"hilbert",99,(void*)hil0,4,"lGGDG"},
                   1550: {"hyperu",99,(void*)hyperu,3,"GGGp"},
                   1551: {"idealadd",3,(void*)idealadd,6,"GGG"},
                   1552: {"idealaddtoone",99,(void*)idealaddtoone0,6,"GGDG"},
                   1553: {"idealappr",25,(void*)idealappr0,6,"GGD0,L,"},
                   1554: {"idealchinese",3,(void*)idealchinese,6,"GGG"},
                   1555: {"idealcoprime",3,(void*)idealcoprime,6,"GGG"},
                   1556: {"idealdiv",99,(void*)idealdiv0,6,"GGGD0,L,"},
                   1557: {"idealfactor",2,(void*)idealfactor,6,"GG"},
                   1558: {"idealhnf",99,(void*)idealhnf0,6,"GGDG"},
                   1559: {"idealintersect",3,(void*)idealintersect,6,"GGG"},
                   1560: {"idealinv",25,(void*)idealinv0,6,"GGD0,L,"},
                   1561: {"ideallist",99,(void*)ideallist0,6,"GLD4,L,"},
                   1562: {"ideallistarch",99,(void*)ideallistarch0,6,"GGDGD0,L,"},
                   1563: {"ideallog",99,(void*)zideallog,6,"GGGp"},
                   1564: {"idealmin",99,(void*)minideal,6,"GGGp"},
                   1565: {"idealmul",99,(void*)idealmul0,6,"GGGD0,L,p"},
                   1566: {"idealnorm",2,(void*)idealnorm,6,"GG"},
                   1567: {"idealpow",99,(void*)idealpow0,6,"GGGD0,L,p"},
                   1568: {"idealprimedec",29,(void*)primedec,6,"GGp"},
                   1569: {"idealprincipal",2,(void*)principalideal,6,"GG"},
                   1570: {"idealred",99,(void*)ideallllred,6,"GGDGp"},
                   1571: {"idealstar",99,(void*)idealstar0,6,"GGD1,L,"},
                   1572: {"idealtwoelt",99,(void*)ideal_two_elt0,6,"GGDG"},
                   1573: {"idealval",30,(void*)idealval,6,"lGGG"},
                   1574: {"ideleprincipal",29,(void*)principalidele,6,"GGp"},
                   1575: {"if",80,NULL,11,NULL},
                   1576: {"imag",18,(void*)gimag,2,"G"},
                   1577: {"incgam",99,(void*)incgam0,3,"GGDGp"},
                   1578: {"incgamc",29,(void*)incgam3,3,"GGp"},
                   1579: {"intformal",14,(void*)integ,7,"GDn"},
                   1580: {"intnum",99,(void*)intnum0,9,"V=GGID0,L,p"},
                   1581: {"isfundamental",18,(void*)gisfundamental,4,"G"},
                   1582: {"isprime",18,(void*)gisprime,4,"G"},
                   1583: {"ispseudoprime",18,(void*)gispsp,4,"G"},
                   1584: {"issquare",99,(void*)gcarrecomplet,4,"GD&"},
                   1585: {"issquarefree",18,(void*)gissquarefree,4,"G"},
                   1586: {"kronecker",2,(void*)gkronecker,4,"GG"},
                   1587: {"lcm",2,(void*)glcm,4,"GG"},
                   1588: {"length",10,(void*)glength,2,"lG"},
                   1589: {"lex",20,(void*)lexcmp,2,"lGG"},
                   1590: {"lift",99,(void*)lift0,2,"GDn"},
                   1591: {"lindep",99,(void*)lindep0,8,"GD0,L,p"},
                   1592: {"listcreate",11,(void*)listcreate,8,"L"},
                   1593: {"listinsert",99,(void*)listinsert,8,"GGL"},
                   1594: {"listkill",99,(void*)listkill,8,"vG"},
                   1595: {"listput",25,(void*)listput,8,"GGD0,L,"},
                   1596: {"listsort",99,(void*)listsort,8,"GD0,L,"},
                   1597: {"lngamma",1,(void*)glngamma,3,"Gp"},
                   1598: {"log",99,(void*)log0,3,"GD0,L,p"},
                   1599: {"matadjoint",18,(void*)adj,8,"G"},
                   1600: {"matalgtobasis",2,(void*)matalgtobasis,6,"GG"},
                   1601: {"matbasistoalg",2,(void*)matbasistoalg,6,"GG"},
                   1602: {"matcompanion",18,(void*)assmat,8,"G"},
                   1603: {"matdet",99,(void*)det0,8,"GD0,L,"},
                   1604: {"matdetint",18,(void*)detint,8,"G"},
                   1605: {"matdiagonal",18,(void*)diagonal,8,"G"},
                   1606: {"mateigen",1,(void*)eigen,8,"Gp"},
                   1607: {"mathess",18,(void*)hess,8,"G"},
                   1608: {"mathilbert",11,(void*)mathilbert,8,"L"},
                   1609: {"mathnf",99,(void*)mathnf0,8,"GD0,L,"},
                   1610: {"mathnfmod",2,(void*)hnfmod,8,"GG"},
                   1611: {"mathnfmodid",2,(void*)hnfmodid,8,"GG"},
                   1612: {"matid",11,(void*)idmat,8,"L"},
                   1613: {"matimage",99,(void*)matimage0,8,"GD0,L,"},
                   1614: {"matimagecompl",18,(void*)imagecompl,8,"G"},
                   1615: {"matindexrank",18,(void*)indexrank,8,"G"},
                   1616: {"matintersect",2,(void*)intersect,8,"GG"},
                   1617: {"matinverseimage",2,(void*)inverseimage,8,"GG"},
                   1618: {"matisdiagonal",10,(void*)isdiagonal,8,"lG"},
                   1619: {"matker",99,(void*)matker0,8,"GD0,L,p"},
                   1620: {"matkerint",99,(void*)matkerint0,8,"GD0,L,"},
                   1621: {"matmuldiagonal",2,(void*)matmuldiagonal,8,"GG"},
                   1622: {"matmultodiagonal",2,(void*)matmultodiagonal,8,"GG"},
                   1623: {"matpascal",99,(void*)matqpascal,8,"LDG"},
                   1624: {"matrank",10,(void*)rank,8,"lG"},
                   1625: {"matrix",49,(void*)matrice,8,"GGDVDVDI"},
                   1626: {"matrixqz",2,(void*)matrixqz0,8,"GG"},
                   1627: {"matsize",18,(void*)matsize,8,"G"},
                   1628: {"matsnf",99,(void*)matsnf0,8,"GD0,L,"},
                   1629: {"matsolve",2,(void*)gauss,8,"GG"},
                   1630: {"matsolvemod",99,(void*)matsolvemod0,8,"GGGD0,L,"},
                   1631: {"matsupplement",1,(void*)suppl,8,"Gp"},
                   1632: {"mattranspose",18,(void*)gtrans,8,"G"},
                   1633: {"max",2,(void*)gmax,1,"GG"},
                   1634: {"min",2,(void*)gmin,1,"GG"},
                   1635: {"modreverse",18,(void*)polymodrecip,6,"G"},
                   1636: {"moebius",18,(void*)gmu,4,"G"},
                   1637: {"newtonpoly",2,(void*)newtonpoly,6,"GG"},
                   1638: {"next",0,(void*)next0,11,"D1,L,"},
                   1639: {"nextprime",18,(void*)gnextprime,4,"G"},
                   1640: {"nfalgtobasis",2,(void*)algtobasis,6,"GG"},
                   1641: {"nfbasis",99,(void*)nfbasis0,6,"GD0,L,DG"},
                   1642: {"nfbasistoalg",2,(void*)basistoalg,6,"GG"},
                   1643: {"nfdetint",2,(void*)nfdetint,6,"GG"},
                   1644: {"nfdisc",99,(void*)nfdiscf0,6,"GD0,L,DG"},
                   1645: {"nfeltdiv",3,(void*)element_div,6,"GGG"},
                   1646: {"nfeltdiveuc",3,(void*)nfdiveuc,6,"GGG"},
                   1647: {"nfeltdivmodpr",4,(void*)element_divmodpr,6,"GGGG"},
                   1648: {"nfeltdivrem",3,(void*)nfdivres,6,"GGG"},
                   1649: {"nfeltmod",3,(void*)nfmod,6,"GGG"},
                   1650: {"nfeltmul",3,(void*)element_mul,6,"GGG"},
                   1651: {"nfeltmulmodpr",4,(void*)element_mulmodpr2,6,"GGGG"},
                   1652: {"nfeltpow",3,(void*)element_pow,6,"GGG"},
                   1653: {"nfeltpowmodpr",4,(void*)element_powmodpr,6,"GGGG"},
                   1654: {"nfeltreduce",3,(void*)element_reduce,6,"GGG"},
                   1655: {"nfeltreducemodpr",3,(void*)nfreducemodpr2,6,"GGG"},
                   1656: {"nfeltval",30,(void*)element_val,6,"lGGG"},
                   1657: {"nffactor",99,(void*)nffactor,6,"GG"},
                   1658: {"nffactormod",99,(void*)nffactormod,6,"GGG"},
                   1659: {"nfgaloisapply",3,(void*)galoisapply,6,"GGG"},
                   1660: {"nfgaloisconj",99,(void*)galoisconj0,6,"GD0,L,DGp"},
                   1661: {"nfhilbert",99,(void*)nfhilbert0,6,"lGGGDG"},
                   1662: {"nfhnf",2,(void*)nfhermite,6,"GG"},
                   1663: {"nfhnfmod",3,(void*)nfhermitemod,6,"GGG"},
                   1664: {"nfinit",99,(void*)nfinit0,6,"GD0,L,p"},
                   1665: {"nfisideal",20,(void*)isideal,6,"lGG"},
                   1666: {"nfisincl",2,(void*)nfisincl,6,"GG"},
                   1667: {"nfisisom",2,(void*)nfisisom,6,"GG"},
                   1668: {"nfkermodpr",3,(void*)nfkermodpr,6,"GGG"},
                   1669: {"nfmodprinit",2,(void*)nfmodprinit,6,"GG"},
                   1670: {"nfnewprec",1,(void*)nfnewprec,6,"Gp"},
                   1671: {"nfroots",99,(void*)nfroots,6,"GG"},
                   1672: {"nfrootsof1",1,(void*)rootsof1,6,"Gp"},
                   1673: {"nfsnf",2,(void*)nfsmith,6,"GG"},
                   1674: {"nfsolvemodpr",4,(void*)nfsolvemodpr,6,"GGGG"},
                   1675: {"nfsubfields",99,(void*)subfields0,6,"GDG"},
                   1676: {"norm",18,(void*)gnorm,2,"G"},
                   1677: {"norml2",18,(void*)gnorml2,2,"G"},
                   1678: {"numdiv",18,(void*)gnumbdiv,4,"G"},
                   1679: {"numerator",18,(void*)numer,2,"G"},
                   1680: {"numtoperm",24,(void*)permute,2,"LG"},
                   1681: {"omega",18,(void*)gomega,4,"G"},
                   1682: {"padicappr",2,(void*)apprgen9,7,"GG"},
                   1683: {"padicprec",20,(void*)padicprec,2,"lGG"},
                   1684: {"permtonum",18,(void*)permuteInv,2,"G"},
                   1685: {"polcoeff",99,(void*)polcoeff0,2,"GLDn"},
                   1686: {"polcompositum",25,(void*)polcompositum0,6,"GGD0,L,"},
                   1687: {"polcyclo",99,(void*)cyclo,7,"LDn"},
                   1688: {"poldegree",99,(void*)poldegree,7,"lGDn"},
                   1689: {"poldisc",99,(void*)poldisc0,7,"GDn"},
                   1690: {"poldiscreduced",18,(void*)reduceddiscsmith,7,"G"},
                   1691: {"polgalois",99,(void*)galois,6,"Gp"},
                   1692: {"polinterpolate",31,(void*)polint,7,"GGDGD&"},
                   1693: {"polisirreducible",18,(void*)gisirreducible,7,"G"},
                   1694: {"pollead",99,(void*)pollead,7,"GDn"},
                   1695: {"pollegendre",99,(void*)legendre,7,"LDn"},
                   1696: {"polrecip",18,(void*)polrecip,7,"G"},
                   1697: {"polred",99,(void*)polred0,6,"GD0,L,DGp"},
                   1698: {"polredabs",99,(void*)polredabs0,6,"GD0,L,p"},
                   1699: {"polredord",1,(void*)ordred,6,"Gp"},
                   1700: {"polresultant",99,(void*)polresultant0,7,"GGDnD0,L,"},
                   1701: {"polroots",99,(void*)roots0,7,"GD0,L,p"},
                   1702: {"polrootsmod",25,(void*)rootmod0,7,"GGD0,L,"},
                   1703: {"polrootspadic",32,(void*)rootpadic,7,"GGL"},
                   1704: {"polsturm",99,(void*)sturmpart,7,"lGDGDG"},
                   1705: {"polsubcyclo",99,(void*)subcyclo,6,"GGDn"},
                   1706: {"polsylvestermatrix",29,(void*)sylvestermatrix,7,"GGp"},
                   1707: {"polsym",21,(void*)polsym,7,"GL"},
                   1708: {"poltchebi",99,(void*)tchebi,7,"LDn"},
                   1709: {"poltschirnhaus",18,(void*)tschirnhaus,6,"G"},
                   1710: {"polylog",99,(void*)polylog0,3,"LGD0,L,p"},
                   1711: {"polzagier",99,(void*)polzag,7,"LL"},
                   1712: {"precision",99,(void*)precision0,2,"GD0,L,"},
                   1713: {"precprime",18,(void*)gprecprime,4,"G"},
                   1714: {"prime",11,(void*)prime,4,"L"},
                   1715: {"primes",11,(void*)primes,4,"L"},
                   1716: {"prod",47,(void*)produit,9,"V=GGIDG"},
                   1717: {"prodeuler",37,(void*)prodeuler,9,"V=GGIp"},
                   1718: {"prodinf",99,(void*)prodinf0,9,"V=GID0,L,p"},
                   1719: {"psi",1,(void*)gpsi,3,"Gp"},
                   1720: {"qfbclassno",99,(void*)qfbclassno0,4,"GD0,L,"},
                   1721: {"qfbcompraw",2,(void*)compraw,4,"GG"},
                   1722: {"qfbhclassno",18,(void*)hclassno,4,"G"},
                   1723: {"qfbnucomp",3,(void*)nucomp,4,"GGG"},
                   1724: {"qfbnupow",2,(void*)nupow,4,"GG"},
                   1725: {"qfbpowraw",23,(void*)powraw,4,"GL"},
                   1726: {"qfbprimeform",29,(void*)primeform,4,"GGp"},
                   1727: {"qfbred",99,(void*)qfbred0,4,"GD0,L,DGDGDG"},
                   1728: {"qfgaussred",18,(void*)sqred,8,"G"},
                   1729: {"qfjacobi",1,(void*)jacobi,8,"Gp"},
                   1730: {"qflll",99,(void*)qflll0,8,"GD0,L,p"},
                   1731: {"qflllgram",99,(void*)qflllgram0,8,"GD0,L,p"},
                   1732: {"qfminim",33,(void*)minim0,8,"GGGD0,L,p"},
                   1733: {"qfperfection",18,(void*)perf,8,"G"},
                   1734: {"qfsign",18,(void*)signat,8,"G"},
                   1735: {"quadclassunit",96,(void*)quadclassunit0,4,"GD0,L,DGp"},
                   1736: {"quaddisc",18,(void*)quaddisc,4,"G"},
                   1737: {"quadgen",18,(void*)quadgen,4,"G"},
                   1738: {"quadhilbert",99,(void*)quadhilbert,4,"GDGp"},
                   1739: {"quadpoly",99,(void*)quadpoly0,4,"GDn"},
                   1740: {"quadray",99,(void*)quadray,4,"GGDGp"},
                   1741: {"quadregulator",1,(void*)gregula,4,"Gp"},
                   1742: {"quadunit",1,(void*)gfundunit,4,"Gp"},
                   1743: {"random",0,(void*)genrand,2,"DG"},
                   1744: {"real",18,(void*)greal,2,"G"},
                   1745: {"removeprimes",0,(void*)removeprimes,4,"DG"},
                   1746: {"reorder",0,(void*)reorder,11,"DG"},
                   1747: {"return",0,(void*)return0,11,"DG"},
                   1748: {"rnfalgtobasis",2,(void*)rnfalgtobasis,6,"GG"},
                   1749: {"rnfbasis",2,(void*)rnfbasis,6,"GG"},
                   1750: {"rnfbasistoalg",2,(void*)rnfbasistoalg,6,"GG"},
                   1751: {"rnfcharpoly",99,(void*)rnfcharpoly,6,"GGGDn"},
                   1752: {"rnfconductor",29,(void*)rnfconductor,6,"GGp"},
                   1753: {"rnfdedekind",99,(void*)rnfdedekind,6,"GGG"},
                   1754: {"rnfdet",99,(void*)rnfdet0,6,"GGDG"},
                   1755: {"rnfdisc",2,(void*)rnfdiscf,6,"GG"},
                   1756: {"rnfeltabstorel",2,(void*)rnfelementabstorel,6,"GG"},
                   1757: {"rnfeltdown",2,(void*)rnfelementdown,6,"GG"},
                   1758: {"rnfeltreltoabs",2,(void*)rnfelementreltoabs,6,"GG"},
                   1759: {"rnfeltup",2,(void*)rnfelementup,6,"GG"},
                   1760: {"rnfequation",25,(void*)rnfequation0,6,"GGD0,L,"},
                   1761: {"rnfhnfbasis",2,(void*)rnfhermitebasis,6,"GG"},
                   1762: {"rnfidealabstorel",2,(void*)rnfidealabstorel,6,"GG"},
                   1763: {"rnfidealdown",2,(void*)rnfidealdown,6,"GG"},
                   1764: {"rnfidealhnf",2,(void*)rnfidealhermite,6,"GG"},
                   1765: {"rnfidealmul",2,(void*)rnfidealmul,6,"GG"},
                   1766: {"rnfidealnormabs",2,(void*)rnfidealnormabs,6,"GG"},
                   1767: {"rnfidealnormrel",2,(void*)rnfidealnormrel,6,"GG"},
                   1768: {"rnfidealreltoabs",2,(void*)rnfidealreltoabs,6,"GG"},
                   1769: {"rnfidealtwoelt",2,(void*)rnfidealtwoelement,6,"GG"},
                   1770: {"rnfidealup",2,(void*)rnfidealup,6,"GG"},
                   1771: {"rnfinit",29,(void*)rnfinitalg,6,"GGp"},
                   1772: {"rnfisfree",20,(void*)rnfisfree,6,"lGG"},
                   1773: {"rnfisnorm",99,(void*)rnfisnorm,6,"GGGD1,L,p"},
                   1774: {"rnfkummer",99,(void*)rnfkummer,6,"GGD0,L,p"},
                   1775: {"rnflllgram",99,(void*)rnflllgram,6,"GGGp"},
                   1776: {"rnfnormgroup",2,(void*)rnfnormgroup,6,"GG"},
                   1777: {"rnfpolred",29,(void*)rnfpolred,6,"GGp"},
                   1778: {"rnfpolredabs",99,(void*)rnfpolredabs,6,"GGD0,L,p"},
                   1779: {"rnfpseudobasis",2,(void*)rnfpseudobasis,6,"GG"},
                   1780: {"rnfsteinitz",2,(void*)rnfsteinitz,6,"GG"},
                   1781: {"round",99,(void*)round0,2,"GD&"},
                   1782: {"serconvol",2,(void*)convol,7,"GG"},
                   1783: {"serlaplace",18,(void*)laplace,7,"G"},
                   1784: {"serreverse",18,(void*)recip,7,"G"},
                   1785: {"setintersect",2,(void*)setintersect,8,"GG"},
                   1786: {"setisset",10,(void*)setisset,8,"lG"},
                   1787: {"setminus",2,(void*)setminus,8,"GG"},
                   1788: {"setrand",99,(void*)setrand,11,"lL"},
                   1789: {"setsearch",99,(void*)setsearch,8,"lGGD0,L,"},
                   1790: {"setunion",2,(void*)setunion,8,"GG"},
                   1791: {"shift",99,(void*)gshift,1,"GL"},
                   1792: {"shiftmul",99,(void*)gmul2n,1,"GL"},
                   1793: {"sigma",99,(void*)gsumdivk,4,"GD1,L,"},
                   1794: {"sign",10,(void*)gsigne,1,"lG"},
                   1795: {"simplify",18,(void*)simplify,2,"G"},
                   1796: {"sin",1,(void*)gsin,3,"Gp"},
                   1797: {"sinh",1,(void*)gsh,3,"Gp"},
                   1798: {"sizebyte",10,(void*)taille2,2,"lG"},
                   1799: {"sizedigit",10,(void*)gsize,2,"lG"},
                   1800: {"solve",37,(void*)zbrent,9,"V=GGIp"},
                   1801: {"sqr",18,(void*)gsqr,3,"G"},
                   1802: {"sqrt",1,(void*)gsqrt,3,"Gp"},
                   1803: {"sqrtint",1,(void*)racine,4,"Gp"},
                   1804: {"subgrouplist",99,(void*)subgrouplist0,6,"GD0,L,D0,L,p"},
                   1805: {"subst",26,(void*)gsubst,7,"GnG"},
                   1806: {"sum",48,(void*)somme,9,"V=GGIDG"},
                   1807: {"sumalt",99,(void*)sumalt0,9,"V=GID0,L,p"},
                   1808: {"sumdiv",22,(void*)divsum,9,"GVI"},
                   1809: {"suminf",27,(void*)suminf,9,"V=GIp"},
                   1810: {"sumpos",99,(void*)sumpos0,9,"V=GID0,L,p"},
                   1811: {"tan",1,(void*)gtan,3,"Gp"},
                   1812: {"tanh",1,(void*)gth,3,"Gp"},
                   1813: {"taylor",12,(void*)tayl,7,"GnP"},
                   1814: {"teichmuller",1,(void*)teich,3,"Gp"},
                   1815: {"theta",29,(void*)theta,3,"GGp"},
                   1816: {"thetanullk",99,(void*)thetanullk,3,"GL"},
                   1817: {"thue",99,(void*)thue,7,"GGDG"},
                   1818: {"thueinit",99,(void*)thueinit,7,"GD0,L,p"},
                   1819: {"trace",1,(void*)gtrace,8,"Gp"},
                   1820: {"truncate",99,(void*)trunc0,2,"GD&"},
                   1821: {"until",82,NULL,11,NULL},
                   1822: {"valuation",20,(void*)ggval,2,"lGG"},
                   1823: {"variable",18,(void*)gpolvar,2,"G"},
                   1824: {"vecextract",99,(void*)extract0,8,"GGDG"},
                   1825: {"vecmax",1,(void*)vecmax,1,"Gp"},
                   1826: {"vecmin",1,(void*)vecmin,1,"Gp"},
                   1827: {"vecsort",99,(void*)vecsort0,8,"GDGD0,L,"},
                   1828: {"vector",28,(void*)vecteur,8,"GDVDI"},
                   1829: {"vectorv",28,(void*)vvecteur,8,"GDVDI"},
                   1830: {"weber",99,(void*)weber0,3,"GD0,L,p"},
                   1831: {"while",81,NULL,11,NULL},
                   1832: {"zeta",1,(void*)gzeta,3,"Gp"},
                   1833: {"zetak",99,(void*)gzetakall,6,"GGD0,L,p"},
                   1834: {"zetakinit",1,(void*)initzeta,6,"Gp"},
                   1835: {"znlog",2,(void*)znlog,4,"GG"},
                   1836: {"znorder",18,(void*)order,4,"G"},
                   1837: {"znprimroot",18,(void*)ggener,4,"G"},
                   1838: {"znstar",1,(void*)znstar,4,"Gp"},
                   1839:
                   1840: /* DO NOT REMOVE THIS BLANK LINE: chname & helpsynchro depend on it */
                   1841: {NULL,0,NULL,0,NULL} /* sentinel */
                   1842: };

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>