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