=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/syz0.c,v retrieving revision 1.1 retrieving revision 1.4 diff -u -p -r1.1 -r1.4 --- OpenXM/src/kan96xx/Kan/syz0.c 1999/10/08 02:12:02 1.1 +++ OpenXM/src/kan96xx/Kan/syz0.c 2003/08/27 03:11:12 1.4 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kan96xx/Kan/syz0.c,v 1.3 2001/05/04 01:06:26 takayama Exp $ */ #include #include "datatype.h" #include "extern2.h" @@ -17,7 +18,7 @@ static int getSize00OfGradedSet(struct gradedPolySet * static int positionInPairs(struct pair *top,struct pair *pairs); /* if the top is not in the list pairs, it returns -1. */ static struct pair *oldPairsToNewPairs(struct pair *opairs, - int *table,int size); + int *table,int size); /* In the function getSyzygy(), reduced Grobner basis *grBases is constructed from grG by deleting unnecessary elements. The array <> gives the correspondence between the index @@ -28,7 +29,7 @@ static struct pair *oldPairsToNewPairs(struct pair *op Note that the <> fields are not set properly. */ struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, - struct pair *excludedPairs); + struct pair *excludedPairs); /* When <> is NULL, this function computes all syzygies for the <>. @@ -41,8 +42,8 @@ struct matrixOfPOLY *getSyzygy01(struct gradedPolySet /* if (mark[j]), then the simplification is done. */ void getBackwardTransformation(grG) -struct gradedPolySet *grG; -/* grG->polys[i]->mark[j],syz[j] are modified. */ + struct gradedPolySet *grG; + /* grG->polys[i]->mark[j],syz[j] are modified. */ { int i,j; struct polySet *ps; @@ -52,16 +53,16 @@ struct gradedPolySet *grG; ps = grG->polys[i]; for (j=0; jsize; j++) { if (ps->mark[j] == 0 && ps->del[j] == 0) { - simplifyBT(i,j,grG); + simplifyBT(i,j,grG); } } } } void simplifyBT(grd,index,grG) -int grd; -int index; -struct gradedPolySet *grG; + int grd; + int index; + struct gradedPolySet *grG; { POLY s,r; int g0,i0; @@ -88,9 +89,9 @@ struct gradedPolySet *grG; static POLY getFactor0(grG,grd,index) -struct gradedPolySet *grG; -int grd; -int index; + struct gradedPolySet *grG; + int grd; + int index; { POLY ans; int i,j; @@ -101,7 +102,7 @@ int index; ps = grG->polys[i]; for (j=0; jsize; j++) { if (ps->mark[j] && !(i == grd && j == index)) { - ans = ppMult(ps->syz[j]->cf,ans); + ans = ppMult(ps->syz[j]->cf,ans); } } } @@ -109,8 +110,8 @@ int index; } struct arrayOfPOLY *getSyzygy0(grG,zeroPairs) -struct gradedPolySet *grG; -struct pair *zeroPairs; + struct gradedPolySet *grG; + struct pair *zeroPairs; { struct pair *tmp; int size,k,i; @@ -149,10 +150,10 @@ struct pair *zeroPairs; } struct matrixOfPOLY *getSyzygy(grG,zeroPairs,grBasesp,backwardMatp) -struct gradedPolySet *grG; -struct pair *zeroPairs; -struct gradedPolySet **grBasesp; -struct matrixOfPOLY **backwardMatp; + struct gradedPolySet *grG; + struct pair *zeroPairs; + struct gradedPolySet **grBasesp; + struct matrixOfPOLY **backwardMatp; { int serial; int i,j,kk; @@ -186,13 +187,13 @@ struct matrixOfPOLY **backwardMatp; ps = grG->polys[i]; for (j=0; jsize; j++) { if (ps->del[j] == 0) { - fi = ps->g[j]; - grd = -1;whereInG(*grBasesp,fi,&grd,&indx,Sugar); - *grBasesp = - putPolyInG(*grBasesp,fi,grd,indx,newSyz0(),0,serial); - table[4*serial] = i; table[4*serial+1] = j; - table[4*serial+2] = grd; table[4*serial+3] = indx; - serial++; + fi = ps->g[j]; + grd = -1;whereInG(*grBasesp,fi,&grd,&indx,Sugar); + *grBasesp = + putPolyInG(*grBasesp,fi,grd,indx,newSyz0(),0,serial); + table[4*serial] = i; table[4*serial+1] = j; + table[4*serial+2] = grd; table[4*serial+3] = indx; + serial++; } } } @@ -228,7 +229,7 @@ struct matrixOfPOLY **backwardMatp; printf("zeroPairs = "); outputNode(zeroPairs); for (i=0; in = %d, serial=%d \n",ap->n, serial); - printf("\nmp = \n"); printMatrixOfPOLY(mp); */ + printf("\nmp = \n"); printMatrixOfPOLY(mp); */ if (KanGBmessage) {printf(";"); fflush(stdout);} m1 = aaMult(mp,b); @@ -274,7 +276,7 @@ struct matrixOfPOLY **backwardMatp; for (i=0; im; i++) { if (!isZeroRow(m0,i)) { for (j=0; jn; j++) { - getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m0,i,j); + getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m0,i,j); } kk++; } @@ -282,7 +284,7 @@ struct matrixOfPOLY **backwardMatp; for (i=0; im; i++) { if (!isZeroRow(m1,i)) { for (j=0; jn; j++) { - getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m1,i,j); + getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m1,i,j); } kk++; } @@ -290,7 +292,7 @@ struct matrixOfPOLY **backwardMatp; for (i=0; im; i++) { if (!isZeroRow(m2,i)) { for (j=0; jn; j++) { - getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m2,i,j); + getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m2,i,j); } kk++; if (KanGBmessage) printf("*"); } @@ -299,7 +301,7 @@ struct matrixOfPOLY **backwardMatp; ans2 = newMatrixOfPOLY(kk,ans->n); for (i=0; in; j++) { - getMatrixOfPOLY(ans2,i,j) = getMatrixOfPOLY(ans,i,j); + getMatrixOfPOLY(ans2,i,j) = getMatrixOfPOLY(ans,i,j); } } return(ans2); @@ -310,8 +312,8 @@ struct matrixOfPOLY **backwardMatp; } POLY getSyzPolyFromSp(spij,grG) -struct pair *spij; -struct gradedPolySet *grG; + struct pair *spij; + struct gradedPolySet *grG; { int ig,ii,jg,ji; POLY dk; @@ -347,7 +349,7 @@ struct gradedPolySet *grG; } static void clearMark(grG) -struct gradedPolySet *grG; + struct gradedPolySet *grG; { int i,j; struct polySet *ps; @@ -361,9 +363,9 @@ struct gradedPolySet *grG; struct arrayOfPOLY *syzPolyToArrayOfPOLY(size,f,grG) -int size; -POLY f; /* f is in the SyzRingp */ -struct gradedPolySet *grG; + int size; + POLY f; /* f is in the SyzRingp */ + struct gradedPolySet *grG; { struct arrayOfPOLY *ap; int i,g0,i0,serial; @@ -415,11 +417,11 @@ struct matrixOfPOLY *getBackwardMatrixOfPOLY(struct gr ps = grG->polys[i]; for (j=0; jsize; j++) { if (ps->del[j] == 0) { - vec = syzPolyToArrayOfPOLY(inputSize,ps->syz[j]->syz,grG); - for (p=0; psyz[j]->syz,grG); + for (p=0; ppolys[i]; for (j=0; jsize; j++) { if (ps->serial[j] >= 0) { - ii = ps->serial[j]; - vec = syzPolyToArrayOfPOLY(n,ps->syz[j]->syz,grBases); - for (k=0; kserial[j]; + vec = syzPolyToArrayOfPOLY(n,ps->syz[j]->syz,grBases); + for (k=0; kpolys[i]; for (j=0; jsize; j++) { if (ps->serial[j] >= 0) { - ii = ps->serial[j]; - getArrayOfPOLY(mat,ii) = ps->syz[j]->cf; + ii = ps->serial[j]; + getArrayOfPOLY(mat,ii) = ps->syz[j]->cf; } } } @@ -498,9 +500,9 @@ struct gradedPolySet *newG; /* F is stored and index /* Syzygy from E-CB */ struct matrixOfPOLY *getSyzygy1(b,nc,dc) -struct matrixOfPOLY *b; -struct matrixOfPOLY *nc; -struct arrayOfPOLY *dc; + struct matrixOfPOLY *b; + struct matrixOfPOLY *nc; + struct arrayOfPOLY *dc; { int m,n2,n; struct matrixOfPOLY *mat; @@ -516,11 +518,11 @@ struct arrayOfPOLY *dc; for (j=0; jn; @@ -541,15 +543,15 @@ int i; } void errorSyz0(s) -char *s; + char *s; { fprintf(stderr,"Error(syz0.c): %s \n",s); exit(10); } - + static void printMatrixOfPOLY(mat) -struct matrixOfPOLY *mat; + struct matrixOfPOLY *mat; { int n,m,i,j; POLY f; @@ -565,7 +567,7 @@ struct matrixOfPOLY *mat; } static void printArrayOfPOLY(mat) -struct arrayOfPOLY *mat; + struct arrayOfPOLY *mat; { int n,m,i,j; POLY f; @@ -578,7 +580,7 @@ struct arrayOfPOLY *mat; } struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, - struct pair *excludePairs) + struct pair *excludePairs) { int r; struct gradedPolySet *g; @@ -624,7 +626,7 @@ struct matrixOfPOLY *getSyzygy01(struct gradedPolySet d = updatePairs(d,gt,grade,indx,g); g = putPolyInG(g,gt,grade,indx,newSyz0(),1,ps->serial[j]); if (Debugsyz0) { - outputGradedPairs(d); outputGradedPolySet(g,1); + outputGradedPairs(d); outputGradedPolySet(g,1); } } } @@ -646,28 +648,28 @@ struct matrixOfPOLY *getSyzygy01(struct gradedPolySet syzCf = syz.cf; if (KanGBmessage) { - if (pgrade != top->grade) { - pgrade = top->grade; - printf(" %d",pgrade); - fflush(stdout); - }else{ - if (rd ISZERO) { - printf("o"); fflush(stdout); - }else{ - printf("."); fflush(stdout); - } - } + if (pgrade != top->grade) { + pgrade = top->grade; + printf(" %d",pgrade); + fflush(stdout); + }else{ + if (rd ISZERO) { + printf("o"); fflush(stdout); + }else{ + printf("."); fflush(stdout); + } + } } if (!(rd ISZERO)) { - fprintf(stderr,"The given argument of getSyzygy01 is not a g-basis.\n"); - return((struct matrixOfPOLY *)NULL); + fprintf(stderr,"The given argument of getSyzygy01 is not a g-basis.\n"); + return((struct matrixOfPOLY *)NULL); }else{ - top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); - top->syz = cpMult(toSyzCoeff(syzCf),top->syz); - top->syz = ppAdd(top->syz,syzPoly); - listP->next = top; top->prev = listP; listP = listP->next; - listPsize++; + top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); + top->syz = cpMult(toSyzCoeff(syzCf),top->syz); + top->syz = ppAdd(top->syz,syzPoly); + listP->next = top; top->prev = listP; listP = listP->next; + listPsize++; } } } @@ -699,7 +701,7 @@ static int getSize00OfGradedSet(struct gradedPolySet * ps = g->polys[i]; for (j=0; jsize; j++) { if (ps->del[j] == 0) { - size += 1; + size += 1; } } } @@ -714,9 +716,9 @@ static int positionInPairs(struct pair *top, struct pa if (top == (struct pair *)NULL) return(-1); while (tmp != (struct pair *)NULL) { if (((top->ig == tmp->ig) && (top->ii == tmp->ii) && - (top->jg == tmp->jg) && (top->ji == tmp->ji)) || - ((top->ig == tmp->jg) && (top->ii == tmp->ji) && - (top->jg == tmp->ig) && (top->ji == tmp->ii))) { + (top->jg == tmp->jg) && (top->ji == tmp->ji)) || + ((top->ig == tmp->jg) && (top->ii == tmp->ji) && + (top->jg == tmp->ig) && (top->ji == tmp->ii))) { return(pos); } pos++; @@ -726,7 +728,7 @@ static int positionInPairs(struct pair *top, struct pa } static struct pair *oldPairsToNewPairs(struct pair *opairs, - int *table,int size) { + int *table,int size) { /* Never loop up prev field. */ int ig,ii,jg,ji; int p,q; @@ -738,15 +740,15 @@ static struct pair *oldPairsToNewPairs(struct pair *op for (p=0; pprev = NULL; - ans->ig = table[4*p+2]; ans->ii = table[4*p+3]; - ans->jg = table[4*q+2]; ans->ji = table[4*q+3]; - ans->next = oldPairsToNewPairs(opairs->next,table,size); - return(ans); - } + if (table[4*q] == jg && table[4*q+1] == ji) { + ans = newPair(NULL); + *ans = *opairs; + ans->prev = NULL; + ans->ig = table[4*p+2]; ans->ii = table[4*p+3]; + ans->jg = table[4*q+2]; ans->ji = table[4*q+3]; + ans->next = oldPairsToNewPairs(opairs->next,table,size); + return(ans); + } } } }