version 1.1, 1999/10/08 02:12:02 |
version 1.3, 2001/05/04 01:06:26 |
|
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/syz0.c,v 1.2 2000/01/16 07:55:41 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "extern2.h" |
#include "extern2.h" |
Line 17 static int getSize00OfGradedSet(struct gradedPolySet * |
|
Line 18 static int getSize00OfGradedSet(struct gradedPolySet * |
|
static int positionInPairs(struct pair *top,struct pair *pairs); |
static int positionInPairs(struct pair *top,struct pair *pairs); |
/* if the top is not in the list pairs, it returns -1. */ |
/* if the top is not in the list pairs, it returns -1. */ |
static struct pair *oldPairsToNewPairs(struct pair *opairs, |
static struct pair *oldPairsToNewPairs(struct pair *opairs, |
int *table,int size); |
int *table,int size); |
/* In the function getSyzygy(), reduced Grobner basis *grBases is |
/* In the function getSyzygy(), reduced Grobner basis *grBases is |
constructed from grG by deleting unnecessary elements. |
constructed from grG by deleting unnecessary elements. |
The array <<table>> gives the correspondence between the index |
The array <<table>> gives the correspondence between the index |
Line 28 static struct pair *oldPairsToNewPairs(struct pair *op |
|
Line 29 static struct pair *oldPairsToNewPairs(struct pair *op |
|
Note that the <<prev>> fields are not set properly. |
Note that the <<prev>> fields are not set properly. |
*/ |
*/ |
struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, |
struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, |
struct pair *excludedPairs); |
struct pair *excludedPairs); |
/* |
/* |
When <<excludedPairs>> is NULL, |
When <<excludedPairs>> is NULL, |
this function computes all syzygies for the <<reducedBasis>>. |
this function computes all syzygies for the <<reducedBasis>>. |
Line 41 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
Line 42 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
|
|
/* if (mark[j]), then the simplification is done. */ |
/* if (mark[j]), then the simplification is done. */ |
void getBackwardTransformation(grG) |
void getBackwardTransformation(grG) |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
/* grG->polys[i]->mark[j],syz[j] are modified. */ |
/* grG->polys[i]->mark[j],syz[j] are modified. */ |
{ |
{ |
int i,j; |
int i,j; |
struct polySet *ps; |
struct polySet *ps; |
Line 52 struct gradedPolySet *grG; |
|
Line 53 struct gradedPolySet *grG; |
|
ps = grG->polys[i]; |
ps = grG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->mark[j] == 0 && ps->del[j] == 0) { |
if (ps->mark[j] == 0 && ps->del[j] == 0) { |
simplifyBT(i,j,grG); |
simplifyBT(i,j,grG); |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
void simplifyBT(grd,index,grG) |
void simplifyBT(grd,index,grG) |
int grd; |
int grd; |
int index; |
int index; |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
{ |
{ |
POLY s,r; |
POLY s,r; |
int g0,i0; |
int g0,i0; |
Line 88 struct gradedPolySet *grG; |
|
Line 89 struct gradedPolySet *grG; |
|
|
|
|
|
static POLY getFactor0(grG,grd,index) |
static POLY getFactor0(grG,grd,index) |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
int grd; |
int grd; |
int index; |
int index; |
{ |
{ |
POLY ans; |
POLY ans; |
int i,j; |
int i,j; |
|
|
ps = grG->polys[i]; |
ps = grG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->mark[j] && !(i == grd && j == index)) { |
if (ps->mark[j] && !(i == grd && j == index)) { |
ans = ppMult(ps->syz[j]->cf,ans); |
ans = ppMult(ps->syz[j]->cf,ans); |
} |
} |
} |
} |
} |
} |
|
|
} |
} |
|
|
struct arrayOfPOLY *getSyzygy0(grG,zeroPairs) |
struct arrayOfPOLY *getSyzygy0(grG,zeroPairs) |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
struct pair *zeroPairs; |
struct pair *zeroPairs; |
{ |
{ |
struct pair *tmp; |
struct pair *tmp; |
int size,k,i; |
int size,k,i; |
Line 149 struct pair *zeroPairs; |
|
Line 150 struct pair *zeroPairs; |
|
} |
} |
|
|
struct matrixOfPOLY *getSyzygy(grG,zeroPairs,grBasesp,backwardMatp) |
struct matrixOfPOLY *getSyzygy(grG,zeroPairs,grBasesp,backwardMatp) |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
struct pair *zeroPairs; |
struct pair *zeroPairs; |
struct gradedPolySet **grBasesp; |
struct gradedPolySet **grBasesp; |
struct matrixOfPOLY **backwardMatp; |
struct matrixOfPOLY **backwardMatp; |
{ |
{ |
int serial; |
int serial; |
int i,j,kk; |
int i,j,kk; |
Line 186 struct matrixOfPOLY **backwardMatp; |
|
Line 187 struct matrixOfPOLY **backwardMatp; |
|
ps = grG->polys[i]; |
ps = grG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->del[j] == 0) { |
if (ps->del[j] == 0) { |
fi = ps->g[j]; |
fi = ps->g[j]; |
grd = -1;whereInG(*grBasesp,fi,&grd,&indx,Sugar); |
grd = -1;whereInG(*grBasesp,fi,&grd,&indx,Sugar); |
*grBasesp = |
*grBasesp = |
putPolyInG(*grBasesp,fi,grd,indx,newSyz0(),0,serial); |
putPolyInG(*grBasesp,fi,grd,indx,newSyz0(),0,serial); |
table[4*serial] = i; table[4*serial+1] = j; |
table[4*serial] = i; table[4*serial+1] = j; |
table[4*serial+2] = grd; table[4*serial+3] = indx; |
table[4*serial+2] = grd; table[4*serial+3] = indx; |
serial++; |
serial++; |
} |
} |
} |
} |
} |
} |
Line 228 struct matrixOfPOLY **backwardMatp; |
|
Line 229 struct matrixOfPOLY **backwardMatp; |
|
printf("zeroPairs = "); outputNode(zeroPairs); |
printf("zeroPairs = "); outputNode(zeroPairs); |
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
printf("old gi=%d, old ii=%d, new gi=%d, new ii=%d\n", |
printf("old gi=%d, old ii=%d, new gi=%d, new ii=%d\n", |
table[4*i],table[4*i+1],table[4*i+2],table[4*i+3]); |
table[4*i],table[4*i+1],table[4*i+2],table[4*i+3]); |
} |
} |
printf("excludePairs = "); outputNode(excludePairs); |
printf("excludePairs = "); outputNode(excludePairs); |
printf("\n"); |
printf("\n"); |
Line 247 struct matrixOfPOLY **backwardMatp; |
|
Line 248 struct matrixOfPOLY **backwardMatp; |
|
printf("\nb=\n"); printMatrixOfPOLY(b); |
printf("\nb=\n"); printMatrixOfPOLY(b); |
printf("\n\nnc=\n"); printMatrixOfPOLY(nc); |
printf("\n\nnc=\n"); printMatrixOfPOLY(nc); |
printf("\n\ndc=\n"); printArrayOfPOLY(dc); |
printf("\n\ndc=\n"); printArrayOfPOLY(dc); |
}*/ |
}*/ |
|
|
if (KanGBmessage) {printf(":"); fflush(stdout);} |
if (KanGBmessage) {printf(":"); fflush(stdout);} |
m2 = getSyzygy1(b,nc,dc); |
m2 = getSyzygy1(b,nc,dc); |
Line 262 struct matrixOfPOLY **backwardMatp; |
|
Line 263 struct matrixOfPOLY **backwardMatp; |
|
} |
} |
} |
} |
/*printf(" ap->n = %d, serial=%d \n",ap->n, serial); |
/*printf(" ap->n = %d, serial=%d \n",ap->n, serial); |
printf("\nmp = \n"); printMatrixOfPOLY(mp); */ |
printf("\nmp = \n"); printMatrixOfPOLY(mp); */ |
|
|
if (KanGBmessage) {printf(";"); fflush(stdout);} |
if (KanGBmessage) {printf(";"); fflush(stdout);} |
m1 = aaMult(mp,b); |
m1 = aaMult(mp,b); |
Line 274 struct matrixOfPOLY **backwardMatp; |
|
Line 275 struct matrixOfPOLY **backwardMatp; |
|
for (i=0; i<m0->m; i++) { |
for (i=0; i<m0->m; i++) { |
if (!isZeroRow(m0,i)) { |
if (!isZeroRow(m0,i)) { |
for (j=0; j<m0->n; j++) { |
for (j=0; j<m0->n; j++) { |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m0,i,j); |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m0,i,j); |
} |
} |
kk++; |
kk++; |
} |
} |
Line 282 struct matrixOfPOLY **backwardMatp; |
|
Line 283 struct matrixOfPOLY **backwardMatp; |
|
for (i=0; i<m1->m; i++) { |
for (i=0; i<m1->m; i++) { |
if (!isZeroRow(m1,i)) { |
if (!isZeroRow(m1,i)) { |
for (j=0; j<m1->n; j++) { |
for (j=0; j<m1->n; j++) { |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m1,i,j); |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m1,i,j); |
} |
} |
kk++; |
kk++; |
} |
} |
Line 290 struct matrixOfPOLY **backwardMatp; |
|
Line 291 struct matrixOfPOLY **backwardMatp; |
|
for (i=0; i<m2->m; i++) { |
for (i=0; i<m2->m; i++) { |
if (!isZeroRow(m2,i)) { |
if (!isZeroRow(m2,i)) { |
for (j=0; j<m2->n; j++) { |
for (j=0; j<m2->n; j++) { |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m2,i,j); |
getMatrixOfPOLY(ans,kk,j) = getMatrixOfPOLY(m2,i,j); |
} |
} |
kk++; if (KanGBmessage) printf("*"); |
kk++; if (KanGBmessage) printf("*"); |
} |
} |
Line 299 struct matrixOfPOLY **backwardMatp; |
|
Line 300 struct matrixOfPOLY **backwardMatp; |
|
ans2 = newMatrixOfPOLY(kk,ans->n); |
ans2 = newMatrixOfPOLY(kk,ans->n); |
for (i=0; i<kk; i++) { |
for (i=0; i<kk; i++) { |
for (j=0; j<ans->n; j++) { |
for (j=0; j<ans->n; j++) { |
getMatrixOfPOLY(ans2,i,j) = getMatrixOfPOLY(ans,i,j); |
getMatrixOfPOLY(ans2,i,j) = getMatrixOfPOLY(ans,i,j); |
} |
} |
} |
} |
return(ans2); |
return(ans2); |
Line 310 struct matrixOfPOLY **backwardMatp; |
|
Line 311 struct matrixOfPOLY **backwardMatp; |
|
} |
} |
|
|
POLY getSyzPolyFromSp(spij,grG) |
POLY getSyzPolyFromSp(spij,grG) |
struct pair *spij; |
struct pair *spij; |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
{ |
{ |
int ig,ii,jg,ji; |
int ig,ii,jg,ji; |
POLY dk; |
POLY dk; |
Line 347 struct gradedPolySet *grG; |
|
Line 348 struct gradedPolySet *grG; |
|
} |
} |
|
|
static void clearMark(grG) |
static void clearMark(grG) |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
{ |
{ |
int i,j; |
int i,j; |
struct polySet *ps; |
struct polySet *ps; |
Line 361 struct gradedPolySet *grG; |
|
Line 362 struct gradedPolySet *grG; |
|
|
|
|
|
struct arrayOfPOLY *syzPolyToArrayOfPOLY(size,f,grG) |
struct arrayOfPOLY *syzPolyToArrayOfPOLY(size,f,grG) |
int size; |
int size; |
POLY f; /* f is in the SyzRingp */ |
POLY f; /* f is in the SyzRingp */ |
struct gradedPolySet *grG; |
struct gradedPolySet *grG; |
{ |
{ |
struct arrayOfPOLY *ap; |
struct arrayOfPOLY *ap; |
int i,g0,i0,serial; |
int i,g0,i0,serial; |
Line 415 struct matrixOfPOLY *getBackwardMatrixOfPOLY(struct gr |
|
Line 416 struct matrixOfPOLY *getBackwardMatrixOfPOLY(struct gr |
|
ps = grG->polys[i]; |
ps = grG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->del[j] == 0) { |
if (ps->del[j] == 0) { |
vec = syzPolyToArrayOfPOLY(inputSize,ps->syz[j]->syz,grG); |
vec = syzPolyToArrayOfPOLY(inputSize,ps->syz[j]->syz,grG); |
for (p=0; p<inputSize; p++) { |
for (p=0; p<inputSize; p++) { |
getMatrixOfPOLY(mat,k,p)=getArrayOfPOLY(vec,p); |
getMatrixOfPOLY(mat,k,p)=getArrayOfPOLY(vec,p); |
} |
} |
k++; |
k++; |
} |
} |
} |
} |
} |
} |
Line 428 struct matrixOfPOLY *getBackwardMatrixOfPOLY(struct gr |
|
Line 429 struct matrixOfPOLY *getBackwardMatrixOfPOLY(struct gr |
|
|
|
|
|
struct matrixOfPOLY *getNC(newG,n,grBases) |
struct matrixOfPOLY *getNC(newG,n,grBases) |
struct gradedPolySet *newG; /* F is stored and indexed by serial. */ |
struct gradedPolySet *newG; /* F is stored and indexed by serial. */ |
int n; /* The number of G. */ |
int n; /* The number of G. */ |
struct gradedPolySet *grBases; /* G (G-basis) is stored. */ |
struct gradedPolySet *grBases; /* G (G-basis) is stored. */ |
{ |
{ |
int size,i,j,k,ii; |
int size,i,j,k,ii; |
struct matrixOfPOLY *mat; |
struct matrixOfPOLY *mat; |
Line 452 struct gradedPolySet *grBases; /* G (G-basis) is store |
|
Line 453 struct gradedPolySet *grBases; /* G (G-basis) is store |
|
ps = newG->polys[i]; |
ps = newG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->serial[j] >= 0) { |
if (ps->serial[j] >= 0) { |
ii = ps->serial[j]; |
ii = ps->serial[j]; |
vec = syzPolyToArrayOfPOLY(n,ps->syz[j]->syz,grBases); |
vec = syzPolyToArrayOfPOLY(n,ps->syz[j]->syz,grBases); |
for (k=0; k<n; k++) { |
for (k=0; k<n; k++) { |
getMatrixOfPOLY(mat,ii,k) = getArrayOfPOLY(vec,k); |
getMatrixOfPOLY(mat,ii,k) = getArrayOfPOLY(vec,k); |
} |
} |
} |
} |
} |
} |
} |
} |
Line 464 struct gradedPolySet *grBases; /* G (G-basis) is store |
|
Line 465 struct gradedPolySet *grBases; /* G (G-basis) is store |
|
} |
} |
|
|
struct arrayOfPOLY *getDC(newG) |
struct arrayOfPOLY *getDC(newG) |
struct gradedPolySet *newG; /* F is stored and indexed by serial. */ |
struct gradedPolySet *newG; /* F is stored and indexed by serial. */ |
{ |
{ |
int size,i,j,k,ii; |
int size,i,j,k,ii; |
struct arrayOfPOLY *mat; |
struct arrayOfPOLY *mat; |
Line 486 struct gradedPolySet *newG; /* F is stored and index |
|
Line 487 struct gradedPolySet *newG; /* F is stored and index |
|
ps = newG->polys[i]; |
ps = newG->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->serial[j] >= 0) { |
if (ps->serial[j] >= 0) { |
ii = ps->serial[j]; |
ii = ps->serial[j]; |
getArrayOfPOLY(mat,ii) = ps->syz[j]->cf; |
getArrayOfPOLY(mat,ii) = ps->syz[j]->cf; |
} |
} |
} |
} |
} |
} |
Line 498 struct gradedPolySet *newG; /* F is stored and index |
|
Line 499 struct gradedPolySet *newG; /* F is stored and index |
|
|
|
/* Syzygy from E-CB */ |
/* Syzygy from E-CB */ |
struct matrixOfPOLY *getSyzygy1(b,nc,dc) |
struct matrixOfPOLY *getSyzygy1(b,nc,dc) |
struct matrixOfPOLY *b; |
struct matrixOfPOLY *b; |
struct matrixOfPOLY *nc; |
struct matrixOfPOLY *nc; |
struct arrayOfPOLY *dc; |
struct arrayOfPOLY *dc; |
{ |
{ |
int m,n2,n; |
int m,n2,n; |
struct matrixOfPOLY *mat; |
struct matrixOfPOLY *mat; |
Line 516 struct arrayOfPOLY *dc; |
|
Line 517 struct arrayOfPOLY *dc; |
|
for (j=0; j<n; j++) { |
for (j=0; j<n; j++) { |
r = ZERO; |
r = ZERO; |
if (i == j) { |
if (i == j) { |
r = getArrayOfPOLY(dc,i); |
r = getArrayOfPOLY(dc,i); |
} |
} |
for (k=0; k<n2; k++) { |
for (k=0; k<n2; k++) { |
tmp = ppMult(getMatrixOfPOLY(nc,i,k),getMatrixOfPOLY(b,k,j)); |
tmp = ppMult(getMatrixOfPOLY(nc,i,k),getMatrixOfPOLY(b,k,j)); |
r = ppAdd(r,tmp); |
r = ppAdd(r,tmp); |
} |
} |
getMatrixOfPOLY(mat,i,j) = r; |
getMatrixOfPOLY(mat,i,j) = r; |
} |
} |
Line 529 struct arrayOfPOLY *dc; |
|
Line 530 struct arrayOfPOLY *dc; |
|
} |
} |
|
|
static int isZeroRow(mat,i) |
static int isZeroRow(mat,i) |
struct matrixOfPOLY *mat; |
struct matrixOfPOLY *mat; |
int i; |
int i; |
{ |
{ |
int n,j; |
int n,j; |
n = mat->n; |
n = mat->n; |
|
|
} |
} |
|
|
void errorSyz0(s) |
void errorSyz0(s) |
char *s; |
char *s; |
{ |
{ |
fprintf(stderr,"Error(syz0.c): %s \n",s); |
fprintf(stderr,"Error(syz0.c): %s \n",s); |
exit(10); |
exit(10); |
} |
} |
|
|
|
|
static void printMatrixOfPOLY(mat) |
static void printMatrixOfPOLY(mat) |
struct matrixOfPOLY *mat; |
struct matrixOfPOLY *mat; |
{ |
{ |
int n,m,i,j; |
int n,m,i,j; |
POLY f; |
POLY f; |
Line 565 struct matrixOfPOLY *mat; |
|
Line 566 struct matrixOfPOLY *mat; |
|
} |
} |
|
|
static void printArrayOfPOLY(mat) |
static void printArrayOfPOLY(mat) |
struct arrayOfPOLY *mat; |
struct arrayOfPOLY *mat; |
{ |
{ |
int n,m,i,j; |
int n,m,i,j; |
POLY f; |
POLY f; |
Line 578 struct arrayOfPOLY *mat; |
|
Line 579 struct arrayOfPOLY *mat; |
|
} |
} |
|
|
struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, |
struct matrixOfPOLY *getSyzygy01(struct gradedPolySet *reducedBasis, |
struct pair *excludePairs) |
struct pair *excludePairs) |
{ |
{ |
int r; |
int r; |
struct gradedPolySet *g; |
struct gradedPolySet *g; |
Line 624 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
Line 625 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
d = updatePairs(d,gt,grade,indx,g); |
d = updatePairs(d,gt,grade,indx,g); |
g = putPolyInG(g,gt,grade,indx,newSyz0(),1,ps->serial[j]); |
g = putPolyInG(g,gt,grade,indx,newSyz0(),1,ps->serial[j]); |
if (Debugsyz0) { |
if (Debugsyz0) { |
outputGradedPairs(d); outputGradedPolySet(g,1); |
outputGradedPairs(d); outputGradedPolySet(g,1); |
} |
} |
} |
} |
} |
} |
Line 646 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
Line 647 struct matrixOfPOLY *getSyzygy01(struct gradedPolySet |
|
syzCf = syz.cf; |
syzCf = syz.cf; |
|
|
if (KanGBmessage) { |
if (KanGBmessage) { |
if (pgrade != top->grade) { |
if (pgrade != top->grade) { |
pgrade = top->grade; |
pgrade = top->grade; |
printf(" %d",pgrade); |
printf(" %d",pgrade); |
fflush(stdout); |
fflush(stdout); |
}else{ |
}else{ |
if (rd ISZERO) { |
if (rd ISZERO) { |
printf("o"); fflush(stdout); |
printf("o"); fflush(stdout); |
}else{ |
}else{ |
printf("."); fflush(stdout); |
printf("."); fflush(stdout); |
} |
} |
} |
} |
} |
} |
|
|
if (!(rd ISZERO)) { |
if (!(rd ISZERO)) { |
fprintf(stderr,"The given argument of getSyzygy01 is not a g-basis.\n"); |
fprintf(stderr,"The given argument of getSyzygy01 is not a g-basis.\n"); |
return((struct matrixOfPOLY *)NULL); |
return((struct matrixOfPOLY *)NULL); |
}else{ |
}else{ |
top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
top->syz = ppAdd(toSyzPoly(h.a,ig,ii),toSyzPoly(h.b,jg,ji)); |
top->syz = cpMult(toSyzCoeff(syzCf),top->syz); |
top->syz = cpMult(toSyzCoeff(syzCf),top->syz); |
top->syz = ppAdd(top->syz,syzPoly); |
top->syz = ppAdd(top->syz,syzPoly); |
listP->next = top; top->prev = listP; listP = listP->next; |
listP->next = top; top->prev = listP; listP = listP->next; |
listPsize++; |
listPsize++; |
} |
} |
} |
} |
} |
} |
Line 699 static int getSize00OfGradedSet(struct gradedPolySet * |
|
Line 700 static int getSize00OfGradedSet(struct gradedPolySet * |
|
ps = g->polys[i]; |
ps = g->polys[i]; |
for (j=0; j<ps->size; j++) { |
for (j=0; j<ps->size; j++) { |
if (ps->del[j] == 0) { |
if (ps->del[j] == 0) { |
size += 1; |
size += 1; |
} |
} |
} |
} |
} |
} |
Line 714 static int positionInPairs(struct pair *top, struct pa |
|
Line 715 static int positionInPairs(struct pair *top, struct pa |
|
if (top == (struct pair *)NULL) return(-1); |
if (top == (struct pair *)NULL) return(-1); |
while (tmp != (struct pair *)NULL) { |
while (tmp != (struct pair *)NULL) { |
if (((top->ig == tmp->ig) && (top->ii == tmp->ii) && |
if (((top->ig == tmp->ig) && (top->ii == tmp->ii) && |
(top->jg == tmp->jg) && (top->ji == tmp->ji)) || |
(top->jg == tmp->jg) && (top->ji == tmp->ji)) || |
((top->ig == tmp->jg) && (top->ii == tmp->ji) && |
((top->ig == tmp->jg) && (top->ii == tmp->ji) && |
(top->jg == tmp->ig) && (top->ji == tmp->ii))) { |
(top->jg == tmp->ig) && (top->ji == tmp->ii))) { |
return(pos); |
return(pos); |
} |
} |
pos++; |
pos++; |
Line 726 static int positionInPairs(struct pair *top, struct pa |
|
Line 727 static int positionInPairs(struct pair *top, struct pa |
|
} |
} |
|
|
static struct pair *oldPairsToNewPairs(struct pair *opairs, |
static struct pair *oldPairsToNewPairs(struct pair *opairs, |
int *table,int size) { |
int *table,int size) { |
/* Never loop up prev field. */ |
/* Never loop up prev field. */ |
int ig,ii,jg,ji; |
int ig,ii,jg,ji; |
int p,q; |
int p,q; |
Line 738 static struct pair *oldPairsToNewPairs(struct pair *op |
|
Line 739 static struct pair *oldPairsToNewPairs(struct pair *op |
|
for (p=0; p<size; p++) { |
for (p=0; p<size; p++) { |
if (table[4*p] == ig && table[4*p+1] == ii ) { |
if (table[4*p] == ig && table[4*p+1] == ii ) { |
for (q = 0; q<size; q++) { |
for (q = 0; q<size; q++) { |
if (table[4*q] == jg && table[4*q+1] == ji) { |
if (table[4*q] == jg && table[4*q+1] == ji) { |
ans = newPair(NULL); |
ans = newPair(NULL); |
*ans = *opairs; |
*ans = *opairs; |
ans->prev = NULL; |
ans->prev = NULL; |
ans->ig = table[4*p+2]; ans->ii = table[4*p+3]; |
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->jg = table[4*q+2]; ans->ji = table[4*q+3]; |
ans->next = oldPairsToNewPairs(opairs->next,table,size); |
ans->next = oldPairsToNewPairs(opairs->next,table,size); |
return(ans); |
return(ans); |
} |
} |
} |
} |
} |
} |
} |
} |