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