Annotation of OpenXM_contrib2/asir2018/parse/parse.h, Revision 1.7
1.1 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
26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
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.7 ! kondoh 48: * $OpenXM: OpenXM_contrib2/asir2018/parse/parse.h,v 1.6 2019/11/12 07:47:45 noro Exp $
1.1 noro 49: */
50: # if defined(VISUAL) || defined(__MINGW32__)
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: #include <math.h>
63: #include <ctype.h>
64:
65: /* identifiers for expressions */
66:
67: typedef enum {
68: I_BOP, I_COP, I_AND, I_OR, I_NOT, I_CE,
69: I_PRESELF, I_POSTSELF,
70: I_FUNC, I_FUNC_OPT, I_IFUNC, I_MAP, I_RECMAP, I_PFDERIV,
71: I_ANS, I_PVAR, I_ASSPVAR,
72: I_FORMULA, I_LIST, I_STR, I_NEWCOMP, I_CAR, I_CDR, I_CAST,
73: I_INDEX, I_EV, I_TIMER, I_GF2NGEN, I_GFPNGEN, I_GFSNGEN,
74: I_LOP, I_OPT, I_GETOPT, I_POINT, I_PAREN, I_MINUS,
75: I_NARYOP, I_CONS, I_FUNC_QARG, I_FUNC_HEAD, I_EVM
76: } fid;
77:
78: /* identifiers for statements */
79:
80: typedef enum {
81: S_BP, S_PFDEF,
82: S_SINGLE, S_CPLX,
83: S_IFELSE, S_FOR, S_DO,
84: S_BREAK, S_RETURN, S_CONTINUE,
85: S_MODULE
86: } sid;
87:
88: /* identifiers for comparison operators */
89:
90: typedef enum { C_LT, C_GT, C_LE, C_GE, C_EQ, C_NE } cid;
91:
92: /* identifiers for logical operators */
93:
94: 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;
95:
96: /* identifiers for functions */
97:
98: typedef enum { A_UNDEF, A_BIN, A_USR, A_PURE, A_PARI } aid;
99:
100: /* identifiers for indeterminates */
101:
102: typedef enum { V_IND, V_UC, V_PF, V_SR } vid;
103:
104: typedef struct oVS {
105: unsigned int n;
106: unsigned int asize;
107: unsigned int at;
108: unsigned int level;
109: struct oFUNC *usrf;
110: struct oPV *va;
111: NODE opt;
112: } *VS;
113:
114: typedef struct oMODULE {
115: char *name;
116: VS pvs;
117: NODE usrf_list;
118: } *MODULE;
119:
120: typedef struct oPV {
121: char *name;
122: short attr,type;
123: pointer priv;
124: } *PV;
125:
126: typedef struct oINFILE {
127: char *name;
128: FILE *fp;
129: JMP_BUF jmpbuf;
130: int ready_for_longjmp;
131: int ln;
132: struct oINFILE *next;
133: char *tname;
134: int encoded;
135: short vol;
136: } *INFILE;
137:
138: struct oTKWD {
139: char *name;
140: int token;
141: };
142:
143: typedef struct fid_spec {
144: fid id;
145: farg_type type[10];
146: } *fid_spec_p;
147:
148: typedef struct oARF {
149: char *name;
150: void (*fp)();
151: } *ARF;
152:
153: typedef struct oFUNC {
154: char *name,*fullname;
155: int argc;
156: int type;
157: int secure;
158: aid id;
159: unsigned int quote;
160: union {
161: void (*binf)();
162: struct oUSRF *usrf;
163: struct oPF *puref;
164: } f;
165: } *FUNC;
166:
167: typedef struct oUSRF {
168: char *fname;
169: MODULE module;
170: int startl,endl;
171: NODE args;
172: VS pvs;
173: char *desc;
174: struct oSNODE *body;
175: } *USRF;
176:
177: typedef struct oPF {
178: char *name;
179: int argc;
180: Obj body;
181: V *args;
182: Obj *deriv;
183: NODE ins;
184: int (*pari)();
185: double (*libm)();
186: int (*simplify)();
1.7 ! kondoh 187: #if defined(INTERVAL)
! 188: void (**intervalfunc)();
! 189: #endif
1.1 noro 190: } *PF;
191:
192: typedef struct oPFAD {
193: Obj arg;
194: int d;
195: } *PFAD;
196:
197: typedef struct oPFINS {
198: struct oPF *pf;
199: struct oPFAD ad[1];
200: } *PFINS;
201:
202: #define NEWPF(p) ((p)=(PF)MALLOC(sizeof(struct oPF)))
203:
204: typedef struct oFNODE {
205: short id;
206: unsigned normalized:1;
207: unsigned expanded:2;
208: unsigned coef:1;
209: pointer arg[1];
210: } *FNODE;
211:
212: #define NEWFNODE(a,b) \
213: ((a)=(FNODE)MALLOC(sizeof(struct oFNODE)+sizeof(pointer)*(b-1)))
214:
215: typedef struct oSNODE {
216: sid id;
217: int ln;
218: pointer arg[1];
219: } *SNODE;
220:
221: #define NEWSNODE(a,b) \
222: ((a)=(SNODE)MALLOC(sizeof(struct oSNODE)+sizeof(pointer)*(b-1)),(a)->ln=asir_infile->ln)
223:
224: typedef struct oPVI {
225: int pv;
226: NODE index;
227: } *PVI;
228:
229: struct ftab {
230: char *name;
231: void (*f)();
232: int argc;
233: unsigned int quote;
234: };
235:
236: struct wtab {
237: V v;
238: int w;
239: };
240:
241:
242: #define MKPVI(a,b,c)\
243: ((a)=(pointer)MALLOC(sizeof(struct oPVI)),((PVI)(a))->pv=(b),((PVI)(a))->index=(c))
244:
245: #define FA0(f) ((f)->arg[0])
246: #define FA1(f) ((f)->arg[1])
247: #define FA2(f) ((f)->arg[2])
248: #define FA3(f) ((f)->arg[3])
249: #define FA4(f) ((f)->arg[4])
250: #define FA5(f) ((f)->arg[5])
251: #define FA6(f) ((f)->arg[6])
252:
253: #define ARG0(a) ((a)->body)
254: #define ARG1(a) (NEXT(a)->body)
255: #define ARG2(a) (NEXT(NEXT(a))->body)
256: #define ARG3(a) (NEXT(NEXT(NEXT(a)))->body)
257: #define ARG4(a) (NEXT(NEXT(NEXT(NEXT((a)))))->body)
258: #define ARG5(a) (NEXT(NEXT(NEXT(NEXT(NEXT((a))))))->body)
259: #define ARG6(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))->body)
260: #define ARG7(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a))))))))->body)
261: #define ARG8(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))))->body)
262: #define ARG9(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a))))))))))->body)
263: #define ARG10(a) (NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT(NEXT((a)))))))))))->body)
264:
265: #define asir_assert(ptr,id,message)\
266: switch ( id ) {\
267: case O_N: case O_P: case O_R:\
268: if( (ptr) && (OID(ptr) > (id)) ) {\
269: fprintf(stderr,message);\
270: error(" : invalid argument");\
271: }\
272: break;\
273: case O_DP:\
274: if( (ptr) && (OID(ptr) != (id)) ) {\
275: fprintf(stderr,message);\
276: error(" : invalid argument");\
277: }\
278: break;\
279: default:\
280: if( !(ptr) || (OID(ptr) != (id)) ) {\
281: fprintf(stderr,message);\
282: error(" : invalid argument");\
283: }\
284: break;\
285: }
286:
287: #define DEFSIZE 32
288: #define PVGLOBAL(i) (((unsigned long)(i))|(1<<30))
289: #define PVMGLOBAL(i) (((unsigned long)(i))|(2<<30))
290: #define PVPATTERN(i) (((unsigned long)(i))|(3<<30))
291: #define PVATTR(i) (((unsigned long)(i))>>30)
292: #define PVIND(i) (((unsigned long)(i))&0x3fffffff)
293: #define GETPV(i,p) \
294: (PVATTR(i)==0?(long)((p)=CPVS->va[(unsigned int)(i)].priv)\
295: :PVATTR(i)==1?(long)((p)=GPVS->va[PVIND(i)].priv)\
296: :PVATTR(i)==2?(long)((p)=MPVS->va[PVIND(i)].priv)\
297: :(long)((p)=PPVS->va[PVIND(i)].priv))
298:
299: #define GETPVREF(i,p) \
300: (PVATTR(i)==0?(long)((p)=&(CPVS->va[(unsigned long)(i)].priv))\
301: :PVATTR(i)==1?(long)((p)=&(GPVS->va[PVIND(i)].priv))\
302: :PVATTR(i)==2?(long)((p)=&(MPVS->va[PVIND(i)].priv))\
303: :(long)((p)=&(PPVS->va[PVIND(i)].priv)))
304:
305: #define GETPVNAME(i,p) \
306: (PVATTR(i)==0?(long)((p)=CPVS->va[(unsigned long)(i)].name)\
307: :PVATTR(i)==1?(long)((p)=GPVS->va[PVIND(i)].name)\
308: :PVATTR(i)==2?(long)((p)=MPVS->va[PVIND(i)].name)\
309: :(long)((p)=PPVS->va[PVIND(i)].name))
310:
311: #define ASSPV(i,p) \
312: (PVATTR(i)==0?(long)(CPVS->va[(unsigned long)(i)].priv=(pointer)(p))\
313: :PVATTR(i)==1?(long)(GPVS->va[PVIND(i)].priv=(pointer)(p))\
314: :PVATTR(i)==2?(long)(MPVS->va[PVIND(i)].priv=(pointer)(p))\
315: :(long)(PPVS->va[PVIND(i)].priv=(pointer)(p)))
316:
317:
318: extern VS GPVS,CPVS,EPVS,APVS,MPVS,PPVS;
319: extern MODULE CUR_MODULE;
320: extern NODE MODULE_LIST;
321: extern char *CUR_FUNC;
322: extern ARF addfs, subfs, mulfs, divfs, remfs, pwrfs;
323: extern INFILE asir_infile;
324: extern NODE usrf,sysf,noargsysf,ubinf,parif,ONENODE;
325: extern int nextbp,nextbplevel;
326: extern int Verbose;
327: extern int do_quiet;
328: extern SYMBOL Symbol_grlex, Symbol_glex, Symbol_lex;
329: extern NODE current_option;
330:
331: #if defined(VISUAL_LIB)
332: #include <w_stdio.h>
333: #undef getc
334: #define getc w_fgetc
335: #undef putc
336: #define putc w_fputc
337: #define fputc w_fputc
338: #define ungetc w_ungetc
339: #define fgets w_fgets
340: #define fputs w_fputs
341: #define printf w_printf
342: #define fprintf w_fprintf
343: #define fflush w_fflush
344: #endif
345:
346: #if defined(__GNUC__) || defined(VISUAL) || defined(__MINGW32__) || (defined(__MACH__) && defined(__ppc__)) || defined(__FreeBSD__)
347: NODE mknode(int,...);
348: FNODE mkfnode(int,fid,...);
349: SNODE mksnode(int,sid,...);
350: void call_usrf(FUNC f,...);
351: #else
352: NODE mknode();
353: FNODE mkfnode();
354: SNODE mksnode();
355: void call_usrf();
356: #endif
357:
358: /* prototypes */
359:
360: void dp_vtod(Q *,DP,DP *);
361: void dp_idivv_hist(Q,DP *);
362: void dp_igcdv_hist(DP,Q *);
363: void dp_ptozp3(DP,Z *,DP *);
364: void dp_ptozp2(DP,DP,DP *,DP *);
365: void dp_ptozp(DP,DP *);
366: void dp_nf_tab_mod(DP,LIST *,int,DP *);
367: void dp_lnf_mod(DP,DP,NODE,int,DP *,DP *);
368: void insert_to_node(DL,NODE *,int);
369: int _dl_redble(DL,DL,int);
370: void dp_mbase(NODE,NODE *);
371: void dp_dtov(DP,VECT *);
372: void dp_cont(DP,Z *);
373: void dp_idiv(DP,Z,DP *);
374: void dtodpm(DP d,int pos,DPM *dp);
1.5 noro 375: void dpm_nf_z(NODE b,DPM g,VECT ps,int full,int multiple,DPM *rp);
376: void dpm_nf_f(NODE b,DPM g,VECT ps,int full,DPM *rp);
1.1 noro 377: void weyl_actd(VL vl,DP p1,DP p2,DP *pr);
1.4 noro 378: void dpm_sp(DPM p1,DPM p2,DPM *rp,DP *mul1,DP *mul2);
1.1 noro 379: void initdpm(struct order_spec *spec,int type);
380: void dpm_ht(DPM p,DPM *rp);
381: void dpm_hm(DPM p,DPM *rp);
382:
383: int dp_nt(DP);
384: void dp_dehomo(DP,DP *);
385: void dp_homo(DP,DP *);
386: DL lcm_of_DL(int,DL,DL,DL);
387: void dp_rest(DP,DP *);
388: void dp_hm(DP,DP *);
389: void dp_sp_mod(DP,DP,int,DP *);
390: void dp_sp(DP,DP,DP *);
391: void dp_red(DP,DP,DP,DP *,DP *,P *,DP *);
392: void dp_subd(DP,DP,DP *);
393: void dp_red_mod(DP,DP,DP,int,DP *,DP *,P *);
394: int dp_redble(DP,DP);
395: int comp_nm(Q *,Q *);
396: void dp_true_nf_mod(NODE,DP,DP *,int,int,DP *,P *);
397: void dp_nf_mod(NODE,DP,DP *,int,int,DP *);
398: void dp_nf_mod_qindex(NODE,DP,DP *,int,int,DP *);
399: void dp_nf_ptozp(NODE,DP,DP *,int,int,DP *);
400: void dp_nf(NODE,DP,DP *,int,DP *);
401: void dp_rat(DP,DP *);
402: void dp_mod(DP,int,NODE,DP *);
403: void dp_prim_mod(DP,int,DP *);
404: void dp_prim(DP,DP *);
405: void heu_nezgcdnpz(VL,P *,int,P *);
406: void homogenize_order(struct order_spec *,int,struct order_spec **);
407: int create_order_spec(VL,Obj,struct order_spec **);
408:
409: int dl_equal(int,DL,DL);
410: void qltozl(Q *,int,Z *);
411:
412: int mainparse(SNODE *);
413: int exprparse(FUNC,char *,FNODE *);
414: void output_init(void);
415: void GC_init(void);
416: void env_init(void);
417: void soutput_init(char *);
418: void appendparif(NODE *,char *,int (*)(),int);
419: int mmono(P);
420: void mkpow(VL,Obj,Obj,Obj *);
421: void _printdp(DP);
422: int mt_save(char *);
423: int mt_load(char *);
424: void sortbynm(Q *,int);
425: void iqrv(VECT,Z,LIST *);
426: void cpp_main(int,char **);
427: int afternl(void);
428: void glob_init();
429: void input_init(FILE *,char *);
430: void asir_terminate(int);
431: void param_init(void);
432: void sprompt(char *);
433: void cppname_init();
434: void process_args(int,char **);
435: void sig_init(void);
436: void asir_save_handler(void);
437: void asir_set_handler(void);
438: void asir_reset_handler(void);
439: void resetenv(char *);
440: void fatal(int);
441: void restore_handler(void);
442: void resize_buffer(void);
443: void tty_init(void);
444: void tty_reset(void);
445: void set_timer(int);
446: void reset_timer(void);
447: void int_handler(int);
448: void segv_handler(int);
449: void bus_handler(int);
450: void fpe_handler(int);
451: void ill_handler(int);
452: void winch_handler(int);
453: void pipe_handler(int);
454: void usr1_handler(int);
455: void alrm_handler(int);
456: void ox_usr1_handler(int sig);
457: void copyright(void);
458: void kan_init(void);
459: void pushpvs(FUNC);
460: void read_eval_loop(void);
461: void prompt(void);
462: void storeans(pointer);
463: int yyparse(void);
464: void nodetod(NODE,DP *);
465: void poppvs(void);
466: int length(NODE);
467: size_t get_heapsize(void);
468: int searchpvar(char *);
469: void searchuf(char *name,FUNC *r);
470: void mkparif(char *,FUNC *);
471: void makevar(char *,P *);
472: void mkpvs(char *);
473: MODULE mkmodule(char *);
474: void stoarg(char *,int *,char **);
475: void yyerror(char *);
476: void closecurrentinput(void);
477: void asir_terminate(int);
478: void searchasirpath(char *,char **);
479: void get_vars(Obj,VL *);
480: void appendbinf(NODE *,char *,void(*)(),int,unsigned int);
481: void appendubinf(char *,void(*)(),int,unsigned int);
482: void parif_init(void);
483: void sysf_init(void);
484: void makesrvar(FUNC, P *);
485: void sprintexpr(VL,Obj);
486: void printexpr(VL,Obj);
487: void appendvar(VL,V);
488: void change_mvar(VL,P,V,P *);
489: void restore_mvar(VL,P,V,P *);
490: int argc(NODE);
491: // void printn(N);
492: // void sprintn(N);
493: void printv(VL,V);
494: void sprintv(VL,V);
495: int arf_comp(VL, Obj, Obj);
496: int complist(VL, LIST, LIST);
497: int getcompsize(int);
498: int getpvar(VS,char *,int);
499: int gettype(unsigned int);
500: int indextotype(int,int);
501: int loadfile(char *);
502: int loadfiles(NODE);
503: unsigned int makepvar(char *);
504: int membertoindex(int,char *);
505: int qcoefp(Obj);
506: int qcoefr(Obj);
507: int rangecheck(Obj,int);
508: int structtoindex(char *);
509: void _mkpfins(PF ,Obj *,V *);
510: void appendpfins(V ,V *);
511: void appenduf(char *,FUNC *);
512: void arf_add(VL, Obj, Obj, Obj *);
513: void arf_chsgn(Obj, Obj *);
514: void arf_div(VL, Obj, Obj, Obj *);
515: void arf_init(void);
516: void arf_mul(VL, Obj, Obj, Obj *);
517: void arf_pwr(VL, Obj, Obj, Obj *);
518: void arf_remain(VL, Obj, Obj, Obj *);
519: void arf_sub(VL, Obj, Obj, Obj *);
520: void bp(SNODE);
521: void clearbp(FUNC);
522: void debug(SNODE);
523: void debug_init(void);
524: void delbp(int, char **);
525: void derivr(VL ,Obj ,V ,Obj *);
526: void derivvar(VL ,V ,V ,Obj *);
527: void duppfins(V ,V *);
528: void error(char *);
529: void evalins(PFINS ,int ,Obj *);
530: void evalnodebody(NODE,NODE *);
531: void evalp(VL ,P ,int ,P *);
532: void evalr(VL ,Obj ,int ,Obj *);
533: void evalv(VL ,V ,int ,Obj *);
534: void getarrayp(Obj,NODE,Obj **);
535: void getmember(FNODE,Obj *);
536: void getmemberp(FNODE,Obj **);
537: void help(char *);
538: void instov(PFINS ,V *);
539: Obj memberofstruct(COMP,char *);
1.7 ! kondoh 540: #if defined(INTERVAL)
! 541: void mkpf(char *,Obj ,int ,V *,int (*)(),double (*)(),int (*)(),void (*[])(), PF *);
! 542: #else
! 543: void mkpf(char *,Obj ,int ,V *,int (*)(),double (*)(),int (*)(), PF *);
! 544: #endif
1.1 noro 545: void mkpfins(PF ,V *,V *);
546: void mkuf(char *,char *,NODE,SNODE,int,int,char *,MODULE);
547: void newstruct(int,struct oCOMP **);
548: void optobj(Obj *);
549: void println(int, char **, int);
550: void printvars(char *,VS);
551: void resetpvs(void);
552: void searchc(char *,FUNC *);
553: void searchf(NODE,char *,FUNC *);
554: void searchpf(char *,FUNC *);
555: void searchsn(SNODE *, int, SNODE **);
556: void setbp(char *);
557: void setf(int, char **);
558: void setstruct(char *,NODE);
559: void showbp(int);
560: void showbps(void);
561: void showpos(void);
562: void simplify_ins(PFINS ,Obj *);
563: void sprintvars(char *,VS);
564: int structdef(char *,NODE);
565: void substfp(VL ,Obj ,PF ,PF ,Obj *);
566: void substfr(VL ,Obj ,PF ,PF ,Obj *);
567: void substfv(VL ,V ,PF ,PF ,Obj *);
568: void substpr(VL ,int ,Obj ,V ,Obj ,Obj *);
569: void substr(VL ,int ,Obj ,V ,Obj ,Obj *);
570: void appendtonode(NODE,pointer, NODE *);
571: void getarray(pointer,NODE,pointer *);
572: void putarray(pointer,NODE,pointer);
573:
574: void addcomp(VL,COMP,COMP,COMP *);
575: void subcomp(VL,COMP,COMP,COMP *);
576: void mulcomp(VL,COMP,COMP,COMP *);
577: void divcomp(VL,COMP,COMP,COMP *);
578: void chsgncomp(COMP,COMP *);
579: void pwrcomp(VL,COMP,Obj,COMP *);
580: int compcomp(VL,COMP,COMP);
581:
582: void mergedeglist(NODE d0,NODE d1,NODE *dr);
583: void getdeglist(P p,V v,NODE *d);
584: void restore_mvar(VL vl,P p,V v,P *r);
585: void change_mvar(VL vl,P p,V v,P *r);
586: void getcoef(VL vl,P p,V v,Z d,P *r);
587: void ranp(int n,UP *nr);
588:
589: void _print_mp(int nv,MP m);
590: int dp_homogeneous(DP p);
591: int dp_nt(DP p);
592: int dl_equal(int nv,DL dl1,DL dl2);
593: DL lcm_of_DL(int nv,DL dl1,DL dl2,DL dl);
594: void dp_rest(DP p,DP *rp);
595: void dp_hm(DP p,DP *rp);
596: void dltod(DL d,int n,DP *rp);
597: void dp_subd(DP p1,DP p2,DP *rp);
598: int dp_redble(DP p1,DP p2);
599: void sortbynm(Q *w,int n);
600: int comp_nm(Q *a,Q *b);
601: void dp_rat(DP p,DP *rp);
602: void dp_mod(DP p,int mod,NODE subst,DP *rp);
603: void dp_dehomo(DP p,DP *rp);
604: void dp_homo(DP p,DP *rp);
605: void dp_nf_tab_mod(DP p,LIST *tab,int mod,DP *rp);
606: void dp_lnf_mod(DP p1,DP p2,NODE g,int mod,DP *r1p,DP *r2p);
607: void dp_lnf_f(DP p1,DP p2,NODE g,DP *r1p,DP *r2p);
608: void _dp_nf_mod_destructive(NODE b,DP g,DP *ps,int mod,int full,DP *rp);
609: void dp_true_nf_mod(NODE b,DP g,DP *ps,int mod,int full,DP *rp,P *dnp);
610: void dp_nf_mod(NODE b,DP g,DP *ps,int mod,int full,DP *rp);
611: void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp);
612: void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *rp);
613: void _dp_red_mod_destructive(DP p1,DP p2,int mod,DP *rp);
614: void dp_red_mod(DP p0,DP p1,DP p2,int mod,DP *head,DP *rest,P *dnp);
615: void dp_red_f(DP p1,DP p2,DP *rest);
616: void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp,DP *multp);
617: void _dp_sp_mod(DP p1,DP p2,int mod,DP *rp);
618: void _dp_sp_mod_dup(DP p1,DP p2,int mod,DP *rp);
619: void dp_sp_mod(DP p1,DP p2,int mod,DP *rp);
620: void _dp_sp_dup(DP p1,DP p2,DP *rp);
621: void dp_sp(DP p1,DP p2,DP *rp);
622: void dp_dtov(DP dp,VECT *rp);
623: void dp_prim_mod(DP p,int mod,DP *rp);
624: void heu_nezgcdnpz(VL vl,P *pl,int m,P *pr);
625: void dp_prim(DP p,DP *rp);
626: void dp_vtod(Q *c,DP p,DP *rp);
627: void insert_to_node(DL d,NODE *n,int nvar);
628: int _dl_redble(DL d1,DL d2,int nvar);
629: void dp_mbase(NODE hlist,NODE *mbase);
630: void dp_ptozp2(DP p0,DP p1,DP *hp,DP *rp);
631: void dp_ptozp(DP p,DP *rp);
632: void _dpmod_to_vect(DP f,DL *at,int *b);
633: void _tf_to_vect_compress(NODE tf,DL *at,CDP *b);
634: void dp_to_vect(DP f,DL *at,Q *b);
635: NODE dp_dllist(DP f);
636: NODE mul_dllist(DL d,DP f);
637: void pdl(NODE f);
638: void dp_gr_main(LIST f,LIST v,Num homo,int modular,int field,struct order_spec *ord,LIST *rp);
639: void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp);
640: void dp_f4_main(LIST f,LIST v,struct order_spec *ord,LIST *rp);
641: void dp_f4_mod_main(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp);
642: NODE gb_f4(NODE f);
643: NODE gb_f4_mod(NODE f,int m);
644: NODE gb_f4_mod_old(NODE f,int m);
645: int dpm_redble(DPM p1,DPM p2);
646:
647: int DPPlength(DP_pairs n);
648: void printdl(DL dl);
649: void pltovl(LIST l,VL *vl);
650: void makesubst(VL v,NODE *s);
651: void printsubst(NODE s);
652: void vlminus(VL v,VL w,VL *d);
653: int validhc(P a,int m,NODE s);
654: void setup_arrays(NODE f,int m,NODE *r);
655: void prim_part(DP f,int m,DP *r);
656: NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* of DP */ nd, int dec );
657: NODE NODE_sortb( NODE node, int dec );
658: NODE /* of index */ NODE_sortbi_insert( int newdpi, NODE /* of index */ nd, int dec );
659: NODE NODE_sortbi( NODE node, int dec );
660: void reduceall(NODE in,NODE *h);
661: void reduceall_mod(NODE in,int m,NODE *h);
662: int newps(DP a,int m,NODE subst);
663: int newps_nosave(DP a,int m,NODE subst);
664: int newps_mod(DP a,int m);
665: void reducebase_dehomo(NODE f,NODE *g);
666: NODE append_one(NODE f,long n);
667: DP_pairs minp( DP_pairs d, DP_pairs *prest );
668: void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr);
669: NODE gb(NODE f,int m,NODE subst);
670: NODE gb_mod(NODE f,int m);
671: DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, int t);
672: DP_pairs newpairs( NODE /* of index */ g, int t );
673: DP_pairs criterion_B( DP_pairs d, int s );
674: DP_pairs criterion_M( DP_pairs d1 );
675: int criterion_2( int dp1, int dp2 );
676: DP_pairs criterion_F( DP_pairs d1 );
677: NODE updbase(NODE g,int t);
678: NODE /* of index */ remove_reducibles(NODE /* of index */ nd, int newdp );
679: int dl_redble(DL dl1,DL dl2);
680: int dl_weyl_weight(DL dl);
681: int gbcheck(NODE f);
682: int membercheck(NODE f,NODE x);
683: void dp_set_flag(Obj name,Obj value);
684: void dp_make_flaglist(LIST *list);
685: void dp_save(int index,Obj p,char *prefix);
686: void dp_load(int index,DP *p);
687: int dp_load_t(int index,DP *p);
688: void init_stat();
689: void print_stat();
690: void dp_mulc_d(DP p,P c,DP *r);
691: void _dp_nf(NODE b,DP g,DP *ps,int full,DP *rp);
692: void _dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *r);
693: void dp_imul_d(DP p,Q q,DP *rp);
694: void imulv(VECT w,Q c,VECT *rp);
695: void dptoca(DP p,unsigned int **rp);
696: int yylex();
697: void purge_stdin();
698: int afternl();
699: int aftercomment();
700: int myatoi(char *s);
701: void yyerror(char *s);
702: int Egetc(FILE *fp);
703: void Eungetc(int c,FILE *fp);
1.2 noro 704: void xget_line(char *buf);
1.1 noro 705: int readline_getc();
706: void readline_ungetc();
707: char *readline_console(char *prompt);
708: void ox_usr1_handler(int sig);
709: void env_init();
710: void loadasirfile(char *name0);
711: void execasirfile(char *name);
712: void load_and_execfile(char *name);
713: int loadfile(char *s);
714: int loadfiles(NODE node);
715: unsigned char encrypt_char(unsigned char c);
716: unsigned char decrypt_char(unsigned char c);
717: void encrypt_file(char *in,char *out);
718: void decrypt_file(char *in,char *out);
719: void get_vars(Obj t,VL *vlp);
720: void get_vars_recursive(Obj obj,VL *vlp);
721: int comp_obj(Obj *a,Obj *b);
722: int generic_comp_obj(Obj *a,Obj *b);
723: void sepvect(VECT v,int d,VECT *rp);
724: int gauss_elim_mod(int **mat,int row,int col,int md);
725: // int inttorat(N c,N m,N b,int *sgnp,N *nmp,N *dnp);
726: // int intmtoratm(MAT mat,N md,MAT nm,Q *dn);
727: // int intmtoratm_q(MAT mat,N md,MAT nm,Q *dn);
728: void reduce_reducers_mod(int **mat,int row,int col,int md);
729: void pre_reduce_mod(int **mat,int row,int col,int nred,int md);
730: void reduce_sp_by_red_mod(int *sp,int **redmat,int *ind,int nred,int col,int md);
731: void red_by_compress(int m,unsigned int *p,unsigned int *r,
732: unsigned int *ri,unsigned int hc,int len);
733: void red_by_vect(int m,unsigned int *p,unsigned int *r,unsigned int hc,int len);
734: void reduce_sp_by_red_mod_compress (int *sp,CDP *redmat,int *ind,
735: int nred,int col,int md);
736: int lu_gfmmat(GFMMAT mat,unsigned int md,int *perm);
737: int find_lhs_and_lu_mod(unsigned int **a,int row,int col,
738: unsigned int md,int **rinfo,int **cinfo);
739: void solve_by_lu_mod(int **a,int n,int md,int **b,int l,int normalize);
740: int gauss_elim_mod1(int **mat,int row,int col,int md);
741: int gauss_elim_geninv_mod(unsigned int **mat,int row,int col,int md);
742: void solve_by_lu_gfmmat(GFMMAT lu,unsigned int md,unsigned int *b,unsigned int *x);
743: void mat_to_gfmmat(MAT m,unsigned int md,GFMMAT *rp);
744: int gauss_elim_geninv_mod_swap(unsigned int **mat,int row,int col,
745: unsigned int md,unsigned int ***invmatp,int **indexp);
746: int generate_ONB_polynomial(UP2 *rp,int m,int type);
747: int _generate_irreducible_polynomial(UP2 f,int d);
748: int _generate_good_irreducible_polynomial(UP2 f,int d);
749: void printqmat(Q **mat,int row,int col);
750: void printimat(int **mat,int row,int col);
751: void ixor(Z n1,Z n2,Z *r);
752: void ior(Z n1,Z n2,Z *r);
753: void iand(Z n1,Z n2,Z *r);
754: void isqrt(Z a,Z *r);
755: void igcd_cofactor(Z a,Z b,Z *gcd,Z *ca,Z *cb);
756: int TypeT_NB_check(unsigned int m, unsigned int t);
757: int small_jacobi(int a,int m);
758: void pushpvs(FUNC f);
759: void poppvs();
760: unsigned int makepvar(char *str);
761: int searchpvar(char *str);
762: int getpvar(VS pvs,char *str,int searchonly);
763: void closecurrentinput();
764: void resetpvs();
765: void savepvs();
766: void restorepvs();
767: void storeans(pointer p);
768: void get_rootdir(char *name,int len);
769: void set_rootdir(char *name);
770: int process_id();
771: void call_exe(char *name,char **av);
772: void addquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
773: void subquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
774: void mulquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
775: void divquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
776: void pwrquote(VL vl,QUOTE a,QUOTE b,QUOTE *c);
777: void chsgnquote(QUOTE a,QUOTE *c);
778: void objtoquote(Obj a,QUOTE *c);
779: void polytoquote(P a,QUOTE *c);
780: void dptoquote(DP a,QUOTE *c);
781: void dctoquote(DCP dc,QUOTE v,QUOTE *c,int *sgn);
782: void mptoquote(MP m,int n,QUOTE *c,int *sgn);
783: void vartoquote(V v,QUOTE *c);
784: void fnodetotree(FNODE f,LIST *rp);
785: int compfnode(FNODE f1,FNODE f2);
786: FNODE eval_pvar_in_fnode(FNODE f);
787: FNODE subst_in_fnode(FNODE f,V v,FNODE g);
788: char *get_attribute(char *key,LIST attr);
789: void treetofnode(Obj obj,FNODE *f);
790: void glob_init() ;
791: void input_init(FILE *fp,char *name);
792: void notdef(VL vl,Obj a,Obj b,Obj *c);
793: void ExitAsir() ;
794: void asir_terminate(int status);
795: void param_init() ;
796: void prompt() ;
797: void sprompt(char *ptr);
798: void process_args(int ac,char **av);
799: void sig_init() ;
800: void asir_save_handler() ;
801: void asir_set_handler() ;
802: void asir_reset_handler() ;
803: void resetenv(char *s);
804: void fatal(int n);
805: void int_handler(int sig);
806: void restore_handler() ;
807: void segv_handler(int sig);
808: void ill_handler(int sig);
809: void alrm_handler(int sig);
810: void bus_handler(int sig);
811: void fpe_handler(int sig);
812: void pipe_handler(int sig);
813: void resize_buffer();
814: void tty_init() ;
815: void tty_reset() ;
816: void set_lasterror(char *s);
817: void error(char *s);
818: void set_timer(int interval);
819: void reset_timer();
820: void copyright() ;
821: void show_debug_window(int on);
822: void init_cmdwin();
823: void searchpf(char *name,FUNC *fp);
824: void searchc(char *name,FUNC *fp);
1.7 ! kondoh 825: #if defined(INTERVAL)
1.1 noro 826: void mkpf(char *name,Obj body,int argc,V *args,
1.7 ! kondoh 827: int (*parif)(),double (*libmf)(), int (*simp)(), void (*intervalfunc[])(), PF *pfp);
! 828: #else
! 829: void mkpf(char *name,Obj body,int argc,V *args,
! 830: int (*parif)(),double (*libmf)(), int (*simp)(), PF *pfp);
! 831: #endif
1.1 noro 832: void mkpfins(PF pf,V *args,V *vp);
833: void _mkpfins(PF pf,Obj *args,V *vp);
834: void _mkpfins_with_darray(PF pf,Obj *args,int *darray,V *vp);
835: void appendpfins(V v,V *vp);
836: void duppfins(V v,V *vp);
837: void derivvar(VL vl,V pf,V v,Obj *a);
838: void derivr(VL vl,Obj a,V v,Obj *b);
839: void substr(VL vl,int partial,Obj a,V v,Obj b,Obj *c);
840: void substpr(VL vl,int partial,Obj p,V v0,Obj p0,Obj *pr);
841: void evalr(VL vl,Obj a,int prec,Obj *c);
842: void evalp(VL vl,P p,int prec,P *pr);
843: void evalv(VL vl,V v,int prec,Obj *rp);
844: void evalins(PFINS ins,int prec,Obj *rp);
845: void devalr(VL vl,Obj a,Obj *c);
846: void devalp(VL vl,P p,P *pr);
847: void devalv(VL vl,V v,Obj *rp);
848: void devalins(PFINS ins,Obj *rp);
849: void simplify_ins(PFINS ins,Obj *rp);
850: void instov(PFINS ins,V *vp);
851: void substfr(VL vl,Obj a,PF u,PF f,Obj *c);
852: void substfp(VL vl,Obj p,PF u,PF f,Obj *pr);
853: void substfv(VL vl,V v,PF u,PF f,Obj *c);
854: int structdef(char *name,NODE member);
855: void newstruct(int type,COMP *rp);
856: int structtoindex(char *name);
857: int membertoindex(int type,char *name);
858: int getcompsize(int type);
859: Obj memberofstruct(COMP a,char *name);
860: void assign_to_member(COMP a,char *name,Obj obj);
861: void node_concat_dup(NODE n1,NODE n2,NODE *nr);
862: pointer evall(lid id,Obj a1,Obj a2);
863: pointer eval(FNODE f);
864: pointer evalstat(SNODE f);
865: pointer evalnode(NODE node);
866: pointer evalf(FUNC f,FNODE a,FNODE opt);
867: pointer evalparif(FUNC f,NODE a);
868: pointer evalf_deriv(FUNC f,FNODE a,FNODE deriv);
869: pointer evalmapf(FUNC f,FNODE a);
870: pointer eval_rec_mapf(FUNC f,FNODE a);
871: pointer beval_rec_mapf(FUNC f,NODE node);
872: pointer bevalf(FUNC f,NODE a);
873: pointer bevalf_with_opts(FUNC f,NODE a,NODE opts);
874: pointer evalif(FNODE f,FNODE a,FNODE opt);
875: pointer evalpf(PF pf,NODE args,NODE deriv);
876: void evalnodebody(NODE sn,NODE *dnp);
877: void gen_searchf(char *name,FUNC *r);
878: void gen_searchf_searchonly(char *name,FUNC *r,int global);
879: void searchf(NODE fn,char *name,FUNC *r);
880: void appenduf(char *name,FUNC *r);
881: void mkparif(char *name,FUNC *r);
882: void mkuf(char *name,char *fname,NODE args,SNODE body,int startl,int endl,char *desc,MODULE module);
883: Obj getopt_from_cpvs(char *key);
884: void des_enc(unsigned long *, unsigned char *, unsigned long *);
885: unsigned long round_func(unsigned long , unsigned char *);
886: unsigned long s_box_func(unsigned char *);
887: void des_dec(unsigned long *, unsigned char *, unsigned long *);
888: void key_schedule(unsigned char *,unsigned char *);
889: void debug_init();
890: void add_alias(char *com,char *alias);
891: void show_alias(char *alias);
892: void debug(SNODE f);
893: void setf(int ac,char **av);
894: void setbp(char *p);
895: void settp(char *p);
896: void clearbp(FUNC f);
897: int searchbp();
898: void delbp(int ac,char **av);
899: void showbps();
900: void showbp(int n);
901: void searchsn(SNODE *fp,int n,SNODE **fpp);
902: void bp(SNODE f);
903: void println(int ac,char **av,int l);
904: void printvars(char *s,VS vs);
905: void showpos();
906: void showpos_to_string(char *buf);
907: void change_stack(int level,NODE *pvss);
908: void show_stack(VS vs);
909: int estimate_length(VL vl,pointer p);
910: void send_progress(short per,char *msg);
911: void set_error(int code,char *reason,char *action);
912: double get_current_time();
913: void mp_abs(NODE arg,Num *rp);
914: int get_opt(char *key0,Obj *r);
915:
916: #if defined(VISUAL) || defined(__MINGW32__)
1.3 ohara 917: void ox_plot_main();
1.1 noro 918: #else
919: void ox_plot_main(int argc,char **argv);
920: #endif
921: void launch_main(int argc,char **argv);
922: void ox_main(int argc,char **argv);
923: void order_init();
924: void print_crossref(FUNC f);
925: void showpos_to_list(LIST *r);
926: void update_LASTCO();
927:
928: void get_fid_spec(fid id,fid_spec_p *spec);
929: FNODE strip_paren(FNODE f);
930: NODE flatten_fnodenode(NODE n,char *opname);
931: FNODE flatten_fnode(FNODE f,char *opname);
932: int compquote(VL vl,QUOTE q1,QUOTE q2);
933: int compqa(VL vl,QUOTEARG q1,QUOTEARG q2);
934: int compfnode(FNODE f1,FNODE f2);
935: void shuffle_mulnbp(VL vl,NBP p1,NBP p2, NBP *rp);
936: void harmonic_mulnbp(VL vl,NBP p1,NBP p2, NBP *rp);
937: void mulnbmnbp(VL vl,NBM m,NBP p, NBP *rp);
938: void mulnbpnbm(VL vl,NBP p,NBM m, NBP *rp);
939: P separate_nbm(NBM a,NBP *a0,NBP *ah,NBP *ar);
940: P separate_tail_nbm(NBM a,NBP *a0,NBP *ar,NBP *at);
941: P separate_xky_nbm(NBM a,NBP *a0,NBP *ah,NBP *ar);
942:
943: int fnode_is_var(FNODE f);
944: int fnode_is_coef(FNODE f);
945: int fnode_is_number(FNODE f);
946: int fnode_is_rational(FNODE f);
947: int fnode_is_integer(FNODE f);
948: int fnode_is_nonnegative_integer(FNODE f);
949: int fnode_is_one(FNODE f);
950: int fnode_is_minusone(FNODE f);
951: int fnode_is_dependent(FNODE f,V v);
952:
953: int nfnode_weight(struct wtab *tab,FNODE f);
954: int nfnode_comp(FNODE f1,FNODE f2);
955: int nfnode_comp_lex(FNODE f1,FNODE f2);
956: int nfnode_match(FNODE f,FNODE pat,NODE *rp);
957: int nfnode_match_naryadd(FNODE f,FNODE p,NODE *rp);
958: int nfnode_match_narymul(FNODE f,FNODE p,NODE *rp);
959:
960: int exprparse_create_var(FUNC f,char *str,SNODE *statp);
961: int obj_is_dependent(Obj a,V v);
962: void instoobj(PFINS ins,Obj *rp);
963: void goto_toplevel(char *s);
964: void add_bucket(GeoBucket g,NODE d,int nv);
965:
966: #if defined(GC7)
967: void *GC_get_main_stack_base();
968: #else
969: void *GC_get_stack_base();
970: #endif
971:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>