Annotation of OpenXM_contrib2/asir2000/parse/parse.h, Revision 1.44
1.3 noro 1: /*
2: * Copyright (c) 1994-2000 FUJITSU LABORATORIES LIMITED
3: * All rights reserved.
4: *
5: * FUJITSU LABORATORIES LIMITED ("FLL") hereby grants you a limited,
6: * non-exclusive and royalty-free license to use, copy, modify and
7: * redistribute, solely for non-commercial and non-profit purposes, the
8: * computer program, "Risa/Asir" ("SOFTWARE"), subject to the terms and
9: * conditions of this Agreement. For the avoidance of doubt, you acquire
10: * only a limited right to use the SOFTWARE hereunder, and FLL or any
11: * third party developer retains all rights, including but not limited to
12: * copyrights, in and to the SOFTWARE.
13: *
14: * (1) FLL does not grant you a license in any way for commercial
15: * purposes. You may use the SOFTWARE only for non-commercial and
16: * non-profit purposes only, such as academic, research and internal
17: * business use.
18: * (2) The SOFTWARE is protected by the Copyright Law of Japan and
19: * international copyright treaties. If you make copies of the SOFTWARE,
20: * with or without modification, as permitted hereunder, you shall affix
21: * to all such copies of the SOFTWARE the above copyright notice.
22: * (3) An explicit reference to this SOFTWARE and its copyright owner
23: * shall be made on your publication or presentation in any form of the
24: * results obtained by use of the SOFTWARE.
25: * (4) In the event that you modify the SOFTWARE, you shall notify FLL by
1.4 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.3 noro 27: * for such modification or the source code of the modified part of the
28: * SOFTWARE.
29: *
30: * THE SOFTWARE IS PROVIDED AS IS WITHOUT ANY WARRANTY OF ANY KIND. FLL
31: * MAKES ABSOLUTELY NO WARRANTIES, EXPRESSED, IMPLIED OR STATUTORY, AND
32: * EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS
33: * FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT OF THIRD PARTIES'
34: * RIGHTS. NO FLL DEALER, AGENT, EMPLOYEES IS AUTHORIZED TO MAKE ANY
35: * MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS WARRANTY.
36: * UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, TORT, CONTRACT,
37: * OR OTHERWISE, SHALL FLL BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY
38: * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL
39: * DAMAGES OF ANY CHARACTER, INCLUDING, WITHOUT LIMITATION, DAMAGES
40: * ARISING OUT OF OR RELATING TO THE SOFTWARE OR THIS AGREEMENT, DAMAGES
41: * FOR LOSS OF GOODWILL, WORK STOPPAGE, OR LOSS OF DATA, OR FOR ANY
42: * DAMAGES, EVEN IF FLL SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF
43: * SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. EVEN IF A PART
44: * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
45: * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
46: * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
47: *
1.44 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/parse/parse.h,v 1.43 2005/11/06 01:27:28 noro Exp $
1.3 noro 49: */
1.6 noro 50: # if defined(VISUAL)
1.1 noro 51: #include <time.h>
52: #else
53: #include <sys/time.h>
54: #include <sys/resource.h>
55: #endif
56: #include <setjmp.h>
57: #ifdef ABS
58: #undef ABS
59: #define ABS(a) ((a)>0?(a):-(a))
60: #endif
61:
62: /* identifiers for expressions */
63:
64: typedef enum {
65: I_BOP, I_COP, I_AND, I_OR, I_NOT, I_CE,
66: I_PRESELF, I_POSTSELF,
1.10 noro 67: I_FUNC, I_FUNC_OPT, I_IFUNC, I_MAP, I_RECMAP, I_PFDERIV,
1.1 noro 68: I_ANS, I_PVAR, I_ASSPVAR,
69: I_FORMULA, I_LIST, I_STR, I_NEWCOMP, I_CAR, I_CDR, I_CAST,
1.31 noro 70: I_INDEX, I_EV, I_TIMER, I_GF2NGEN, I_GFPNGEN, I_GFSNGEN,
71: I_LOP, I_OPT, I_GETOPT, I_POINT, I_PAREN, I_MINUS,
1.44 ! noro 72: I_NARYOP, I_CONS, I_FUNC_QARG, I_FUNC_HEAD,
1.1 noro 73: } fid;
74:
75: /* identifiers for statements */
76:
77: typedef enum {
78: S_BP, S_PFDEF,
79: S_SINGLE, S_CPLX,
80: S_IFELSE, S_FOR, S_DO,
1.35 noro 81: S_BREAK, S_RETURN, S_CONTINUE,
82: S_MODULE
1.1 noro 83: } sid;
84:
85: /* identifiers for comparison operators */
86:
87: typedef enum { C_LT, C_GT, C_LE, C_GE, C_EQ, C_NE } cid;
88:
89: /* identifiers for logical operators */
90:
91: typedef enum { L_LT, L_GT, L_LE, L_GE, L_EQ, L_NE, L_AND, L_OR, L_NOT, L_IMPL, L_REPL, L_EQUIV } lid;
92:
93: /* identifiers for functions */
94:
95: typedef enum { A_UNDEF, A_BIN, A_USR, A_PURE, A_PARI } aid;
96:
97: /* identifiers for indeterminates */
98:
99: typedef enum { V_IND, V_UC, V_PF, V_SR } vid;
100:
1.18 noro 101: typedef struct oVS {
1.1 noro 102: unsigned int n;
103: unsigned int asize;
104: unsigned int at;
105: unsigned int level;
106: struct oFUNC *usrf;
107: struct oPV *va;
108: NODE opt;
1.18 noro 109: } *VS;
1.1 noro 110:
1.18 noro 111: typedef struct oMODULE {
112: char *name;
113: VS pvs;
1.20 noro 114: NODE usrf_list;
1.18 noro 115: } *MODULE;
1.1 noro 116:
1.18 noro 117: typedef struct oPV {
1.1 noro 118: char *name;
119: short attr,type;
120: pointer priv;
1.18 noro 121: } *PV;
1.1 noro 122:
1.18 noro 123: typedef struct oINFILE {
1.1 noro 124: char *name;
125: FILE *fp;
126: int ln;
1.15 noro 127: struct oINFILE *next;
1.1 noro 128: char *tname;
129: int encoded;
130: short vol;
1.18 noro 131: } *INFILE;
1.1 noro 132:
133: struct oTKWD {
134: char *name;
135: int token;
136: };
1.32 noro 137:
138: typedef struct fid_spec {
1.41 noro 139: fid id;
1.32 noro 140: farg_type type[10];
141: } *fid_spec_p;
1.1 noro 142:
1.18 noro 143: typedef struct oARF {
1.1 noro 144: char *name;
145: void (*fp)();
1.18 noro 146: } *ARF;
1.1 noro 147:
1.18 noro 148: typedef struct oFUNC {
1.20 noro 149: char *name,*fullname;
1.1 noro 150: int argc;
151: int type;
1.33 noro 152: int secure;
1.1 noro 153: aid id;
1.38 noro 154: unsigned int quote;
1.1 noro 155: union {
156: void (*binf)();
157: struct oUSRF *usrf;
158: struct oPF *puref;
159: } f;
1.18 noro 160: } *FUNC;
1.1 noro 161:
1.18 noro 162: typedef struct oUSRF {
1.1 noro 163: char *fname;
1.18 noro 164: MODULE module;
1.1 noro 165: int startl,endl;
166: NODE args;
167: VS pvs;
168: char *desc;
169: struct oSNODE *body;
1.18 noro 170: } *USRF;
1.1 noro 171:
1.18 noro 172: typedef struct oPF {
1.1 noro 173: char *name;
174: int argc;
175: Obj body;
176: V *args;
177: Obj *deriv;
178: NODE ins;
179: int (*pari)();
180: double (*libm)();
181: int (*simplify)();
1.18 noro 182: } *PF;
1.1 noro 183:
1.18 noro 184: typedef struct oPFAD {
1.1 noro 185: Obj arg;
186: int d;
1.18 noro 187: } *PFAD;
1.1 noro 188:
1.18 noro 189: typedef struct oPFINS {
1.1 noro 190: struct oPF *pf;
191: struct oPFAD ad[1];
1.18 noro 192: } *PFINS;
1.1 noro 193:
194: #define NEWPF(p) ((p)=(PF)MALLOC(sizeof(struct oPF)))
195:
1.18 noro 196: typedef struct oFNODE {
1.41 noro 197: short id;
1.43 noro 198: unsigned normalized:1;
199: unsigned expanded:1;
200: unsigned coef:1;
1.1 noro 201: pointer arg[1];
1.18 noro 202: } *FNODE;
1.1 noro 203:
204: #define NEWFNODE(a,b) \
205: ((a)=(FNODE)MALLOC(sizeof(struct oFNODE)+sizeof(pointer)*(b-1)))
206:
1.18 noro 207: typedef struct oSNODE {
1.1 noro 208: sid id;
209: int ln;
210: pointer arg[1];
1.18 noro 211: } *SNODE;
1.1 noro 212:
213: #define NEWSNODE(a,b) \
214: ((a)=(SNODE)MALLOC(sizeof(struct oSNODE)+sizeof(pointer)*(b-1)),(a)->ln=asir_infile->ln)
215:
1.18 noro 216: typedef struct oPVI {
1.1 noro 217: int pv;
218: NODE index;
1.18 noro 219: } *PVI;
1.1 noro 220:
1.18 noro 221: typedef struct oNODE2 {
1.1 noro 222: pointer body1,body2;
223: struct oNODE2 *next;
1.18 noro 224: } *NODE2;
1.1 noro 225:
226: struct ftab {
227: char *name;
228: void (*f)();
229: int argc;
1.38 noro 230: unsigned int quote;
1.1 noro 231: };
232:
233: #define MKPVI(a,b,c)\
234: ((a)=(pointer)MALLOC(sizeof(struct oPVI)),((PVI)(a))->pv=(b),((PVI)(a))->index=(c))
235:
236: #define FA0(f) ((f)->arg[0])
237: #define FA1(f) ((f)->arg[1])
238: #define FA2(f) ((f)->arg[2])
239: #define FA3(f) ((f)->arg[3])
240: #define FA4(f) ((f)->arg[4])
241: #define FA5(f) ((f)->arg[5])
242: #define FA6(f) ((f)->arg[6])
243:
244: #define ARG0(a) ((a)->body)
245: #define ARG1(a) (NEXT(a)->body)
246: #define ARG2(a) (NEXT(NEXT(a))->body)
247: #define ARG3(a) (NEXT(NEXT(NEXT(a)))->body)
248: #define ARG4(a) (NEXT(NEXT(NEXT(NEXT((a)))))->body)
249: #define ARG5(a) (NEXT(NEXT(NEXT(NEXT(NEXT((a))))))->body)
250: #define ARG6(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))->body)
251: #define ARG7(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a))))))))->body)
252: #define ARG8(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))))->body)
253: #define ARG9(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a))))))))))->body)
254: #define ARG10(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))))))->body)
255:
256: #define asir_assert(ptr,id,message)\
257: switch ( id ) {\
258: case O_N: case O_P: case O_R:\
259: if( (ptr) && (OID(ptr) > (id)) ) {\
260: fprintf(stderr,message);\
261: error(" : invalid argument");\
262: }\
263: break;\
264: case O_DP:\
265: if( (ptr) && (OID(ptr) != (id)) ) {\
266: fprintf(stderr,message);\
267: error(" : invalid argument");\
268: }\
269: break;\
270: default:\
271: if( !(ptr) || (OID(ptr) != (id)) ) {\
272: fprintf(stderr,message);\
273: error(" : invalid argument");\
274: }\
275: break;\
276: }
277:
278: #define DEFSIZE 32
1.18 noro 279: #define PVGLOBAL(i) (((unsigned int)(i))|(1<<30))
1.40 noro 280: #define PVMGLOBAL(i) (((unsigned int)(i))|(2<<30))
281: #define PVPATTERN(i) (((unsigned int)(i))|(3<<30))
1.18 noro 282: #define PVATTR(i) (((unsigned int)(i))>>30)
283: #define PVIND(i) (((unsigned int)(i))&0x3fffffff)
1.1 noro 284: #define GETPV(i,p) \
1.18 noro 285: (PVATTR(i)==0?(int)((p)=CPVS->va[(unsigned int)(i)].priv)\
1.40 noro 286: :PVATTR(i)==1?(int)((p)=GPVS->va[PVIND(i)].priv)\
287: :PVATTR(i)==2?(int)((p)=MPVS->va[PVIND(i)].priv)\
288: :(int)((p)=PPVS->va[PVIND(i)].priv))
289:
1.18 noro 290: #define GETPVREF(i,p) \
291: (PVATTR(i)==0?(int)((p)=&(CPVS->va[(unsigned int)(i)].priv))\
1.40 noro 292: :PVATTR(i)==1?(int)((p)=&(GPVS->va[PVIND(i)].priv))\
293: :PVATTR(i)==2?(int)((p)=&(MPVS->va[PVIND(i)].priv))\
294: :(int)((p)=&(PPVS->va[PVIND(i)].priv)))
295:
1.13 noro 296: #define GETPVNAME(i,p) \
1.18 noro 297: (PVATTR(i)==0?(int)((p)=CPVS->va[(unsigned int)(i)].name)\
1.40 noro 298: :PVATTR(i)==1?(int)((p)=GPVS->va[PVIND(i)].name)\
299: :PVATTR(i)==2?(int)((p)=MPVS->va[PVIND(i)].name)\
300: :(int)((p)=PPVS->va[PVIND(i)].name))
301:
1.1 noro 302: #define ASSPV(i,p) \
1.18 noro 303: (PVATTR(i)==0?(int)(CPVS->va[(unsigned int)(i)].priv=(pointer)(p))\
1.40 noro 304: :PVATTR(i)==1?(int)(GPVS->va[PVIND(i)].priv=(pointer)(p))\
305: :PVATTR(i)==2?(int)(MPVS->va[PVIND(i)].priv=(pointer)(p))\
306: :(int)(PPVS->va[PVIND(i)].priv=(pointer)(p)))
1.1 noro 307:
308: #define NEWNODE2(a) ((a)=(NODE2)MALLOC(sizeof(struct oNODE2)))
309: #define MKNODE2(a,b,c,d) \
310: (NEWNODE2(a),(a)->body1=(pointer)b,(a)->body2=(pointer)c,NEXT(a)=(NODE2)(d))
311: #define BDY1(a) ((a)->body1)
312: #define BDY2(a) ((a)->body2)
313:
1.40 noro 314: extern VS GPVS,CPVS,EPVS,APVS,MPVS,PPVS;
1.18 noro 315: extern MODULE CUR_MODULE;
316: extern NODE MODULE_LIST;
1.19 noro 317: extern char *CUR_FUNC;
1.1 noro 318: extern ARF addfs, subfs, mulfs, divfs, remfs, pwrfs;
1.15 noro 319: extern INFILE asir_infile;
1.1 noro 320: extern NODE usrf,sysf,noargsysf,ubinf,parif,ONENODE;
321: extern int nextbp,nextbplevel;
322: extern int Verbose;
1.23 ohara 323: extern int do_quiet;
1.27 noro 324: extern SYMBOL Symbol_grlex, Symbol_glex, Symbol_lex;
1.30 noro 325: extern NODE current_option;
1.1 noro 326:
327: #if defined(VISUAL_LIB)
328: #include <w_stdio.h>
329: #undef getc
330: #define getc w_fgetc
331: #undef putc
332: #define putc w_fputc
333: #define fputc w_fputc
334: #define ungetc w_ungetc
335: #define fgets w_fgets
336: #define fputs w_fputs
337: #define printf w_printf
338: #define fprintf w_fprintf
339: #define fflush w_fflush
340: #endif
341:
1.22 noro 342: #if defined(__GNUC__) || defined(VISUAL) || (defined(__MACH__) && defined(__ppc__)) || defined(__FreeBSD__)
1.1 noro 343: NODE mknode(int,...);
344: FNODE mkfnode(int,fid,...);
345: SNODE mksnode(int,sid,...);
346: void call_usrf(FUNC f,...);
347: #else
348: NODE mknode();
349: FNODE mkfnode();
350: SNODE mksnode();
351: void call_usrf();
352: #endif
353:
354: /* prototypes */
355:
1.7 noro 356: void dp_ptozp2_d(DP,DP,DP *,DP *);
357: void dp_ptozp_d(DP,DP *);
1.1 noro 358: void dp_vtod(Q *,DP,DP *);
359: void dp_idivv_hist(Q,DP *);
360: void dp_igcdv_hist(DP,Q *);
1.36 ohara 361: void dp_ptozp3(DP,Q *,DP *);
1.1 noro 362: void dp_ptozp2(DP,DP,DP *,DP *);
363: void dp_ptozp(DP,DP *);
364: void dp_nf_tab_mod(DP,LIST *,int,DP *);
365: void dp_lnf_mod(DP,DP,NODE,int,DP *,DP *);
366: void insert_to_node(DL,NODE *,int);
367: int _dl_redble(DL,DL,int);
368: void dp_mbase(NODE,NODE *);
369: void dp_dtov(DP,VECT *);
370: void dp_cont(DP,Q *);
371: void dp_idiv(DP,Q,DP *);
372:
373: int dp_nt(DP);
374: void dp_dehomo(DP,DP *);
375: void dp_homo(DP,DP *);
376: DL lcm_of_DL(int,DL,DL,DL);
377: void dp_rest(DP,DP *);
378: void dp_hm(DP,DP *);
379: void dp_sp_mod(DP,DP,int,DP *);
380: void dp_sp(DP,DP,DP *);
1.2 noro 381: void dp_red(DP,DP,DP,DP *,DP *,P *,DP *);
1.1 noro 382: void dp_subd(DP,DP,DP *);
383: void dp_red_mod(DP,DP,DP,int,DP *,DP *,P *);
384: int dp_redble(DP,DP);
385: int comp_nm(Q *,Q *);
386: void dp_true_nf_mod(NODE,DP,DP *,int,int,DP *,P *);
387: void dp_nf_mod(NODE,DP,DP *,int,int,DP *);
388: void dp_nf_mod_qindex(NODE,DP,DP *,int,int,DP *);
389: void dp_nf_ptozp(NODE,DP,DP *,int,int,DP *);
390: void dp_true_nf(NODE,DP,DP *,int,DP *,P *);
391: void dp_nf(NODE,DP,DP *,int,DP *);
392: void dp_rat(DP,DP *);
393: void dp_mod(DP,int,NODE,DP *);
394: void dp_prim_mod(DP,int,DP *);
395: void dp_prim(DP,DP *);
396: void heu_nezgcdnpz(VL,P *,int,P *);
1.24 noro 397: void homogenize_order(struct order_spec *,int,struct order_spec **);
398: int create_order_spec(VL,Obj,struct order_spec **);
1.1 noro 399:
400: int dl_equal(int,DL,DL);
401: void qltozl(Q *,int,Q *);
402: int cmpdl_matrix(int,DL,DL);
403: int cmpdl_order_pair(int,DL,DL);
404: int cmpdl_elim(int,DL,DL);
405: int cmpdl_blexrev(int,DL,DL);
406: int cmpdl_bgradrev(int,DL,DL);
407: int cmpdl_brevrev(int,DL,DL);
408: int cmpdl_brevgradlex(int,DL,DL);
409: int cmpdl_bgradlex(int,DL,DL);
410: int cmpdl_blex(int,DL,DL);
411: int cmpdl_revgradlex(int,DL,DL);
412: int cmpdl_gradlex(int,DL,DL);
413: int cmpdl_revlex(int,DL,DL);
414: int cmpdl_lex(int,DL,DL);
415: int compd(VL,DP,DP);
416: void adddl(int,DL,DL,DL *);
417: void divsdc(VL,DP,P,DP *);
418: void muldc(VL,DP,P,DP *);
419: void muldm(VL,DP,MP,DP *);
420: void muld(VL,DP,DP,DP *);
421: void chsgnd(DP,DP *);
422: void subd(VL,DP,DP,DP *);
423: void addd(VL,DP,DP,DP *);
424: int sugard(MP);
425: void nodetod(NODE,DP *);
426: void dtop(VL,VL,DP,P *);
427: void ptod(VL,VL,P,DP *);
428: void initd(struct order_spec *);
429:
430: int mainparse(SNODE *);
431: int exprparse(FUNC,char *,FNODE *);
432: void output_init(void);
433: void GC_init(void);
434: void env_init(void);
435: void soutput_init(char *);
436: void appendparif(NODE *,char *,int (*)(),int);
437: int mmono(P);
438: void mkpow(VL,Obj,Obj,Obj *);
439: void _printdp(DP);
440: int mt_save(char *);
441: int mt_load(char *);
442: void sortbynm(Q *,int);
443: void iqrv(VECT,Q,LIST *);
444: void igcdv(VECT,Q *);
445: void igcdv_estimate(VECT,Q *);
446: void cpp_main(int,char **);
447: int afternl(void);
448: void glob_init();
449: void input_init(FILE *,char *);
450: void asir_terminate(int);
451: void param_init(void);
452: void sprompt(char *);
1.17 ohara 453: void cppname_init();
1.1 noro 454: void process_args(int,char **);
455: void sig_init(void);
456: void asir_save_handler(void);
457: void asir_set_handler(void);
458: void asir_reset_handler(void);
459: void resetenv(char *);
460: void fatal(int);
461: void restore_handler(void);
462: void resize_buffer(void);
463: void tty_init(void);
464: void tty_reset(void);
465: void set_timer(int);
466: void reset_timer(void);
467: void int_handler(int);
468: void int_handler(int);
469: void segv_handler(int);
470: void bus_handler(int);
471: void fpe_handler(int);
472: void ill_handler(int);
473: void winch_handler(int);
474: void pipe_handler(int);
475: void usr1_handler(int);
476: void alrm_handler(int);
477: void copyright(void);
478: void kan_init(void);
479: void pushpvs(FUNC);
480: void read_eval_loop(void);
481: void prompt(void);
482: void storeans(pointer);
483: int yyparse(void);
484: void nodetod(NODE,DP *);
485: void poppvs(void);
486: int length(NODE);
487: int get_heapsize(void);
488: int searchpvar(char *);
489: void mkparif(char *,FUNC *);
490: void makevar(char *,P *);
1.19 noro 491: void mkpvs(char *);
492: MODULE mkmodule(char *);
1.1 noro 493: void stoarg(char *,int *,char **);
494: void yyerror(char *);
495: void closecurrentinput(void);
496: void asir_terminate(int);
497: void searchasirpath(char *,char **);
498: void get_vars(Obj,VL *);
1.38 noro 499: void appendbinf(NODE *,char *,void(*)(),int,unsigned int);
500: void appendubinf(char *,void(*)(),int,unsigned int);
1.1 noro 501: void parif_init(void);
502: void sysf_init(void);
503: void makesrvar(FUNC, P *);
504: void sprintexpr(VL,Obj);
505: void printexpr(VL,Obj);
506: void appendvar(VL,V);
507: void change_mvar(VL,P,V,P *);
508: void restore_mvar(VL,P,V,P *);
509: int argc(NODE);
510: void printn(N);
511: void sprintn(N);
512: void printv(VL,V);
513: void sprintv(VL,V);
514: int arf_comp(VL, Obj, Obj);
515: int complist(VL, LIST, LIST);
516: int complist(VL, LIST, LIST);
517: int getcompsize(int);
518: int getpvar(VS,char *,int);
519: int getpvar(VS,char *,int);
520: int gettype(unsigned int);
521: int indextotype(int,int);
522: int loadfile(char *);
523: int loadfiles(NODE);
1.18 noro 524: unsigned int makepvar(char *);
1.1 noro 525: int membertoindex(int,char *);
526: int qcoefp(Obj);
527: int qcoefr(Obj);
528: int rangecheck(Obj,int);
529: int structtoindex(char *);
530: void _mkpfins(PF ,Obj *,V *);
531: void appendpfins(V ,V *);
532: void appenduf(char *,FUNC *);
533: void arf_add(VL, Obj, Obj, Obj *);
534: void arf_chsgn(Obj, Obj *);
535: void arf_div(VL, Obj, Obj, Obj *);
536: void arf_init(void);
537: void arf_mul(VL, Obj, Obj, Obj *);
538: void arf_pwr(VL, Obj, Obj, Obj *);
539: void arf_remain(VL, Obj, Obj, Obj *);
540: void arf_sub(VL, Obj, Obj, Obj *);
541: void bp(SNODE);
542: void clearbp(FUNC);
543: void debug(SNODE);
544: void debug_init(void);
545: void delbp(int, char **);
546: void derivr(VL ,Obj ,V ,Obj *);
547: void derivvar(VL ,V ,V ,Obj *);
548: void duppfins(V ,V *);
549: void error(char *);
550: void evalins(PFINS ,int ,Obj *);
551: void evalnodebody(NODE,NODE *);
552: void evalp(VL ,P ,int ,P *);
553: void evalr(VL ,Obj ,int ,Obj *);
554: void evalv(VL ,V ,int ,Obj *);
555: void getarrayp(Obj,NODE,Obj **);
556: void getmember(FNODE,Obj *);
557: void getmemberp(FNODE,Obj **);
558: void help(char *);
559: void instov(PFINS ,V *);
1.5 noro 560: Obj memberofstruct(COMP,char *);
1.1 noro 561: void mkpf(char *,Obj ,int ,V *,int (*)(),double (*)(),int (*)(),PF *);
562: void mkpfins(PF ,V *,V *);
1.18 noro 563: void mkuf(char *,char *,NODE,SNODE,int,int,char *,MODULE);
1.1 noro 564: void newstruct(int,struct oCOMP **);
565: void optobj(Obj *);
566: void println(int, char **, int);
567: void printvars(char *,VS);
568: void resetpvs(void);
569: void searchc(char *,FUNC *);
570: void searchf(NODE,char *,FUNC *);
571: void searchpf(char *,FUNC *);
572: void searchsn(SNODE *, int, SNODE **);
573: void setbp(char *);
574: void setf(int, char **);
575: void setstruct(char *,NODE);
576: void showbp(int);
577: void showbps(void);
578: void showpos(void);
579: void simplify_ins(PFINS ,Obj *);
580: void sprintvars(char *,VS);
1.5 noro 581: int structdef(char *,NODE);
1.1 noro 582: void substfp(VL ,Obj ,PF ,PF ,Obj *);
583: void substfr(VL ,Obj ,PF ,PF ,Obj *);
584: void substfv(VL ,V ,PF ,PF ,Obj *);
585: void substpr(VL ,int ,Obj ,V ,Obj ,Obj *);
586: void substr(VL ,int ,Obj ,V ,Obj ,Obj *);
587: void appendtonode(NODE,pointer, NODE *);
588: void getarray(pointer,NODE,pointer *);
589: void putarray(pointer,NODE,pointer);
590:
591: void addcomp(VL,COMP,COMP,COMP *);
592: void subcomp(VL,COMP,COMP,COMP *);
593: void mulcomp(VL,COMP,COMP,COMP *);
594: void divcomp(VL,COMP,COMP,COMP *);
595: void chsgncomp(COMP,COMP *);
596: void pwrcomp(VL,COMP,Obj,COMP *);
597: int compcomp(VL,COMP,COMP);
1.15 noro 598:
599: void mergedeglist(NODE d0,NODE d1,NODE *dr);
600: void getdeglist(P p,V v,NODE *d);
601: void restore_mvar(VL vl,P p,V v,P *r);
602: void change_mvar(VL vl,P p,V v,P *r);
603: void getcoef(VL vl,P p,V v,Q d,P *r);
604: void ranp(int n,UP *nr);
605:
606: void _print_mp(int nv,MP m);
607: int dp_homogeneous(DP p);
608: int dp_nt(DP p);
609: int dl_equal(int nv,DL dl1,DL dl2);
610: DL lcm_of_DL(int nv,DL dl1,DL dl2,DL dl);
611: void dp_rest(DP p,DP *rp);
612: void dp_hm(DP p,DP *rp);
613: void dltod(DL d,int n,DP *rp);
614: void dp_subd(DP p1,DP p2,DP *rp);
615: int dp_redble(DP p1,DP p2);
616: void sortbynm(Q *w,int n);
617: int comp_nm(Q *a,Q *b);
618: void qltozl(Q *w,int n,Q *dvr);
619: void dp_rat(DP p,DP *rp);
620: void dp_mod(DP p,int mod,NODE subst,DP *rp);
621: void dp_dehomo(DP p,DP *rp);
622: void dp_homo(DP p,DP *rp);
623: void dp_nf_tab_mod(DP p,LIST *tab,int mod,DP *rp);
624: void dp_lnf_mod(DP p1,DP p2,NODE g,int mod,DP *r1p,DP *r2p);
625: void dp_lnf_f(DP p1,DP p2,NODE g,DP *r1p,DP *r2p);
626: void _dp_nf_mod_destructive(NODE b,DP g,DP *ps,int mod,int full,DP *rp);
627: void dp_true_nf_mod(NODE b,DP g,DP *ps,int mod,int full,DP *rp,P *dnp);
628: void dp_nf_mod(NODE b,DP g,DP *ps,int mod,int full,DP *rp);
629: void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp);
630: void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *rp);
631: void dp_true_nf(NODE b,DP g,DP *ps,int full,DP *rp,P *dnp);
632: void _dp_red_mod_destructive(DP p1,DP p2,int mod,DP *rp);
633: void dp_red_mod(DP p0,DP p1,DP p2,int mod,DP *head,DP *rest,P *dnp);
634: void dp_red_f(DP p1,DP p2,DP *rest);
635: void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp,DP *multp);
636: void _dp_sp_mod(DP p1,DP p2,int mod,DP *rp);
637: void _dp_sp_mod_dup(DP p1,DP p2,int mod,DP *rp);
638: void dp_sp_mod(DP p1,DP p2,int mod,DP *rp);
639: void _dp_sp_dup(DP p1,DP p2,DP *rp);
640: void dp_sp(DP p1,DP p2,DP *rp);
641: void dp_dtov(DP dp,VECT *rp);
642: void dp_cont(DP p,Q *rp);
643: void dp_prim_mod(DP p,int mod,DP *rp);
644: void heu_nezgcdnpz(VL vl,P *pl,int m,P *pr);
645: void dp_prim(DP p,DP *rp);
646: void dp_ptozp2_d(DP p0,DP p1,DP *hp,DP *rp);
647: void dp_ptozp_d(DP p,DP *rp);
648: void dp_vtod(Q *c,DP p,DP *rp);
649: void insert_to_node(DL d,NODE *n,int nvar);
650: int _dl_redble(DL d1,DL d2,int nvar);
651: void dp_mbase(NODE hlist,NODE *mbase);
652: void dp_idiv(DP p,Q c,DP *rp);
653: void dp_ptozp2(DP p0,DP p1,DP *hp,DP *rp);
654: void dp_ptozp(DP p,DP *rp);
655: int eqdl(int nv,DL dl1,DL dl2);
656: void _dpmod_to_vect(DP f,DL *at,int *b);
657: void _tf_to_vect_compress(NODE tf,DL *at,CDP *b);
658: void dp_to_vect(DP f,DL *at,Q *b);
659: NODE dp_dllist(DP f);
660: NODE mul_dllist(DL d,DP f);
661: void pdl(NODE f);
662: void dp_gr_main(LIST f,LIST v,Num homo,int modular,int field,struct order_spec *ord,LIST *rp);
663: void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp);
664: void dp_f4_main(LIST f,LIST v,struct order_spec *ord,LIST *rp);
665: void dp_f4_mod_main(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp);
666: NODE gb_f4(NODE f);
667: NODE gb_f4_mod(NODE f,int m);
668: NODE gb_f4_mod_old(NODE f,int m);
669: int DPPlength(DP_pairs n);
670: void printdl(DL dl);
671: void pltovl(LIST l,VL *vl);
672: void makesubst(VL v,NODE *s);
673: void printsubst(NODE s);
674: void vlminus(VL v,VL w,VL *d);
675: int validhc(P a,int m,NODE s);
676: void setup_arrays(NODE f,int m,NODE *r);
677: void prim_part(DP f,int m,DP *r);
678: NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* of DP */ nd, int dec );
679: NODE NODE_sortb( NODE node, int dec );
680: NODE /* of index */ NODE_sortbi_insert( int newdpi, NODE /* of index */ nd, int dec );
681: NODE NODE_sortbi( NODE node, int dec );
682: void reduceall(NODE in,NODE *h);
683: void reduceall_mod(NODE in,int m,NODE *h);
684: int newps(DP a,int m,NODE subst);
685: int newps_nosave(DP a,int m,NODE subst);
686: int newps_mod(DP a,int m);
687: void reducebase_dehomo(NODE f,NODE *g);
688: NODE append_one(NODE f,int n);
689: DP_pairs minp( DP_pairs d, DP_pairs *prest );
690: void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr);
691: NODE gb(NODE f,int m,NODE subst);
692: NODE gb_mod(NODE f,int m);
693: DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, int t);
694: DP_pairs newpairs( NODE /* of index */ g, int t );
695: DP_pairs criterion_B( DP_pairs d, int s );
696: DP_pairs criterion_M( DP_pairs d1 );
697: int criterion_2( int dp1, int dp2 );
698: DP_pairs criterion_F( DP_pairs d1 );
699: NODE updbase(NODE g,int t);
700: NODE /* of index */ remove_reducibles(NODE /* of index */ nd, int newdp );
701: int dl_redble(DL dl1,DL dl2);
1.16 noro 702: int dl_weyl_weight(DL dl);
1.15 noro 703: int gbcheck(NODE f);
704: int membercheck(NODE f,NODE x);
705: void dp_set_flag(Obj name,Obj value);
706: void dp_make_flaglist(LIST *list);
707: void dp_save(int index,Obj p,char *prefix);
708: void dp_load(int index,DP *p);
709: int dp_load_t(int index,DP *p);
710: void init_stat();
711: void print_stat();
712: void dp_mulc_d(DP p,P c,DP *r);
713: void _dp_nf(NODE b,DP g,DP *ps,int full,DP *rp);
714: void _dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *r);
715: void dp_imul_d(DP p,Q q,DP *rp);
716: void imulv(VECT w,Q c,VECT *rp);
717: void dptoca(DP p,unsigned int **rp);
718: int yylex();
719: void purge_stdin();
720: int afternl();
721: int aftercomment();
722: int myatoi(char *s);
723: void yyerror(char *s);
724: int Egetc(FILE *fp);
725: void Eungetc(int c,FILE *fp);
726: int readline_getc();
727: void readline_ungetc();
728: char *readline_console(char *prompt);
729: void ox_usr1_handler(int sig);
730: void env_init();
731: void loadasirfile(char *name0);
732: void execasirfile(char *name);
733: void load_and_execfile(char *name);
734: int loadfile(char *s);
735: int loadfiles(NODE node);
736: unsigned char encrypt_char(unsigned char c);
737: unsigned char decrypt_char(unsigned char c);
738: void encrypt_file(char *in,char *out);
739: void decrypt_file(char *in,char *out);
740: void get_vars(Obj t,VL *vlp);
741: void get_vars_recursive(Obj obj,VL *vlp);
742: int comp_obj(Obj *a,Obj *b);
743: int generic_comp_obj(Obj *a,Obj *b);
744: void sepvect(VECT v,int d,VECT *rp);
745: int gauss_elim_mod(int **mat,int row,int col,int md);
746: int generic_gauss_elim(MAT mat,MAT *nm,Q *dn,int **rindp,int **cindp);
747: int generic_gauss_elim_hensel(MAT mat,MAT *nmmat,Q *dn,int **rindp,int **cindp);
748: int gensolve_check(MAT mat,MAT nm,Q dn,int *rind,int *cind);
749: int inttorat(N c,N m,N b,int *sgnp,N *nmp,N *dnp);
750: int intmtoratm(MAT mat,N md,MAT nm,Q *dn);
751: int intmtoratm_q(MAT mat,N md,MAT nm,Q *dn);
752: void reduce_reducers_mod(int **mat,int row,int col,int md);
753: void pre_reduce_mod(int **mat,int row,int col,int nred,int md);
754: void reduce_sp_by_red_mod(int *sp,int **redmat,int *ind,int nred,int col,int md);
755: void red_by_compress(int m,unsigned int *p,unsigned int *r,
756: unsigned int *ri,unsigned int hc,int len);
757: void red_by_vect(int m,unsigned int *p,unsigned int *r,unsigned int hc,int len);
758: void reduce_sp_by_red_mod_compress (int *sp,CDP *redmat,int *ind,
759: int nred,int col,int md);
760: int generic_gauss_elim_mod(int **mat0,int row,int col,int md,int *colstat);
761: int lu_gfmmat(GFMMAT mat,unsigned int md,int *perm);
762: int find_lhs_and_lu_mod(unsigned int **a,int row,int col,
763: unsigned int md,int **rinfo,int **cinfo);
1.34 noro 764: void solve_by_lu_mod(int **a,int n,int md,int **b,int l,int normalize);
1.15 noro 765: int gauss_elim_mod1(int **mat,int row,int col,int md);
766: int gauss_elim_geninv_mod(unsigned int **mat,int row,int col,int md);
767: void solve_by_lu_gfmmat(GFMMAT lu,unsigned int md,unsigned int *b,unsigned int *x);
768: void mat_to_gfmmat(MAT m,unsigned int md,GFMMAT *rp);
769: int gauss_elim_geninv_mod_swap(unsigned int **mat,int row,int col,
770: unsigned int md,unsigned int ***invmatp,int **indexp);
771: void inner_product_int(Q *a,Q *b,int n,Q *r);
772: void inner_product_mat_int_mod(Q **a,int **b,int n,int k,int l,Q *r);
773: int generate_ONB_polynomial(UP2 *rp,int m,int type);
774: int _generate_irreducible_polynomial(UP2 f,int d);
775: int _generate_good_irreducible_polynomial(UP2 f,int d);
776: void printqmat(Q **mat,int row,int col);
777: void printimat(int **mat,int row,int col);
778: void ixor(N n1,N n2,N *r);
779: void ior(N n1,N n2,N *r);
780: void iand(N n1,N n2,N *r);
781: void isqrt(N a,N *r);
782: void igcd_cofactor(Q a,Q b,Q *gcd,Q *ca,Q *cb);
783: int comp_n(N *a,N *b);
784: int TypeT_NB_check(unsigned int m, unsigned int t);
785: int small_jacobi(int a,int m);
786: void pushpvs(FUNC f);
787: void poppvs();
1.18 noro 788: unsigned int makepvar(char *str);
1.15 noro 789: int searchpvar(char *str);
790: int getpvar(VS pvs,char *str,int searchonly);
791: void closecurrentinput();
792: void resetpvs();
793: void savepvs();
794: void restorepvs();
795: void storeans(pointer p);
796: void get_rootdir(char *name,int len);
797: void set_rootdir(char *name);
798: int process_id();
799: void call_exe(char *name,char **av);
800: void addquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
801: void subquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
802: void mulquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
803: void divquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
804: void pwrquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
805: void chsgnquote(QUOTE a,QUOTE *c);
806: void objtoquote(Obj a,QUOTE *c);
807: void polytoquote(P a,QUOTE *c);
808: void dptoquote(DP a,QUOTE *c);
1.28 noro 809: void dctoquote(DCP dc,QUOTE v,QUOTE *c,int *sgn);
1.29 noro 810: void mptoquote(MP m,int n,QUOTE *c,int *sgn);
1.15 noro 811: void vartoquote(V v,QUOTE *c);
812: void fnodetotree(FNODE f,LIST *rp);
813: FNODE eval_pvar_in_fnode(FNODE f);
814: FNODE subst_in_fnode(FNODE f,V v,FNODE g);
815: char *get_attribute(char *key,LIST attr);
816: void treetofnode(Obj obj,FNODE *f);
817: void glob_init() ;
818: void input_init(FILE *fp,char *name);
819: void notdef(VL vl,Obj a,Obj b,Obj *c);
820: void ExitAsir() ;
821: void asir_terminate(int status);
822: void param_init() ;
823: void prompt() ;
824: void sprompt(char *ptr);
825: void process_args(int ac,char **av);
826: void sig_init() ;
827: static void (*old_int)(int);;
828: void asir_save_handler() ;
829: void asir_set_handler() ;
830: void asir_reset_handler() ;
831: void resetenv(char *s);
832: void fatal(int n);
833: void int_handler(int sig);
834: void restore_handler() ;
835: void segv_handler(int sig);
836: void ill_handler(int sig);
837: void alrm_handler(int sig);
838: void bus_handler(int sig);
839: void fpe_handler(int sig);
840: void pipe_handler(int sig);
841: void resize_buffer();
842: void tty_init() ;
843: void tty_reset() ;
844: void set_lasterror(char *s);
845: void error(char *s);
846: void set_timer(int interval);
847: void reset_timer();
848: void copyright() ;
849: void show_debug_window(int on);
850: void init_cmdwin();
851: void searchpf(char *name,FUNC *fp);
852: void searchc(char *name,FUNC *fp);
853: void mkpf(char *name,Obj body,int argc,V *args,
854: int (*parif)(),double (*libmf)(), int (*simp)(),PF *pfp);
855: void mkpfins(PF pf,V *args,V *vp);
856: void _mkpfins(PF pf,Obj *args,V *vp);
857: void _mkpfins_with_darray(PF pf,Obj *args,int *darray,V *vp);
858: void appendpfins(V v,V *vp);
859: void duppfins(V v,V *vp);
860: void derivvar(VL vl,V pf,V v,Obj *a);
861: void derivr(VL vl,Obj a,V v,Obj *b);
862: void substr(VL vl,int partial,Obj a,V v,Obj b,Obj *c);
863: void substpr(VL vl,int partial,Obj p,V v0,Obj p0,Obj *pr);
864: void evalr(VL vl,Obj a,int prec,Obj *c);
865: void evalp(VL vl,P p,int prec,P *pr);
866: void evalv(VL vl,V v,int prec,Obj *rp);
867: void evalins(PFINS ins,int prec,Obj *rp);
868: void devalr(VL vl,Obj a,Obj *c);
869: void devalp(VL vl,P p,P *pr);
870: void devalv(VL vl,V v,Obj *rp);
871: void devalins(PFINS ins,Obj *rp);
872: void simplify_ins(PFINS ins,Obj *rp);
873: void instov(PFINS ins,V *vp);
874: void substfr(VL vl,Obj a,PF u,PF f,Obj *c);
875: void substfp(VL vl,Obj p,PF u,PF f,Obj *pr);
876: void substfv(VL vl,V v,PF u,PF f,Obj *c);
877: int structdef(char *name,NODE member);
878: void newstruct(int type,COMP *rp);
879: int structtoindex(char *name);
880: int membertoindex(int type,char *name);
881: int getcompsize(int type);
882: Obj memberofstruct(COMP a,char *name);
883: void assign_to_member(COMP a,char *name,Obj obj);
884: void node_concat_dup(NODE n1,NODE n2,NODE *nr);
885: pointer evall(lid id,Obj a1,Obj a2);
886: pointer eval(FNODE f);
887: pointer evalstat(SNODE f);
888: pointer evalnode(NODE node);
889: pointer evalf(FUNC f,FNODE a,FNODE opt);
1.38 noro 890: pointer evalparif(FUNC f,NODE a);
891: pointer evalf_deriv(FUNC f,FNODE a,FNODE deriv);
1.15 noro 892: pointer evalmapf(FUNC f,FNODE a);
893: pointer eval_rec_mapf(FUNC f,FNODE a);
894: pointer beval_rec_mapf(FUNC f,NODE node);
895: pointer bevalf(FUNC f,NODE a);
896: pointer evalif(FNODE f,FNODE a);
1.38 noro 897: pointer evalpf(PF pf,NODE args,NODE deriv);
1.15 noro 898: void evalnodebody(NODE sn,NODE *dnp);
899: void gen_searchf(char *name,FUNC *r);
900: void searchf(NODE fn,char *name,FUNC *r);
901: void appenduf(char *name,FUNC *r);
902: void mkparif(char *name,FUNC *r);
1.18 noro 903: void mkuf(char *name,char *fname,NODE args,SNODE body,int startl,int endl,char *desc,MODULE module);
1.15 noro 904: Obj getopt_from_cpvs(char *key);
905: void des_enc(unsigned long *, unsigned char *, unsigned long *);
906: unsigned long round_func(unsigned long , unsigned char *);
907: unsigned long s_box_func(unsigned char *);
908: void des_dec(unsigned long *, unsigned char *, unsigned long *);
909: void key_schedule(unsigned char *,unsigned char *);
910: void debug_init();
911: void add_alias(char *com,char *alias);
912: void show_alias(char *alias);
913: void debug(SNODE f);
914: void setf(int ac,char **av);
915: void setbp(char *p);
916: void settp(char *p);
917: void clearbp(FUNC f);
918: int searchbp();
919: void delbp(int ac,char **av);
920: void showbps();
921: void showbp(int n);
922: void searchsn(SNODE *fp,int n,SNODE **fpp);
923: void bp(SNODE f);
924: void println(int ac,char **av,int l);
925: void printvars(char *s,VS vs);
926: void showpos();
927: void showpos_to_string(char *buf);
928: void change_stack(int level,NODE *pvss);
929: void show_stack(VS vs);
930: int estimate_length(VL vl,pointer p);
931: void send_progress(short per,char *msg);
932: void set_error(int code,char *reason,char *action);
933: double get_current_time();
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>