version 1.1, 2001/10/02 11:17:10 |
version 1.2, 2002/09/11 07:27:04 |
|
|
char *current_logfile, *current_psfile; |
char *current_logfile, *current_psfile; |
int gp_colors[c_LAST]; |
int gp_colors[c_LAST]; |
int disable_color = 1, added_newline = 1; |
int disable_color = 1, added_newline = 1; |
int under_emacs = 0, under_texmacs = 0; |
|
|
|
int functions_tblsz = 135; /* size of functions_hash */ |
int functions_tblsz = 135; /* size of functions_hash */ |
entree **varentries; |
entree **varentries; |
Line 45 entree **varentries; |
|
Line 44 entree **varentries; |
|
void *global_err_data; |
void *global_err_data; |
jmp_buf environnement; |
jmp_buf environnement; |
long *ordvar; |
long *ordvar; |
long DEBUGFILES,DEBUGLEVEL,DEBUGMEM,compatible; |
ulong DEBUGFILES, DEBUGLEVEL, DEBUGMEM, compatible; |
long prec,precdl; |
ulong prec, precdl; |
ulong init_opts = INIT_JMPm | INIT_SIGm; |
ulong init_opts = INIT_JMPm | INIT_SIGm; |
ulong top, bot, avma, memused; |
gpmem_t bot = 0, top = 0, avma; |
|
size_t memused; |
|
|
|
gp_data *GP_DATA = NULL; |
|
|
void *foreignHandler; /* Handler for foreign commands. */ |
void *foreignHandler; /* Handler for foreign commands. */ |
char foreignExprSwitch = 3; /* Just some unprobable char. */ |
char foreignExprSwitch = 3; /* Just some unprobable char. */ |
GEN (*foreignExprHandler)(char*); /* Handler for foreign expressions.*/ |
GEN (*foreignExprHandler)(char*); /* Handler for foreign expressions.*/ |
Line 57 entree * (*foreignAutoload)(char*, long); /* Autoloade |
|
Line 59 entree * (*foreignAutoload)(char*, long); /* Autoloade |
|
void (*foreignFuncFree)(entree *); /* How to free external entree. */ |
void (*foreignFuncFree)(entree *); /* How to free external entree. */ |
|
|
int (*default_exception_handler)(long); |
int (*default_exception_handler)(long); |
GEN (*gp_history_fun)(long, long, char *, char *); |
|
int (*whatnow_fun)(char *, int); |
int (*whatnow_fun)(char *, int); |
void (*output_fun)(GEN); |
pariout_t DFLT_OUTPUT = { 'g', 0, -1, 1, 0, f_RAW }; |
|
|
|
extern void delete_dirs(gp_path *p); |
extern void initout(int initerr); |
extern void initout(int initerr); |
extern int term_width(void); |
extern int term_width(void); |
|
|
|
#ifdef BOTH_GNUPLOT_AND_X11 |
|
/* Satisfy DLL dependencies: dummy only */ |
|
#define EXTERM_DLL_DPES *PL_markstack_ptr, PL_stack_max, *PL_Sv, *PL_stack_sp, \ |
|
*PL_tmps_floor, *PL_tmps_ix, *PL_markstack_max, *PL_stack_base, *PL_na, \ |
|
*PL_sv_yes, *PL_sv_no, *PL_curpad, *PL_op |
|
extern int EXTERM_DLL_DPES; |
|
int EXTERM_DLL_DPES; |
|
#endif /* defined BOTH_GNUPLOT_AND_X11 */ |
|
|
typedef struct cell { |
typedef struct cell { |
void *env; |
void *env; |
void *data; |
void *data; |
Line 129 static int var_not_changed; /* altered in reorder() */ |
|
Line 140 static int var_not_changed; /* altered in reorder() */ |
|
static int try_to_recover = 0; |
static int try_to_recover = 0; |
static long next_bloc; |
static long next_bloc; |
static GEN cur_bloc=NULL; /* current bloc in bloc list */ |
static GEN cur_bloc=NULL; /* current bloc in bloc list */ |
static long *universal_constants; |
static GEN universal_constants; |
|
|
|
#if __MWERKS__ |
|
static void * |
|
macalloc(size_t size) |
|
{ |
|
OSErr resultCode; |
|
Handle newH = TempNewHandle((size),&resultCode); |
|
if (!newH) return NULL; |
|
HLock(newH); return (void*) *newH; |
|
} |
|
# define __gpmalloc(size) ((size) > 1000000)? macalloc(size): malloc((size)) |
|
#else |
|
# define __gpmalloc(size) (malloc(size)) |
|
#endif |
|
|
|
char* |
|
gpmalloc(size_t size) |
|
{ |
|
if (size) |
|
{ |
|
char *tmp = (char*)__gpmalloc(size); |
|
if (!tmp) err(memer); |
|
return tmp; |
|
} |
|
if (DEBUGMEM) err(warner,"mallocing NULL object"); |
|
return NULL; |
|
} |
|
|
|
char* |
|
gprealloc(void *pointer, size_t size) |
|
{ |
|
char *tmp; |
|
|
|
if (!pointer) tmp = (char *) malloc(size); |
|
else tmp = (char *) realloc(pointer,size); |
|
if (!tmp) err(memer); |
|
return tmp; |
|
} |
|
|
static void |
static void |
pari_handle_SIGINT() |
pari_handle_SIGINT(void) |
{ |
{ |
#ifdef _WIN32 |
#ifdef _WIN32 |
if (++win32ctrlc >= 5) _exit(3); |
if (++win32ctrlc >= 5) _exit(3); |
|
|
pari_sighandler(int sig) |
pari_sighandler(int sig) |
{ |
{ |
char *msg; |
char *msg; |
os_signal(sig,pari_sighandler); |
(void)os_signal(sig,pari_sighandler); |
switch(sig) |
switch(sig) |
{ |
{ |
#ifdef SIGBREAK |
#ifdef SIGBREAK |
Line 354 pari_addfunctions(module **modlist_p, entree *func, ch |
|
Line 403 pari_addfunctions(module **modlist_p, entree *func, ch |
|
modlist->help = NULL; |
modlist->help = NULL; |
} |
} |
|
|
static long |
|
fix_size(long a) |
|
{ |
|
/* BYTES_IN_LONG*ceil(a/BYTES_IN_LONG) */ |
|
ulong b = a+BYTES_IN_LONG - (((a-1) & (BYTES_IN_LONG-1)) + 1); |
|
if (b > VERYBIGINT) err(talker,"stack too large"); |
|
return b; |
|
} |
|
|
|
void |
void |
pari_sig_init(void (*f)(int)) |
pari_sig_init(void (*f)(int)) |
{ |
{ |
Line 394 reset_traps(int warn) |
|
Line 434 reset_traps(int warn) |
|
for (i=0; i <= noer; i++) err_catch_array[i] = 0; |
for (i=0; i <= noer; i++) err_catch_array[i] = 0; |
} |
} |
|
|
|
static void |
|
init_universal_constants(void) |
|
{ |
|
/* 2 (gnil) + 2 (gzero) + 3 (gun) + 3 (gdeux) + 3 (half) + 3 (gi) */ |
|
GEN p = universal_constants = (long*) gpmalloc(16*sizeof(long)); |
|
gzero = p; p+=2; gnil = p; p+=2; |
|
gzero[0] = gnil[0] = evaltyp(t_INT) | evallg(2); |
|
gzero[1] = gnil[1] = evallgefint(2); |
|
|
|
gun = p; p+=3; gdeux = p; p+=3; |
|
gun[0] = gdeux[0] = evaltyp(t_INT) | evallg(3); |
|
gun[1] = gdeux[1] = evalsigne(1) | evallgefint(3); |
|
gun[2] = 1; gdeux[2]= 2; |
|
|
|
ghalf = p; p+=3; gi = p; p+=3; |
|
ghalf[0] = evaltyp(t_FRAC) | evallg(3); |
|
ghalf[1] = un; |
|
ghalf[2] = deux; |
|
gi[0] = evaltyp(t_COMPLEX) | evallg(3); |
|
gi[1] = zero; |
|
gi[2] = un; |
|
} |
|
|
|
static long |
|
fix_size(size_t a) |
|
{ |
|
/* BYTES_IN_LONG*ceil(a/BYTES_IN_LONG) */ |
|
size_t b = a+BYTES_IN_LONG - (((a-1) & (BYTES_IN_LONG-1)) + 1); |
|
if (b > VERYBIGINT) err(talker,"stack too large"); |
|
if (b < 1024) b = 1024; |
|
return b; |
|
} |
|
|
|
static long |
|
init_stack(size_t size) |
|
{ |
|
size_t s = fix_size(size), old = 0; |
|
if (bot) |
|
{ |
|
old = top - bot; |
|
free((void*)bot); |
|
} |
|
/* NOT gpmalloc, memer would be deadly */ |
|
bot = (gpmem_t)__gpmalloc(s); |
|
if (!bot) |
|
for (s = old;; s>>=1) |
|
{ |
|
if (!s) err(memer); /* no way out. Die */ |
|
err(warner,"not enough memory, new stack %lu",s); |
|
bot = (gpmem_t)__gpmalloc(s); |
|
if (bot) break; |
|
} |
|
avma = top = bot+s; |
|
memused = 0; return s; |
|
} |
|
|
/* initialise les donnees de la bibliotheque PARI. Peut être précédée d'un |
/* initialise les donnees de la bibliotheque PARI. Peut être précédée d'un |
* appel à pari_addfunctions si on ajoute d'autres fonctions au pool de base. |
* appel à pari_addfunctions si on ajoute d'autres fonctions au pool de base. |
*/ |
*/ |
void |
void |
pari_init(long parisize, long maxprime) |
pari_init(size_t parisize, ulong maxprime) |
{ |
{ |
long i, size; |
long i; |
GEN p; |
|
|
|
#ifdef STACK_CHECK |
#ifdef STACK_CHECK |
pari_init_stackcheck(&i); |
pari_init_stackcheck(&i); |
Line 413 pari_init(long parisize, long maxprime) |
|
Line 508 pari_init(long parisize, long maxprime) |
|
exit(1); |
exit(1); |
} |
} |
if (INIT_SIG) pari_sig_init(pari_sighandler); |
if (INIT_SIG) pari_sig_init(pari_sighandler); |
size = fix_size(parisize); |
(void)init_stack(parisize); |
#if __MWERKS__ |
|
{ |
|
OSErr resultCode; |
|
Handle newHand = TempNewHandle(size,&resultCode); |
|
|
|
if (!newHand) err(memer); |
|
HLock(newHand); |
|
bot = (long)*newHand; |
|
} |
|
#else |
|
bot = (long) gpmalloc(size); |
|
#endif |
|
top = avma = memused = bot+size; |
|
diffptr = initprimes(maxprime); |
diffptr = initprimes(maxprime); |
|
init_universal_constants(); |
|
|
varentries = (entree**) gpmalloc((MAXVARN+1)*sizeof(entree*)); |
varentries = (entree**) gpmalloc((MAXVARN+1)*sizeof(entree*)); |
polvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long)); |
polvar = (GEN) gpmalloc((MAXVARN+1)*sizeof(long)); |
Line 437 pari_init(long parisize, long maxprime) |
|
Line 520 pari_init(long parisize, long maxprime) |
|
polvar[0] = evaltyp(t_VEC) | evallg(1); |
polvar[0] = evaltyp(t_VEC) | evallg(1); |
for (i=0; i <= MAXVARN; i++) { ordvar[i] = i; varentries[i] = NULL; } |
for (i=0; i <= MAXVARN; i++) { ordvar[i] = i; varentries[i] = NULL; } |
|
|
/* 2 (gnil) + 2 (gzero) + 3 (gun) + 3 (gdeux) + 3 (half) + 3 (gi) */ |
(void)fetch_var(); /* create polx/polun[MAXVARN] */ |
p = universal_constants = (long *) gpmalloc(16*sizeof(long)); |
|
|
|
gzero = p; p+=2; gnil = p; p+=2; |
|
gzero[0] = gnil[0] = evaltyp(t_INT) | evallg(2); |
|
gzero[1] = gnil[1] = evallgefint(2); |
|
|
|
gun = p; p+=3; gdeux = p; p+=3; |
|
gun[0] = gdeux[0] = evaltyp(t_INT) | evallg(3); |
|
gun[1] = gdeux[1] = evalsigne(1) | evallgefint(3); |
|
gun[2] = 1; gdeux[2]= 2; |
|
|
|
ghalf = p; p+=3; gi = p; p+=3; |
|
ghalf[0] = evaltyp(t_FRAC) | evallg(3); |
|
ghalf[1] = un; |
|
ghalf[2] = deux; |
|
gi[0] = evaltyp(t_COMPLEX) | evallg(3); |
|
gi[1] = zero; |
|
gi[2] = un; |
|
fetch_var(); /* create polx/polun[MAXVARN] */ |
|
primetab = (GEN) gpmalloc(1 * sizeof(long)); |
primetab = (GEN) gpmalloc(1 * sizeof(long)); |
primetab[0] = evaltyp(t_VEC) | evallg(1); |
primetab[0] = evaltyp(t_VEC) | evallg(1); |
|
|
Line 479 pari_init(long parisize, long maxprime) |
|
Line 543 pari_init(long parisize, long maxprime) |
|
for (i = 0; i < functions_tblsz; i++) members_hash[i] = NULL; |
for (i = 0; i < functions_tblsz; i++) members_hash[i] = NULL; |
gp_init_entrees(pari_membermodules, members_hash, 1); |
gp_init_entrees(pari_membermodules, members_hash, 1); |
|
|
gp_history_fun = NULL; |
|
whatnow_fun = NULL; |
whatnow_fun = NULL; |
output_fun = &outbrute; |
|
err_catch_array = (long *) gpmalloc((noer + 1) *sizeof(long)); |
err_catch_array = (long *) gpmalloc((noer + 1) *sizeof(long)); |
reset_traps(0); |
reset_traps(0); |
default_exception_handler = NULL; |
default_exception_handler = NULL; |
|
|
(void)manage_var(2,NULL); /* init nvar */ |
(void)manage_var(2,NULL); /* init nvar */ |
(void)get_timer(-1); /* init timers */ |
var_not_changed = 1; (void)fetch_named_var("x", 0); |
var_not_changed = 1; fetch_named_var("x", 0); |
|
try_to_recover=1; |
try_to_recover=1; |
} |
} |
|
|
|
static void |
|
delete_hist(gp_hist *h) |
|
{ |
|
if (h->res) free((void*)h->res); |
|
} |
|
static void |
|
delete_pp(gp_pp *p) |
|
{ |
|
if (p->cmd) free((void*)p->cmd); |
|
} |
|
static void |
|
delete_path(gp_path *p) |
|
{ |
|
delete_dirs(p); |
|
free((void*)p->PATH); |
|
} |
|
|
|
static void |
|
free_gp_data(gp_data *D) |
|
{ |
|
if (!D) return; |
|
delete_hist(D->hist); |
|
delete_path(D->path); |
|
delete_pp(D->pp); |
|
if (D->help) free((void*)D->help); |
|
} |
|
|
void |
void |
freeall(void) |
freeall(void) |
{ |
{ |
|
|
while (delete_var()) /* empty */; |
while (delete_var()) /* empty */; |
for (i = 0; i < functions_tblsz; i++) |
for (i = 0; i < functions_tblsz; i++) |
{ |
{ |
for (ep = functions_hash[i]; ep; ep = ep1) |
for (ep = functions_hash[i]; ep; ep = ep1) { ep1 = ep->next; freeep(ep); } |
{ |
for (ep = members_hash[i]; ep; ep = ep1) { ep1 = ep->next; freeep(ep); } |
ep1 = ep->next; freeep(ep); |
|
} |
|
for (ep = members_hash[i]; ep; ep = ep1) |
|
{ |
|
ep1 = ep->next; freeep(ep); |
|
} |
|
} |
} |
free((void*)varentries); free((void*)ordvar); free((void*)polvar); |
free((void*)varentries); |
free((void*)polx[MAXVARN]); free((void*)polx); free((void*)polun); |
free((void*)ordvar); |
|
free((void*)polvar); |
|
free((void*)polx[MAXVARN]); |
|
free((void*)polx); |
|
free((void*)polun); |
free((void*)primetab); |
free((void*)primetab); |
free((void*)universal_constants); |
free((void*)universal_constants); |
|
|
|
|
while (cur_bloc) { *cur_bloc=0; killbloc(cur_bloc); } |
while (cur_bloc) { *cur_bloc=0; killbloc(cur_bloc); } |
killallfiles(1); |
killallfiles(1); |
free((void *)functions_hash); |
free((void *)functions_hash); |
free((void *)bot); free((void *)diffptr); |
free((void *)bot); |
|
free((void *)diffptr); |
free(current_logfile); |
free(current_logfile); |
free(current_psfile); |
free(current_psfile); |
|
|
if (gp_history_fun) |
free_gp_data(GP_DATA); |
gp_history_fun(0,-1,NULL,NULL); |
|
} |
} |
|
|
GEN |
GEN |
|
|
{ |
{ |
if (!n) err(warner,"mallocing NULL object in newbloc"); |
if (!n) err(warner,"mallocing NULL object in newbloc"); |
if (DEBUGMEM > 2) |
if (DEBUGMEM > 2) |
fprintferr("new bloc, size %6ld (no %ld): %08lx\n", n, next_bloc-1, x); |
fprintferr("new bloc, size %6lu (no %ld): %08lx\n", n, next_bloc-1, x); |
} |
} |
return cur_bloc = x; |
return cur_bloc = x; |
} |
} |
|
|
void |
/* recursively look for clones in the container and kill them */ |
killbloc0(GEN x, int inspect) |
static void |
|
inspect(GEN x) |
{ |
{ |
long tx,lx,l,i,j; |
long i, lx; |
GEN p1; |
switch(typ(x)) /* HACK: if x is not a GEN, we have typ(x)=0 */ |
|
{ |
|
case t_VEC: case t_COL: case t_MAT: |
|
lx = lg(x); |
|
for (i=1;i<lx;i++) inspect((GEN)x[i]); |
|
break; |
|
case t_LIST: |
|
lx = lgef(x); |
|
for (i=2;i<lx;i++) inspect((GEN)x[i]); |
|
break; |
|
} |
|
if (isclone(x)) gunclone(x); /* Don't inspect here! components are dead */ |
|
} |
|
|
|
/* If insp is set, recursively inspect x, killing all clones found. The GP |
|
* expression x[i] = y is implemented as x[i] := gclone(y) and we need to |
|
* reclaim the memory. Useless to inspect when x does not correspond to a GP |
|
* variable [not dangerous, though] */ |
|
void |
|
killbloc0(GEN x, int insp) |
|
{ |
if (!x || isonstack(x)) return; |
if (!x || isonstack(x)) return; |
if (bl_next(x)) bl_prev(bl_next(x)) = bl_prev(x); |
if (bl_next(x)) bl_prev(bl_next(x)) = bl_prev(x); |
else |
else |
Line 588 killbloc0(GEN x, int inspect) |
|
Line 694 killbloc0(GEN x, int inspect) |
|
if (bl_prev(x)) bl_next(bl_prev(x)) = bl_next(x); |
if (bl_prev(x)) bl_next(bl_prev(x)) = bl_next(x); |
if (DEBUGMEM > 2) |
if (DEBUGMEM > 2) |
fprintferr("killing bloc (no %ld): %08lx\n", bl_num(x), x); |
fprintferr("killing bloc (no %ld): %08lx\n", bl_num(x), x); |
if (inspect) |
if (insp) |
{ |
{ /* FIXME: SIGINT should be blocked until inspect() returns */ |
/* FIXME: SIGINT should be blocked at this point */ |
unsetisclone(x); /* important: oo recursion otherwise */ |
tx=typ(x); /* if x is not a GEN, we will have tx=0 */ |
inspect(x); |
if (is_vec_t(tx)) |
|
{ |
|
lx = lg(x); |
|
for (i=1;i<lx;i++) |
|
{ |
|
p1=(GEN)x[i]; |
|
if (isclone(p1)) killbloc(p1); |
|
} |
|
} |
|
else if (tx==t_MAT) |
|
{ |
|
lx = lg(x); |
|
if (lx>1) |
|
{ |
|
l=lg(x[1]); |
|
if (l>1) |
|
for (i=1;i<lx;i++) |
|
for (j=1;j<l;j++) |
|
{ |
|
p1=gmael(x,i,j); |
|
if (isclone(p1)) killbloc(p1); |
|
} |
|
} |
|
} |
|
else if (tx==t_LIST) |
|
{ |
|
lx = lgef(x); |
|
for (i=2;i<lx;i++) |
|
{ |
|
p1=(GEN)x[i]; |
|
if (isclone(p1)) killbloc(p1); |
|
} |
|
} |
|
unsetisclone(x); |
|
/* FIXME: SIGINT should be released here */ |
|
} |
} |
free((void *)bl_base(x)); |
free((void *)bl_base(x)); |
} |
} |
Line 645 gunclone(GEN x) { killbloc0(x,0); } |
|
Line 716 gunclone(GEN x) { killbloc0(x,0); } |
|
GEN |
GEN |
changevar(GEN x, GEN y) |
changevar(GEN x, GEN y) |
{ |
{ |
long tx,ty,lx,vx,vy,i,av,tetpil; |
long tx, ty, lx, vx, vy, i; |
|
gpmem_t av, tetpil; |
GEN p1,p2,z; |
GEN p1,p2,z; |
|
|
if (var_not_changed && y==polvar) return x; |
if (var_not_changed && y==polvar) return x; |
Line 810 recover(int flag) |
|
Line 882 recover(int flag) |
|
} |
} |
#endif |
#endif |
try_to_recover=1; |
try_to_recover=1; |
os_signal(SIGINT, sigfun); |
(void)os_signal(SIGINT, sigfun); |
} |
} |
|
|
void |
void |
Line 865 errcontext(char *msg, char *s, char *entry) |
|
Line 937 errcontext(char *msg, char *s, char *entry) |
|
void * |
void * |
err_catch(long errnum, jmp_buf env, void *data) |
err_catch(long errnum, jmp_buf env, void *data) |
{ |
{ |
cell *v = (cell*)gpmalloc(sizeof(cell)); |
cell *v; |
|
/* for fear of infinite recursion don't trap memory errors */ |
|
if (errnum == memer) err(talker, "can't trap memory errors"); |
if (errnum < 0) errnum = noer; |
if (errnum < 0) errnum = noer; |
|
if (errnum > noer) err(talker, "no such error number: %ld", errnum); |
|
v = (cell*)gpmalloc(sizeof(cell)); |
v->data = data; |
v->data = data; |
v->env = env; |
v->env = env; |
v->flag = errnum; |
v->flag = errnum; |
Line 875 err_catch(long errnum, jmp_buf env, void *data) |
|
Line 951 err_catch(long errnum, jmp_buf env, void *data) |
|
return (void*)v; |
return (void*)v; |
} |
} |
|
|
/* reset traps younger than V (included) */ |
static void |
void |
pop_catch_cell(stack **s) |
err_leave(void **V) |
|
{ |
{ |
cell *t, *v = (cell*)*V; |
cell *c = (cell*)pop_stack(s); |
|
if (c) |
for (;;) |
|
{ |
{ |
t = (cell*)pop_stack(&err_catch_stack); |
err_catch_array[c->flag]--; |
if (t == v || !t) break; |
free(c); |
err_catch_array[t->flag]--; |
|
free(t); |
|
} |
} |
if (!t) reset_traps(1); |
|
err_catch_array[v->flag]--; |
|
free(v); |
|
} |
} |
|
|
/* get last (most recent) handler for error n */ |
|
static cell * |
|
err_seek(long n) |
|
{ |
|
stack *s = err_catch_stack; |
|
cell *t = NULL; |
|
|
|
for (;s; s = s->prev) |
|
{ |
|
t = (cell*)s->value; |
|
if (!t || t->flag == n) break; |
|
} |
|
if (!t) reset_traps(1); |
|
return t; |
|
} |
|
|
|
/* kill last handler for error n */ |
/* kill last handler for error n */ |
void |
static void |
err_leave_default(long n) |
err_leave_default(long n) |
{ |
{ |
stack *s = err_catch_stack, *lasts = NULL; |
stack *s = err_catch_stack, *lasts; |
cell *c; |
|
|
|
if (n < 0) n = noer; |
if (n < 0) n = noer; |
if (!s || !err_catch_array[n]) return; |
if (!s || !err_catch_array[n]) return; |
for (;s; s = s->prev) |
for (lasts = NULL; s; lasts = s, s = s->prev) |
|
if (((cell*)s->value)->flag == n) break; |
|
pop_catch_cell(&s); |
|
if (!lasts) err_catch_stack = s; else lasts->prev = s; |
|
} |
|
|
|
/* reset traps younger than V (included) */ |
|
void |
|
err_leave(void **V) |
|
{ |
|
cell *v = (cell*)*V; |
|
while (err_catch_stack) |
{ |
{ |
c = (cell*)s->value; |
cell *t = (cell*)err_catch_stack->value; |
if (c->flag == n) |
pop_catch_cell(&err_catch_stack); |
{ /* kill */ |
if (t == v) return; |
stack *v = s->prev; |
|
free((void*)s); s = v; |
|
if (lasts) lasts->prev = s; |
|
break; |
|
} |
|
else lasts = s; |
|
} |
} |
if (!lasts) |
reset_traps(1); |
|
} |
|
|
|
/* We know somebody is trapping n (from err_catch_array). |
|
* Get last (most recent) handler for error n (or generic noer) killing all |
|
* more recent non-applicable handlers (now obsolete) */ |
|
static cell * |
|
err_seek(long n) |
|
{ |
|
while (err_catch_stack) |
{ |
{ |
err_catch_stack = s; |
cell *t = err_catch_stack->value; |
if (!s) reset_traps(0); |
if (t->flag == n || t->flag == noer) return t; |
|
pop_catch_cell(&err_catch_stack); |
} |
} |
|
reset_traps(1); return NULL; |
} |
} |
|
|
/* untrapped error: remove all traps depending from a longjmp */ |
/* untrapped error: find oldest trap depending from a longjmp, and kill |
|
* everything more recent */ |
void |
void |
err_clean() |
err_clean(void) |
{ |
{ |
stack *s = err_catch_stack, *lasts = NULL; |
stack *s = err_catch_stack, *lasts = NULL; |
cell *c; |
for ( ; s; s = s->prev) |
|
|
if (!s) return; |
|
while (s) |
|
{ |
{ |
c = (cell*)s->value; |
cell *c = (cell*)s->value; |
if (c->env) |
if (c->env) lasts = s; |
{ /* kill */ |
|
stack *v = s->prev; |
|
free((void*)s); s = v; |
|
if (lasts) lasts->prev = s; |
|
} |
|
else |
|
{ /* preserve */ |
|
if (lasts) lasts->prev = s; else err_catch_stack = s; |
|
lasts = s; s = s->prev; |
|
} |
|
} |
} |
if (!lasts) |
if (lasts) |
{ |
{ |
err_catch_stack = NULL; |
void *c = (void*)s->value; |
reset_traps(0); |
err_leave(&c); |
} |
} |
} |
} |
|
|
Line 978 err_recover(long numerr) |
|
Line 1034 err_recover(long numerr) |
|
{ |
{ |
initout(0); |
initout(0); |
disable_dbg(-1); |
disable_dbg(-1); |
get_timer(-1); |
|
killallfiles(0); |
killallfiles(0); |
|
|
if (pariErr->die) pariErr->die(); /* Caller wants to catch exceptions? */ |
if (pariErr->die) pariErr->die(); /* Caller wants to catch exceptions? */ |
Line 1003 err(long numerr, ...) |
|
Line 1058 err(long numerr, ...) |
|
|
|
va_start(ap,numerr); |
va_start(ap,numerr); |
|
|
|
global_err_data = NULL; |
if (err_catch_stack && !is_warn(numerr)) |
if (err_catch_stack && !is_warn(numerr)) |
{ |
{ |
int trap = 0; |
if (!err_catch_array[numerr] && !err_catch_array[noer]) err_clean(); |
if (numerr != memer) |
else if ( (trapped = err_seek(numerr)) ) |
{ /* for fear of infinite recursion don't trap memory errors */ |
{ |
if (err_catch_array[numerr]) trap = numerr; |
void *e = trapped->env; |
else if (err_catch_array[noer]) trap = noer; |
if (e) |
|
{ |
|
if (numerr == invmoder) |
|
{ |
|
(void)va_arg(ap, char*); /* junk 1st arg */ |
|
global_err_data = (void*)va_arg(ap, GEN); |
|
} |
|
longjmp(e, numerr); |
|
} |
|
global_err_data = trapped->data; |
} |
} |
if (trap) trapped = err_seek(trap); else err_clean(); |
|
} |
} |
if (trapped) |
|
{ /* all errors (noer), or numerr individually trapped */ |
|
void *e = trapped->env; |
|
global_err_data = trapped->data; |
|
if (e) longjmp(e, numerr); |
|
} |
|
else |
|
global_err_data = NULL; |
|
|
|
if (!added_newline) { pariputc('\n'); added_newline=1; } |
if (!added_newline) { pariputc('\n'); added_newline=1; } |
pariflush(); pariOut = pariErr; |
pariflush(); pariOut = pariErr; |
Line 1057 err(long numerr, ...) |
|
Line 1113 err(long numerr, ...) |
|
errcontext(s,ch1,va_arg(ap,char *)); |
errcontext(s,ch1,va_arg(ap,char *)); |
} |
} |
} |
} |
|
else if (numerr == user) |
|
{ |
|
GEN *g = va_arg(ap, GEN*); |
|
pariputsf(" ### user error: "); |
|
print0(g, f_RAW); |
|
} |
else |
else |
{ |
{ |
pariputsf(" *** %s", errmessage[numerr]); |
pariputsf(" *** %s", errmessage[numerr]); |
Line 1082 err(long numerr, ...) |
|
Line 1144 err(long numerr, ...) |
|
case operi: case operf: |
case operi: case operf: |
{ |
{ |
char *f, *op = va_arg(ap, char*); |
char *f, *op = va_arg(ap, char*); |
long x = va_arg(ap, long); |
GEN x = va_arg(ap, GEN); |
long y = va_arg(ap, long); |
GEN y = va_arg(ap, GEN); |
if (*op == '+') f = "addition"; |
if (*op == '+') f = "addition"; |
else if (*op == '*') f = "multiplication"; |
else if (*op == '*') f = "multiplication"; |
else if (*op == '/' || *op == '%') f = "division"; |
else if (*op == '/' || *op == '%' || *op == '\\') f = "division"; |
else if (*op == 'g') { op = ","; f = "gcd"; } |
else if (*op == 'g') { op = ","; f = "gcd"; } |
else { op = "-->"; f = "assignment"; } |
else { op = "-->"; f = "assignment"; } |
pariputsf(" %s %s %s %s.",f,type_name(x),op,type_name(y)); |
pariputsf(" %s %s %s %s.",f,type_name(typ(x)),op,type_name(typ(y))); |
break; |
break; |
} |
} |
|
|
Line 1112 err(long numerr, ...) |
|
Line 1174 err(long numerr, ...) |
|
term_color(c_NONE); va_end(ap); |
term_color(c_NONE); va_end(ap); |
if (numerr==errpile) |
if (numerr==errpile) |
{ |
{ |
fprintferr("\n current stack size: %ld (%.3f Mbytes)\n", |
fprintferr("\n current stack size: %lu (%.3f Mbytes)\n", |
top-bot, (top-bot)/1048576.); |
top-bot, (top-bot)/1048576.); |
fprintferr(" [hint] you can increase GP stack with allocatemem()\n"); |
fprintferr(" [hint] you can increase GP stack with allocatemem()\n"); |
} |
} |
Line 1122 err(long numerr, ...) |
|
Line 1184 err(long numerr, ...) |
|
err_recover(numerr); |
err_recover(numerr); |
} |
} |
|
|
|
/* Try f (trapping error e), recover using r (break_loop, if NULL) */ |
|
GEN |
|
trap0(char *e, char *r, char *f) |
|
{ |
|
long numerr = -1; |
|
GEN x = gnil; |
|
char *F; |
|
if (!strcmp(e,"errpile")) numerr = errpile; |
|
else if (!strcmp(e,"typeer")) numerr = typeer; |
|
else if (!strcmp(e,"gdiver2")) numerr = gdiver2; |
|
else if (!strcmp(e,"invmoder")) numerr = invmoder; |
|
else if (!strcmp(e,"accurer")) numerr = accurer; |
|
else if (!strcmp(e,"archer")) numerr = archer; |
|
else if (*e) err(impl,"this trap keyword"); |
|
/* TO BE CONTINUED */ |
|
|
|
if (f && r) |
|
{ /* explicit recovery text */ |
|
char *a = get_analyseur(); |
|
gpmem_t av = avma; |
|
|
|
CATCH(numerr) { x = NULL; } |
|
TRY { x = lisseq(f); } ENDCATCH; |
|
if (!x) { avma = av; x = lisseq(r); } |
|
set_analyseur(a); return x; |
|
} |
|
|
|
F = f? f: r; /* define a default handler */ |
|
/* default will execute F (or start a break loop), then jump to |
|
* environnement */ |
|
if (F) |
|
{ |
|
if (!*F || (*F == '"' && F[1] == '"')) /* unset previous handler */ |
|
{/* TODO: find a better interface |
|
* TODO: no leaked handler from the library should have survived |
|
*/ |
|
err_leave_default(numerr); |
|
return x; |
|
} |
|
F = pari_strdup(F); |
|
} |
|
(void)err_catch(numerr, NULL, F); |
|
return x; |
|
} |
|
|
/*******************************************************************/ |
/*******************************************************************/ |
/* */ |
/* */ |
/* CLONING & COPY */ |
/* CLONING & COPY */ |
|
|
for ( ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]); |
for ( ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]); |
for ( ; i<lx; i++) y[i]=lcopy((GEN)x[i]); |
for ( ; i<lx; i++) y[i]=lcopy((GEN)x[i]); |
} |
} |
/* unsetisclone(y); useless because gunclone checks isonstack */ |
unsetisclone(y); return y; |
return y; |
|
} |
} |
|
|
GEN |
GEN |
Line 1178 gcopy_i(GEN x, long lx) |
|
Line 1284 gcopy_i(GEN x, long lx) |
|
for ( ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]); |
for ( ; i<lontyp2[tx]; i++) copyifstack(x[i],y[i]); |
for ( ; i<lx; i++) y[i]=lcopy((GEN)x[i]); |
for ( ; i<lx; i++) y[i]=lcopy((GEN)x[i]); |
} |
} |
return y; |
unsetisclone(y); return y; |
} |
} |
|
|
GEN |
GEN |
Line 1204 forcecopy(GEN x) |
|
Line 1310 forcecopy(GEN x) |
|
unsetisclone(y); return y; |
unsetisclone(y); return y; |
} |
} |
|
|
|
GEN |
|
dummycopy(GEN x) |
|
{ |
|
long tx=typ(x), lx=lg(x),i; |
|
GEN y=new_chunk(lx); |
|
|
|
switch(tx) |
|
{ |
|
case t_POLMOD: |
|
y[1]=x[1]; y[2]=(long)dummycopy((GEN)x[2]); |
|
break; |
|
case t_MAT: |
|
for (i=lx-1;i;i--) y[i]=(long)dummycopy((GEN)x[i]); |
|
break; |
|
default: |
|
for (i=lx-1;i;i--) y[i]=x[i]; |
|
} |
|
y[0]=x[0]; return y; |
|
} |
|
|
/* copy x as if avma = *AVMA, update *AVMA */ |
/* copy x as if avma = *AVMA, update *AVMA */ |
GEN |
GEN |
gcopy_av(GEN x, GEN *AVMA) |
gcopy_av(GEN x, GEN *AVMA) |
Line 1211 gcopy_av(GEN x, GEN *AVMA) |
|
Line 1337 gcopy_av(GEN x, GEN *AVMA) |
|
long i,lx,tx=typ(x); |
long i,lx,tx=typ(x); |
GEN y; |
GEN y; |
|
|
if (tx == t_SMALL) return (*--AVMA = x); |
if (tx == t_SMALL) return x; |
lx = lg(x); *AVMA = y = *AVMA - lx; |
lx = lg(x); *AVMA = y = *AVMA - lx; |
if (! is_recursive_t(tx)) |
if (! is_recursive_t(tx)) |
{ |
{ |
Line 1226 gcopy_av(GEN x, GEN *AVMA) |
|
Line 1352 gcopy_av(GEN x, GEN *AVMA) |
|
unsetisclone(y); return y; |
unsetisclone(y); return y; |
} |
} |
|
|
GEN |
/* same but use NULL to code an exact 0 */ |
dummycopy(GEN x) |
static GEN |
|
gcopy_av0(GEN x, GEN *AVMA) |
{ |
{ |
long tx=typ(x), lx=lg(x),i; |
long i,lx,tx=typ(x); |
GEN y=new_chunk(lx); |
GEN y; |
|
|
switch(tx) |
if (! is_recursive_t(tx)) |
{ |
{ |
case t_POLMOD: |
if (tx == t_INT && !signe(x)) return NULL; /* special marker */ |
y[1]=x[1]; y[2]=(long)dummycopy((GEN)x[2]); |
if (tx == t_SMALL) return x; |
break; |
lx = lg(x); *AVMA = y = *AVMA - lx; |
case t_MAT: |
for (i=0; i<lx; i++) y[i] = x[i]; |
for (i=lx-1;i;i--) y[i]=(long)dummycopy((GEN)x[i]); |
|
break; |
|
default: |
|
for (i=lx-1;i;i--) y[i]=x[i]; |
|
} |
} |
y[0]=x[0]; return y; |
else |
|
{ |
|
lx = lg(x); *AVMA = y = *AVMA - lx; |
|
if (tx==t_POL || tx==t_LIST) lx = lgef(x); |
|
for (i=0; i<lontyp[tx]; i++) y[i] = x[i]; |
|
for ( ; i<lx; i++) y[i] = (long)gcopy_av0((GEN)x[i], AVMA); |
|
} |
|
unsetisclone(y); return y; |
} |
} |
|
|
|
/* size of a gcopy_av0 */ |
|
static long |
|
taille0(GEN x) |
|
{ |
|
long i,n,lx, tx = typ(x); |
|
if (!is_recursive_t(tx)) |
|
{ |
|
if (tx == t_INT && !signe(x)) return 0; |
|
n = lg(x); |
|
} |
|
else |
|
{ |
|
n = lg(x); |
|
lx = (tx==t_POL || tx==t_LIST)? lgef(x): n; |
|
for (i=lontyp[tx]; i<lx; i++) n += taille0((GEN)x[i]); |
|
} |
|
return n; |
|
} |
|
|
|
long |
|
taille(GEN x) |
|
{ |
|
long i,n,lx, tx = typ(x); |
|
n = lg(x); |
|
if (is_recursive_t(tx)) |
|
{ |
|
lx = (tx==t_POL || tx==t_LIST)? lgef(x): n; |
|
for (i=lontyp[tx]; i<lx; i++) n += taille((GEN)x[i]); |
|
} |
|
return n; |
|
} |
|
|
|
long |
|
taille2(GEN x) { return taille(x)<<TWOPOTBYTES_IN_LONG; } |
|
|
GEN |
GEN |
gclone(GEN x) |
gclone(GEN x) |
{ |
{ |
|
|
void |
void |
shiftaddress(GEN x, long dec) |
shiftaddress(GEN x, long dec) |
{ |
{ |
long i,lx, tx = typ(x); |
long i,lx,tx; |
|
|
|
tx = typ(x); |
if (is_recursive_t(tx)) |
if (is_recursive_t(tx)) |
{ |
{ |
lx = (tx==t_POL || tx==t_LIST)? lgef(x): lg(x); |
lx = (tx==t_POL || tx==t_LIST)? lgef(x): lg(x); |
for (i=lontyp[tx]; i<lx; i++) { |
for (i=lontyp[tx]; i<lx; i++) { |
x[i] += dec; |
if (!x[i]) x[i] = zero; |
shiftaddress((GEN)x[i], dec); |
else |
|
{ |
|
x[i] += dec; |
|
shiftaddress((GEN)x[i], dec); |
|
} |
} |
} |
} |
} |
} |
} |
|
|
/* return a clone of x structured as a gcopy. To free it, free(*base). |
/* return a clone of x structured as a gcopy */ |
* Can be copied via memcpy(, *base, ((x - *base)+lg(x)) * sizeof(long)) */ |
|
GENbin* |
GENbin* |
copy_bin(GEN x) |
copy_bin(GEN x) |
{ |
{ |
long t = taille(x); |
long t = taille0(x); |
GENbin *p = (GENbin*)gpmalloc(sizeof(GENbin) + t*sizeof(long)); |
GENbin *p = (GENbin*)gpmalloc(sizeof(GENbin) + t*sizeof(long)); |
GEN AVMA = GENbase(p) + t; |
GEN AVMA = GENbase(p) + t; |
p->len = t; |
p->len = t; |
p->x = gcopy_av(x, &AVMA); |
p->x = gcopy_av0(x, &AVMA); |
p->base= AVMA; return p; |
p->base= AVMA; return p; |
} |
} |
|
|
Line 1300 bin_copy(GENbin *p) |
|
Line 1470 bin_copy(GENbin *p) |
|
GEN x,y,base; |
GEN x,y,base; |
long dx,len; |
long dx,len; |
|
|
|
x = p->x; if (!x) { free(p); return gzero; } |
len = p->len; |
len = p->len; |
x = p->x; |
|
base= p->base; dx = x - base; |
base= p->base; dx = x - base; |
y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbase(p), len*sizeof(long)); |
y = (GEN)memcpy((void*)new_chunk(len), (void*)GENbase(p), len*sizeof(long)); |
if (dx) { y += dx; shiftaddress(y, (y-x)*sizeof(long)); } |
y += dx; shiftaddress(y, (y-x)*sizeof(long)); |
free(p); return y; |
free(p); return y; |
} |
} |
|
|
Line 1321 bin_copy(GENbin *p) |
|
Line 1491 bin_copy(GENbin *p) |
|
* stackdummy(z,l); z += l; We lose l words but save a costly gerepile. |
* stackdummy(z,l); z += l; We lose l words but save a costly gerepile. |
*/ |
*/ |
void |
void |
stackdummy(GEN z, long l) { z[0] = evaltyp(t_STR) | evallg(l); } |
stackdummy(GEN z, long l) { z[0] = evaltyp(t_VECSMALL) | evallg(l); } |
|
|
/* gerepileupto(av, forcecopy(x)) */ |
/* gerepileupto(av, forcecopy(x)) */ |
GEN |
GEN |
gerepilecopy(long av, GEN x) |
gerepilecopy(gpmem_t av, GEN x) |
{ |
{ |
GENbin *p = copy_bin(x); |
GENbin *p = copy_bin(x); |
avma = av; return bin_copy(p); |
avma = av; return bin_copy(p); |
Line 1335 gerepilecopy(long av, GEN x) |
|
Line 1505 gerepilecopy(long av, GEN x) |
|
* objects to contiguous locations and cleans up the stack between |
* objects to contiguous locations and cleans up the stack between |
* av and avma. */ |
* av and avma. */ |
void |
void |
gerepilemany(long av, GEN* gptr[], long n) |
gerepilemany(gpmem_t av, GEN* gptr[], int n) |
{ |
{ |
GENbin **l = (GENbin**)gpmalloc(n*sizeof(GENbin*)); |
GENbin **l = (GENbin**)gpmalloc(n*sizeof(GENbin*)); |
long i; |
int i; |
for (i=0; i<n; i++) l[i] = copy_bin(*(gptr[i])); |
for (i=0; i<n; i++) l[i] = copy_bin(*(gptr[i])); |
avma = av; |
avma = av; |
for (i=0; i<n; i++) *(gptr[i]) = bin_copy(l[i]); |
for (i=0; i<n; i++) *(gptr[i]) = bin_copy(l[i]); |
Line 1346 gerepilemany(long av, GEN* gptr[], long n) |
|
Line 1516 gerepilemany(long av, GEN* gptr[], long n) |
|
} |
} |
|
|
void |
void |
gerepilemanycoeffs(long av, GEN x, long n) |
gerepileall(gpmem_t av, int n, ...) |
{ |
{ |
long i; |
GENbin **l = (GENbin**)gpmalloc(n*sizeof(GENbin*)); |
|
GEN **gptr = (GEN**) gpmalloc(n*sizeof(GEN*)); |
|
int i; |
|
va_list a; va_start(a, n); |
|
|
|
for (i=0; i<n; i++) { gptr[i] = va_arg(a,GEN*); l[i] = copy_bin(*(gptr[i])); } |
|
avma = av; |
|
for (--i; i>=0; i--) *(gptr[i]) = bin_copy(l[i]); |
|
free(l); free(gptr); |
|
} |
|
|
|
void |
|
gerepilemanycoeffs(gpmem_t av, GEN x, int n) |
|
{ |
|
int i; |
for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]); |
for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]); |
avma = av; |
avma = av; |
for (i=0; i<n; i++) x[i] = (long)bin_copy((GENbin*)x[i]); |
for (i=0; i<n; i++) x[i] = (long)bin_copy((GENbin*)x[i]); |
} |
} |
|
|
void |
void |
gerepilemanycoeffs2(long av, GEN x, long n, GEN y, long o) |
gerepilemanycoeffs2(gpmem_t av, GEN x, int n, GEN y, int o) |
{ |
{ |
long i; |
int i; |
for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]); |
for (i=0; i<n; i++) x[i] = (long)copy_bin((GEN)x[i]); |
for (i=0; i<o; i++) y[i] = (long)copy_bin((GEN)y[i]); |
for (i=0; i<o; i++) y[i] = (long)copy_bin((GEN)y[i]); |
avma = av; |
avma = av; |
Line 1368 gerepilemanycoeffs2(long av, GEN x, long n, GEN y, lon |
|
Line 1552 gerepilemanycoeffs2(long av, GEN x, long n, GEN y, lon |
|
/* Takes an array of pointers to GENs, of length n. |
/* Takes an array of pointers to GENs, of length n. |
* Cleans up the stack between av and tetpil, updating those GENs. */ |
* Cleans up the stack between av and tetpil, updating those GENs. */ |
void |
void |
gerepilemanysp(long av, long tetpil, GEN* gptr[], long n) |
gerepilemanysp(gpmem_t av, gpmem_t tetpil, GEN* gptr[], int n) |
{ |
{ |
const long av2 = avma, dec = av-tetpil; |
const gpmem_t av2 = avma; |
long i; |
const size_t dec = av-tetpil; |
|
int i; |
|
|
(void)gerepile(av,tetpil,NULL); |
(void)gerepile(av,tetpil,NULL); |
for (i=0; i<n; i++) |
for (i=0; i<n; i++) |
{ |
{ |
ulong *g1 = (ulong*) gptr[i]; |
gpmem_t *g1 = (gpmem_t*) gptr[i]; |
if (*g1 < (ulong)tetpil) |
if (*g1 < tetpil) |
{ |
{ |
if (*g1 >= (ulong)av2) *g1 += dec; /* Update address if in stack */ |
if (*g1 >= av2) *g1 += dec; /* Update address if in stack */ |
else if (*g1 >=(ulong)av) err(gerper); |
else if (*g1 >= av) err(gerper); |
} |
} |
} |
} |
} |
} |
Line 1388 gerepilemanysp(long av, long tetpil, GEN* gptr[], long |
|
Line 1573 gerepilemanysp(long av, long tetpil, GEN* gptr[], long |
|
/* Takes an array of GENs (cast to longs), of length n. |
/* Takes an array of GENs (cast to longs), of length n. |
* Cleans up the stack between av and tetpil, updating those GENs. */ |
* Cleans up the stack between av and tetpil, updating those GENs. */ |
void |
void |
gerepilemanyvec(long av, long tetpil, long *g, long n) |
gerepilemanyvec(gpmem_t av, gpmem_t tetpil, long *g, int n) |
{ |
{ |
const long av2 = avma, dec = av-tetpil; |
const gpmem_t av2 = avma; |
long i; |
const size_t dec = av-tetpil; |
|
int i; |
|
|
(void)gerepile(av,tetpil,NULL); |
(void)gerepile(av,tetpil,NULL); |
for (i=0; i<n; i++,g++) |
for (i=0; i<n; i++,g++) |
if ((ulong)*g < (ulong)tetpil) |
if ((gpmem_t)*g < tetpil) |
{ |
{ |
if ((ulong)*g >= (ulong)av2) *g += dec;/* Update addresses if in stack */ |
if ((gpmem_t)*g >= av2) *g += dec;/* Update addresses if in stack */ |
else if ((ulong)*g >= (ulong)av) err(gerper); |
else if ((gpmem_t)*g >= av) err(gerper); |
} |
} |
} |
} |
|
|
GEN |
GEN |
gerepileupto(long av, GEN q) |
gerepileupto(gpmem_t av, GEN q) |
{ |
{ |
if (!isonstack(q)) { avma=av; return q; } /* universal object */ |
if (!isonstack(q)) { avma = av; return q; } /* universal object */ |
/* empty garbage */ |
/* empty garbage */ |
if ((ulong)av <= (ulong)q) return q; |
if (av <= (gpmem_t)q) return q; |
/* The garbage is only empty when av==q. It's probably a mistake if |
/* The garbage is only empty when av==q. It's probably a mistake if |
* av < q. But "temporary variables" from sumiter are a problem since |
* av < q. But "temporary variables" from sumiter are a problem since |
* ep->values are returned as-is by identifier() and they can be in the |
* ep->values are returned as-is by identifier() and they can be in the |
Line 1416 gerepileupto(long av, GEN q) |
|
Line 1602 gerepileupto(long av, GEN q) |
|
*/ |
*/ |
|
|
/* Beware: (long)(q+i) --> ((long)q)+i*sizeof(long) */ |
/* Beware: (long)(q+i) --> ((long)q)+i*sizeof(long) */ |
return gerepile(av, (long) (q+lg(q)), q); |
return gerepile(av, (gpmem_t) (q+lg(q)), q); |
} |
} |
|
|
/* internal */ |
/* internal */ |
GEN |
GEN |
gerepileuptoleaf(long av, GEN q) |
gerepileuptoleaf(gpmem_t av, GEN q) |
{ |
{ |
long i; |
long i; |
GEN q0; |
GEN q0; |
|
|
if (!isonstack(q) || av==(long)q) { avma=av; return q; } |
if (!isonstack(q) || av==(gpmem_t)q) { avma = av; return q; } |
i=lg(q); avma = (long)(((GEN)av) - i); |
i=lg(q); avma = (gpmem_t)(((GEN)av) - i); |
q0 = (GEN)avma; while (--i >= 0) q0[i]=q[i]; |
q0 = (GEN)avma; while (--i >= 0) q0[i]=q[i]; |
return q0; |
return q0; |
} |
} |
/* internal */ |
/* internal */ |
GEN |
GEN |
gerepileuptoint(long av, GEN q) |
gerepileuptoint(gpmem_t av, GEN q) |
{ |
{ |
if (!isonstack(q) || av==(long)q) { avma=av; return q; } |
if (!isonstack(q) || (GEN)av==q) { avma = av; return q; } |
avma = (long)icopy_av(q, (GEN)av); |
avma = (gpmem_t)icopy_av(q, (GEN)av); |
return (GEN)avma; |
return (GEN)avma; |
} |
} |
|
|
|
|
ok_gerepileupto(GEN x) { return _ok_gerepileupto(x, x); } |
ok_gerepileupto(GEN x) { return _ok_gerepileupto(x, x); } |
|
|
GEN |
GEN |
gerepile(long av, long tetpil, GEN q) |
gerepile(gpmem_t av, gpmem_t tetpil, GEN q) |
{ |
{ |
long avmb, dec = av - tetpil; |
gpmem_t avmb; |
|
size_t dec = av - tetpil; |
GEN ll,a,b; |
GEN ll,a,b; |
|
|
if (dec==0) return q; |
if (dec==0) return q; |
if (dec<0) err(talker,"lbot>ltop in gerepile"); |
if ((long)dec<0) err(talker,"lbot>ltop in gerepile"); |
|
|
if ((ulong)q>=(ulong)avma && (ulong)q<(ulong)tetpil) |
if ((gpmem_t)q >= avma && (gpmem_t)q < tetpil) |
q = (GEN) (((long)q) + dec); |
q = (GEN) (((gpmem_t)q) + dec); |
|
|
for (ll=(GEN)av, a=(GEN)tetpil; a > (GEN)avma; ) *--ll= *--a; |
for (ll=(GEN)av, a=(GEN)tetpil; a > (GEN)avma; ) *--ll= *--a; |
avmb = (long)ll; |
avmb = (gpmem_t)ll; |
while (ll < (GEN)av) |
while (ll < (GEN)av) |
{ |
{ |
const long tl=typ(ll); |
const long tl=typ(ll); |
Line 1489 gerepile(long av, long tetpil, GEN q) |
|
Line 1676 gerepile(long av, long tetpil, GEN q) |
|
a = ll+lontyp[tl]; |
a = ll+lontyp[tl]; |
if (tl==t_POL) { b=ll+lgef(ll); ll+=lg(ll); } else { ll+=lg(ll); b=ll; } |
if (tl==t_POL) { b=ll+lgef(ll); ll+=lg(ll); } else { ll+=lg(ll); b=ll; } |
for ( ; a<b; a++) |
for ( ; a<b; a++) |
if ((ulong)*a < (ulong)av && (ulong)*a >= (ulong)avma) |
if ((gpmem_t)*a < av && (gpmem_t)*a >= avma) |
{ |
{ |
if ((ulong)*a < (ulong)tetpil) *a += dec; else err(gerper); |
if ((gpmem_t)*a < tetpil) *a += dec; else err(gerper); |
} |
} |
} |
} |
avma = avmb; return q; |
avma = avmb; return q; |
} |
} |
|
|
long |
long |
allocatemoremem(ulong newsize) |
allocatemoremem(size_t newsize) |
{ |
{ |
long sizeold = top - bot, newbot; |
|
|
|
if (!newsize) |
if (!newsize) |
{ |
{ |
newsize = sizeold << 1; |
newsize = (top - bot) << 1; |
err(warner,"doubling stack size; new stack = %ld (%.3f Mbytes)", |
err(warner,"doubling stack size; new stack = %lu (%.3f Mbytes)", |
newsize, newsize/1048576.); |
newsize, newsize/1048576.); |
} |
} |
else if ((long)newsize < 1000L) |
return init_stack(newsize); |
err(talker,"required stack memory too small"); |
|
/* can't do bot = malloc directly, in case we lack memory */ |
|
newsize = fix_size(newsize); |
|
newbot = (long) gpmalloc(newsize); |
|
free((void*)bot); bot = newbot; |
|
memused = avma = top = bot + newsize; |
|
return newsize; |
|
} |
} |
|
|
/* alternate stack management routine */ |
/* alternate stack management routine */ |
Line 1524 switch_stack(stackzone *z, long n) |
|
Line 1702 switch_stack(stackzone *z, long n) |
|
{ |
{ |
if (!z) |
if (!z) |
{ /* create parallel stack */ |
{ /* create parallel stack */ |
long size = n*sizeof(long) + sizeof(stackzone); |
size_t size = n*sizeof(long) + sizeof(stackzone); |
z = (stackzone*) gpmalloc(size); |
z = (stackzone*) gpmalloc(size); |
z->zonetop = ((long)z) + size; |
z->zonetop = ((gpmem_t)z) + size; |
return z; |
return z; |
} |
} |
|
|
Line 1536 switch_stack(stackzone *z, long n) |
|
Line 1714 switch_stack(stackzone *z, long n) |
|
z->top = top; |
z->top = top; |
z->avma = avma; |
z->avma = avma; |
z->memused = memused; |
z->memused = memused; |
bot = (long) (z+1); |
bot = (gpmem_t) (z+1); |
top = z->zonetop; |
top = z->zonetop; |
avma = top; |
avma = top; |
memused = (ulong)-1; |
memused = (size_t)-1; |
} |
} |
else |
else |
{ /* back to normalcy */ |
{ /* back to normalcy */ |
Line 1551 switch_stack(stackzone *z, long n) |
|
Line 1729 switch_stack(stackzone *z, long n) |
|
return NULL; |
return NULL; |
} |
} |
|
|
char* |
|
gpmalloc(size_t bytes) |
|
{ |
|
char *tmp; |
|
|
|
if (bytes) |
|
{ |
|
tmp = (char *) malloc(bytes); |
|
if (!tmp) err(memer); |
|
return tmp; |
|
} |
|
if (DEBUGMEM) err(warner,"mallocing NULL object"); |
|
return NULL; |
|
} |
|
|
|
#if __MWERKS__ |
|
static void * |
|
macrealloc(void *p, size_t newsize, size_t oldsize) |
|
{ |
|
char *q = gpmalloc(newsize), *qq = q, *pp = p; |
|
int l = newsize > oldsize ? oldsize : newsize; |
|
|
|
while (l--) *qq++ = *pp++; |
|
free(p); return q; |
|
} |
|
#endif |
|
|
|
char* |
|
gprealloc(void *pointer, size_t newsize, size_t oldsize) |
|
{ |
|
char *tmp; |
|
|
|
if (!pointer) tmp = (char *) malloc(newsize); |
|
#if __MWERKS__ |
|
else tmp = (char *) macrealloc(pointer,newsize,oldsize); |
|
#else |
|
else tmp = (char *) realloc(pointer,newsize); |
|
#endif |
|
(void)oldsize; |
|
if (!tmp) err(memer); |
|
return tmp; |
|
} |
|
|
|
#ifdef MEMSTEP |
#ifdef MEMSTEP |
void |
void |
checkmemory(GEN z) |
checkmemory(GEN z) |
{ |
{ |
if (DEBUGMEM && memused != (ulong)-1 && |
if (DEBUGMEM && memused != (size_t)-1 && |
((GEN)memused > z + MEMSTEP || z > (GEN)memused + MEMSTEP)) |
((GEN)memused > z + MEMSTEP || z > (GEN)memused + MEMSTEP)) |
{ |
{ |
memused=(ulong)z; |
memused=(size_t)z; |
#if MEMSTEP >= 1048576 |
#if MEMSTEP >= 1048576 |
fprintferr("...%4.0lf Mbytes used\n",(top-memused)/1048576.); |
fprintferr("...%4.0lf Mbytes used\n",(top-memused)/1048576.); |
#else |
#else |
Line 1612 checkmemory(GEN z) |
|
Line 1747 checkmemory(GEN z) |
|
#endif |
#endif |
|
|
void |
void |
init_stack() |
fill_stack(void) |
{ |
{ |
GEN x = ((GEN)bot); |
GEN x = ((GEN)bot); |
while (x < (GEN)avma) *x++ = 0xfefefefe; |
while (x < (GEN)avma) *x++ = 0xfefefefeUL; |
} |
} |
|
|
/*******************************************************************/ |
/*******************************************************************/ |
|
|
/* TIMER */ |
/* TIMER */ |
/* */ |
/* */ |
/*******************************************************************/ |
/*******************************************************************/ |
#define MAX_TIMER 32 |
long |
#define MIN_TIMER 3 |
_get_time(pari_timer *T, long Ticks, long TickPerSecond) |
|
{ |
|
long s = Ticks / TickPerSecond; |
|
long us = (long) (Ticks % TickPerSecond) * (1000000. / TickPerSecond); |
|
long delay = 1000 * (s - T->s) + (us - T->us) / 1000; |
|
T->us = us; |
|
T->s = s; return delay; |
|
} |
|
|
#ifdef WINCE |
#ifdef WINCE |
static long |
long |
timer_proto(int i) |
TIMER(pari_timer *T) |
{ |
{ |
static DWORD oldticks[MAX_TIMER]; |
return _get_time(T, GetTickCount(), 1000); |
DWORD ticks = GetTickCount(); |
} |
DWORD delay = ticks - oldticks[i]; |
|
oldticks[i] = ticks; |
|
return delay; |
|
} |
|
#elif defined(macintosh) |
#elif defined(macintosh) |
# include <Events.h> |
# include <Events.h> |
static long |
long |
timer_proto(int i) |
TIMER(pari_timer *T) |
{ |
{ |
static long oldticks[MAX_TIMER]; |
return _get_time(T, TickCount(), 60); |
long ticks = TickCount(), delay = ticks - oldticks[i]; |
} |
|
|
oldticks[i] = ticks; |
|
return 50 * delay / 3; |
|
} |
|
#elif USE_TIMES |
#elif USE_TIMES |
|
|
# include <sys/times.h> |
# include <sys/times.h> |
# include <sys/time.h> |
# include <sys/time.h> |
# include <time.h> |
# include <time.h> |
static long |
long |
timer_proto(int i) |
TIMER(pari_timer *T) |
{ |
{ |
static clock_t oldticks[MAX_TIMER]; |
struct tms t; times(&t); |
struct tms t; |
return _get_time(T, t.tms_utime, CLK_TCK); |
long delay; |
} |
|
|
times(&t); |
|
delay = (long)((t.tms_utime - oldticks[i]) * (1000. / CLK_TCK)); |
|
oldticks[i] = t.tms_utime; |
|
return delay; |
|
} |
|
#elif USE_GETRUSAGE |
#elif USE_GETRUSAGE |
|
|
# include <sys/time.h> |
# include <sys/time.h> |
# include <sys/resource.h> |
# include <sys/resource.h> |
static long |
long |
timer_proto(int i) |
TIMER(pari_timer *T) |
{ |
{ |
static long oldmusec[MAX_TIMER],oldsec[MAX_TIMER]; |
struct rusage r; |
struct rusage r; |
struct timeval t; |
struct timeval t; |
long delay; |
long delay; |
|
|
|
getrusage(0,&r); t=r.ru_utime; |
getrusage(0,&r); t = r.ru_utime; |
delay = 1000 * (t.tv_sec - oldsec[i]) + (t.tv_usec - oldmusec[i]) / 1000; |
delay = 1000 * (t.tv_sec - T->s) + (t.tv_usec - T->us) / 1000; |
oldmusec[i] = t.tv_usec; oldsec[i] = t.tv_sec; |
T->us = t.tv_usec; |
return delay; |
T->s = t.tv_sec; return delay; |
} |
} |
#elif USE_FTIME |
#elif USE_FTIME |
|
|
# include <sys/timeb.h> |
# include <sys/timeb.h> |
static long |
long |
timer_proto(int i) |
TIMER(pari_timer *T) |
{ |
{ |
static long oldmsec[MAX_TIMER],oldsec[MAX_TIMER]; |
struct timeb t; |
struct timeb t; |
long delay; |
long delay; |
|
|
|
ftime(&t); |
ftime(&t); |
delay = 1000 * (t.time - oldsec[i]) + (t.millitm - oldmsec[i]); |
delay = 1000 * (t.time - T->s) + (t.millitm - T->us / 1000); |
oldmsec[i] = t.millitm; oldsec[i] = t.time; |
T->us = t.millitm * 1000; |
return delay; |
T->s = t.time; return delay; |
} |
} |
#else |
#else |
|
|
# include <time.h> |
# include <time.h> |
# ifndef CLOCKS_PER_SEC |
# ifndef CLOCKS_PER_SEC |
# define CLOCKS_PER_SEC 1000000 /* may be false on YOUR system */ |
# define CLOCKS_PER_SEC 1000000 /* may be false on YOUR system */ |
# endif |
# endif |
static long |
|
timer_proto(int i) |
|
{ |
|
static clock_t oldclocks[MAX_TIMER]; |
|
clock_t t = clock(); |
|
long delay = (long)((t-oldclocks[i]) * 1000. / CLOCKS_PER_SEC); |
|
|
|
oldclocks[i] = t; |
|
return delay; |
|
} |
|
#endif |
|
|
|
#define is_valid_timer(t) ((t) < MAX_TIMER || (t) >= MIN_TIMER) |
|
long |
long |
gptimer() {return timer_proto(0);} |
TIMER(pari_timer *T) |
long |
|
timer(void) {return timer_proto(1);} |
|
long |
|
timer2(void) {return timer_proto(2);} |
|
long |
|
gentimer(long t) |
|
{ |
{ |
if (!is_valid_timer(t)) |
return _get_time(T, clock(), CLOCKS_PER_SEC); |
err(talker,"not an available timer (%ld)",t); |
|
return timer_proto(t); |
|
} |
} |
|
#endif |
|
void |
|
TIMERstart(pari_timer *T) { (void)TIMER(T); } |
|
|
/* internal */ |
|
|
|
long |
long |
get_timer(long t) |
timer(void) { static pari_timer T; return TIMER(&T);} |
{ |
long |
static int used[MAX_TIMER]; |
timer2(void) { static pari_timer T; return TIMER(&T);} |
int i; |
|
if (!t) |
|
{ /* get new timer */ |
|
for (i=MIN_TIMER; i < MAX_TIMER; i++) |
|
if (!used[i]) { used[i] = 1; t = i; break; } |
|
if (!t) { t = 2; err(warner, "no timers left! Using timer2()"); } |
|
timer_proto(t); /* init timer */ |
|
} |
|
else if (t < 0) |
|
{ /* initialize */ |
|
for (i=MIN_TIMER; i < MAX_TIMER; i++) used[i] = 0; |
|
} |
|
else |
|
{ /* delete */ |
|
if (!is_valid_timer(t) || !used[t]) |
|
err(warner, "timer %ld wasn't in use", t); |
|
else |
|
used[t] = 0; |
|
} |
|
return t; |
|
} |
|
|
|
void |
void |
genmsgtimer(long t, char *format, ...) |
msgTIMER(pari_timer *T, char *format, ...) |
{ |
{ |
va_list args; |
va_list args; |
PariOUT *out = pariOut; pariOut = pariErr; |
PariOUT *out = pariOut; pariOut = pariErr; |
|
|
pariputs("Time "); va_start(args, format); |
pariputs("Time "); va_start(args, format); |
vpariputs(format,args); va_end(args); |
vpariputs(format,args); va_end(args); |
pariputsf(": %ld\n", timer_proto(t)); pariflush(); |
pariputsf(": %ld\n", TIMER(T)); pariflush(); |
pariOut = out; |
pariOut = out; |
} |
} |
|
|
Line 1777 msgtimer(char *format, ...) |
|
Line 1862 msgtimer(char *format, ...) |
|
|
|
pariputs("Time "); va_start(args, format); |
pariputs("Time "); va_start(args, format); |
vpariputs(format,args); va_end(args); |
vpariputs(format,args); va_end(args); |
pariputsf(": %ld\n", timer_proto(2)); pariflush(); |
pariputsf(": %ld\n", timer2()); pariflush(); |
pariOut = out; |
pariOut = out; |
} |
} |
|
|
Line 1848 geni(void) { return gi; } |
|
Line 1933 geni(void) { return gi; } |
|
* The unquoted components can be of any pari type (converted according to |
* The unquoted components can be of any pari type (converted according to |
* the current output format) |
* the current output format) |
* s* any number of strings (see s) |
* s* any number of strings (see s) |
* s*p idem, setting prettyp=1 |
* M Mnemonic or a flag (converted to a long); description follows |
* s*t idem, in TeX format. |
* after \n at the end of the argument description |
* D Has a default value. Format is "Dvalue,type," (the ending comma is |
* D Has a default value. Format is "Dvalue,type," (the ending comma is |
* mandatory). Ex: D0,L, (arg is long, 0 by default). |
* mandatory). Ex: D0,L, (arg is long, 0 by default). |
* Special syntax: |
* Special syntax: |
* if type = G, &, I or V: D[G&IV] all send NULL. |
* if type = G, &, I or V: D[G&IV] all send NULL. |
* if type = v: Dn sends -1. |
* if type = n: Dn sends -1. |
* |
* |
* The user-given args are read first, then completed by the defaults |
* The user-given args are read first, then completed by the defaults |
* |
* |
Line 1913 entree functions_basic[]={ |
|
Line 1998 entree functions_basic[]={ |
|
{"bernfrac",11,(void*)bernfrac,3,"L"}, |
{"bernfrac",11,(void*)bernfrac,3,"L"}, |
{"bernreal",99,(void*)bernreal,3,"Lp"}, |
{"bernreal",99,(void*)bernreal,3,"Lp"}, |
{"bernvec",11,(void*)bernvec,3,"L"}, |
{"bernvec",11,(void*)bernvec,3,"L"}, |
|
{"besselh1",29,(void*)hbessel1,3,"GGp"}, |
|
{"besselh2",29,(void*)hbessel2,3,"GGp"}, |
|
{"besseli",29,(void*)ibessel,3,"GGp"}, |
|
{"besselj",29,(void*)jbessel,3,"GGp"}, |
{"besseljh",29,(void*)jbesselh,3,"GGp"}, |
{"besseljh",29,(void*)jbesselh,3,"GGp"}, |
{"besselk",99,(void*)kbessel0,3,"GGD0,L,p"}, |
{"besselk",99,(void*)kbessel0,3,"GGD0,L,p"}, |
|
{"besseln",29,(void*)nbessel,3,"GGp"}, |
{"bestappr",99,(void*)bestappr0,4,"GGDG"}, |
{"bestappr",99,(void*)bestappr0,4,"GGDG"}, |
{"bezout",2,(void*)vecbezout,4,"GG"}, |
{"bezout",2,(void*)vecbezout,4,"GG"}, |
{"bezoutres",2,(void*)vecbezoutres,4,"GG"}, |
{"bezoutres",2,(void*)vecbezoutres,4,"GG"}, |
Line 1925 entree functions_basic[]={ |
|
Line 2015 entree functions_basic[]={ |
|
{"bitneg",99,(void*)gbitneg,2,"GD-1,L,"}, |
{"bitneg",99,(void*)gbitneg,2,"GD-1,L,"}, |
{"bitnegimply",2,(void*)gbitnegimply,2,"GG"}, |
{"bitnegimply",2,(void*)gbitnegimply,2,"GG"}, |
{"bitor",2,(void*)gbitor,2,"GG"}, |
{"bitor",2,(void*)gbitor,2,"GG"}, |
{"bittest",2,(void*)gbittest,2,"GG"}, |
{"bittest",99,(void*)gbittest3,2,"GGD1,L,"}, |
{"bitxor",2,(void*)gbitxor,2,"GG"}, |
{"bitxor",2,(void*)gbitxor,2,"GG"}, |
{"bnfcertify",10,(void*)certifybuchall,6,"lG"}, |
{"bnfcertify",10,(void*)certifybuchall,6,"lG"}, |
{"bnfclassunit",99,(void*)bnfclassunit0,6,"GD0,L,DGp"}, |
{"bnfclassunit",99,(void*)bnfclassunit0,6,"GD0,L,DGp"}, |
Line 1943 entree functions_basic[]={ |
|
Line 2033 entree functions_basic[]={ |
|
{"bnfsignunit",18,(void*)signunits,6,"G"}, |
{"bnfsignunit",18,(void*)signunits,6,"G"}, |
{"bnfsunit",99,(void*)bnfsunit,6,"GGp"}, |
{"bnfsunit",99,(void*)bnfsunit,6,"GGp"}, |
{"bnfunit",18,(void*)buchfu,6,"G"}, |
{"bnfunit",18,(void*)buchfu,6,"G"}, |
{"bnrL1",99,(void*)bnrL1,6,"GGD0,L,p"}, |
{"bnrL1",99,(void*)bnrL1,6,"GDGD0,L,p"}, |
{"bnrclass",99,(void*)bnrclass0,6,"GGD0,L,"}, |
{"bnrclass",99,(void*)bnrclass0,6,"GGD0,L,"}, |
{"bnrclassno",2,(void*)rayclassno,6,"GG"}, |
{"bnrclassno",2,(void*)rayclassno,6,"GG"}, |
{"bnrclassnolist",2,(void*)rayclassnolist,6,"GG"}, |
{"bnrclassnolist",2,(void*)rayclassnolist,6,"GG"}, |
Line 1955 entree functions_basic[]={ |
|
Line 2045 entree functions_basic[]={ |
|
{"bnrisconductor",99,(void*)bnrisconductor,6,"lGDGDG"}, |
{"bnrisconductor",99,(void*)bnrisconductor,6,"lGDGDG"}, |
{"bnrisprincipal",99,(void*)isprincipalrayall,6,"GGD1,L,"}, |
{"bnrisprincipal",99,(void*)isprincipalrayall,6,"GGD1,L,"}, |
{"bnrrootnumber",99,(void*)bnrrootnumber,6,"GGD0,L,p"}, |
{"bnrrootnumber",99,(void*)bnrrootnumber,6,"GGD0,L,p"}, |
{"bnrstark",99,(void*)bnrstark,6,"GGD0,L,p"}, |
{"bnrstark",99,(void*)bnrstark,6,"GDGD0,L,p"}, |
{"break",0,(void*)break0,11,"D1,L,"}, |
{"break",0,(void*)break0,11,"D1,L,"}, |
{"ceil",18,(void*)gceil,2,"G"}, |
{"ceil",18,(void*)gceil,2,"G"}, |
{"centerlift",99,(void*)centerlift0,2,"GDn"}, |
{"centerlift",99,(void*)centerlift0,2,"GDn"}, |
Line 1982 entree functions_basic[]={ |
|
Line 2072 entree functions_basic[]={ |
|
{"dirmul",2,(void*)dirmul,4,"GG"}, |
{"dirmul",2,(void*)dirmul,4,"GG"}, |
{"dirzetak",2,(void*)dirzetak,6,"GG"}, |
{"dirzetak",2,(void*)dirzetak,6,"GG"}, |
{"divisors",18,(void*)divisors,4,"G"}, |
{"divisors",18,(void*)divisors,4,"G"}, |
{"divrem",2,(void*)gdiventres,1,"GG"}, |
{"divrem",2,(void*)divrem,1,"GGDn"}, |
{"eint1",99,(void*)veceint1,3,"GDGp"}, |
{"eint1",99,(void*)veceint1,3,"GDGp"}, |
{"elladd",3,(void*)addell,5,"GGG"}, |
{"elladd",3,(void*)addell,5,"GGG"}, |
{"ellak",2,(void*)akell,5,"GG"}, |
{"ellak",2,(void*)akell,5,"GG"}, |
Line 2001 entree functions_basic[]={ |
|
Line 2091 entree functions_basic[]={ |
|
{"ellj",1,(void*)jell,5,"Gp"}, |
{"ellj",1,(void*)jell,5,"Gp"}, |
{"elllocalred",2,(void*)localreduction,5,"GG"}, |
{"elllocalred",2,(void*)localreduction,5,"GG"}, |
{"elllseries",99,(void*)lseriesell,5,"GGDGp"}, |
{"elllseries",99,(void*)lseriesell,5,"GGDGp"}, |
|
{"ellminimalmodel",99,(void*)ellminimalmodel,5,"GD&"}, |
{"ellorder",2,(void*)orderell,5,"GG"}, |
{"ellorder",2,(void*)orderell,5,"GG"}, |
{"ellordinate",29,(void*)ordell,5,"GGp"}, |
{"ellordinate",29,(void*)ordell,5,"GGp"}, |
{"ellpointtoz",29,(void*)zell,5,"GGp"}, |
{"ellpointtoz",29,(void*)zell,5,"GGp"}, |
Line 2019 entree functions_basic[]={ |
|
Line 2110 entree functions_basic[]={ |
|
{"eval",18,(void*)geval,7,"G"}, |
{"eval",18,(void*)geval,7,"G"}, |
{"exp",1,(void*)gexp,3,"Gp"}, |
{"exp",1,(void*)gexp,3,"Gp"}, |
{"factor",99,(void*)factor0,4,"GD-1,L,"}, |
{"factor",99,(void*)factor0,4,"GD-1,L,"}, |
{"factorback",99,(void*)factorback,4,"GDG"}, |
{"factorback",99,(void*)factorback0,4,"GDGDG"}, |
{"factorcantor",2,(void*)factcantor,4,"GG"}, |
{"factorcantor",2,(void*)factcantor,4,"GG"}, |
{"factorff",3,(void*)factmod9,4,"GGG"}, |
{"factorff",3,(void*)factmod9,4,"GGG"}, |
{"factorial",99,(void*)mpfactr,4,"Lp"}, |
{"factorial",99,(void*)mpfactr,4,"Lp"}, |
Line 2034 entree functions_basic[]={ |
|
Line 2125 entree functions_basic[]={ |
|
{"fordiv",84,(void*)fordiv,11,"vGVI"}, |
{"fordiv",84,(void*)fordiv,11,"vGVI"}, |
{"forprime",83,(void*)forprime,11,"vV=GGI"}, |
{"forprime",83,(void*)forprime,11,"vV=GGI"}, |
{"forstep",86,(void*)forstep,11,"vV=GGGI"}, |
{"forstep",86,(void*)forstep,11,"vV=GGGI"}, |
{"forsubgroup",99,(void*)forsubgroup,11,"vV=GD0,L,I"}, |
{"forsubgroup",99,(void*)forsubgroup,11,"vV=GDGI"}, |
{"forvec",87,(void*)forvec,11,"vV=GID0,L,"}, |
{"forvec",87,(void*)forvec,11,"vV=GID0,L,"}, |
{"frac",18,(void*)gfrac,2,"G"}, |
{"frac",18,(void*)gfrac,2,"G"}, |
{"galoisfixedfield",99,(void*)galoisfixedfield,6,"GGD0,L,Dn"}, |
{"galoisfixedfield",99,(void*)galoisfixedfield,6,"GGD0,L,Dn"}, |
{"galoisinit",99,(void*)galoisinit,6,"GDGD0,L,"}, |
{"galoisinit",99,(void*)galoisinit,6,"GDGD0,L,"}, |
|
{"galoisisabelian",99,(void*)galoisisabelian,6,"GD0,L,"}, |
{"galoispermtopol",2,(void*)galoispermtopol,6,"GG"}, |
{"galoispermtopol",2,(void*)galoispermtopol,6,"GG"}, |
{"galoissubcyclo",99,(void*)galoissubcyclo,6,"LGDGDnD0,L,"}, |
{"galoissubcyclo",99,(void*)galoissubcyclo,6,"GDGD0,L,Dn"}, |
|
{"galoissubfields",99,(void*)galoissubfields,6,"GD0,L,Dn"}, |
|
{"galoissubgroups",18,(void*)galoissubgroups,6,"G"}, |
{"gamma",1,(void*)ggamma,3,"Gp"}, |
{"gamma",1,(void*)ggamma,3,"Gp"}, |
{"gammah",1,(void*)ggamd,3,"Gp"}, |
{"gammah",1,(void*)ggamd,3,"Gp"}, |
{"gcd",99,(void*)gcd0,4,"GDGD0,L,"}, |
{"gcd",99,(void*)gcd0,4,"GDGD0,L,"}, |
Line 2082 entree functions_basic[]={ |
|
Line 2176 entree functions_basic[]={ |
|
{"intnum",99,(void*)intnum0,9,"V=GGED0,L,p"}, |
{"intnum",99,(void*)intnum0,9,"V=GGED0,L,p"}, |
{"isfundamental",18,(void*)gisfundamental,4,"G"}, |
{"isfundamental",18,(void*)gisfundamental,4,"G"}, |
{"isprime",99,(void*)gisprime,4,"GD0,L,"}, |
{"isprime",99,(void*)gisprime,4,"GD0,L,"}, |
{"ispseudoprime",18,(void*)gispsp,4,"G"}, |
{"ispseudoprime",18,(void*)gispseudoprime,4,"GD0,L,"}, |
{"issquare",99,(void*)gcarrecomplet,4,"GD&"}, |
{"issquare",99,(void*)gcarrecomplet,4,"GD&"}, |
{"issquarefree",18,(void*)gissquarefree,4,"G"}, |
{"issquarefree",18,(void*)gissquarefree,4,"G"}, |
{"kronecker",2,(void*)gkronecker,4,"GG"}, |
{"kronecker",2,(void*)gkronecker,4,"GG"}, |
Line 2097 entree functions_basic[]={ |
|
Line 2191 entree functions_basic[]={ |
|
{"listput",25,(void*)listput,8,"GGD0,L,"}, |
{"listput",25,(void*)listput,8,"GGD0,L,"}, |
{"listsort",99,(void*)listsort,8,"GD0,L,"}, |
{"listsort",99,(void*)listsort,8,"GD0,L,"}, |
{"lngamma",1,(void*)glngamma,3,"Gp"}, |
{"lngamma",1,(void*)glngamma,3,"Gp"}, |
{"log",99,(void*)log0,3,"GD0,L,p"}, |
{"log",99,(void*)log0,99,"GD0,M,p\nAGM==1"}, |
{"matadjoint",18,(void*)adj,8,"G"}, |
{"matadjoint",18,(void*)adj,8,"G"}, |
{"matalgtobasis",2,(void*)matalgtobasis,6,"GG"}, |
{"matalgtobasis",2,(void*)matalgtobasis,6,"GG"}, |
{"matbasistoalg",2,(void*)matbasistoalg,6,"GG"}, |
{"matbasistoalg",2,(void*)matbasistoalg,6,"GG"}, |
Line 2150 entree functions_basic[]={ |
|
Line 2244 entree functions_basic[]={ |
|
{"nfeltdivrem",3,(void*)nfdivres,6,"GGG"}, |
{"nfeltdivrem",3,(void*)nfdivres,6,"GGG"}, |
{"nfeltmod",3,(void*)nfmod,6,"GGG"}, |
{"nfeltmod",3,(void*)nfmod,6,"GGG"}, |
{"nfeltmul",3,(void*)element_mul,6,"GGG"}, |
{"nfeltmul",3,(void*)element_mul,6,"GGG"}, |
{"nfeltmulmodpr",4,(void*)element_mulmodpr2,6,"GGGG"}, |
{"nfeltmulmodpr",4,(void*)element_mulmodpr,6,"GGGG"}, |
{"nfeltpow",3,(void*)element_pow,6,"GGG"}, |
{"nfeltpow",3,(void*)element_pow,6,"GGG"}, |
{"nfeltpowmodpr",4,(void*)element_powmodpr,6,"GGGG"}, |
{"nfeltpowmodpr",4,(void*)element_powmodpr,6,"GGGG"}, |
{"nfeltreduce",3,(void*)element_reduce,6,"GGG"}, |
{"nfeltreduce",3,(void*)element_reduce,6,"GGG"}, |
{"nfeltreducemodpr",3,(void*)nfreducemodpr2,6,"GGG"}, |
{"nfeltreducemodpr",3,(void*)nfreducemodpr,6,"GGG"}, |
{"nfeltval",30,(void*)element_val,6,"lGGG"}, |
{"nfeltval",30,(void*)element_val,6,"lGGG"}, |
{"nffactor",99,(void*)nffactor,6,"GG"}, |
{"nffactor",99,(void*)nffactor,6,"GG"}, |
{"nffactormod",99,(void*)nffactormod,6,"GGG"}, |
{"nffactormod",99,(void*)nffactormod,6,"GGG"}, |
Line 2197 entree functions_basic[]={ |
|
Line 2291 entree functions_basic[]={ |
|
{"pollead",99,(void*)pollead,7,"GDn"}, |
{"pollead",99,(void*)pollead,7,"GDn"}, |
{"pollegendre",99,(void*)legendre,7,"LDn"}, |
{"pollegendre",99,(void*)legendre,7,"LDn"}, |
{"polrecip",18,(void*)polrecip,7,"G"}, |
{"polrecip",18,(void*)polrecip,7,"G"}, |
{"polred",99,(void*)polred0,6,"GD0,L,DGp"}, |
{"polred",99,(void*)polred0,6,"GD0,L,DG"}, |
{"polredabs",99,(void*)polredabs0,6,"GD0,L,p"}, |
{"polredabs",99,(void*)polredabs0,6,"GD0,L,"}, |
{"polredord",1,(void*)ordred,6,"Gp"}, |
{"polredord",1,(void*)ordred,6,"G"}, |
{"polresultant",99,(void*)polresultant0,7,"GGDnD0,L,"}, |
{"polresultant",99,(void*)polresultant0,7,"GGDnD0,L,"}, |
{"polroots",99,(void*)roots0,7,"GD0,L,p"}, |
{"polroots",99,(void*)roots0,7,"GD0,L,p"}, |
{"polrootsmod",25,(void*)rootmod0,7,"GGD0,L,"}, |
{"polrootsmod",25,(void*)rootmod0,7,"GGD0,L,"}, |
{"polrootspadic",32,(void*)rootpadic,7,"GGL"}, |
{"polrootspadic",32,(void*)rootpadic,7,"GGL"}, |
{"polsturm",99,(void*)sturmpart,7,"lGDGDG"}, |
{"polsturm",99,(void*)sturmpart,7,"lGDGDG"}, |
{"polsubcyclo",99,(void*)subcyclo,7,"GGDn"}, |
{"polsubcyclo",99,(void*)polsubcyclo,7,"LLDn"}, |
{"polsylvestermatrix",2,(void*)sylvestermatrix,7,"GG"}, |
{"polsylvestermatrix",2,(void*)sylvestermatrix,7,"GG"}, |
{"polsym",21,(void*)polsym,7,"GL"}, |
{"polsym",21,(void*)polsym,7,"GL"}, |
{"poltchebi",99,(void*)tchebi,7,"LDn"}, |
{"poltchebi",99,(void*)tchebi,7,"LDn"}, |
Line 2273 entree functions_basic[]={ |
|
Line 2367 entree functions_basic[]={ |
|
{"rnfidealup",2,(void*)rnfidealup,6,"GG"}, |
{"rnfidealup",2,(void*)rnfidealup,6,"GG"}, |
{"rnfinit",29,(void*)rnfinitalg,6,"GGp"}, |
{"rnfinit",29,(void*)rnfinitalg,6,"GGp"}, |
{"rnfisfree",20,(void*)rnfisfree,6,"lGG"}, |
{"rnfisfree",20,(void*)rnfisfree,6,"lGG"}, |
{"rnfisnorm",99,(void*)rnfisnorm,6,"GGGD1,L,p"}, |
{"rnfisnorm",99,(void*)rnfisnorm,6,"GGD0,L,"}, |
{"rnfkummer",99,(void*)rnfkummer,6,"GGD0,L,p"}, |
{"rnfisnorminit",99,(void*)rnfisnorminit,6,"GGD2,L,"}, |
|
{"rnfkummer",99,(void*)rnfkummer,6,"GDGD0,L,p"}, |
{"rnflllgram",99,(void*)rnflllgram,6,"GGGp"}, |
{"rnflllgram",99,(void*)rnflllgram,6,"GGGp"}, |
{"rnfnormgroup",2,(void*)rnfnormgroup,6,"GG"}, |
{"rnfnormgroup",2,(void*)rnfnormgroup,6,"GG"}, |
{"rnfpolred",29,(void*)rnfpolred,6,"GGp"}, |
{"rnfpolred",29,(void*)rnfpolred,6,"GGp"}, |
{"rnfpolredabs",99,(void*)rnfpolredabs,6,"GGD0,L,p"}, |
{"rnfpolredabs",99,(void*)rnfpolredabs,6,"GGD0,L,"}, |
{"rnfpseudobasis",2,(void*)rnfpseudobasis,6,"GG"}, |
{"rnfpseudobasis",2,(void*)rnfpseudobasis,6,"GG"}, |
{"rnfsteinitz",2,(void*)rnfsteinitz,6,"GG"}, |
{"rnfsteinitz",2,(void*)rnfsteinitz,6,"GG"}, |
{"round",99,(void*)round0,2,"GD&"}, |
{"round",99,(void*)round0,2,"GD&"}, |
Line 2291 entree functions_basic[]={ |
|
Line 2386 entree functions_basic[]={ |
|
{"setrand",99,(void*)setrand,11,"lL"}, |
{"setrand",99,(void*)setrand,11,"lL"}, |
{"setsearch",99,(void*)setsearch,8,"lGGD0,L,"}, |
{"setsearch",99,(void*)setsearch,8,"lGGD0,L,"}, |
{"setunion",2,(void*)setunion,8,"GG"}, |
{"setunion",2,(void*)setunion,8,"GG"}, |
{"shift",99,(void*)gshift,1,"GL"}, |
{"shift",99,(void*)gshift3,1,"GLD0,L,"}, |
{"shiftmul",99,(void*)gmul2n,1,"GL"}, |
{"shiftmul",99,(void*)gmul2n,1,"GL"}, |
{"sigma",99,(void*)gsumdivk,4,"GD1,L,"}, |
{"sigma",99,(void*)gsumdivk,4,"GD1,L,"}, |
{"sign",10,(void*)gsigne,1,"lG"}, |
{"sign",10,(void*)gsigne,1,"lG"}, |
Line 2305 entree functions_basic[]={ |
|
Line 2400 entree functions_basic[]={ |
|
{"sqrt",1,(void*)gsqrt,3,"Gp"}, |
{"sqrt",1,(void*)gsqrt,3,"Gp"}, |
{"sqrtint",18,(void*)racine,4,"G"}, |
{"sqrtint",18,(void*)racine,4,"G"}, |
{"sqrtn",99,(void*)gsqrtn,3,"GGD&p"}, |
{"sqrtn",99,(void*)gsqrtn,3,"GGD&p"}, |
{"subgrouplist",99,(void*)subgrouplist0,6,"GD0,L,D0,L,p"}, |
{"subgrouplist",99,(void*)subgrouplist0,6,"GDGD0,L,p"}, |
{"subst",99,(void*)gsubst0,7,"GGG"}, |
{"subst",99,(void*)gsubst0,7,"GGG"}, |
{"sum",48,(void*)somme,9,"V=GGEDG"}, |
{"sum",48,(void*)somme,9,"V=GGEDG"}, |
{"sumalt",99,(void*)sumalt0,9,"V=GED0,L,p"}, |
{"sumalt",99,(void*)sumalt0,9,"V=GED0,L,p"}, |
Line 2330 entree functions_basic[]={ |
|
Line 2425 entree functions_basic[]={ |
|
{"vecmin",18,(void*)vecmin,1,"G"}, |
{"vecmin",18,(void*)vecmin,1,"G"}, |
{"vecsort",99,(void*)vecsort0,8,"GDGD0,L,"}, |
{"vecsort",99,(void*)vecsort0,8,"GDGD0,L,"}, |
{"vector",28,(void*)vecteur,8,"GDVDI"}, |
{"vector",28,(void*)vecteur,8,"GDVDI"}, |
|
{"vectorsmall",28,(void*)vecteursmall,8,"GDVDI"}, |
{"vectorv",28,(void*)vvecteur,8,"GDVDI"}, |
{"vectorv",28,(void*)vvecteur,8,"GDVDI"}, |
{"weber",99,(void*)weber0,3,"GD0,L,p"}, |
{"weber",99,(void*)weber0,3,"GD0,L,p"}, |
{"while",81,NULL,11,NULL}, |
{"while",81,NULL,11,NULL}, |