Annotation of OpenXM_contrib2/asir2000/include/ca.h, Revision 1.9
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.9 ! noro 48: * $OpenXM: OpenXM_contrib2/asir2000/include/ca.h,v 1.8 2000/12/05 06:59:17 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)))
1.9 ! noro 554: #define NEWDL_NOINIT(d,n) \
! 555: ((d)=(DL)MALLOC_ATOMIC(TRUESIZE(oDL,(n)-1,int)))
1.1 noro 556:
557: #define MKP(v,dc,p) \
558: (!DEG(dc)?((p)=COEF(dc)):(NEWP(p),VR(p)=(v),DC(p)=(dc),(p)))
559: #define MKV(v,p) \
560: (NEWP(p),VR(p)=(v),NEWDC(DC(p)),\
561: DEG(DC(p))=ONE,COEF(DC(p))=(P)ONE,NEXT(DC(p))=0)
562: #define MKRAT(n,d,r,p) \
563: (NEWR(p),NM(p)=(n),DN(p)=(d),(p)->reduced=(r))
564: #define MKMV(v,p) \
565: (NEWP(p),VR(p)=(v),NEWDC(DC(p)),\
566: DEG(DC(p))=ONE,COEF(DC(p))=(P)ONEM,NEXT(DC(p))=0)
567: #define MKNODE(a,b,c) \
568: (NEWNODE(a),(a)->body=(pointer)b,NEXT(a)=(NODE)(c))
569: #define MKLIST(a,b) (NEWLIST(a),(a)->body=(NODE)(b))
570: #define MKVECT(m,l) \
571: (NEWVECT(m),(m)->len=(l),(m)->body=(pointer *)CALLOC((l),sizeof(pointer)))
572: #define MKMAT(m,r,c) \
573: (NEWMAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(pointer **)almat_pointer((r),(c)))
574: #define TOGF2MAT(r,c,b,m) (NEWGF2MAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(b))
575: #define TOGFMMAT(r,c,b,m) (NEWGFMMAT(m),(m)->row=(r),(m)->col=(c),(m)->body=(b))
576: #define MKSTR(a,b) (NEWSTR(a),(a)->body=(char *)(b))
577: #define MKDP(n,m,d) (NEWDP(d),(d)->nv=(n),BDY(d)=(m))
578: #define MKLM(b,l) (!(b)?(l)=0:(NEWLM(l),(l)->body=(b),(l)))
579: #define MKGF2N(b,l) (!(b)?(l)=0:(NEWGF2N(l),(l)->body=(b),(l)))
580: #define MKGFPN(b,l) (!(b)?(l)=0:(NEWGFPN(l),(l)->body=(b),(l)))
581: #define MKUSINT(u,b) (NEWUSINT(u),(u)->body=(unsigned)(b))
582: #define MKERR(e,b) (NEWERR(e),(e)->body=(Obj)(b))
583: #define MKMATHCAP(e,b) (NEWMATHCAP(e),(e)->body=(LIST)(b))
1.6 noro 584: #define MKBYTEARRAY(m,l) \
585: (NEWBYTEARRAY(m),(m)->len=(l),(m)->body=(char *)MALLOC_ATOMIC((l)),bzero((m)->body,(l)))
1.1 noro 586:
587: #define NEXTDC(r,c) \
588: if(!(r)){NEWDC(r);(c)=(r);}else{NEWDC(NEXT(c));(c)=NEXT(c);}
589: #define NEXTNODE(r,c) \
590: if(!(r)){NEWNODE(r);(c)=(r);}else{NEWNODE(NEXT(c));(c)=NEXT(c);}
591: #define NEXTMP(r,c) \
592: if(!(r)){NEWMP(r);(c)=(r);}else{NEWMP(NEXT(c));(c)=NEXT(c);}
1.9 ! noro 593: #define NEXTMP2(r,c,s) \
! 594: if(!(r)){(c)=(r)=(s);}else{NEXT(c)=(s);(c)=(s);}
1.1 noro 595:
596: /* convertors */
597: #define NTOQ(n,s,q) \
598: (!(n)?((q)=0):(NEWQ(q),SGN(q)=(s),NM(q)=(n),DN(q)=0,(q)))
599: #define NDTOQ(n,d,s,q) \
600: ((!(d)||UNIN(d))?NTOQ(n,s,q):(NEWQ(q),SGN(q)=(s),NM(q)=(n),DN(q)=(d),(q)))
601: #define DUPQ(p,q) \
602: (NEWQ(q),SGN(q)=SGN(p),NM(q)=NM(p),DN(q)=DN(p))
603: #define STOQ(n,q) \
604: ((!(n))?((q)=(Q)NULL):(NEWQ(q),\
605: SGN(q)=((n)>0?1:-1),NM(q)=NALLOC(1),\
606: PL(NM(q))=1,BD(NM(q))[0]=ABS(n),DN(q)=0,(q)))
607: #define UTOMQ(a,b) \
608: ((a)?(NEWMQ(b),CONT(b)=(unsigned int)(a),(b)):((b)=0))
609: #define STOMQ(a,b) \
610: ((a)?(NEWMQ(b),CONT(b)=(a),(b)):((b)=0))
611: #define UTON(u,n) \
612: ((!(u))?((n)=(N)NULL):((n)=NALLOC(1),PL(n)=1,BD(n)[0]=(unsigned int)(u),(n)))
613: #define UTOQ(n,q) \
614: ((!(n))?((q)=(Q)NULL):(NEWQ(q),\
615: SGN(q)=1,NM(q)=NALLOC(1),\
616: PL(NM(q))=1,BD(NM(q))[0]=(unsigned int)(n),DN(q)=0,(q)))
617: #define QTOS(q) (!(q)?0:SGN(q)*((int)BD(NM(q))[0]))
618: #define STON(i,n)\
619: (i?((n)=NALLOC(1),PL(n)=1,BD(n)[0]=(i),(n)):((n)=(N)0))
620: #define PTOR(a,b) \
621: (!(a)?((b)=0):(NEWR(b),NM(b)=(a),DN(b)=(P)ONE,(b)->reduced=1,(b)))
622: #define RTOS(a) (!(a)?0:QTOS((Q)NM((R)a)))
623: #define MKReal(a,b) (!(a)?((b)=0):(NEWReal(b),BDY(b)=(a),(b)))
624: #define MKAlg(b,r) \
625: (!(b)?((r)=0):NUM(b)?((r)=(Alg)(b)):(NEWAlg(r),BDY(r)=(Obj)(b),(r)))
626:
1.3 noro 627: #if PARI
628: #define ToReal(a) (!(a)?(double)0.0:REAL(a)?BDY((Real)a):RATN(a)?RatnToReal((Q)a):BIGFLOAT(a)?rtodbl(BDY((BF)a)):0)
629: #else
630: #define ToReal(a) (!(a)?(double)0.0:REAL(a)?BDY((Real)a):RATN(a)?RatnToReal((Q)a):0.0)
631: #endif
1.1 noro 632:
633: /* predicates */
634: #define NUM(p) (OID(p)==O_N)
635: #define RAT(p) (OID(p)==O_R)
636: #define INT(q) (!DN((Q)q))
637: #define RATN(a) (NID(a)==N_Q)
638: #define REAL(a) (NID(a)==N_R)
1.3 noro 639: #define BIGFLOAT(a) (NID(a)==N_B)
1.1 noro 640: #define SFF(a) (NID(a)==N_M)
641: #define UNIQ(q) ((q)&&NUM(q)&&RATN(q)&&(SGN((Q)q)==1)&&UNIN(NM((Q)q))&&(!DN((Q)q)))
642: #define UNIMQ(q) ((q)&&NUM(q)&&SFF(q)&&(CONT((MQ)q)==1))
643: #define MUNIQ(q) ((q)&&NUM(q)&&RATN(q)&&(SGN((Q)q)==-1)&&UNIN(NM((Q)q))&&(!DN((Q)q)))
644: #define MUNIMQ(q) ((q)&&NUM(q)&&SFF(q)&&(CONT((MQ)q)==-1))
645: #define UNIN(n) ((n)&&(PL(n)==1)&&(BD(n)[0]==1))
646: #define EVENN(n) ((!(n))||(!(BD(n)[0]%2)))
647:
1.8 noro 648: /* special macros for private memory management */
649:
650: #define NV(p) ((p)->nv)
651: #define C(p) ((p)->c)
652: #define ITOS(p) (((unsigned int)(p))&0x7fffffff)
653: #define STOI(i) ((P)((unsigned int)(i)|0x80000000))
654:
655: struct cdl {
656: P c;
657: DL d;
658: };
659:
660: struct cdlm {
661: int c;
662: DL d;
663: };
664:
665: extern MP _mp_free_list;
666: extern DP _dp_free_list;
667: extern DL _dl_free_list;
668: extern int current_dl_length;
669:
670: #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)
671: #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)))
672: #define _NEWMP(m) if(!_mp_free_list)_MP_alloc(); (m)=_mp_free_list; _mp_free_list = NEXT(_mp_free_list)
673: #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)
674:
675: #define _NEXTMP(r,c) \
676: if(!(r)){_NEWMP(r);(c)=(r);}else{_NEWMP(NEXT(c));(c)=NEXT(c);}
677:
678: #define _NEXTMP2(r,c,s) \
679: if(!(r)){(c)=(r)=(s);}else{NEXT(c)=(s);(c)=(s);}
680:
681: #define _FREEDL(m) *((DL *)m)=_dl_free_list; _dl_free_list=(m)
682: #define _FREEMP(m) NEXT(m)=_mp_free_list; _mp_free_list=(m)
683: #define _FREEDP(m) BDY(m)=(MP)_dp_free_list; _dp_free_list=(m)
1.1 noro 684:
685: /* externals */
686: #if 0
687: double NatToReal();
688: double RatnToReal();
689: #endif
690:
691: extern struct oR oUNIR;
692: extern struct oQ oUNIQ;
693: extern struct oMQ oUNIMQ;
694: extern struct oN oUNIN;
695: extern struct oUP2 oONEUP2;
696: extern struct oV oVAR[];
697: extern struct oV oPVAR[];
698: extern struct oVL oVLIST[];
699: extern struct oVL oPVLIST[];
700: extern VL CO,ALG;
701: extern VL PVL;
702: extern R ONER;
703: extern Q ONE;
704: extern MQ ONEM;
705: extern LM ONELM;
706: extern N ONEN;
707: extern UP2 ONEUP2;
708:
709: extern FILE *asir_out;
1.7 noro 710: #if defined(__GNUC__)
1.1 noro 711: extern const int sprime[];
712: extern const int lprime[];
713: #else
714: extern int sprime[];
715: extern int lprime[];
716: #endif
717:
718: extern void (*addnumt[])();
719: extern void (*subnumt[])();
720: extern void (*mulnumt[])();
721: extern void (*divnumt[])();
722: extern void (*pwrnumt[])();
723: extern int (*cmpnumt[])();
724: extern void (*chsgnnumt[])();
725:
726: /* prototypes */
727: int compui(VL,USINT,USINT);
1.6 noro 728: int compbytearray(VL,BYTEARRAY,BYTEARRAY);
1.1 noro 729:
730: void powermodup(UP,UP *);
731: void hybrid_powermodup(UP,UP *);
732:
733: void powertabup(UP,UP,UP *);
734: void hybrid_powertabup(UP,UP,UP *);
735:
736: void generic_powermodup(UP,UP,Q,UP *);
737: void hybrid_generic_powermodup(UP,UP,Q,UP *);
738:
739: void powermod1up(UP,UP *);
740: void hybrid_rembymulup_special(int,UP,UP,UP,UP *);
741: void hybrid_tmulup(int,UP,UP,int,UP *);
742: void hybrid_squareup(int,UP,UP *);
743: void hybrid_mulup(int,UP,UP,UP *);
744:
745: void getmod_lm(N *);
746:
747: int maxblenup(UP);
748: void monicup(UP,UP *);
749: void simpup(UP,UP *);
750: void simpnum(Num,Num *);
751: void decompp(P,Q,P *,P *);
752: void truncp(P,Q,P *);
753: void uremp(P,P,P *);
754: void ugcdp(P,P,P *);
755: void reversep(P,Q,P *);
756: void invmodp(P,Q,P *);
757: void addup(UP,UP,UP *);
758: void subup(UP,UP,UP *);
759: void chsgnup(UP,UP *);
760: void mulup(UP,UP,UP *);
761: void tmulup(UP,UP,int,UP *);
762: void squareup(UP,UP *);
763: void remup(UP,UP,UP *);
764: void remup_destructive(UP,UP);
765: void qrup(UP,UP,UP *,UP *);
766: void qrup_destructive(UP,UP);
767: void gcdup(UP,UP,UP *);
768: void reverseup(UP,int,UP *);
769: void invmodup(UP,int,UP *);
770: void pwrup(UP,Q,UP *);
771: void squarep_gf2n(VL,P,P *);
772: void kmulp(VL,P,P,P *);
773: void ksquarep(VL,P,P *);
774: void kmulup(UP,UP,UP *);
775: void ksquareup(UP,UP *);
776: void extractup(UP,int,int,UP *);
777: void copyup(UP,UP);
778: void c_copyup(UP,int,pointer *);
779: void kmulupmain(UP,UP,UP *);
780: void ksquareupmain(UP,UP *);
781: void rembymulup(UP,UP,UP *);
782: void rembymulup_special(UP,UP,UP,UP *);
783: void tkmulup(UP,UP,int,UP *);
784: void shiftup(UP,int,UP *);
785: void set_degreeup(UP,int);
786: void decompup(UP,int,UP *,UP *);
787: void truncup(UP,int,UP *);
788: void uptofmarray(int,UP,ModNum *);
789: void fmarraytoup(ModNum *,int,UP *);
790: void uiarraytoup(unsigned int **,int,int,UP *);
791: void adj_coefup(UP,N,N,UP *);
792: void uptolmup(UP,UP *);
793: void remcup(UP,N,UP *);
794: void fft_mulup(UP,UP,UP *);
795: void fft_squareup(UP,UP *);
796: void trunc_fft_mulup(UP,UP,int,UP *);
797: void shoup_fft_mulup(UP,UP,UP *);
798: void shoup_fft_squareup(UP,UP *);
799: void shoup_trunc_fft_mulup(UP,UP,int,UP *);
800: void crup(ModNum **,int,int *,int,N,UP *);
801: void shoup_crup(ModNum **,int,int *,int,N,N,UP *);
802: void squareup_gf2n(UP,UP *);
803: void powermodup_gf2n(UP,UP *);
804: void generic_powermodup_gf2n(UP,UP,Q,UP *);
805: void tracemodup_gf2n(UP,UP,Q,UP *);
806: void tracemodup_gf2n_slow(UP,UP,Q,UP *);
807: void tracemodup_gf2n_tab(UP,UP,Q,UP *);
808: void square_rem_tab_up_gf2n(UP,UP *,UP *);
809: void powertabup_gf2n(UP,UP,UP *);
810: void find_root_gf2n(UP,GF2N *);
811:
812: int cmpdl_matrix(int,DL,DL);
813: int cmpdl_order_pair(int,DL,DL);
814: int cmpdl_elim(int,DL,DL);
815: int cmpdl_blexrev(int,DL,DL);
816: int cmpdl_bgradrev(int,DL,DL);
817: int cmpdl_brevrev(int,DL,DL);
818: int cmpdl_brevgradlex(int,DL,DL);
819: int cmpdl_bgradlex(int,DL,DL);
820: int cmpdl_blex(int,DL,DL);
821: int cmpdl_revgradlex(int,DL,DL);
822: int cmpdl_gradlex(int,DL,DL);
823: int cmpdl_revlex(int,DL,DL);
824: int cmpdl_lex(int,DL,DL);
825: int compd(VL,DP,DP);
826: void adddl(int,DL,DL,DL *);
827: void divsdc(VL,DP,P,DP *);
828: void muldc(VL,DP,P,DP *);
829: void muldm(VL,DP,MP,DP *);
830: void muld(VL,DP,DP,DP *);
831: void chsgnd(DP,DP *);
832: void subd(VL,DP,DP,DP *);
833: void addd(VL,DP,DP,DP *);
834: int sugard(MP);
835: void nodetod(NODE,DP *);
836: void dtop(VL,VL,DP,P *);
837: void ptod(VL,VL,P,DP *);
838: void initd(struct order_spec *);
839:
840: void _printdp(DP);
841: void _dp_sp_mod(DP,DP,int,DP *);
842: void _dp_mod(DP,int,NODE,DP *);
843: void _dp_red_mod(DP,DP,int,DP *);
844: void _dtop_mod(VL,VL,DP,P *);
845: void _mulmdm(VL,int,DP,MP,DP *);
846: void _mulmd(VL,int,DP,DP,DP *);
847: void _chsgnmd(int,DP,DP *);
848: void _submd(VL,int,DP,DP,DP *);
849: void _addmd(VL,int,DP,DP,DP *);
850: void _mdtop(VL,int,VL,DP,P *);
851: void divsmdc(VL,int,DP,P,DP *);
852: void mulmdc(VL,int,DP,P,DP *);
853: void mulmdm(VL,int,DP,MP,DP *);
854: void mulmd(VL,int,DP,DP,DP *);
855: void chsgnmd(int,DP,DP *);
856: void submd(VL,int,DP,DP,DP *);
857: void addmd(VL,int,DP,DP,DP *);
858: void mdtop(VL,int,VL,DP,P *);
859: void mptomd(VL,int,VL,P,DP *);
860: void ptomd(VL,int,VL,P,DP *);
861: int p_mag(P);
862: int n_bits(N);
863: void gcdBinary_27n(N,N,N *);
864: void rtime_init(void);
865: void setmod_gf2n(P);
866: void mt_sgenrand(unsigned long);
867: unsigned long mt_genrand(void);
868: #if defined(VISUAL)
869: void srandom(unsigned int);
870: unsigned int random(void);
871: #endif
872: void gcdbmodn(N,N,N *);
873: void gcdbinn(N,N,N *);
874: void gcdmodn(N,N,N *);
875: void gcdaccn(N,N,N *);
876: void gcdEuclidn(N,N,N *);
877: void GC_free(void *);
878: void FFT_primes(int,int *,int *,int *);
879: int FFT_pol_product(unsigned int,unsigned int *, unsigned int,unsigned int *,
880: unsigned int *,int,unsigned int *);
881: int FFT_pol_square(unsigned int,unsigned int *,
882: unsigned int *,int,unsigned int *);
883: void dcptolist(DCP,LIST *);
884: void gcdprsmp(VL,int,P,P,P *);
885: void mult_mod_tab(UM,int,UM *,UM,int);
886: int nfctr_mod(UM,int);
887: int irred_check(UM,int);
888: void modfctrp(P,int,int,DCP *);
889: void pf_init(void);
890: void binaryton(char *,N *);
891: void hexton(char *,N *);
892: void ptolmp(P,P *);
893: void lmptop(P,P *);
894: void ulmptoum(int,UP,UM);
895: void objtobobj(int,Obj,Obj *);
896: void bobjtoobj(int,Obj,Obj *);
897: void numtobnum(int,Num,Num *);
898: void bnumtonum(int,Num,Num *);
899: void ptobp(int,P,P *);
900: void bptop(int,P,P *);
901: void listtoblist(int,LIST,LIST *);
902: void blisttolist(int,LIST,LIST *);
903: void vecttobvect(int,VECT,VECT *);
904: void bvecttovect(int,VECT,VECT *);
905: void mattobmat(int,MAT,MAT *);
906: void bmattomat(int,MAT,MAT *);
907: void n32ton27(N,N *);
908: void n27ton32(N,N *);
909: void kmulum(int,UM,UM,UM);
910: void saveobj(FILE *,Obj);
911: void endian_init(void);
912: void write_char(FILE *,unsigned char *);
913: void write_short(FILE *,unsigned short *);
914: void write_int(FILE *,unsigned int *);
915: void write_double(FILE *,double *);
916: void write_intarray(FILE *,unsigned int *,int);
917: void write_string(FILE *,unsigned char *,int);
918: void savestr(FILE *,char *);
919: void loadstr(FILE *,char **);
920: void savevl(FILE *,VL);
921: void loadvl(FILE *);
922: void skipvl(FILE *);
923: void savev(FILE *,V);
924: void loadv(FILE *,V *);
925: int save_convv(V);
926: V load_convv(int);
927: void swap_bytes(char *,int,int);
928: void read_char(FILE *,unsigned char *);
929: void read_short(FILE *,unsigned short *);
930: void read_int(FILE *,unsigned int *);
931: void read_double(FILE *,double *);
932: void read_intarray(FILE *,unsigned int *,int);
933: void read_string(FILE *,unsigned char *,int);
934: void loadobj(FILE *,Obj *);
935: void invum(int,UM,UM,UM);
936: void addarray_to(unsigned int *,int,unsigned int *,int);
937: void muln_1(unsigned int *,int,unsigned int,unsigned int *);
938: unsigned int divn_1(unsigned int *,int,unsigned int,unsigned int *);
939: void ptoup(P,UP *);
940: void uptop(UP,P *);
941: void printnum(Num);
942: void printv(VL,V);
943: void kmulq(Q,Q,Q *);
944: void bshiftn(N,int,N *);
945: void remn(N,N,N*);
946: void simplm(LM,LM *);
947: void qtolm(Q,LM *);
948: int qpcheck(Obj);
949: int headsgn(P);
950: void adjsgn(P,DCP);
951: void setmod_g2n(P);
952: void simpgf2n(GF2N,GF2N *);
953: void ptogf2n(Obj,GF2N *);
954: void gf2ntop(GF2N,P *);
955: void gf2ntovect(GF2N,VECT *);
956: void squaregf2n(GF2N,GF2N *);
957: void randomgf2n(GF2N *);
958: void invgf2n(GF2N,GF2N *);
959: void kmuln(N,N,N *);
960: void extractn(N,int,int,N *);
961: void copyn(N,int,int *);
962: void kmulnmain(N,N,N *);
963: int qcoefp(Obj);
964: int qcoefr(Obj);
965: int get_allocwords(void);
966: double get_clock(void);
967: void get_eg(struct oEGT *);
968: void printtime(struct oEGT *,struct oEGT *,double);
969: void init_eg(struct oEGT *);
970: void add_eg(struct oEGT *,struct oEGT *,struct oEGT *);
971: void print_eg(char *,struct oEGT *);
972: void print_split_eg(struct oEGT *,struct oEGT *);
973: void print_split_e(struct oEGT *,struct oEGT *);
974: void suspend_timer(void);
975: void resume_timer(void);
976: void reset_engine(void);
977: void notdef(VL,Obj,Obj,Obj *);
978: void error(char *);
979: void ptoup2(P,UP2 *);
980: void ptoup2_sparse(P,UP2 *);
981: void up2top(UP2,P *);
982: void up2tovect(UP2,VECT *);
983: void up2ton(UP2,Q *);
984: void ntoup2(Q,UP2 *);
985: void gen_simpup2(UP2,GEN_UP2,UP2 *);
986: void gen_simpup2_destructive(UP2,GEN_UP2);
987: void gen_invup2(UP2,GEN_UP2,UP2 *);
988: void gen_pwrmodup2(UP2,Q,GEN_UP2,UP2 *);
989: void simpup2(UP2,UP2,UP2 *);
990: int degup2(UP2);
991: int degup2_sparse(UP2);
992: int degup2_1(unsigned int);
993: void addup2(UP2,UP2,UP2 *);
994: void subup2(UP2,UP2,UP2 *);
995: void mulup2_n1(unsigned int *,int,unsigned int,unsigned int *);
996: void mulup2_nh(unsigned int *,int,unsigned int,unsigned int *);
997: void _mulup2_1(UP2,unsigned int,UP2);
998: void _mulup2_h(UP2,unsigned int,UP2);
999: void mulup2(UP2,UP2,UP2 *);
1000: void _kmulup2_(unsigned int *,unsigned int *,int,unsigned int *);
1001: void _mulup2_nn(unsigned int *,unsigned int *,int,unsigned int *);
1002: void _mulup2(UP2,UP2,UP2);
1003: void _mulup2_(_UP2,_UP2,_UP2);
1004: void squareup2(UP2,UP2 *);
1005: void _adjup2(UP2);
1006: void _adjup2_(_UP2);
1007: void _addup2(UP2,UP2,UP2);
1008: void _addup2_destructive(UP2,UP2);
1009: void _addup2_(_UP2,_UP2,_UP2);
1010: void _addtoup2_(_UP2,_UP2);
1011: unsigned int mulup2_bb(unsigned int,unsigned int);
1012: void init_up2_tab(void);
1013: unsigned int quoup2_11(unsigned int,unsigned int);
1014: void divup2_1(unsigned int,unsigned int,int,int,unsigned int *,unsigned int *);
1015: void qrup2(UP2,UP2,UP2 *,UP2 *);
1016: void _qrup2(UP2,UP2,UP2,UP2);
1017: void remup2(UP2,UP2,UP2 *);
1018: void _remup2(UP2,UP2,UP2);
1019: void remup2_sparse(UP2,UP2,UP2 *);
1020: void remup2_sparse_destructive(UP2,UP2);
1021: void remup2_type1_destructive(UP2,int);
1022: void remup2_3_destructive(UP2,UP2);
1023: void remup2_5_destructive(UP2,UP2);
1024: void _invup2_1(unsigned int,unsigned int,unsigned int *,unsigned int *);
1025: void _gcdup2_1(unsigned int,unsigned int,unsigned int *);
1026: void up2_init_eg(void);
1027: void up2_show_eg(void);
1028: void invup2(UP2,UP2,UP2 *);
1029: void gcdup2(UP2,UP2,UP2 *);
1030: void chsgnup2(UP2,UP2 *);
1031: void pwrmodup2(UP2,Q,UP2,UP2 *);
1032: void pwrmodup2_sparse(UP2,Q,UP2,UP2 *);
1033: int compup2(UP2,UP2);
1034: void printup2(UP2);
1035: void _copyup2(UP2,UP2);
1036: void _bshiftup2(UP2,int,UP2);
1037: void _bshiftup2_destructive(UP2,int);
1038: void diffup2(UP2,UP2 *);
1039: int sqfrcheckup2(UP2);
1040: int irredcheckup2(UP2);
1041: int irredcheck_dddup2(UP2);
1042: void _copy_up2bits(UP2,unsigned int **,int);
1043: void _print_frobmat(unsigned int **,int,int);
1044: int compute_multiplication_matrix(P,GF2MAT *);
1045: void compute_change_of_basis_matrix(P,P,int,GF2MAT *,GF2MAT *);
1046: int compute_representation_conversion_matrix(P,GF2MAT *,GF2MAT *);
1047: void mul_nb(GF2MAT,unsigned int *,unsigned int *,unsigned int *);
1048: void leftshift(unsigned int *,int);
1049: void mat_to_gf2mat(MAT,unsigned int ***);
1050: void gf2mat_to_mat(unsigned int **,int,MAT *);
1051: void mulgf2mat(int,unsigned int **,unsigned int **,unsigned int **);
1052: void mulgf2vectmat(int,unsigned int *,unsigned int **,unsigned int *);
1053: int mulgf2vectvect(int,unsigned int *,unsigned int *);
1054: int invgf2mat(int,unsigned int **,unsigned int **);
1055: void _mulup2_11(unsigned int,unsigned int,unsigned int *);
1056: void _mulup2_22(unsigned int *,unsigned int *,unsigned int *);
1057: void _mulup2_33(unsigned int *,unsigned int *,unsigned int *);
1058: void _mulup2_44(unsigned int *,unsigned int *,unsigned int *);
1059: void _mulup2_55(unsigned int *,unsigned int *,unsigned int *);
1060: void _mulup2_66(unsigned int *,unsigned int *,unsigned int *);
1061: void printup2_(unsigned int *,int);
1062: void type1_bin_invup2(UP2,int,UP2 *);
1063: int int_bits(int);
1064:
1065:
1066: LUM LUMALLOC(int, int);
1067: Obj ToAlg(Num);
1068: UM *berlemain(register int, UM, UM *);
1069: void *Risa_GC_malloc(size_t);
1070: void *Risa_GC_malloc_atomic(size_t);
1071: void *Risa_GC_realloc(void *,size_t);
1072: void *GC_malloc(size_t);
1073: void *GC_malloc_atomic(size_t);
1074: void *GC_realloc(void *,size_t);
1075: double NatToReal(N,int *);
1076: double RatnToReal(Q);
1077: double pwrreal0(double,int);
1.3 noro 1078: double rtodbl(); /* XXX */
1.1 noro 1079: int **almat(int,int);
1080: pointer **almat_pointer(int,int);
1081: int berlecnt(register int,UM);
1082: int berlecntmain(register int,int,int,register int **);
1083: int cmpalg(Num,Num);
1084: int cmpbf(Num,Num);
1085: int cmpcplx(Num,Num);
1086: int cmpn(N,N);
1087: int cmpq(Q,Q);
1088: int cmpreal(Real,Real);
1089: int cmpmi(MQ,MQ);
1090: int cmplm(LM,LM);
1091: int compmat(VL,MAT,MAT);
1092: int compnum(VL,Num,Num);
1093: int compp(VL,P,P);
1094: int compr(VL,Obj,Obj);
1095: int compstr(VL,STRING,STRING);
1096: int compvect(VL,VECT,VECT);
1097: int ctest(P,ML,int,int *);
1098: int cycchk(P);
1099: int dbound(V,P);
1100: int dcomp(P,P);
1101: int deg(V,P);
1102: int degtest(int,int *,ML,int);
1103: int divcheck(VL,P *,int,P,P);
1104: unsigned int divin(N,unsigned int,N *);
1105: int divtdcpz(VL,P,P,P *);
1106: int divtpz(VL,P,P,P *);
1107: int divum(register int,UM,UM,UM);
1108: int dm(int,int,int *);
1109: int dmb(int,int,int,int *);
1110: int dma(int,int,int,int *);
1111: int dmab(int,int,int,int,int *);
1112: int dmar(int,int,int,int);
1113: int dtestmain(P,Q,ML,int,int *,P *,P *);
1114: int geldb(VL,P);
1115: int getchomdeg(V,P);
1116: int getdeg(V,P);
1117: int getlchomdeg(V,P,int *);
1118: int homdeg(P);
1119: unsigned int invm(unsigned int,int);
1120: int iscycm(P);
1121: int iscycp(P);
1122: int lengthp(P);
1123: int mig(int,int,P);
1124: int mignotte(int,P);
1125: int minimain(register int,int,int,register int **);
1126: int ncombi(int,int,int,int *);
1127: int nextbin(VN,int);
1128: int nmonop(P);
1129: int pcoef(VL,VL,P,P *);
1130: int pcoef0(VL,VL,P,P *);
1131: unsigned int pwrm(register int,register int,int);
1132: unsigned int rem(N,unsigned int);
1133: int sqfrchk(P);
1134: int subn(N,N,N *);
1135: int ucmpp(P,P);
1136: int valideval(VL,DCP,VN);
1137: int zerovpchk(VL,P,VN);
1138:
1139: void addgf2n(GF2N,GF2N,GF2N *);
1140: void subgf2n(GF2N,GF2N,GF2N *);
1141: void mulgf2n(GF2N,GF2N,GF2N *);
1142: void divgf2n(GF2N,GF2N,GF2N *);
1143: void chsgngf2n(GF2N,GF2N *);
1144: void pwrgf2n(GF2N,Q, GF2N *);
1145: int cmpgf2n(GF2N,GF2N);
1146:
1147: void addgfpn(GFPN,GFPN,GFPN *);
1148: void subgfpn(GFPN,GFPN,GFPN *);
1149: void mulgfpn(GFPN,GFPN,GFPN *);
1150: void divgfpn(GFPN,GFPN,GFPN *);
1151: void chsgngfpn(GFPN,GFPN *);
1152: void pwrgfpn(GFPN,Q, GFPN *);
1153: int cmpgfpn(GFPN,GFPN);
1154:
1155: void addalg(Num,Num,Num *);
1156: void addbf(Num,Num,Num *);
1157: void addcplx(Num,Num,Num *);
1158: void addm2p(VL,Q,Q,P,P,P *);
1159: void addm2q(Q,Q,Q,Q,Q *);
1160: void addmat(VL,MAT,MAT,MAT *);
1161: void addmp(VL,int,P,P,P *);
1162: void addmpq(int,P,P,P *);
1163: void addmptoc(VL,int,P,P,P *);
1164: void addmq(int,MQ,MQ,MQ *);
1165: void addn(N,N,N *);
1166: void addnum(VL,Num,Num,Num *);
1167: void addp(VL,P,P,P *);
1168: void addpadic(int,int,unsigned int *,unsigned int *);
1169: void addpq(P,P,P *);
1170: void addptoc(VL,P,P,P *);
1171: void addq(Q,Q,Q *);
1172: void addr(VL,Obj,Obj,Obj *);
1173: void addreal(Num,Num,Real *);
1174: void addmi(MQ,MQ,MQ *);
1175: void addlm(LM,LM,LM *);
1176: void addstr(VL,STRING,STRING,STRING *);
1177: void addum(int,UM,UM,UM);
1178: void addvect(VL,VECT,VECT,VECT *);
1179: void adjc(VL,P,P,P,Q,P *,P *);
1180: void afctr(VL,P,P,DCP *);
1181: void afctrmain(VL,P,P,int,DCP *);
1182: void affine(VL,P,VN,P *);
1183: void affinemain(VL,P,V,int,P *,P *);
1184: void berle(int,int,P,ML *);
1185: void bnton(register int,N,N *);
1186: void cbound(VL,P,Q *);
1187: void chnrem(int,V,P,Q,UM,P *,Q *);
1188: void chnremp(VL,int,P,Q,P,P *);
1189: void chsgnalg(Num,Num *);
1190: void chsgnbf(Num a,Num *);
1191: void chsgncplx(Num,Num *);
1192: void chsgnmat(MAT,MAT *);
1193: void chsgnmp(int,P,P *);
1194: void chsgnnum(Num,Num *);
1195: void chsgnp(P,P *);
1196: void chsgnq(Q,Q *);
1197: void chsgnr(Obj,Obj *);
1198: void chsgnreal(Num,Num *);
1199: void chsgnmi(MQ,MQ *);
1200: void chsgnlm(LM,LM *);
1201: void chsgnvect(VECT,VECT *);
1202: void clctv(VL,P,VL *);
1203: void clctvr(VL,Obj,VL *);
1204: void cm2p(Q,Q,P,P *);
1205: void cmax(P,Q *);
1206: void cmp(Q,P,P *);
1207: void coefp(P,int,P *);
1208: void cpylum(int,LUM,LUM);
1209: void cpyum(UM,UM);
1210: void csump(VL,P,Q *);
1211: void cycm(V,register int,DCP *);
1212: void cycp(V,register int,DCP *);
1213: void degp(V,P,Q *);
1214: void degum(UM,int);
1215: void detmp(VL,int,P **,int,P *);
1216: void detp(VL,P **,int,P *);
1217: void diffp(VL,P,V,P *);
1218: void diffum(register int,UM,UM);
1219: void divalg(Num,Num,Num *);
1220: void divbf(Num,Num,Num *);
1221: void divcp(P,Q,P *);
1222: void divcplx(Num,Num,Num *);
1223: void divmat(VL,Obj,Obj,Obj *);
1224: void divmq(int,MQ,MQ,MQ *);
1225: void divn(N,N,N *,N *);
1226: void divnmain(int,int,unsigned int *,unsigned int *,unsigned int *);
1227: void divnum(VL,Num,Num,Num *);
1228: void divq(Q,Q,Q *);
1229: void divr(VL,Obj,Obj,Obj *);
1230: void divreal(Num,Num,Real *);
1231: void divmi(MQ,MQ,MQ *);
1232: void divlm(LM,LM,LM *);
1233: void divsdcmp(VL,int,P,P,P *);
1234: void divsdcp(VL,P,P,P *);
1235: void divsmp(VL,int,P,P,P *);
1236: void divsn(N,N,N *);
1237: void divsp(VL,P,P,P *);
1238: void divsrdcmp(VL,int,P,P,P *,P *);
1239: void divsrdcp(VL,P,P,P *,P *);
1240: void divsrmp(VL,int,P,P,P *,P *);
1241: void divsrp(VL,P,P,P *,P *);
1242: void divvect(VL,Obj,Obj,Obj *);
1243: void dtest(P,ML,int,DCP *);
1244: void dtestroot(int,int,P,LUM,struct oDUM *,DCP *);
1245: void dtestroot1(int,int,P,LUM,P *);
1246: void dtestsq(int,int,P,LUM,P *);
1247: void dtestsql(P,ML,struct oDUM *,DCP *);
1248: void estimatelc(VL,Q,DCP,VN,P *);
1249: void eucum(register int,UM,UM,UM,UM);
1250: void exthp(VL,P,int,P *);
1251: void exthpc(VL,V,P,int,P *);
1252: void ezgcd1p(VL,P,P,P *);
1253: void ezgcdhensel(P,int,UM,UM,ML *);
1254: void ezgcdnp(VL,P,P *,int,P *);
1255: void ezgcdnpp(VL,DCP,P *,int,P *);
1256: void ezgcdnpz(VL,P *,int,P *);
1257: void ezgcdp(VL,P,P,P *);
1258: void ezgcdpp(VL,DCP,P,P *);
1259: void ezgcdpz(VL,P,P,P *);
1260: void factorial(int,Q *);
1261: void fctrp(VL,P,DCP *);
1262: void fctrwithmvp(VL,P,V,DCP *);
1263: void gcda(VL,P,P,P,P *);
1264: void gcdcp(VL,P,P *);
1265: void gcdgen(P,ML,ML *);
1266: void gcdmonomial(VL,DCP *,int,P *);
1267: void gcdn(N,N,N *);
1268: void gcdprsp(VL,P,P,P *);
1269: void gcdum(register int,UM,UM,UM);
1270: void getmindeg(V,P,Q *);
1271: void henmain(LUM,ML,ML,ML *);
1272: void henmv(VL,VN,P,P,P,P,P,P,P,P,P,Q,int,P *,P *);
1273: void henmvmain(VL,VN,P,P,P,P,P,P,P,Q,Q,int,P *,P *);
1274: void henprep(P,ML,ML,ML *,ML *);
1275: void hensel(int,int,P,ML *);
1276: void henzq(P,P,UM,P,UM,int,int,P *,P *,P *,P *,Q *);
1277: void henzq1(P,P,Q,P *,P *,Q *);
1278: void hsq(int,int,P,int *,DCP *);
1279: void intersectv(VL,VL,VL *);
1280: void invl(Q,Q,Q *);
1281: void invmq(int,MQ,MQ *);
1282: void invq(Q,Q *);
1283: void lgp(P,N *,N *);
1284: void lumtop(V,int,int,LUM,P *);
1285: void markv(VN,int,P);
1286: void maxdegp(VL,P,VL *,P *);
1287: void mergev(VL,VL,VL,VL *);
1288: void mfctr(VL,P,DCP *);
1289: void mfctrhen2(VL,VN,P,P,P,P,P,P,P *);
1290: void mfctrmain(VL,P,DCP *);
1291: void mfctrwithmv(VL,P,V,DCP *);
1292: void min_common_vars_in_coefp(VL,P,VL *,P *);
1293: void minchdegp(VL,P,VL *,P *);
1294: void mindegp(VL,P,VL *,P *);
1295: void mini(register int,UM,UM);
1296: void minlcdegp(VL,P,VL *,P *);
1297: void mkbc(int,Q *);
1298: void mkbcm(int,int,MQ *);
1299: void mkssum(V,int,int,int,P *);
1300: void monomialfctr(VL,P,P *,DCP *);
1301: void mptop(P,P *);
1302: void mptoum(P,UM);
1303: void msqfr(VL,P,DCP *);
1304: void msqfrmain(VL,P,DCP *);
1305: void msqfrmainmain(VL,P,VN,P,DCP,DCP *,P *);
1306: void mulalg(Num,Num,Num *);
1307: void mulbf(Num,Num,Num *);
1308: void mulcplx(Num,Num,Num *);
1309: void mulin(N,unsigned int,unsigned int *);
1310: void mullum(int,int,LUM,LUM,LUM);
1311: void mullumarray(P,ML,int,int *,P *);
1312: void mulm2p(VL,Q,Q,P,P,P *);
1313: void mulm2q(Q,Q,Q,Q,Q *);
1314: void mulmat(VL,Obj,Obj,Obj *);
1315: void mulmatmat(VL,MAT,MAT,MAT *);
1316: void mulmatvect(VL,MAT,VECT,VECT *);
1317: void mulmp(VL,int,P,P,P *);
1318: void mulmpc(VL,int,P,P,P *);
1319: void mulmpq(int,P,P,P *);
1320: void mulmq(int,MQ,MQ,MQ *);
1321: void muln(N,N,N *);
1322: void mulnum(VL,Num,Num,Num *);
1323: void mulp(VL,P,P,P *);
1324: void mulpadic(int,int,unsigned int *,unsigned int *,unsigned int *);
1325: void mulpc(VL,P,P,P *);
1326: void mulpq(P,P,P *);
1327: void mulq(Q,Q,Q *);
1328: void mulr(VL,Obj,Obj,Obj *);
1329: void mulreal(Num,Num,Real *);
1330: void mulmi(MQ,MQ,MQ *);
1331: void mullm(LM,LM,LM *);
1332: void mulrmat(VL,Obj,MAT,MAT *);
1333: void mulrvect(VL,Obj,VECT,VECT *);
1334: void mulsgn(VN,VN,int,VN);
1335: void mulsum(register int,UM,register int,UM);
1336: void mulum(register int,UM,UM,UM);
1337: void mulvect(VL,Obj,Obj,Obj *);
1338: void mulvectmat(VL,VECT,MAT,VECT *);
1339: void next(VN);
1340: void nezgcdnp_sqfr_primitive(VL,P,P *,int,P *);
1341: void nezgcdnpp(VL,DCP,P *,int,P *);
1342: void nezgcdnpz(VL,P *,int,P *);
1343: void nezgcdnpzmain(VL,P *,int,P *);
1344: void nglob_init(void);
1345: void norm(P,Q *);
1346: void norm1(P,P *);
1347: void norm1c(P,Q *);
1348: void normalizemp(int,P);
1349: void nthrootchk(P,struct oDUM *,ML,DCP *);
1350: void nthrootn(N,int,N *);
1351: void ntobn(register int,N,N *);
1352: void nuezgcdnpzmain(VL,P *,int,P *);
1353: void padictoq(int,int,int *,Q *);
1354: void risa_pari_init(void);
1355: void pcp(VL,P,P *,P *);
1356: void pderivr(VL,Obj,V,Obj *);
1357: void pdiva(VL,P,P,P,P *);
1358: void pinva(P,P,P *);
1359: void plisttop(P *,V,int,P *);
1360: void pmonic(VL,P,P,P *);
1361: void pqra(VL,P,P,P,P *,P *);
1362: void premmp(VL,int,P,P,P *);
1363: void premp(VL,P,P,P *);
1364: void ptolum(int,int,P,LUM);
1365: void ptomp(int,P,P *);
1366: void ptoum(int,P,UM);
1367: void ptozp(P,int,Q *,P *);
1368: void ptozp0(P,P *);
1369: void pwralg(Num,Num,Num *);
1370: void pwrbf(Num,Num,Num *);
1371: void pwrcplx(Num,Num,Num *);
1372: void pwrcplx0(Num,int,Num *);
1373: void pwrlum(int,int,LUM,int,LUM);
1374: void pwrmat(VL,MAT,Obj,MAT *);
1375: void pwrmatmain(VL,MAT,int,MAT *);
1376: void pwrmp(VL,int,P,Q,P *);
1377: void pwrmq(int,MQ,Q,MQ *);
1378: void pwrn(N,int,N *);
1379: void pwrnum(VL,Num,Num,Num *);
1380: void pwrp(VL,P,Q,P *);
1381: void pwrq(Q,Q,Q *);
1382: void pwrr(VL,Obj,Obj,Obj *);
1383: void pwrreal(Num,Num,Real *);
1384: void pwrmi(MQ,Q,MQ *);
1385: void pwrlm(LM,Q,LM *);
1386: void pwrum(int,UM,int,UM);
1387: void reallocarray(char **,int *,int *,int);
1388: void reductr(VL,Obj,Obj *);
1389: void reimtocplx(Num,Num,Num *);
1390: void rem2q(Q,Q,Q,Q *);
1391: void rema(VL,P,P,P,P *);
1392: void remq(Q,Q,Q *);
1393: void remsdcp(VL,P,P,P *);
1394: void reordermp(VL,int,VL,P,P *);
1395: void reorderp(VL,VL,P,P *);
1396: void reordvar(VL,V,VL *);
1397: void res_ch_det(VL,V,P,P,P *);
1398: void res_detmp(VL,int,V,P,P,P *);
1399: void restore(VL,P,VN,P *);
1400: void resultmp(VL,int,V,P,P,P *);
1401: void resultp(VL,V,P,P,P *);
1402: void setlum(int,int,LUM);
1403: void sort_by_deg(int,P *,P *);
1404: void sort_by_deg_rev(int,P *,P *);
1405: void sortfs(DCP *);
1406: void sortfsrev(DCP *);
1407: void sortplist(P *,int);
1408: void sortplistbyhomdeg(P *,int);
1409: void sprs(VL,V,P,P,P *);
1410: void sqa(VL,P,P,DCP *);
1411: void sqad(unsigned int,int);
1412: void sqfrp(VL,P,DCP *);
1413: void sqfrum(int,int,P,int *,struct oDUM **,ML *);
1414: void sqfrummain(int,UM,UM,struct oDUM **);
1415: void sqrtn(N,N *);
1416: void srch2(VL,V,P,P,P *);
1417: void srchmp(VL,int,V,P,P,P *);
1418: void srchump(int,P,P,P *);
1419: void srcr(VL,V,P,P,P *);
1420: void strtobf(char *,BF *);
1421: void subalg(Num,Num,Num *);
1422: void subbf(Num,Num,Num *);
1423: void subcplx(Num,Num,Num *);
1424: void subm2p(VL,Q,Q,P,P,P *);
1425: void subm2q(Q,Q,Q,Q,Q *);
1426: void submat(VL,MAT,MAT,MAT *);
1427: void submp(VL,int,P,P,P *);
1428: void submq(int,MQ,MQ,MQ *);
1429: void subnum(VL,Num,Num,Num *);
1430: void subp(VL,P,P,P *);
1431: void subq(Q,Q,Q *);
1432: void subr(VL,Obj,Obj,Obj *);
1433: void subreal(Num,Num,Real *);
1434: void submi(MQ,MQ,MQ *);
1435: void sublm(LM,LM,LM *);
1436: void substmp(VL,int,P,V,P,P *);
1437: void substp(VL,P,V,P,P *);
1438: void substvp(VL,P,VN,P *);
1439: void subum(int,UM,UM,UM);
1440: void subvect(VL,VECT,VECT,VECT *);
1441: void toreim(Num,Num *,Num *);
1442: void ucsump(P,Q *);
1443: void udivpwm(Q,P,P,P *,P *);
1444: void udivpz(P,P,P *,P *);
1445: void udivpzwm(Q,P,P,P *,P *);
1446: void uexgcdnp(VL,P,P *,int,VN,Q,P *,P *,P *,P *,Q *);
1447: void uezgcd1p(P,P,P *);
1448: void uezgcdpp(DCP,P,P *);
1449: void uezgcdpz(VL,P,P,P *);
1450: void ufctr(P,int,DCP *);
1451: void ufctrmain(P,int,DCP *);
1452: void umtomp(V,UM,P *);
1453: void umtop(V,UM,P *);
1454: void usqp(P,DCP *);
1455: void vntovl(VN,int,VL *);
1456:
1457: #if 0 && !defined(VISUAL)
1458: void bzero(const void *,int);
1459: void bcopy(const void *,void *,int);
1460: char *index(char *,int);
1461: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>