Annotation of OpenXM/src/kan96xx/Kan/poly4.c, Revision 1.8
1.8 ! takayama 1: /* $OpenXM: OpenXM/src/kan96xx/Kan/poly4.c,v 1.7 2003/07/19 06:03:57 takayama Exp $ */
1.1 maekawa 2: #include <stdio.h>
3: #include "datatype.h"
4: #include "stackm.h"
5: #include "extern.h"
6: #include "extern2.h"
7: #include "matrix.h"
8: static void shell(int v[],int n);
9: static int degreeOfPrincipalPart(POLY f);
10: static int degreeOfInitW(POLY f,int w[]);
11:
12:
13: static void shell(v,n)
1.3 takayama 14: int v[];
15: int n;
1.1 maekawa 16: {
17: int gap,i,j,temp;
18:
19: for (gap = n/2; gap > 0; gap /= 2) {
20: for (i = gap; i<n; i++) {
21: for (j=i-gap ; j>=0 && v[j]<v[j+gap]; j -= gap) {
1.3 takayama 22: temp = v[j];
23: v[j] = v[j+gap];
24: v[j+gap] = temp;
1.1 maekawa 25: }
26: }
27: }
28: }
29:
30:
31: struct matrixOfPOLY *parts(f,v)
1.3 takayama 32: POLY f;
33: POLY v; /* v must be a single variable, e.g. x */
1.1 maekawa 34: {
35: struct matrixOfPOLY *evPoly;
36: int vi = 0; /* index of v */
37: int vx = 1; /* x --> 1, D--> 0 */
38: int n,evSize,i,k,e;
39: int *ev;
40: struct object *evList;
41: struct object *list;
42: struct object ob;
43: POLY ans;
44: POLY h;
45: extern struct ring *CurrentRingp;
46: POLY ft;
47:
48:
49: if (f ISZERO || v ISZERO) {
50: evPoly = newMatrixOfPOLY(2,1);
51: getMatrixOfPOLY(evPoly,0,0) = ZERO;
52: getMatrixOfPOLY(evPoly,1,0) = ZERO;
53: return(evPoly);
54: }
55: n = v->m->ringp->n;
56: /* get the index of the variable v */
57: for (i=0; i<n; i++) {
58: if (v->m->e[i].x) {
59: vx = 1; vi = i; break;
60: }else if (v->m->e[i].D) {
61: vx = 0; vi = i; break;
62: }
63: }
64: ft = f;
65: /* get the vector of exponents */
66: evList = NULLLIST;
67: while (ft != POLYNULL) {
68: if (vx) {
69: e = ft->m->e[vi].x;
70: }else{
71: e = ft->m->e[vi].D;
72: }
73: ft = ft->next;
74: ob = KpoInteger(e);
75: if (!memberQ(evList,ob)) {
76: list = newList(&ob);
77: evList = vJoin(evList,list);
78: }
79: }
80: /*printf("evList = "); printObjectList(evList);*/
81: evSize = klength(evList);
82: ev = (int *)sGC_malloc(sizeof(int)*(evSize+1));
83: if (ev == (int *)NULL) errorPoly("No more memory.");
84: for (i=0; i<evSize; i++) {
85: ev[i] = KopInteger(car(evList));
86: evList = cdr(evList);
87: }
88: /* sort ev */
89: shell(ev,evSize);
90:
91: /* get coefficients */
92: evPoly = newMatrixOfPOLY(2,evSize);
93: for (i=0; i<evSize; i++) {
94: ans = ZERO;
95: getMatrixOfPOLY(evPoly,0,i) = cxx(ev[i],0,0,CurrentRingp);
96: ft = f;
97: while (ft != POLYNULL) {
98: if (vx) {
1.3 takayama 99: if (ft->m->e[vi].x == ev[i]) {
100: h = newCell(ft->coeffp,monomialCopy(ft->m));
101: xset0(h,vi); /* touch monomial part, so you need to copy it above. */
102: ans = ppAdd(ans,h);
103: }
1.1 maekawa 104: }else{
1.3 takayama 105: if (ft->m->e[vi].D == ev[i]) {
106: h = newCell(ft->coeffp,monomialCopy(ft->m));
107: dset0(h,vi);
108: ans = ppAdd(ans,h);
109: }
1.1 maekawa 110: }
111: ft = ft->next;
112: }
113: getMatrixOfPOLY(evPoly,1,i) = ans;
114: }
115: return(evPoly);
116: }
1.3 takayama 117:
1.1 maekawa 118: struct object parts2(f,v)
1.3 takayama 119: POLY f;
120: POLY v; /* v must be a single variable, e.g. x */
1.1 maekawa 121: {
122: struct matrixOfPOLY *evPoly;
123: int vi = 0; /* index of v */
124: int vx = 1; /* x --> 1, D--> 0 */
125: int n,evSize,i,k,e;
126: int *ev;
127: struct object *evList;
128: struct object *list;
129: struct object ob;
130: POLY ans;
131: POLY h;
132: POLY ft;
133: struct object ob1,ob2,rob;
134:
135:
136: if (f ISZERO || v ISZERO) {
137: evPoly = newMatrixOfPOLY(2,1);
138: getMatrixOfPOLY(evPoly,0,0) = ZERO;
139: getMatrixOfPOLY(evPoly,1,0) = ZERO;
140: rob = newObjectArray(2);
141: ob1 = newObjectArray(1);
142: ob2 = newObjectArray(1);
143: putoa(ob1,0,KpoInteger(0));
144: putoa(ob2,0,KpoPOLY(POLYNULL));
145: putoa(rob,0,ob1); putoa(rob,1,ob2);
146: return(rob);
147: }
148: n = v->m->ringp->n;
149: /* get the index of the variable v */
150: for (i=0; i<n; i++) {
151: if (v->m->e[i].x) {
152: vx = 1; vi = i; break;
153: }else if (v->m->e[i].D) {
154: vx = 0; vi = i; break;
155: }
156: }
157: ft = f;
158: /* get the vector of exponents */
159: evList = NULLLIST;
160: while (ft != POLYNULL) {
161: if (vx) {
162: e = ft->m->e[vi].x;
163: }else{
164: e = ft->m->e[vi].D;
165: }
166: ft = ft->next;
167: ob = KpoInteger(e);
168: if (!memberQ(evList,ob)) {
169: list = newList(&ob);
170: evList = vJoin(evList,list);
171: }
172: }
173: /*printf("evList = "); printObjectList(evList);*/
174: evSize = klength(evList);
175: ev = (int *)sGC_malloc(sizeof(int)*(evSize+1));
176: if (ev == (int *)NULL) errorPoly("No more memory.");
177: for (i=0; i<evSize; i++) {
178: ev[i] = KopInteger(car(evList));
179: evList = cdr(evList);
180: }
181: /* sort ev */
182: shell(ev,evSize);
183:
184: /* get coefficients */
185: evPoly = newMatrixOfPOLY(2,evSize);
186: for (i=0; i<evSize; i++) {
187: ans = ZERO;
188: /* getMatrixOfPOLY(evPoly,0,i) = cxx(ev[i],0,0,CurrentRingp); */
189: getMatrixOfPOLY(evPoly,0,i) = POLYNULL;
190: ft = f;
191: while (ft != POLYNULL) {
192: if (vx) {
1.3 takayama 193: if (ft->m->e[vi].x == ev[i]) {
194: h = newCell(ft->coeffp,monomialCopy(ft->m));
195: xset0(h,vi); /* touch monomial part, so you need to copy it above. */
196: ans = ppAdd(ans,h);
197: }
1.1 maekawa 198: }else{
1.3 takayama 199: if (ft->m->e[vi].D == ev[i]) {
200: h = newCell(ft->coeffp,monomialCopy(ft->m));
201: dset0(h,vi);
202: ans = ppAdd(ans,h);
203: }
1.1 maekawa 204: }
205: ft = ft->next;
206: }
207: getMatrixOfPOLY(evPoly,1,i) = ans;
208: }
209: rob = newObjectArray(2);
210: ob1 = newObjectArray(evSize);
211: ob2 = newObjectArray(evSize);
212: for (i=0; i<evSize; i++) {
213: putoa(ob2,i,KpoPOLY(getMatrixOfPOLY(evPoly,1,i)));
214: putoa(ob1,i,KpoInteger(ev[i]));
215: }
216: putoa(rob,0,ob1); putoa(rob,1,ob2);
217: return(rob);
218: }
1.3 takayama 219:
1.1 maekawa 220: int pDegreeWrtV(f,v)
1.3 takayama 221: POLY f;
222: POLY v;
1.1 maekawa 223: {
224: int vx = 1;
225: int vi = 0;
226: int i,n;
227: int ans;
228: if (f ISZERO || v ISZERO) return(0);
229: n = f->m->ringp->n;
230: for (i=0; i<n; i++) {
231: if (v->m->e[i].x) {
232: vx = 1; vi = i;
233: break;
234: }else if (v->m->e[i].D) {
235: vx = 0; vi = i;
236: break;
237: }
238: }
239: if (vx) {
240: ans = f->m->e[vi].x;
241: }else{
242: ans = f->m->e[vi].D;
243: }
244: f = f->next;
245: while (f != POLYNULL) {
246: if (vx) {
247: if (f->m->e[vi].x > ans) ans = f->m->e[vi].x;
248: }else{
249: if (f->m->e[vi].D > ans) ans = f->m->e[vi].D;
250: }
251: f = f->next;
252: }
253: return(ans);
254: }
255:
256: int containVectorVariable(POLY f)
257: {
258: MONOMIAL tf;
259: static int nn,mm,ll,cc,n,m,l,c;
260: static struct ring *cr = (struct ring *)NULL;
261: int i;
262:
263: if (f ISZERO) return(0);
264: tf = f->m;
265: if (tf->ringp != cr) {
266: n = tf->ringp->n;
267: m = tf->ringp->m;
268: l = tf->ringp->l;
269: c = tf->ringp->c;
270: nn = tf->ringp->nn;
271: mm = tf->ringp->mm;
272: ll = tf->ringp->ll;
273: cc = tf->ringp->cc;
274: cr = tf->ringp;
275: }
276:
277: while (f != POLYNULL) {
278: tf = f->m;
279: for (i=cc; i<c; i++) {
280: if ( tf->e[i].x ) return(1);
281: if ( tf->e[i].D ) return(1);
282: }
283: for (i=ll; i<l; i++) {
284: if (tf->e[i].x) return(1);
285: if (tf->e[i].D) return(1);
286: }
287: for (i=mm; i<m; i++) {
288: if (tf->e[i].x) return(1);
289: if (tf->e[i].D) return(1);
290: }
291: for (i=nn; i<n; i++) {
292: if (tf->e[i].x) return(1);
293: if (tf->e[i].D) return(1);
294: }
295: f = f->next;
296: }
297: return(0);
298:
299: }
300:
301: POLY homogenize(f)
1.3 takayama 302: POLY f;
303: /* homogenize by using (*grade)(f) */
1.1 maekawa 304: {
305: POLY t;
306: int maxg;
307: int flag,d;
308:
309: if (f == ZERO) return(f);
310: t = f; maxg = (*grade)(f); flag = 0;
311: while (t != POLYNULL) {
312: d = (*grade)(t);
313: if (d != maxg) flag = 1;
314: if (d > maxg) {
315: maxg = d;
316: }
317: t = t->next;
318: }
319: if (flag == 0) return(f);
320:
321: f = pmCopy(f); /* You can rewrite the monomial parts */
322: t = f;
323: while (t != POLYNULL) {
324: d = (*grade)(t);
325: if (d != maxg) {
326: t->m->e[0].D += maxg-d; /* Multiply h^(maxg-d) */
327: }
328: t = t->next;
329: }
330: return(f);
331: }
332:
333: int isHomogenized(f)
1.3 takayama 334: POLY f;
1.1 maekawa 335: {
336: POLY t;
337: extern int Homogenize_vec;
338: int maxg;
339: if (!Homogenize_vec) return(isHomogenized_vec(f));
340: if (f == ZERO) return(1);
1.4 takayama 341: if (f->m->ringp->weightedHomogenization) {
342: return 1; /* BUG: do not chech in case of one-zero homogenization */
343: }
1.1 maekawa 344: maxg = (*grade)(f);
345: t = f;
346: while (t != POLYNULL) {
347: if (maxg != (*grade)(t)) return(0);
348: t = t->next;
349: }
350: return(1);
351: }
352:
353: int isHomogenized_vec(f)
1.3 takayama 354: POLY f;
1.1 maekawa 355: {
1.3 takayama 356: /* This is not efficient version. *grade should be grade_module1v(). */
1.1 maekawa 357: POLY t;
358: int ggg;
359: if (f == ZERO) return(1);
1.4 takayama 360: if (f->m->ringp->weightedHomogenization) {
361: return 1; /* BUG: do not chech in case of one-zero homogenization */
362: }
1.1 maekawa 363: while (f != POLYNULL) {
364: t = f;
365: ggg = (*grade)(f);
366: while (t != POLYNULL) {
367: if ((*isSameComponent)(f,t)) {
1.3 takayama 368: if (ggg != (*grade)(t)) return(0);
1.1 maekawa 369: }
370: t = t->next;
371: }
372: f = f->next;
373: }
374: return(1);
375: }
376:
377:
378: static int degreeOfPrincipalPart(f)
1.3 takayama 379: POLY f;
1.1 maekawa 380: {
381: int n,i,dd;
382: if (f ISZERO) return(0);
383: n = f->m->ringp->n; dd = 0;
384: /* D[0] is homogenization var */
385: for (i=1; i<n; i++) {
386: dd += f->m->e[i].D;
387: }
388: return(dd);
389: }
390:
391: POLY POLYToPrincipalPart(f)
1.3 takayama 392: POLY f;
1.1 maekawa 393: {
394: POLY node;
395: struct listPoly nod;
396: POLY h;
397: POLY g;
398: int maxd = -20000; /* very big negative number */
399: int dd;
400: node = &nod; node->next = POLYNULL; h = node;
401:
402: g = pCopy(f); /* shallow copy */
403: while (!(f ISZERO)) {
404: dd = degreeOfPrincipalPart(f);
405: if (dd > maxd) maxd = dd;
406: f = f->next;
407: }
408: while (!(g ISZERO)) {
409: dd = degreeOfPrincipalPart(g);
410: if (dd == maxd) {
411: h->next = g;
412: h = h->next;
413: }
414: g = g->next;
415: }
416: h->next = POLYNULL;
417: return(node->next);
418: }
419:
420: static int degreeOfInitW(f,w)
1.3 takayama 421: POLY f;
422: int w[];
1.1 maekawa 423: {
424: int n,i,dd;
425: if (f ISZERO) {
426: errorPoly("degreeOfInitW(0,w) ");
427: }
428: n = f->m->ringp->n; dd = 0;
429: for (i=0; i<n; i++) {
430: dd += (f->m->e[i].D)*w[n+i];
431: dd += (f->m->e[i].x)*w[i];
432: }
433: return(dd);
434: }
435:
436: POLY POLYToInitW(f,w)
1.3 takayama 437: POLY f;
438: int w[]; /* weight vector */
1.1 maekawa 439: {
440: POLY node;
441: struct listPoly nod;
442: POLY h;
443: POLY g;
444: int maxd;
445: int dd;
446: node = &nod; node->next = POLYNULL; h = node;
447:
448: if (f ISZERO) return(f);
449: maxd = degreeOfInitW(f,w);
450: g = pCopy(f); /* shallow copy */
451: while (!(f ISZERO)) {
452: dd = degreeOfInitW(f,w);
453: if (dd > maxd) maxd = dd;
454: f = f->next;
455: }
456: while (!(g ISZERO)) {
457: dd = degreeOfInitW(g,w);
458: if (dd == maxd) {
459: h->next = g;
460: h = h->next;
461: }
462: g = g->next;
463: }
464: h->next = POLYNULL;
465: return(node->next);
466: }
467:
468:
469: /*
470: 1.The substitution "ringp->multiplication = ...." is allowed only in
471: KsetUpRing(), so the check in KswitchFunction is not necessary.
472: 2.mmLarger != matrix and AvoidTheSameRing==1, then error
473: 3.If Schreyer = 1, then the system always generates a new ring.
474: 4.The execution of set_order_by_matrix is not allowed when Avoid... == 1.
475: 5.When mmLarger == tower (in tower.sm1, tower-sugar.sm1), we do
476: as follows with our own risk.
477: [(AvoidTheSameRing)] pushEnv [ [(AvoidTheSameRing) 0] system_variable (mmLarger) (tower) switch_function ] pop popEnv
478: */
479: int isTheSameRing(struct ring *rstack[],int rp, struct ring *newRingp)
480: {
481: struct ring *rrr;
482: int i,j,k;
483: int a=0;
484: for (k=0; k<rp; k++) {
485: rrr = rstack[k];
486: if (rrr->p != newRingp->p) { a=1; goto bbb ; }
487: if (rrr->n != newRingp->n) { a=2; goto bbb ; }
488: if (rrr->nn != newRingp->nn) { a=3; goto bbb ; }
489: if (rrr->m != newRingp->m) { a=4; goto bbb ; }
490: if (rrr->mm != newRingp->mm) { a=5; goto bbb ; }
491: if (rrr->l != newRingp->l) { a=6; goto bbb ; }
492: if (rrr->ll != newRingp->ll) { a=7; goto bbb ; }
493: if (rrr->c != newRingp->c) { a=8; goto bbb ; }
494: if (rrr->cc != newRingp->cc) { a=9; goto bbb ; }
495: for (i=0; i<rrr->n; i++) {
496: if (strcmp(rrr->x[i],newRingp->x[i])!=0) { a=10; goto bbb ; }
497: if (strcmp(rrr->D[i],newRingp->D[i])!=0) { a=11; goto bbb ; }
498: }
499: if (rrr->orderMatrixSize != newRingp->orderMatrixSize) { a=12; goto bbb ; }
500: for (i=0; i<rrr->orderMatrixSize; i++) {
501: for (j=0; j<2*(rrr->n); j++) {
1.3 takayama 502: if (rrr->order[i*2*(rrr->n)+j] != newRingp->order[i*2*(rrr->n)+j])
503: { a=13; goto bbb ; }
1.1 maekawa 504: }
505: }
506: if (rrr->next != newRingp->next) { a=14; goto bbb ; }
507: if (rrr->multiplication != newRingp->multiplication) { a=15; goto bbb ; }
508: /* if (rrr->schreyer != newRingp->schreyer) { a=16; goto bbb ; }*/
509: if (newRingp->schreyer == 1) { a=16; goto bbb; }
1.4 takayama 510: if (rrr->weightedHomogenization != newRingp->weightedHomogenization) { a=16; goto bbb; }
1.7 takayama 511: if (rrr->degreeShiftSize != newRingp->degreeShiftSize) {
512: a = 17; goto bbb;
513: }
514: if (rrr->degreeShiftN != newRingp->degreeShiftN) {
515: a = 17; goto bbb;
516: }
517: for (i=0; i < rrr->degreeShiftSize; i++) {
518: for (j=0; j< rrr->degreeShiftN; j++) {
519: if (rrr->degreeShift[i*(rrr->degreeShiftN)+j] !=
520: newRingp->degreeShift[i*(rrr->degreeShiftN)+j]) {
521: a = 17; goto bbb;
522: }
523: }
524: }
525:
1.1 maekawa 526: /* The following fields are ignored.
527: void *gbListTower;
528: int *outputOrder;
529: char *name;
530: */
531: /* All tests are passed. */
532: return(k);
533: bbb: ;
534: /* for debugging. */
535: /* fprintf(stderr," reason=%d, ",a); */
536: }
537: return(-1);
538: }
1.6 takayama 539:
540: /* s->1 */
541: POLY goDeHomogenizeS(POLY f) {
542: POLY node;
543: POLY lastf;
544: struct listPoly nod;
545: POLY h;
546: POLY tf;
547: int gt,first;
548:
549: if (f == POLYNULL) return(POLYNULL);
550: node = &nod;
551: node->next = POLYNULL;
552: lastf = POLYNULL;
553: first = 1;
554: while (f != POLYNULL) {
555: tf = newCell(f->coeffp,monomialCopy(f->m));
556: tf->m->e[0].x = 0; /* H, s variable in the G-O paper. */
557: if (first) {
558: node->next = tf;
559: lastf = tf;
560: first = 0;
561: }else{
562: gt = (*mmLarger)(lastf,tf);
563: if (gt == 1) {
564: lastf->next = tf;
565: lastf = tf;
566: }else{
567: h = node->next;
568: h = ppAddv(h,tf);
569: node->next = h;
570: lastf = h;
571: while (lastf->next != POLYNULL) {
572: lastf = lastf->next;
573: }
574: }
575: }
576: f = f->next;
577: }
578: return (node->next);
579: }
580:
1.5 takayama 581: /* Granger-Oaku's homogenization for the ecart tangent cone.
582: Note: 2003.07.10.
583: ds[] is the degree shift.
584: ei ( element index ). If it is < 0, then e[n-1]->x will be used,
585: else ei is used.
1.6 takayama 586: if onlyS is set to 1, then input is assumed to be (u,v)-h-homogeneous.
1.5 takayama 587: */
1.6 takayama 588: POLY goHomogenize(POLY f,int u[],int v[],int ds[],int dssize,int ei,int onlyS)
1.5 takayama 589: {
590: POLY node;
591: POLY lastf;
592: struct listPoly nod;
593: POLY h;
594: POLY tf;
595: int gt,first,m,mp,t,tp,dsIdx,message;
1.7 takayama 596: struct ring *rp;
1.5 takayama 597:
598: message = 1;
599: if (f == POLYNULL) return(POLYNULL);
1.7 takayama 600: rp = f->m->ringp;
601: if ((rp->degreeShiftSize == 0) && (dssize > 0)) {
602: warningPoly("You are trying to homogenize a polynomial with degree shift. However, the polynomial belongs to the ring without degreeShift option. It may cause a trouble in comparison in free module.\n");
603: }
1.5 takayama 604: node = &nod;
605: node->next = POLYNULL;
606: lastf = POLYNULL;
607: first = 1;
608: while (f != POLYNULL) {
609: if (first) {
610: t = m = dGrade1(f);
611: tp = mp = uvGrade1(f,u,v,ds,dssize,ei);
612: }else{
613: t = dGrade1(f);
614: tp = uvGrade1(f,u,v,ds,dssize,ei);
615: if (t > m) m = t;
616: if (tp < mp) mp = tp;
617: }
618:
619: tf = newCell(f->coeffp,monomialCopy(f->m));
620: /* Automatic dehomogenize. Not += */
621: if (message && ((tf->m->e[0].D != 0) || (tf->m->e[0].x != 0))) {
622: /*go-debug fprintf(stderr,"Automatic dehomogenize and homogenize.\n"); */
623: message = 0;
624: }
1.6 takayama 625: if (!onlyS) {
626: tf->m->e[0].D = -t; /* h */
627: }
1.5 takayama 628: tf->m->e[0].x = tp; /* H, s variable in the G-O paper. */
629: /*go-debug printf("t(h)=%d, tp(uv+ds)=%d\n",t,tp); */
630: if (first) {
631: node->next = tf;
632: lastf = tf;
633: first = 0;
634: }else{
635: gt = (*mmLarger)(lastf,tf);
636: if (gt == 1) {
637: lastf->next = tf;
638: lastf = tf;
639: }else{
640: /*go-debug printf("?\n"); */
641: h = node->next;
642: h = ppAddv(h,tf);
643: node->next = h;
644: lastf = h;
645: while (lastf->next != POLYNULL) {
646: lastf = lastf->next;
647: }
648: }
649: }
650: f = f->next;
651: }
652: h = node->next;
653: /*go-debug printf("m=%d, mp=%d\n",m,mp); */
654: while (h != POLYNULL) {
655: /*go-debug printf("Old: h=%d, s=%d\n",h->m->e[0].D,h->m->e[0].x); */
1.6 takayama 656: if (!onlyS) h->m->e[0].D += m; /* h */
1.5 takayama 657: h->m->e[0].x += -mp; /* H, s*/
658: /*go-debug printf("New: h=%d, s=%d\n",h->m->e[0].D,h->m->e[0].x); */
659: h = h->next;
660: }
661: return (node->next);
662: }
663:
664: /* u[] = -1, v[] = 1 */
1.6 takayama 665: POLY goHomogenize11(POLY f,int ds[],int dssize,int ei,int onlyS)
1.5 takayama 666: {
667: int r;
668: int i,t,n,m,nn;
669: MONOMIAL tf;
670: static int *u;
671: static int *v;
672: static struct ring *cr = (struct ring *)NULL;
673:
674: if (f == POLYNULL) return POLYNULL;
675:
676: tf = f->m;
677: if (tf->ringp != cr) {
678: n = tf->ringp->n;
679: m = tf->ringp->m;
680: nn = tf->ringp->nn;
681: cr = tf->ringp;
682: u = (int *)sGC_malloc(sizeof(int)*n);
683: v = (int *)sGC_malloc(sizeof(int)*n);
684: for (i=0; i<n; i++) u[i]=v[i]=0;
685: for (i=m; i<nn; i++) {
686: u[i] = -1; v[i] = 1;
687: }
688: }
1.6 takayama 689: return(goHomogenize(f,u,v,ds,dssize,ei,onlyS));
1.5 takayama 690: }
691:
1.6 takayama 692: POLY goHomogenize_dsIdx(POLY f,int u[],int v[],int dsIdx,int ei,int onlyS)
1.5 takayama 693: {
694: if (f == POLYNULL) return POLYNULL;
695: }
1.6 takayama 696: POLY goHomogenize11_dsIdx(POLY f,int ds[],int dsIdx,int ei,int onlyS)
1.5 takayama 697: {
698: if (f == POLYNULL) return POLYNULL;
1.8 ! takayama 699: }
! 700:
! 701: /* cf. KsetUpRing() in kanExport0.c */
! 702: struct ring *newRingOverFp(struct ring *rp,int p) {
! 703: struct ring *newRingp;
! 704: char *ringName = NULL;
! 705: char pstr[64];
! 706: sprintf(pstr,"_%d",p);
! 707: ringName = (char *)sGC_malloc(128);
! 708: newRingp = (struct ring *)sGC_malloc(sizeof(struct ring));
! 709: if (newRingp == NULL) errorPoly("No more memory.\n");
! 710: strcpy(ringName,rp->name);
! 711: strcat(ringName,pstr);
! 712: *newRingp = *rp;
! 713: newRingp->p = p;
! 714: newRingp->name = ringName;
! 715: return newRingp;
! 716: }
! 717:
! 718: /*
! 719: P = 3001;
! 720: L = [ ];
! 721: while (P<10000) {
! 722: L=cons(P,L);
! 723: P = pari(nextprime,P+1);
! 724: }
! 725: print(L);
! 726: */
! 727: #define N799 799
! 728: static int nextPrime(void) {
! 729: static int pt = 0;
! 730: static int tb[N799] =
! 731: {3001,3011,3019,3023,3037,3041,3049,3061,3067,3079,3083,3089,3109,3119,3121,3137,3163,3167,3169,3181,3187,3191,3203,3209,3217,3221,3229,3251,3253,3257,3259,3271,3299,3301,3307,3313,3319,3323,3329,3331,3343,3347,3359,3361,3371,3373,3389,3391,3407,3413,3433,3449,3457,3461,3463,3467,3469,3491,3499,3511,3517,3527,3529,3533,3539,3541,3547,3557,3559,3571,3581,3583,3593,3607,3613,3617,3623,3631,3637,3643,3659,3671,3673,3677,3691,3697,3701,3709,3719,3727,3733,3739,3761,3767,3769,3779,3793,3797,3803,3821,3823,3833,3847,3851,3853,3863,3877,3881,3889,3907,3911,3917,3919,3923,3929,3931,3943,3947,3967,3989,
! 732: 4001,4003,4007,4013,4019,4021,4027,4049,4051,4057,4073,4079,4091,4093,4099,4111,4127,4129,4133,4139,4153,4157,4159,4177,4201,4211,4217,4219,4229,4231,4241,4243,4253,4259,4261,4271,4273,4283,4289,4297,4327,4337,4339,4349,4357,4363,4373,4391,4397,4409,4421,4423,4441,4447,4451,4457,4463,4481,4483,4493,4507,4513,4517,4519,4523,4547,4549,4561,4567,4583,4591,4597,4603,4621,4637,4639,4643,4649,4651,4657,4663,4673,4679,4691,4703,4721,4723,4729,4733,4751,4759,4783,4787,4789,4793,4799,4801,4813,4817,4831,4861,4871,4877,4889,4903,4909,4919,4931,4933,4937,4943,4951,4957,4967,4969,4973,4987,4993,4999,
! 733: 5003,5009,5011,5021,5023,5039,5051,5059,5077,5081,5087,5099,5101,5107,5113,5119,5147,5153,5167,5171,5179,5189,5197,5209,5227,5231,5233,5237,5261,5273,5279,5281,5297,5303,5309,5323,5333,5347,5351,5381,5387,5393,5399,5407,5413,5417,5419,5431,5437,5441,5443,5449,5471,5477,5479,5483,5501,5503,5507,5519,5521,5527,5531,5557,5563,5569,5573,5581,5591,5623,5639,5641,5647,5651,5653,5657,5659,5669,5683,5689,5693,5701,5711,5717,5737,5741,5743,5749,5779,5783,5791,5801,5807,5813,5821,5827,5839,5843,5849,5851,5857,5861,5867,5869,5879,5881,5897,5903,5923,5927,5939,5953,5981,5987,
! 734: 6007,6011,6029,6037,6043,6047,6053,6067,6073,6079,6089,6091,6101,6113,6121,6131,6133,6143,6151,6163,6173,6197,6199,6203,6211,6217,6221,6229,6247,6257,6263,6269,6271,6277,6287,6299,6301,6311,6317,6323,6329,6337,6343,6353,6359,6361,6367,6373,6379,6389,6397,6421,6427,6449,6451,6469,6473,6481,6491,6521,6529,6547,6551,6553,6563,6569,6571,6577,6581,6599,6607,6619,6637,6653,6659,6661,6673,6679,6689,6691,6701,6703,6709,6719,6733,6737,6761,6763,6779,6781,6791,6793,6803,6823,6827,6829,6833,6841,6857,6863,6869,6871,6883,6899,6907,6911,6917,6947,6949,6959,6961,6967,6971,6977,6983,6991,6997,
! 735: 7001,7013,7019,7027,7039,7043,7057,7069,7079,7103,7109,7121,7127,7129,7151,7159,7177,7187,7193,7207,7211,7213,7219,7229,7237,7243,7247,7253,7283,7297,7307,7309,7321,7331,7333,7349,7351,7369,7393,7411,7417,7433,7451,7457,7459,7477,7481,7487,7489,7499,7507,7517,7523,7529,7537,7541,7547,7549,7559,7561,7573,7577,7583,7589,7591,7603,7607,7621,7639,7643,7649,7669,7673,7681,7687,7691,7699,7703,7717,7723,7727,7741,7753,7757,7759,7789,7793,7817,7823,7829,7841,7853,7867,7873,7877,7879,7883,7901,7907,7919,7927,7933,7937,7949,7951,7963,7993,
! 736: 8009,8011,8017,8039,8053,8059,8069,8081,8087,8089,8093,8101,8111,8117,8123,8147,8161,8167,8171,8179,8191,8209,8219,8221,8231,8233,8237,8243,8263,8269,8273,8287,8291,8293,8297,8311,8317,8329,8353,8363,8369,8377,8387,8389,8419,8423,8429,8431,8443,8447,8461,8467,8501,8513,8521,8527,8537,8539,8543,8563,8573,8581,8597,8599,8609,8623,8627,8629,8641,8647,8663,8669,8677,8681,8689,8693,8699,8707,8713,8719,8731,8737,8741,8747,8753,8761,8779,8783,8803,8807,8819,8821,8831,8837,8839,8849,8861,8863,8867,8887,8893,8923,8929,8933,8941,8951,8963,8969,8971,8999,
! 737: 9001,9007,9011,9013,9029,9041,9043,9049,9059,9067,9091,9103,9109,9127,9133,9137,9151,9157,9161,9173,9181,9187,9199,9203,9209,9221,9227,9239,9241,9257,9277,9281,9283,9293,9311,9319,9323,9337,9341,9343,9349,9371,9377,9391,9397,9403,9413,9419,9421,9431,9433,9437,9439,9461,9463,9467,9473,9479,9491,9497,9511,9521,9533,9539,9547,9551,9587,9601,9613,9619,9623,9629,9631,9643,9649,9661,9677,9679,9689,9697,9719,9721,9733,9739,9743,9749,9767,9769,9781,9787,9791,9803,9811,9817,9829,9833,9839,9851,9857,9859,9871,9883,9887,9901,9907,9923,9929,9931,9941,9949,9967,9973};
! 738:
! 739: if (pt <N799) {
! 740: return tb[pt++];
! 741: }else{
! 742: pt = 0;
! 743: return tb[pt++];
! 744: }
! 745: }
! 746:
! 747: int getPrime(int p) {
! 748: int i;
! 749: if (p <= 2) return nextPrime();
! 750: for (i=2; i<p; i++) {
! 751: if (p % i == 0) {
! 752: return nextPrime();
! 753: }
! 754: }
! 755: return p;
1.5 takayama 756: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>