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