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