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