Annotation of OpenXM_contrib2/asir2000/include/ca.h, Revision 1.8
1.4 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.5 noro 26: * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification
1.4 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.8 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/include/ca.h,v 1.7 2000/12/05 01:24:53 noro Exp $
1.4 noro 49: */
1.1 noro 50: #include <stdio.h>
51:
52: #if defined(hpux)
53: #include <netinet/in.h>
54: # define setbuffer(FP,buf,siz) setvbuf(FP,buf,_IOFBF,siz)
55: #endif
56:
57: #if defined(VISUAL)
58: #include <stdlib.h>
59: #endif
60:
61: #if defined(linux) || (defined(sun) && !defined(SYSV)) || defined(news5000) || (defined(mips) && defined(ultrix))
62: #include <alloca.h>
63: #endif
64:
65: #if (defined(sun) && defined(SYSV))
66: #define alloca(x) __builtin_alloca(x)
67: #endif
68:
69: #if defined(VISUAL)
70: #include <malloc.h>
71: #endif
72:
73: #if 0
74: #include <sys/types.h>
75: typedef caddr_t pointer;
76: #endif
77:
78: typedef void * pointer;
79:
80: #if defined(VISUAL)
81: #include <string.h>
82: #define index(s,c) strchr(s,c)
83: #define bzero(s,len) memset(s,0,len)
84: #define bcopy(x,y,len) memcpy(y,x,len)
85: #endif
86:
87: #define COPY(a,b) ((b)=(a))
88: #define FREEN(p)
89: #define FREEQ(p)
90: #define FREE(p)
91: #define INITRC(p)
92:
93: /* data structures */
94:
95: #define O_N 1
96: #define O_P 2
97: #define O_R 3
98: #define O_LIST 4
99: #define O_VECT 5
100: #define O_MAT 6
101: #define O_STR 7
102: #define O_COMP 8
103: #define O_DP 9
104: #define O_USINT 10
105: #define O_ERR 11
106: #define O_GF2MAT 12
107: #define O_MATHCAP 13
108: #define O_F 14
109: #define O_GFMMAT 15
1.6 noro 110: #define O_BYTEARRAY 16
1.1 noro 111: #define O_VOID -1
112:
113: #define N_Q 0
114: #define N_R 1
115: #define N_A 2
116: #define N_B 3
117: #define N_C 4
118: #define N_M 5
119: #define N_LM 6
120: #define N_GF2N 7
121: #define N_GFPN 8
122:
123: #define ORD_REVGRADLEX 0
124: #define ORD_GRADLEX 1
125: #define ORD_LEX 2
126:
127: #if LONG_IS_32BIT
128: #if defined(VISUAL)
129: typedef _int64 L;
130: typedef unsigned _int64 UL;
131: #else
132: typedef long long L;
133: typedef unsigned long long UL;
134: #endif
135: #else
136: typedef long L;
137: typedef unsigned long UL;
138: #endif
139:
140: typedef struct oN {
141: int p;
142: unsigned int b[1];
143: } *N;
144:
145: typedef struct oUP2 {
146: int w;
147: unsigned int b[1];
148: } *UP2;
149:
150: typedef struct _oUP2 {
151: int w;
152: unsigned int *b;
153: } *_UP2;
154:
155: #define UP2_DENSE 0
156: #define UP2_SPARSE 1
157:
158: typedef struct oGEN_UP2 {
159: int id;
160: UP2 dense;
161: UP2 sparse;
162: } *GEN_UP2;
163:
164: typedef struct oV {
165: char *name;
166: pointer attr;
167: pointer priv;
168: } *V;
169:
170: typedef struct oQ {
171: short id;
172: char nid;
173: char sgn;
174: N nm;
175: N dn;
176: } *Q;
177:
178: typedef struct oReal {
179: short id;
180: char nid;
181: char pad;
182: double body;
183: } *Real;
184:
185: typedef struct oAlg {
186: short id;
187: char nid;
188: char pad;
189: struct oObj *body;
190: } *Alg;
191:
192: typedef struct oBF {
193: short id;
194: char nid;
195: char pad;
196: long body[1];
197: } *BF;
198:
199: typedef struct oC {
200: short id;
201: char nid;
202: char pad;
203: struct oNum *r,*i;
204: } *C;
205:
206: typedef struct oLM {
207: short id;
208: char nid;
209: char pad;
210: struct oN *body;
211: } *LM;
212:
213: typedef struct oGF2N {
214: short id;
215: char nid;
216: char pad;
217: struct oUP2 *body;
218: } *GF2N;
219:
220: typedef struct oGFPN {
221: short id;
222: char nid;
223: char pad;
224: struct oUP *body;
225: } *GFPN;
226:
227: typedef struct oNum {
228: short id;
229: char nid;
230: char pad;
231: } *Num;
232:
233: typedef struct oMQ {
234: short id;
235: char nid;
236: char pad;
237: int cont;
238: } *MQ;
239:
240: typedef struct oP {
241: short id;
242: short pad;
243: V v;
244: struct oDCP *dc;
245: } *P;
246:
247: typedef struct oR {
248: short id;
249: short reduced;
250: P nm;
251: P dn;
252: } *R;
253:
254: typedef struct oVECT {
255: short id;
256: short pad;
257: int len;
258: pointer *body;
259: } *VECT;
260:
261: typedef struct oMAT {
262: short id;
263: short pad;
264: int row,col;
265: pointer **body;
266: } *MAT;
267:
268: typedef struct oGF2MAT {
269: short id;
270: short pad;
271: int row,col;
272: unsigned int **body;
273: } *GF2MAT, *GFMMAT;
274:
275: typedef struct oLIST {
276: short id;
277: short pad;
278: struct oNODE *body;
279: } *LIST;
280:
281: typedef struct oSTRING {
282: short id;
283: short pad;
284: char *body;
285: } *STRING;
286:
287: typedef struct oCOMP {
288: short id;
289: short type;
290: struct oObj *member[1];
291: } *COMP;
292:
293: typedef struct oDP {
294: short id;
295: short nv;
296: int sugar;
297: struct oMP *body;
298: } *DP;
299:
300: typedef struct oUSINT {
301: short id;
302: short pad;
303: unsigned body;
304: } *USINT;
305:
306: typedef struct oERR {
307: short id;
308: short pad;
309: struct oObj *body;
310: } *ERR;
311:
312: typedef struct oMATHCAP {
313: short id;
314: short pad;
315: struct oLIST *body;
316: } *MATHCAP;
317:
1.6 noro 318: typedef struct oBYTEARRAY {
319: short id;
320: short pad;
321: int len;
322: unsigned char *body;
323: } *BYTEARRAY;
324:
1.1 noro 325: typedef struct oObj {
326: short id;
327: short pad;
328: } *Obj;
329:
330: typedef struct oDCP {
331: Q d;
332: P c;
333: struct oDCP *next;
334: } *DCP;
335:
336: typedef struct oMP {
337: struct oDL *dl;
338: P c;
339: struct oMP *next;
340: } *MP;
341:
342: typedef struct oDL {
343: int td;
344: int d[1];
345: } *DL;
346:
347: typedef struct oVL {
348: V v;
349: struct oVL *next;
350: } *VL;
351:
352: typedef struct oNODE {
353: pointer body;
354: struct oNODE *next;
355: } *NODE;
356:
357: typedef struct oUM {
358: int d;
359: int c[1];
360: } *UM;
361:
362: typedef struct oLUM {
363: int d;
364: int *c[1];
365: } *LUM;
366:
367: typedef struct oML {
368: int n;
369: int mod;
370: int bound;
371: pointer c[1];
372: } *ML;
373:
374: typedef struct oUB {
375: int d;
376: N c[1];
377: } *UB;
378:
379: typedef struct oVN {
380: V v;
381: int n;
382: } *VN;
383:
384: typedef struct oUP {
385: int d;
386: Num c[1];
387: } *UP;
388:
389: typedef struct oDUM {
390: int n;
391: UM f;
392: } *DUM;
393:
394: struct order_pair {
395: int order, length;
396: };
397:
398: struct order_spec {
399: int id;
400: Obj obj;
401: int nv;
402: union {
403: int simple;
404: struct {
405: int length;
406: struct order_pair *order_pair;
407: } block;
408: struct {
409: int row;
410: int **matrix;
411: } matrix;
412: } ord;
413: };
414:
415: /* structure for cputime */
416:
417: struct oEGT {
418: double exectime,gctime;
419: };
420:
421: /* constant */
422:
423: /* ground finite field specification */
424: #define FF_NOT_SET 0
425: #define FF_GFP 1
426: #define FF_GF2N 2
427: #define FF_GFPN 3
428:
429: #define INDEX 100
430:
431: #if USE_FLOAT
432: typedef float ModNum;
433: #define NPrimes 536
434: #else
435: typedef unsigned int ModNum;
436: #define NPrimes 13681
437: #endif
438:
439: /* general macros */
440: #define MAX(a,b) ((a) > (b) ? (a) : (b) )
441: #define MIN(a,b) ((a) > (b) ? (b) : (a) )
442: #ifdef ABS
443: #undef ABS
444: #endif
445: #define ABS(a) ((a)>0?(a):-(a))
446: #define ID(p) ((p)->id)
447: #define OID(p) (((Obj)(p))->id)
448: #define NID(p) (((Num)(p))->nid)
449: #define BDY(p) ((p)->body)
450: #define VR(p) ((p)->v)
451: #define NAME(p) ((p)->name)
452: #define NEXT(p) ((p)->next)
453: #define NM(q) ((q)->nm)
454: #define DN(q) ((q)->dn)
455: #define SGN(q) ((q)->sgn)
456: #define DC(p) ((p)->dc)
457: #define COEF(p) ((p)->c)
458: #define DEG(p) ((p)->d)
459: #define PL(n) ((n)->p)
460: #define BD(n) ((n)->b)
461: #define CONT(a) ((a)->cont)
462: #define UDEG(f) BD(NM(DEG(DC(f))))[0]
463: #define UCOEF(f) (COEF(DC(f)))
464: #define LC(f) (NUM(f)?(f):COEF(DC(f)))
465:
466: /* memory allocators (W_... : uses alloca) */
467:
468: #if 0
469: #define MALLOC(d) Risa_GC_malloc(d)
470: #define MALLOC_ATOMIC(d) Risa_GC_malloc_atomic(d)
471: #define REALLOC(p,d) Risa_GC_realloc(p,d)
472: #else
473: #define MALLOC(d) GC_malloc(d)
474: #define MALLOC_ATOMIC(d) GC_malloc_atomic(d)
475: #define REALLOC(p,d) GC_realloc(p,d)
476: #endif
477: #define CALLOC(d,e) MALLOC((d)*(e))
478:
479: #if (defined(__GNUC__) || defined(vax) || defined(apollo) || defined(alloca) || defined(VISUAL))
480: #define ALLOCA(d) alloca(d)
481: #else
482: #define ALLOCA(d) MALLOC(d)
483: #endif
484:
485: #define TRUESIZE(type,n,atype) (sizeof(struct type)+MAX((n),0)*sizeof(atype))
486: #define NALLOC(d) ((N)MALLOC_ATOMIC(TRUESIZE(oN,(d)-1,int)))
487: #define UMALLOC(d) ((UM)MALLOC(TRUESIZE(oUM,d,int)))
488: #define UPALLOC(d) ((UP)MALLOC(TRUESIZE(oUP,(d),Num)))
489: #define C_UMALLOC(d) ((UM)MALLOC(TRUESIZE(oUM,d,int)))
490: #define MLALLOC(d) ((ML)MALLOC(TRUESIZE(oML,d,pointer)))
491:
492: #define W_ALLOC(d) ((int *)ALLOCA(((d)+1)*sizeof(int)))
493: #define W_CALLOC(n,type,p) \
494: ((p)=(type *)ALLOCA(((n)+1)*sizeof(type)),\
495: bzero((char *)(p),(int)(((n)+1)*sizeof(type))))
496: #define W_UMALLOC(d) ((UM)ALLOCA(TRUESIZE(oUM,d,int)))
497: #define W_UPALLOC(d) ((UP)ALLOCA(TRUESIZE(oUP,(d),Num)))
498: #define W_MLALLOC(d) ((ML)ALLOCA(TRUESIZE(oML,d,pointer)))
499: #define W_LUMALLOC(n,bound,p)\
500: {\
501: LUM ___q___;\
502: int ___i___,**___c___;\
503: (___q___) = (LUM)ALLOCA(TRUESIZE(oLUM,(n),int *));\
504: DEG(___q___) = n;\
505: for ( ___i___ = 0, ___c___ = (int **)COEF(___q___); ___i___ <= n; ___i___++ ) {\
506: ___c___[___i___] = (int *)ALLOCA(((bound)+1)*sizeof(int));\
507: bzero((char *)___c___[___i___],((bound)+1)*sizeof(int));\
508: }\
509: (p) = ___q___;\
510: }
511:
512: #define NEWUP2(q,w)\
513: ((q)=(UP2)MALLOC_ATOMIC(TRUESIZE(oUP2,(w)-1,unsigned int)),\
514: bzero((char *)(q)->b,(w)*sizeof(unsigned int)))
515: #define W_NEWUP2(q,w)\
516: ((q)=(UP2)ALLOCA(TRUESIZE(oUP2,(w)-1,unsigned int)),\
517: bzero((char *)(q)->b,(w)*sizeof(unsigned int)))
518: #define W_NEW_UP2(q,w)\
519: ((q).b=(unsigned int *)ALLOCA((w)*sizeof(unsigned int)))
520:
521: /* cell allocators */
522: #define NEWQ(q) ((q)=(Q)MALLOC(sizeof(struct oQ)),OID(q)=O_N,NID(q)=N_Q)
523: #define NEWMQ(q) ((q)=(MQ)MALLOC_ATOMIC(sizeof(struct oMQ)),OID(q)=O_N,NID(q)=N_M)
524: #define NEWP(p) ((p)=(P)MALLOC(sizeof(struct oP)),OID(p)=O_P)
525: #define NEWR(r) ((r)=(R)MALLOC(sizeof(struct oR)),OID(r)=O_R,(r)->reduced=0)
526: #define NEWLIST(l) ((l)=(LIST)MALLOC(sizeof(struct oLIST)),OID(l)=O_LIST)
527: #define NEWVECT(l) ((l)=(VECT)MALLOC(sizeof(struct oVECT)),OID(l)=O_VECT)
528: #define NEWSTR(l) ((l)=(STRING)MALLOC(sizeof(struct oSTRING)),OID(l)=O_STR)
529: #define NEWCOMP(c,n) ((c)=(COMP)MALLOC(sizeof(struct oCOMP)+((n)-1)*sizeof(Obj)),OID(c)=O_COMP)
530: #define NEWDP(d) ((d)=(DP)MALLOC(sizeof(struct oDP)),OID(d)=O_DP)
531: #define NEWUSINT(u) ((u)=(USINT)MALLOC_ATOMIC(sizeof(struct oUSINT)),OID(u)=O_USINT)
532: #define NEWERR(e) ((e)=(ERR)MALLOC(sizeof(struct oERR)),OID(e)=O_ERR)
533: #define NEWMATHCAP(e) ((e)=(MATHCAP)MALLOC(sizeof(struct oMATHCAP)),OID(e)=O_MATHCAP)
1.6 noro 534: #define NEWBYTEARRAY(e) ((e)=(BYTEARRAY)MALLOC(sizeof(struct oBYTEARRAY)),OID(e)=O_BYTEARRAY)
1.1 noro 535:
536: #define NEWNODE(a) ((a)=(NODE)MALLOC(sizeof(struct oNODE)))
537: #define NEWDC(dc) ((dc)=(DCP)MALLOC(sizeof(struct oDCP)))
538: #define NEWV(v) ((v)=(V)MALLOC(sizeof(struct oV)))
539: #define NEWVL(vl) ((vl)=(VL)MALLOC(sizeof(struct oVL)))
540: #define NEWMP(m) ((m)=(MP)MALLOC(sizeof(struct oMP)))
541:
542: #define NEWMAT(l) ((l)=(MAT)MALLOC(sizeof(struct oMAT)),OID(l)=O_MAT)
543: #define NEWGF2MAT(l) ((l)=(GF2MAT)MALLOC(sizeof(struct oGF2MAT)),OID(l)=O_GF2MAT)
544: #define NEWGFMMAT(l) ((l)=(GFMMAT)MALLOC(sizeof(struct oGF2MAT)),OID(l)=O_GFMMAT)
545: #define NEWReal(q) ((q)=(Real)MALLOC_ATOMIC(sizeof(struct oReal)),OID(q)=O_N,NID(q)=N_R)
546: #define NEWAlg(r) ((r)=(Alg)MALLOC(sizeof(struct oAlg)),OID(r)=O_N,NID(r)=N_A)
547: #define NEWBF(q,l) ((q)=(BF)MALLOC_ATOMIC(TRUESIZE(oBF,(l)-1,long)),OID(q)=O_N,NID(q)=N_B)
548: #define NEWC(r) ((r)=(C)MALLOC(sizeof(struct oC)),OID(r)=O_N,NID(r)=N_C)
549: #define NEWLM(r) ((r)=(LM)MALLOC(sizeof(struct oLM)),OID(r)=O_N,NID(r)=N_LM)
550: #define NEWGF2N(r) ((r)=(GF2N)MALLOC(sizeof(struct oGF2N)),OID(r)=O_N,NID(r)=N_GF2N)
551: #define NEWGFPN(r) ((r)=(GFPN)MALLOC(sizeof(struct oGFPN)),OID(r)=O_N,NID(r)=N_GFPN)
552: #define NEWDL(d,n) \
553: ((d)=(DL)MALLOC_ATOMIC(TRUESIZE(oDL,(n)-1,int)),bzero((char *)(d),TRUESIZE(oDL,(n)-1,int)))
554:
555: #define MKP(v,dc,p) \
556: (!DEG(dc)?((p)=COEF(dc)):(NEWP(p),VR(p)=(v),DC(p)=(dc),(p)))
557: #define MKV(v,p) \
558: (NEWP(p),VR(p)=(v),NEWDC(DC(p)),\
559: DEG(DC(p))=ONE,COEF(DC(p))=(P)ONE,NEXT(DC(p))=0)
560: #define MKRAT(n,d,r,p) \
561: (NEWR(p),NM(p)=(n),DN(p)=(d),(p)->reduced=(r))
562: #define MKMV(v,p) \
563: (NEWP(p),VR(p)=(v),NEWDC(DC(p)),\
564: DEG(DC(p))=ONE,COEF(DC(p))=(P)ONEM,NEXT(DC(p))=0)
565: #define MKNODE(a,b,c) \
566: (NEWNODE(a),(a)->body=(pointer)b,NEXT(a)=(NODE)(c))
567: #define MKLIST(a,b) (NEWLIST(a),(a)->body=(NODE)(b))
568: #define MKVECT(m,l) \
569: (NEWVECT(m),(m)->len=(l),(m)->body=(pointer *)CALLOC((l),sizeof(pointer)))
570: #define MKMAT(m,r,c) \
571: (NEWMAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(pointer **)almat_pointer((r),(c)))
572: #define TOGF2MAT(r,c,b,m) (NEWGF2MAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(b))
573: #define TOGFMMAT(r,c,b,m) (NEWGFMMAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(b))
574: #define MKSTR(a,b) (NEWSTR(a),(a)->body=(char *)(b))
575: #define MKDP(n,m,d) (NEWDP(d),(d)->nv=(n),BDY(d)=(m))
576: #define MKLM(b,l) (!(b)?(l)=0:(NEWLM(l),(l)->body=(b),(l)))
577: #define MKGF2N(b,l) (!(b)?(l)=0:(NEWGF2N(l),(l)->body=(b),(l)))
578: #define MKGFPN(b,l) (!(b)?(l)=0:(NEWGFPN(l),(l)->body=(b),(l)))
579: #define MKUSINT(u,b) (NEWUSINT(u),(u)->body=(unsigned)(b))
580: #define MKERR(e,b) (NEWERR(e),(e)->body=(Obj)(b))
581: #define MKMATHCAP(e,b) (NEWMATHCAP(e),(e)->body=(LIST)(b))
1.6 noro 582: #define MKBYTEARRAY(m,l) \
583: (NEWBYTEARRAY(m),(m)->len=(l),(m)->body=(char *)MALLOC_ATOMIC((l)),bzero((m)->body,(l)))
1.1 noro 584:
585: #define NEXTDC(r,c) \
586: if(!(r)){NEWDC(r);(c)=(r);}else{NEWDC(NEXT(c));(c)=NEXT(c);}
587: #define NEXTNODE(r,c) \
588: if(!(r)){NEWNODE(r);(c)=(r);}else{NEWNODE(NEXT(c));(c)=NEXT(c);}
589: #define NEXTMP(r,c) \
590: if(!(r)){NEWMP(r);(c)=(r);}else{NEWMP(NEXT(c));(c)=NEXT(c);}
591:
592: /* convertors */
593: #define NTOQ(n,s,q) \
594: (!(n)?((q)=0):(NEWQ(q),SGN(q)=(s),NM(q)=(n),DN(q)=0,(q)))
595: #define NDTOQ(n,d,s,q) \
596: ((!(d)||UNIN(d))?NTOQ(n,s,q):(NEWQ(q),SGN(q)=(s),NM(q)=(n),DN(q)=(d),(q)))
597: #define DUPQ(p,q) \
598: (NEWQ(q),SGN(q)=SGN(p),NM(q)=NM(p),DN(q)=DN(p))
599: #define STOQ(n,q) \
600: ((!(n))?((q)=(Q)NULL):(NEWQ(q),\
601: SGN(q)=((n)>0?1:-1),NM(q)=NALLOC(1),\
602: PL(NM(q))=1,BD(NM(q))[0]=ABS(n),DN(q)=0,(q)))
603: #define UTOMQ(a,b) \
604: ((a)?(NEWMQ(b),CONT(b)=(unsigned int)(a),(b)):((b)=0))
605: #define STOMQ(a,b) \
606: ((a)?(NEWMQ(b),CONT(b)=(a),(b)):((b)=0))
607: #define UTON(u,n) \
608: ((!(u))?((n)=(N)NULL):((n)=NALLOC(1),PL(n)=1,BD(n)[0]=(unsigned int)(u),(n)))
609: #define UTOQ(n,q) \
610: ((!(n))?((q)=(Q)NULL):(NEWQ(q),\
611: SGN(q)=1,NM(q)=NALLOC(1),\
612: PL(NM(q))=1,BD(NM(q))[0]=(unsigned int)(n),DN(q)=0,(q)))
613: #define QTOS(q) (!(q)?0:SGN(q)*((int)BD(NM(q))[0]))
614: #define STON(i,n)\
615: (i?((n)=NALLOC(1),PL(n)=1,BD(n)[0]=(i),(n)):((n)=(N)0))
616: #define PTOR(a,b) \
617: (!(a)?((b)=0):(NEWR(b),NM(b)=(a),DN(b)=(P)ONE,(b)->reduced=1,(b)))
618: #define RTOS(a) (!(a)?0:QTOS((Q)NM((R)a)))
619: #define MKReal(a,b) (!(a)?((b)=0):(NEWReal(b),BDY(b)=(a),(b)))
620: #define MKAlg(b,r) \
621: (!(b)?((r)=0):NUM(b)?((r)=(Alg)(b)):(NEWAlg(r),BDY(r)=(Obj)(b),(r)))
622:
1.3 noro 623: #if PARI
624: #define ToReal(a) (!(a)?(double)0.0:REAL(a)?BDY((Real)a):RATN(a)?RatnToReal((Q)a):BIGFLOAT(a)?rtodbl(BDY((BF)a)):0)
625: #else
626: #define ToReal(a) (!(a)?(double)0.0:REAL(a)?BDY((Real)a):RATN(a)?RatnToReal((Q)a):0.0)
627: #endif
1.1 noro 628:
629: /* predicates */
630: #define NUM(p) (OID(p)==O_N)
631: #define RAT(p) (OID(p)==O_R)
632: #define INT(q) (!DN((Q)q))
633: #define RATN(a) (NID(a)==N_Q)
634: #define REAL(a) (NID(a)==N_R)
1.3 noro 635: #define BIGFLOAT(a) (NID(a)==N_B)
1.1 noro 636: #define SFF(a) (NID(a)==N_M)
637: #define UNIQ(q) ((q)&&NUM(q)&&RATN(q)&&(SGN((Q)q)==1)&&UNIN(NM((Q)q))&&(!DN((Q)q)))
638: #define UNIMQ(q) ((q)&&NUM(q)&&SFF(q)&&(CONT((MQ)q)==1))
639: #define MUNIQ(q) ((q)&&NUM(q)&&RATN(q)&&(SGN((Q)q)==-1)&&UNIN(NM((Q)q))&&(!DN((Q)q)))
640: #define MUNIMQ(q) ((q)&&NUM(q)&&SFF(q)&&(CONT((MQ)q)==-1))
641: #define UNIN(n) ((n)&&(PL(n)==1)&&(BD(n)[0]==1))
642: #define EVENN(n) ((!(n))||(!(BD(n)[0]%2)))
643:
1.8 ! noro 644: /* special macros for private memory management */
! 645:
! 646: #define NV(p) ((p)->nv)
! 647: #define C(p) ((p)->c)
! 648: #define ITOS(p) (((unsigned int)(p))&0x7fffffff)
! 649: #define STOI(i) ((P)((unsigned int)(i)|0x80000000))
! 650:
! 651: struct cdl {
! 652: P c;
! 653: DL d;
! 654: };
! 655:
! 656: struct cdlm {
! 657: int c;
! 658: DL d;
! 659: };
! 660:
! 661: extern MP _mp_free_list;
! 662: extern DP _dp_free_list;
! 663: extern DL _dl_free_list;
! 664: extern int current_dl_length;
! 665:
! 666: #define _NEWDL_NOINIT(d,n) if ((n)!= current_dl_length){_dl_free_list=0; current_dl_length=(n);} if(!_dl_free_list)_DL_alloc(); (d)=_dl_free_list; _dl_free_list = *((DL *)_dl_free_list)
! 667: #define _NEWDL(d,n) if ((n)!= current_dl_length){_dl_free_list=0; current_dl_length=(n);} if(!_dl_free_list)_DL_alloc(); (d)=_dl_free_list; _dl_free_list = *((DL *)_dl_free_list); bzero((d),(((n)+1)*sizeof(int)))
! 668: #define _NEWMP(m) if(!_mp_free_list)_MP_alloc(); (m)=_mp_free_list; _mp_free_list = NEXT(_mp_free_list)
! 669: #define _MKDP(n,m,d) if(!_dp_free_list)_DP_alloc(); (d)=_dp_free_list; _dp_free_list = (DP)BDY(_dp_free_list); (d)->nv=(n); BDY(d)=(m)
! 670:
! 671: #define _NEXTMP(r,c) \
! 672: if(!(r)){_NEWMP(r);(c)=(r);}else{_NEWMP(NEXT(c));(c)=NEXT(c);}
! 673:
! 674: #define _NEXTMP2(r,c,s) \
! 675: if(!(r)){(c)=(r)=(s);}else{NEXT(c)=(s);(c)=(s);}
! 676:
! 677: #define _FREEDL(m) *((DL *)m)=_dl_free_list; _dl_free_list=(m)
! 678: #define _FREEMP(m) NEXT(m)=_mp_free_list; _mp_free_list=(m)
! 679: #define _FREEDP(m) BDY(m)=(MP)_dp_free_list; _dp_free_list=(m)
1.1 noro 680:
681: /* externals */
682: #if 0
683: double NatToReal();
684: double RatnToReal();
685: #endif
686:
687: extern struct oR oUNIR;
688: extern struct oQ oUNIQ;
689: extern struct oMQ oUNIMQ;
690: extern struct oN oUNIN;
691: extern struct oUP2 oONEUP2;
692: extern struct oV oVAR[];
693: extern struct oV oPVAR[];
694: extern struct oVL oVLIST[];
695: extern struct oVL oPVLIST[];
696: extern VL CO,ALG;
697: extern VL PVL;
698: extern R ONER;
699: extern Q ONE;
700: extern MQ ONEM;
701: extern LM ONELM;
702: extern N ONEN;
703: extern UP2 ONEUP2;
704:
705: extern FILE *asir_out;
1.7 noro 706: #if defined(__GNUC__)
1.1 noro 707: extern const int sprime[];
708: extern const int lprime[];
709: #else
710: extern int sprime[];
711: extern int lprime[];
712: #endif
713:
714: extern void (*addnumt[])();
715: extern void (*subnumt[])();
716: extern void (*mulnumt[])();
717: extern void (*divnumt[])();
718: extern void (*pwrnumt[])();
719: extern int (*cmpnumt[])();
720: extern void (*chsgnnumt[])();
721:
722: /* prototypes */
723: int compui(VL,USINT,USINT);
1.6 noro 724: int compbytearray(VL,BYTEARRAY,BYTEARRAY);
1.1 noro 725:
726: void powermodup(UP,UP *);
727: void hybrid_powermodup(UP,UP *);
728:
729: void powertabup(UP,UP,UP *);
730: void hybrid_powertabup(UP,UP,UP *);
731:
732: void generic_powermodup(UP,UP,Q,UP *);
733: void hybrid_generic_powermodup(UP,UP,Q,UP *);
734:
735: void powermod1up(UP,UP *);
736: void hybrid_rembymulup_special(int,UP,UP,UP,UP *);
737: void hybrid_tmulup(int,UP,UP,int,UP *);
738: void hybrid_squareup(int,UP,UP *);
739: void hybrid_mulup(int,UP,UP,UP *);
740:
741: void getmod_lm(N *);
742:
743: int maxblenup(UP);
744: void monicup(UP,UP *);
745: void simpup(UP,UP *);
746: void simpnum(Num,Num *);
747: void decompp(P,Q,P *,P *);
748: void truncp(P,Q,P *);
749: void uremp(P,P,P *);
750: void ugcdp(P,P,P *);
751: void reversep(P,Q,P *);
752: void invmodp(P,Q,P *);
753: void addup(UP,UP,UP *);
754: void subup(UP,UP,UP *);
755: void chsgnup(UP,UP *);
756: void mulup(UP,UP,UP *);
757: void tmulup(UP,UP,int,UP *);
758: void squareup(UP,UP *);
759: void remup(UP,UP,UP *);
760: void remup_destructive(UP,UP);
761: void qrup(UP,UP,UP *,UP *);
762: void qrup_destructive(UP,UP);
763: void gcdup(UP,UP,UP *);
764: void reverseup(UP,int,UP *);
765: void invmodup(UP,int,UP *);
766: void pwrup(UP,Q,UP *);
767: void squarep_gf2n(VL,P,P *);
768: void kmulp(VL,P,P,P *);
769: void ksquarep(VL,P,P *);
770: void kmulup(UP,UP,UP *);
771: void ksquareup(UP,UP *);
772: void extractup(UP,int,int,UP *);
773: void copyup(UP,UP);
774: void c_copyup(UP,int,pointer *);
775: void kmulupmain(UP,UP,UP *);
776: void ksquareupmain(UP,UP *);
777: void rembymulup(UP,UP,UP *);
778: void rembymulup_special(UP,UP,UP,UP *);
779: void tkmulup(UP,UP,int,UP *);
780: void shiftup(UP,int,UP *);
781: void set_degreeup(UP,int);
782: void decompup(UP,int,UP *,UP *);
783: void truncup(UP,int,UP *);
784: void uptofmarray(int,UP,ModNum *);
785: void fmarraytoup(ModNum *,int,UP *);
786: void uiarraytoup(unsigned int **,int,int,UP *);
787: void adj_coefup(UP,N,N,UP *);
788: void uptolmup(UP,UP *);
789: void remcup(UP,N,UP *);
790: void fft_mulup(UP,UP,UP *);
791: void fft_squareup(UP,UP *);
792: void trunc_fft_mulup(UP,UP,int,UP *);
793: void shoup_fft_mulup(UP,UP,UP *);
794: void shoup_fft_squareup(UP,UP *);
795: void shoup_trunc_fft_mulup(UP,UP,int,UP *);
796: void crup(ModNum **,int,int *,int,N,UP *);
797: void shoup_crup(ModNum **,int,int *,int,N,N,UP *);
798: void squareup_gf2n(UP,UP *);
799: void powermodup_gf2n(UP,UP *);
800: void generic_powermodup_gf2n(UP,UP,Q,UP *);
801: void tracemodup_gf2n(UP,UP,Q,UP *);
802: void tracemodup_gf2n_slow(UP,UP,Q,UP *);
803: void tracemodup_gf2n_tab(UP,UP,Q,UP *);
804: void square_rem_tab_up_gf2n(UP,UP *,UP *);
805: void powertabup_gf2n(UP,UP,UP *);
806: void find_root_gf2n(UP,GF2N *);
807:
808: int cmpdl_matrix(int,DL,DL);
809: int cmpdl_order_pair(int,DL,DL);
810: int cmpdl_elim(int,DL,DL);
811: int cmpdl_blexrev(int,DL,DL);
812: int cmpdl_bgradrev(int,DL,DL);
813: int cmpdl_brevrev(int,DL,DL);
814: int cmpdl_brevgradlex(int,DL,DL);
815: int cmpdl_bgradlex(int,DL,DL);
816: int cmpdl_blex(int,DL,DL);
817: int cmpdl_revgradlex(int,DL,DL);
818: int cmpdl_gradlex(int,DL,DL);
819: int cmpdl_revlex(int,DL,DL);
820: int cmpdl_lex(int,DL,DL);
821: int compd(VL,DP,DP);
822: void adddl(int,DL,DL,DL *);
823: void divsdc(VL,DP,P,DP *);
824: void muldc(VL,DP,P,DP *);
825: void muldm(VL,DP,MP,DP *);
826: void muld(VL,DP,DP,DP *);
827: void chsgnd(DP,DP *);
828: void subd(VL,DP,DP,DP *);
829: void addd(VL,DP,DP,DP *);
830: int sugard(MP);
831: void nodetod(NODE,DP *);
832: void dtop(VL,VL,DP,P *);
833: void ptod(VL,VL,P,DP *);
834: void initd(struct order_spec *);
835:
836: void _printdp(DP);
837: void _dp_sp_mod(DP,DP,int,DP *);
838: void _dp_mod(DP,int,NODE,DP *);
839: void _dp_red_mod(DP,DP,int,DP *);
840: void _dtop_mod(VL,VL,DP,P *);
841: void _mulmdm(VL,int,DP,MP,DP *);
842: void _mulmd(VL,int,DP,DP,DP *);
843: void _chsgnmd(int,DP,DP *);
844: void _submd(VL,int,DP,DP,DP *);
845: void _addmd(VL,int,DP,DP,DP *);
846: void _mdtop(VL,int,VL,DP,P *);
847: void divsmdc(VL,int,DP,P,DP *);
848: void mulmdc(VL,int,DP,P,DP *);
849: void mulmdm(VL,int,DP,MP,DP *);
850: void mulmd(VL,int,DP,DP,DP *);
851: void chsgnmd(int,DP,DP *);
852: void submd(VL,int,DP,DP,DP *);
853: void addmd(VL,int,DP,DP,DP *);
854: void mdtop(VL,int,VL,DP,P *);
855: void mptomd(VL,int,VL,P,DP *);
856: void ptomd(VL,int,VL,P,DP *);
857: int p_mag(P);
858: int n_bits(N);
859: void gcdBinary_27n(N,N,N *);
860: void rtime_init(void);
861: void setmod_gf2n(P);
862: void mt_sgenrand(unsigned long);
863: unsigned long mt_genrand(void);
864: #if defined(VISUAL)
865: void srandom(unsigned int);
866: unsigned int random(void);
867: #endif
868: void gcdbmodn(N,N,N *);
869: void gcdbinn(N,N,N *);
870: void gcdmodn(N,N,N *);
871: void gcdaccn(N,N,N *);
872: void gcdEuclidn(N,N,N *);
873: void GC_free(void *);
874: void FFT_primes(int,int *,int *,int *);
875: int FFT_pol_product(unsigned int,unsigned int *, unsigned int,unsigned int *,
876: unsigned int *,int,unsigned int *);
877: int FFT_pol_square(unsigned int,unsigned int *,
878: unsigned int *,int,unsigned int *);
879: void dcptolist(DCP,LIST *);
880: void gcdprsmp(VL,int,P,P,P *);
881: void mult_mod_tab(UM,int,UM *,UM,int);
882: int nfctr_mod(UM,int);
883: int irred_check(UM,int);
884: void modfctrp(P,int,int,DCP *);
885: void pf_init(void);
886: void binaryton(char *,N *);
887: void hexton(char *,N *);
888: void ptolmp(P,P *);
889: void lmptop(P,P *);
890: void ulmptoum(int,UP,UM);
891: void objtobobj(int,Obj,Obj *);
892: void bobjtoobj(int,Obj,Obj *);
893: void numtobnum(int,Num,Num *);
894: void bnumtonum(int,Num,Num *);
895: void ptobp(int,P,P *);
896: void bptop(int,P,P *);
897: void listtoblist(int,LIST,LIST *);
898: void blisttolist(int,LIST,LIST *);
899: void vecttobvect(int,VECT,VECT *);
900: void bvecttovect(int,VECT,VECT *);
901: void mattobmat(int,MAT,MAT *);
902: void bmattomat(int,MAT,MAT *);
903: void n32ton27(N,N *);
904: void n27ton32(N,N *);
905: void kmulum(int,UM,UM,UM);
906: void saveobj(FILE *,Obj);
907: void endian_init(void);
908: void write_char(FILE *,unsigned char *);
909: void write_short(FILE *,unsigned short *);
910: void write_int(FILE *,unsigned int *);
911: void write_double(FILE *,double *);
912: void write_intarray(FILE *,unsigned int *,int);
913: void write_string(FILE *,unsigned char *,int);
914: void savestr(FILE *,char *);
915: void loadstr(FILE *,char **);
916: void savevl(FILE *,VL);
917: void loadvl(FILE *);
918: void skipvl(FILE *);
919: void savev(FILE *,V);
920: void loadv(FILE *,V *);
921: int save_convv(V);
922: V load_convv(int);
923: void swap_bytes(char *,int,int);
924: void read_char(FILE *,unsigned char *);
925: void read_short(FILE *,unsigned short *);
926: void read_int(FILE *,unsigned int *);
927: void read_double(FILE *,double *);
928: void read_intarray(FILE *,unsigned int *,int);
929: void read_string(FILE *,unsigned char *,int);
930: void loadobj(FILE *,Obj *);
931: void invum(int,UM,UM,UM);
932: void addarray_to(unsigned int *,int,unsigned int *,int);
933: void muln_1(unsigned int *,int,unsigned int,unsigned int *);
934: unsigned int divn_1(unsigned int *,int,unsigned int,unsigned int *);
935: void ptoup(P,UP *);
936: void uptop(UP,P *);
937: void printnum(Num);
938: void printv(VL,V);
939: void kmulq(Q,Q,Q *);
940: void bshiftn(N,int,N *);
941: void remn(N,N,N*);
942: void simplm(LM,LM *);
943: void qtolm(Q,LM *);
944: int qpcheck(Obj);
945: int headsgn(P);
946: void adjsgn(P,DCP);
947: void setmod_g2n(P);
948: void simpgf2n(GF2N,GF2N *);
949: void ptogf2n(Obj,GF2N *);
950: void gf2ntop(GF2N,P *);
951: void gf2ntovect(GF2N,VECT *);
952: void squaregf2n(GF2N,GF2N *);
953: void randomgf2n(GF2N *);
954: void invgf2n(GF2N,GF2N *);
955: void kmuln(N,N,N *);
956: void extractn(N,int,int,N *);
957: void copyn(N,int,int *);
958: void kmulnmain(N,N,N *);
959: int qcoefp(Obj);
960: int qcoefr(Obj);
961: int get_allocwords(void);
962: double get_clock(void);
963: void get_eg(struct oEGT *);
964: void printtime(struct oEGT *,struct oEGT *,double);
965: void init_eg(struct oEGT *);
966: void add_eg(struct oEGT *,struct oEGT *,struct oEGT *);
967: void print_eg(char *,struct oEGT *);
968: void print_split_eg(struct oEGT *,struct oEGT *);
969: void print_split_e(struct oEGT *,struct oEGT *);
970: void suspend_timer(void);
971: void resume_timer(void);
972: void reset_engine(void);
973: void notdef(VL,Obj,Obj,Obj *);
974: void error(char *);
975: void ptoup2(P,UP2 *);
976: void ptoup2_sparse(P,UP2 *);
977: void up2top(UP2,P *);
978: void up2tovect(UP2,VECT *);
979: void up2ton(UP2,Q *);
980: void ntoup2(Q,UP2 *);
981: void gen_simpup2(UP2,GEN_UP2,UP2 *);
982: void gen_simpup2_destructive(UP2,GEN_UP2);
983: void gen_invup2(UP2,GEN_UP2,UP2 *);
984: void gen_pwrmodup2(UP2,Q,GEN_UP2,UP2 *);
985: void simpup2(UP2,UP2,UP2 *);
986: int degup2(UP2);
987: int degup2_sparse(UP2);
988: int degup2_1(unsigned int);
989: void addup2(UP2,UP2,UP2 *);
990: void subup2(UP2,UP2,UP2 *);
991: void mulup2_n1(unsigned int *,int,unsigned int,unsigned int *);
992: void mulup2_nh(unsigned int *,int,unsigned int,unsigned int *);
993: void _mulup2_1(UP2,unsigned int,UP2);
994: void _mulup2_h(UP2,unsigned int,UP2);
995: void mulup2(UP2,UP2,UP2 *);
996: void _kmulup2_(unsigned int *,unsigned int *,int,unsigned int *);
997: void _mulup2_nn(unsigned int *,unsigned int *,int,unsigned int *);
998: void _mulup2(UP2,UP2,UP2);
999: void _mulup2_(_UP2,_UP2,_UP2);
1000: void squareup2(UP2,UP2 *);
1001: void _adjup2(UP2);
1002: void _adjup2_(_UP2);
1003: void _addup2(UP2,UP2,UP2);
1004: void _addup2_destructive(UP2,UP2);
1005: void _addup2_(_UP2,_UP2,_UP2);
1006: void _addtoup2_(_UP2,_UP2);
1007: unsigned int mulup2_bb(unsigned int,unsigned int);
1008: void init_up2_tab(void);
1009: unsigned int quoup2_11(unsigned int,unsigned int);
1010: void divup2_1(unsigned int,unsigned int,int,int,unsigned int *,unsigned int *);
1011: void qrup2(UP2,UP2,UP2 *,UP2 *);
1012: void _qrup2(UP2,UP2,UP2,UP2);
1013: void remup2(UP2,UP2,UP2 *);
1014: void _remup2(UP2,UP2,UP2);
1015: void remup2_sparse(UP2,UP2,UP2 *);
1016: void remup2_sparse_destructive(UP2,UP2);
1017: void remup2_type1_destructive(UP2,int);
1018: void remup2_3_destructive(UP2,UP2);
1019: void remup2_5_destructive(UP2,UP2);
1020: void _invup2_1(unsigned int,unsigned int,unsigned int *,unsigned int *);
1021: void _gcdup2_1(unsigned int,unsigned int,unsigned int *);
1022: void up2_init_eg(void);
1023: void up2_show_eg(void);
1024: void invup2(UP2,UP2,UP2 *);
1025: void gcdup2(UP2,UP2,UP2 *);
1026: void chsgnup2(UP2,UP2 *);
1027: void pwrmodup2(UP2,Q,UP2,UP2 *);
1028: void pwrmodup2_sparse(UP2,Q,UP2,UP2 *);
1029: int compup2(UP2,UP2);
1030: void printup2(UP2);
1031: void _copyup2(UP2,UP2);
1032: void _bshiftup2(UP2,int,UP2);
1033: void _bshiftup2_destructive(UP2,int);
1034: void diffup2(UP2,UP2 *);
1035: int sqfrcheckup2(UP2);
1036: int irredcheckup2(UP2);
1037: int irredcheck_dddup2(UP2);
1038: void _copy_up2bits(UP2,unsigned int **,int);
1039: void _print_frobmat(unsigned int **,int,int);
1040: int compute_multiplication_matrix(P,GF2MAT *);
1041: void compute_change_of_basis_matrix(P,P,int,GF2MAT *,GF2MAT *);
1042: int compute_representation_conversion_matrix(P,GF2MAT *,GF2MAT *);
1043: void mul_nb(GF2MAT,unsigned int *,unsigned int *,unsigned int *);
1044: void leftshift(unsigned int *,int);
1045: void mat_to_gf2mat(MAT,unsigned int ***);
1046: void gf2mat_to_mat(unsigned int **,int,MAT *);
1047: void mulgf2mat(int,unsigned int **,unsigned int **,unsigned int **);
1048: void mulgf2vectmat(int,unsigned int *,unsigned int **,unsigned int *);
1049: int mulgf2vectvect(int,unsigned int *,unsigned int *);
1050: int invgf2mat(int,unsigned int **,unsigned int **);
1051: void _mulup2_11(unsigned int,unsigned int,unsigned int *);
1052: void _mulup2_22(unsigned int *,unsigned int *,unsigned int *);
1053: void _mulup2_33(unsigned int *,unsigned int *,unsigned int *);
1054: void _mulup2_44(unsigned int *,unsigned int *,unsigned int *);
1055: void _mulup2_55(unsigned int *,unsigned int *,unsigned int *);
1056: void _mulup2_66(unsigned int *,unsigned int *,unsigned int *);
1057: void printup2_(unsigned int *,int);
1058: void type1_bin_invup2(UP2,int,UP2 *);
1059: int int_bits(int);
1060:
1061:
1062: LUM LUMALLOC(int, int);
1063: Obj ToAlg(Num);
1064: UM *berlemain(register int, UM, UM *);
1065: void *Risa_GC_malloc(size_t);
1066: void *Risa_GC_malloc_atomic(size_t);
1067: void *Risa_GC_realloc(void *,size_t);
1068: void *GC_malloc(size_t);
1069: void *GC_malloc_atomic(size_t);
1070: void *GC_realloc(void *,size_t);
1071: double NatToReal(N,int *);
1072: double RatnToReal(Q);
1073: double pwrreal0(double,int);
1.3 noro 1074: double rtodbl(); /* XXX */
1.1 noro 1075: int **almat(int,int);
1076: pointer **almat_pointer(int,int);
1077: int berlecnt(register int,UM);
1078: int berlecntmain(register int,int,int,register int **);
1079: int cmpalg(Num,Num);
1080: int cmpbf(Num,Num);
1081: int cmpcplx(Num,Num);
1082: int cmpn(N,N);
1083: int cmpq(Q,Q);
1084: int cmpreal(Real,Real);
1085: int cmpmi(MQ,MQ);
1086: int cmplm(LM,LM);
1087: int compmat(VL,MAT,MAT);
1088: int compnum(VL,Num,Num);
1089: int compp(VL,P,P);
1090: int compr(VL,Obj,Obj);
1091: int compstr(VL,STRING,STRING);
1092: int compvect(VL,VECT,VECT);
1093: int ctest(P,ML,int,int *);
1094: int cycchk(P);
1095: int dbound(V,P);
1096: int dcomp(P,P);
1097: int deg(V,P);
1098: int degtest(int,int *,ML,int);
1099: int divcheck(VL,P *,int,P,P);
1100: unsigned int divin(N,unsigned int,N *);
1101: int divtdcpz(VL,P,P,P *);
1102: int divtpz(VL,P,P,P *);
1103: int divum(register int,UM,UM,UM);
1104: int dm(int,int,int *);
1105: int dmb(int,int,int,int *);
1106: int dma(int,int,int,int *);
1107: int dmab(int,int,int,int,int *);
1108: int dmar(int,int,int,int);
1109: int dtestmain(P,Q,ML,int,int *,P *,P *);
1110: int geldb(VL,P);
1111: int getchomdeg(V,P);
1112: int getdeg(V,P);
1113: int getlchomdeg(V,P,int *);
1114: int homdeg(P);
1115: unsigned int invm(unsigned int,int);
1116: int iscycm(P);
1117: int iscycp(P);
1118: int lengthp(P);
1119: int mig(int,int,P);
1120: int mignotte(int,P);
1121: int minimain(register int,int,int,register int **);
1122: int ncombi(int,int,int,int *);
1123: int nextbin(VN,int);
1124: int nmonop(P);
1125: int pcoef(VL,VL,P,P *);
1126: int pcoef0(VL,VL,P,P *);
1127: unsigned int pwrm(register int,register int,int);
1128: unsigned int rem(N,unsigned int);
1129: int sqfrchk(P);
1130: int subn(N,N,N *);
1131: int ucmpp(P,P);
1132: int valideval(VL,DCP,VN);
1133: int zerovpchk(VL,P,VN);
1134:
1135: void addgf2n(GF2N,GF2N,GF2N *);
1136: void subgf2n(GF2N,GF2N,GF2N *);
1137: void mulgf2n(GF2N,GF2N,GF2N *);
1138: void divgf2n(GF2N,GF2N,GF2N *);
1139: void chsgngf2n(GF2N,GF2N *);
1140: void pwrgf2n(GF2N,Q, GF2N *);
1141: int cmpgf2n(GF2N,GF2N);
1142:
1143: void addgfpn(GFPN,GFPN,GFPN *);
1144: void subgfpn(GFPN,GFPN,GFPN *);
1145: void mulgfpn(GFPN,GFPN,GFPN *);
1146: void divgfpn(GFPN,GFPN,GFPN *);
1147: void chsgngfpn(GFPN,GFPN *);
1148: void pwrgfpn(GFPN,Q, GFPN *);
1149: int cmpgfpn(GFPN,GFPN);
1150:
1151: void addalg(Num,Num,Num *);
1152: void addbf(Num,Num,Num *);
1153: void addcplx(Num,Num,Num *);
1154: void addm2p(VL,Q,Q,P,P,P *);
1155: void addm2q(Q,Q,Q,Q,Q *);
1156: void addmat(VL,MAT,MAT,MAT *);
1157: void addmp(VL,int,P,P,P *);
1158: void addmpq(int,P,P,P *);
1159: void addmptoc(VL,int,P,P,P *);
1160: void addmq(int,MQ,MQ,MQ *);
1161: void addn(N,N,N *);
1162: void addnum(VL,Num,Num,Num *);
1163: void addp(VL,P,P,P *);
1164: void addpadic(int,int,unsigned int *,unsigned int *);
1165: void addpq(P,P,P *);
1166: void addptoc(VL,P,P,P *);
1167: void addq(Q,Q,Q *);
1168: void addr(VL,Obj,Obj,Obj *);
1169: void addreal(Num,Num,Real *);
1170: void addmi(MQ,MQ,MQ *);
1171: void addlm(LM,LM,LM *);
1172: void addstr(VL,STRING,STRING,STRING *);
1173: void addum(int,UM,UM,UM);
1174: void addvect(VL,VECT,VECT,VECT *);
1175: void adjc(VL,P,P,P,Q,P *,P *);
1176: void afctr(VL,P,P,DCP *);
1177: void afctrmain(VL,P,P,int,DCP *);
1178: void affine(VL,P,VN,P *);
1179: void affinemain(VL,P,V,int,P *,P *);
1180: void berle(int,int,P,ML *);
1181: void bnton(register int,N,N *);
1182: void cbound(VL,P,Q *);
1183: void chnrem(int,V,P,Q,UM,P *,Q *);
1184: void chnremp(VL,int,P,Q,P,P *);
1185: void chsgnalg(Num,Num *);
1186: void chsgnbf(Num a,Num *);
1187: void chsgncplx(Num,Num *);
1188: void chsgnmat(MAT,MAT *);
1189: void chsgnmp(int,P,P *);
1190: void chsgnnum(Num,Num *);
1191: void chsgnp(P,P *);
1192: void chsgnq(Q,Q *);
1193: void chsgnr(Obj,Obj *);
1194: void chsgnreal(Num,Num *);
1195: void chsgnmi(MQ,MQ *);
1196: void chsgnlm(LM,LM *);
1197: void chsgnvect(VECT,VECT *);
1198: void clctv(VL,P,VL *);
1199: void clctvr(VL,Obj,VL *);
1200: void cm2p(Q,Q,P,P *);
1201: void cmax(P,Q *);
1202: void cmp(Q,P,P *);
1203: void coefp(P,int,P *);
1204: void cpylum(int,LUM,LUM);
1205: void cpyum(UM,UM);
1206: void csump(VL,P,Q *);
1207: void cycm(V,register int,DCP *);
1208: void cycp(V,register int,DCP *);
1209: void degp(V,P,Q *);
1210: void degum(UM,int);
1211: void detmp(VL,int,P **,int,P *);
1212: void detp(VL,P **,int,P *);
1213: void diffp(VL,P,V,P *);
1214: void diffum(register int,UM,UM);
1215: void divalg(Num,Num,Num *);
1216: void divbf(Num,Num,Num *);
1217: void divcp(P,Q,P *);
1218: void divcplx(Num,Num,Num *);
1219: void divmat(VL,Obj,Obj,Obj *);
1220: void divmq(int,MQ,MQ,MQ *);
1221: void divn(N,N,N *,N *);
1222: void divnmain(int,int,unsigned int *,unsigned int *,unsigned int *);
1223: void divnum(VL,Num,Num,Num *);
1224: void divq(Q,Q,Q *);
1225: void divr(VL,Obj,Obj,Obj *);
1226: void divreal(Num,Num,Real *);
1227: void divmi(MQ,MQ,MQ *);
1228: void divlm(LM,LM,LM *);
1229: void divsdcmp(VL,int,P,P,P *);
1230: void divsdcp(VL,P,P,P *);
1231: void divsmp(VL,int,P,P,P *);
1232: void divsn(N,N,N *);
1233: void divsp(VL,P,P,P *);
1234: void divsrdcmp(VL,int,P,P,P *,P *);
1235: void divsrdcp(VL,P,P,P *,P *);
1236: void divsrmp(VL,int,P,P,P *,P *);
1237: void divsrp(VL,P,P,P *,P *);
1238: void divvect(VL,Obj,Obj,Obj *);
1239: void dtest(P,ML,int,DCP *);
1240: void dtestroot(int,int,P,LUM,struct oDUM *,DCP *);
1241: void dtestroot1(int,int,P,LUM,P *);
1242: void dtestsq(int,int,P,LUM,P *);
1243: void dtestsql(P,ML,struct oDUM *,DCP *);
1244: void estimatelc(VL,Q,DCP,VN,P *);
1245: void eucum(register int,UM,UM,UM,UM);
1246: void exthp(VL,P,int,P *);
1247: void exthpc(VL,V,P,int,P *);
1248: void ezgcd1p(VL,P,P,P *);
1249: void ezgcdhensel(P,int,UM,UM,ML *);
1250: void ezgcdnp(VL,P,P *,int,P *);
1251: void ezgcdnpp(VL,DCP,P *,int,P *);
1252: void ezgcdnpz(VL,P *,int,P *);
1253: void ezgcdp(VL,P,P,P *);
1254: void ezgcdpp(VL,DCP,P,P *);
1255: void ezgcdpz(VL,P,P,P *);
1256: void factorial(int,Q *);
1257: void fctrp(VL,P,DCP *);
1258: void fctrwithmvp(VL,P,V,DCP *);
1259: void gcda(VL,P,P,P,P *);
1260: void gcdcp(VL,P,P *);
1261: void gcdgen(P,ML,ML *);
1262: void gcdmonomial(VL,DCP *,int,P *);
1263: void gcdn(N,N,N *);
1264: void gcdprsp(VL,P,P,P *);
1265: void gcdum(register int,UM,UM,UM);
1266: void getmindeg(V,P,Q *);
1267: void henmain(LUM,ML,ML,ML *);
1268: void henmv(VL,VN,P,P,P,P,P,P,P,P,P,Q,int,P *,P *);
1269: void henmvmain(VL,VN,P,P,P,P,P,P,P,Q,Q,int,P *,P *);
1270: void henprep(P,ML,ML,ML *,ML *);
1271: void hensel(int,int,P,ML *);
1272: void henzq(P,P,UM,P,UM,int,int,P *,P *,P *,P *,Q *);
1273: void henzq1(P,P,Q,P *,P *,Q *);
1274: void hsq(int,int,P,int *,DCP *);
1275: void intersectv(VL,VL,VL *);
1276: void invl(Q,Q,Q *);
1277: void invmq(int,MQ,MQ *);
1278: void invq(Q,Q *);
1279: void lgp(P,N *,N *);
1280: void lumtop(V,int,int,LUM,P *);
1281: void markv(VN,int,P);
1282: void maxdegp(VL,P,VL *,P *);
1283: void mergev(VL,VL,VL,VL *);
1284: void mfctr(VL,P,DCP *);
1285: void mfctrhen2(VL,VN,P,P,P,P,P,P,P *);
1286: void mfctrmain(VL,P,DCP *);
1287: void mfctrwithmv(VL,P,V,DCP *);
1288: void min_common_vars_in_coefp(VL,P,VL *,P *);
1289: void minchdegp(VL,P,VL *,P *);
1290: void mindegp(VL,P,VL *,P *);
1291: void mini(register int,UM,UM);
1292: void minlcdegp(VL,P,VL *,P *);
1293: void mkbc(int,Q *);
1294: void mkbcm(int,int,MQ *);
1295: void mkssum(V,int,int,int,P *);
1296: void monomialfctr(VL,P,P *,DCP *);
1297: void mptop(P,P *);
1298: void mptoum(P,UM);
1299: void msqfr(VL,P,DCP *);
1300: void msqfrmain(VL,P,DCP *);
1301: void msqfrmainmain(VL,P,VN,P,DCP,DCP *,P *);
1302: void mulalg(Num,Num,Num *);
1303: void mulbf(Num,Num,Num *);
1304: void mulcplx(Num,Num,Num *);
1305: void mulin(N,unsigned int,unsigned int *);
1306: void mullum(int,int,LUM,LUM,LUM);
1307: void mullumarray(P,ML,int,int *,P *);
1308: void mulm2p(VL,Q,Q,P,P,P *);
1309: void mulm2q(Q,Q,Q,Q,Q *);
1310: void mulmat(VL,Obj,Obj,Obj *);
1311: void mulmatmat(VL,MAT,MAT,MAT *);
1312: void mulmatvect(VL,MAT,VECT,VECT *);
1313: void mulmp(VL,int,P,P,P *);
1314: void mulmpc(VL,int,P,P,P *);
1315: void mulmpq(int,P,P,P *);
1316: void mulmq(int,MQ,MQ,MQ *);
1317: void muln(N,N,N *);
1318: void mulnum(VL,Num,Num,Num *);
1319: void mulp(VL,P,P,P *);
1320: void mulpadic(int,int,unsigned int *,unsigned int *,unsigned int *);
1321: void mulpc(VL,P,P,P *);
1322: void mulpq(P,P,P *);
1323: void mulq(Q,Q,Q *);
1324: void mulr(VL,Obj,Obj,Obj *);
1325: void mulreal(Num,Num,Real *);
1326: void mulmi(MQ,MQ,MQ *);
1327: void mullm(LM,LM,LM *);
1328: void mulrmat(VL,Obj,MAT,MAT *);
1329: void mulrvect(VL,Obj,VECT,VECT *);
1330: void mulsgn(VN,VN,int,VN);
1331: void mulsum(register int,UM,register int,UM);
1332: void mulum(register int,UM,UM,UM);
1333: void mulvect(VL,Obj,Obj,Obj *);
1334: void mulvectmat(VL,VECT,MAT,VECT *);
1335: void next(VN);
1336: void nezgcdnp_sqfr_primitive(VL,P,P *,int,P *);
1337: void nezgcdnpp(VL,DCP,P *,int,P *);
1338: void nezgcdnpz(VL,P *,int,P *);
1339: void nezgcdnpzmain(VL,P *,int,P *);
1340: void nglob_init(void);
1341: void norm(P,Q *);
1342: void norm1(P,P *);
1343: void norm1c(P,Q *);
1344: void normalizemp(int,P);
1345: void nthrootchk(P,struct oDUM *,ML,DCP *);
1346: void nthrootn(N,int,N *);
1347: void ntobn(register int,N,N *);
1348: void nuezgcdnpzmain(VL,P *,int,P *);
1349: void padictoq(int,int,int *,Q *);
1350: void risa_pari_init(void);
1351: void pcp(VL,P,P *,P *);
1352: void pderivr(VL,Obj,V,Obj *);
1353: void pdiva(VL,P,P,P,P *);
1354: void pinva(P,P,P *);
1355: void plisttop(P *,V,int,P *);
1356: void pmonic(VL,P,P,P *);
1357: void pqra(VL,P,P,P,P *,P *);
1358: void premmp(VL,int,P,P,P *);
1359: void premp(VL,P,P,P *);
1360: void ptolum(int,int,P,LUM);
1361: void ptomp(int,P,P *);
1362: void ptoum(int,P,UM);
1363: void ptozp(P,int,Q *,P *);
1364: void ptozp0(P,P *);
1365: void pwralg(Num,Num,Num *);
1366: void pwrbf(Num,Num,Num *);
1367: void pwrcplx(Num,Num,Num *);
1368: void pwrcplx0(Num,int,Num *);
1369: void pwrlum(int,int,LUM,int,LUM);
1370: void pwrmat(VL,MAT,Obj,MAT *);
1371: void pwrmatmain(VL,MAT,int,MAT *);
1372: void pwrmp(VL,int,P,Q,P *);
1373: void pwrmq(int,MQ,Q,MQ *);
1374: void pwrn(N,int,N *);
1375: void pwrnum(VL,Num,Num,Num *);
1376: void pwrp(VL,P,Q,P *);
1377: void pwrq(Q,Q,Q *);
1378: void pwrr(VL,Obj,Obj,Obj *);
1379: void pwrreal(Num,Num,Real *);
1380: void pwrmi(MQ,Q,MQ *);
1381: void pwrlm(LM,Q,LM *);
1382: void pwrum(int,UM,int,UM);
1383: void reallocarray(char **,int *,int *,int);
1384: void reductr(VL,Obj,Obj *);
1385: void reimtocplx(Num,Num,Num *);
1386: void rem2q(Q,Q,Q,Q *);
1387: void rema(VL,P,P,P,P *);
1388: void remq(Q,Q,Q *);
1389: void remsdcp(VL,P,P,P *);
1390: void reordermp(VL,int,VL,P,P *);
1391: void reorderp(VL,VL,P,P *);
1392: void reordvar(VL,V,VL *);
1393: void res_ch_det(VL,V,P,P,P *);
1394: void res_detmp(VL,int,V,P,P,P *);
1395: void restore(VL,P,VN,P *);
1396: void resultmp(VL,int,V,P,P,P *);
1397: void resultp(VL,V,P,P,P *);
1398: void setlum(int,int,LUM);
1399: void sort_by_deg(int,P *,P *);
1400: void sort_by_deg_rev(int,P *,P *);
1401: void sortfs(DCP *);
1402: void sortfsrev(DCP *);
1403: void sortplist(P *,int);
1404: void sortplistbyhomdeg(P *,int);
1405: void sprs(VL,V,P,P,P *);
1406: void sqa(VL,P,P,DCP *);
1407: void sqad(unsigned int,int);
1408: void sqfrp(VL,P,DCP *);
1409: void sqfrum(int,int,P,int *,struct oDUM **,ML *);
1410: void sqfrummain(int,UM,UM,struct oDUM **);
1411: void sqrtn(N,N *);
1412: void srch2(VL,V,P,P,P *);
1413: void srchmp(VL,int,V,P,P,P *);
1414: void srchump(int,P,P,P *);
1415: void srcr(VL,V,P,P,P *);
1416: void strtobf(char *,BF *);
1417: void subalg(Num,Num,Num *);
1418: void subbf(Num,Num,Num *);
1419: void subcplx(Num,Num,Num *);
1420: void subm2p(VL,Q,Q,P,P,P *);
1421: void subm2q(Q,Q,Q,Q,Q *);
1422: void submat(VL,MAT,MAT,MAT *);
1423: void submp(VL,int,P,P,P *);
1424: void submq(int,MQ,MQ,MQ *);
1425: void subnum(VL,Num,Num,Num *);
1426: void subp(VL,P,P,P *);
1427: void subq(Q,Q,Q *);
1428: void subr(VL,Obj,Obj,Obj *);
1429: void subreal(Num,Num,Real *);
1430: void submi(MQ,MQ,MQ *);
1431: void sublm(LM,LM,LM *);
1432: void substmp(VL,int,P,V,P,P *);
1433: void substp(VL,P,V,P,P *);
1434: void substvp(VL,P,VN,P *);
1435: void subum(int,UM,UM,UM);
1436: void subvect(VL,VECT,VECT,VECT *);
1437: void toreim(Num,Num *,Num *);
1438: void ucsump(P,Q *);
1439: void udivpwm(Q,P,P,P *,P *);
1440: void udivpz(P,P,P *,P *);
1441: void udivpzwm(Q,P,P,P *,P *);
1442: void uexgcdnp(VL,P,P *,int,VN,Q,P *,P *,P *,P *,Q *);
1443: void uezgcd1p(P,P,P *);
1444: void uezgcdpp(DCP,P,P *);
1445: void uezgcdpz(VL,P,P,P *);
1446: void ufctr(P,int,DCP *);
1447: void ufctrmain(P,int,DCP *);
1448: void umtomp(V,UM,P *);
1449: void umtop(V,UM,P *);
1450: void usqp(P,DCP *);
1451: void vntovl(VN,int,VL *);
1452:
1453: #if 0 && !defined(VISUAL)
1454: void bzero(const void *,int);
1455: void bcopy(const void *,void *,int);
1456: char *index(char *,int);
1457: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>