version 1.1, 1999/10/08 02:12:01 |
version 1.6, 2002/09/08 10:49:50 |
|
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/order.c,v 1.5 2002/02/09 06:21:02 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
Line 20 static void warningOrder(char *s); |
|
Line 21 static void warningOrder(char *s); |
|
static void errorOrder(char *s); |
static void errorOrder(char *s); |
|
|
void setOrderByMatrix(order,n,c,l,omsize) |
void setOrderByMatrix(order,n,c,l,omsize) |
int order[]; |
int order[]; |
int n,c,l,omsize; |
int n,c,l,omsize; |
{ |
{ |
int i,j; |
int i,j; |
int *Order; |
int *Order; |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
|
|
switch_mmLarger("default"); |
switch_mmLarger("default"); |
/* q-case */ |
/* q-case */ |
if ( l-c > 0) { |
if ( l-c > 0) { |
switch_mmLarger("qmatrix"); |
switch_mmLarger("qmatrix"); |
} |
} |
Line 45 int n,c,l,omsize; |
|
Line 46 int n,c,l,omsize; |
|
} |
} |
|
|
void showRing(level,ringp) |
void showRing(level,ringp) |
int level; |
int level; |
struct ring *ringp; |
struct ring *ringp; |
{ |
{ |
int i,j; |
int i,j; |
FILE *fp; |
FILE *fp; |
Line 57 struct ring *ringp; |
|
Line 58 struct ring *ringp; |
|
int P; |
int P; |
char *mtype; |
char *mtype; |
extern char *F_isSameComponent; |
extern char *F_isSameComponent; |
|
POLY f; |
|
POLY fx; |
|
POLY fd; |
|
POLY rf; |
fp = stdout; |
fp = stdout; |
|
|
N=ringp->n; M = ringp->m; L = ringp->l; C = ringp->c; |
N=ringp->n; M = ringp->m; L = ringp->l; C = ringp->c; |
Line 79 struct ring *ringp; |
|
Line 84 struct ring *ringp; |
|
fprintf(fp,"\n"); |
fprintf(fp,"\n"); |
fprintf(fp,"where "); |
fprintf(fp,"where "); |
for (i=M; i<N; i++) { |
for (i=M; i<N; i++) { |
fprintf(fp," %s %s - %s %s = 1, ",TransD[i],TransX[i], |
fx = cxx(1,i,1,ringp); fd = cdd(1,i,1,ringp); |
TransX[i],TransD[i]); |
rf = ppSub(ppMult(fd,fx),ppMult(fx,fd)); |
|
fprintf(fp," %s %s - %s %s = %s, ",TransD[i],TransX[i], |
|
TransX[i],TransD[i],POLYToString(rf,'*',0)); |
} |
} |
fprintf(fp,"\n\n"); |
fprintf(fp,"\n\n"); |
} |
} |
Line 91 struct ring *ringp; |
|
Line 98 struct ring *ringp; |
|
fprintf(fp,"\n"); |
fprintf(fp,"\n"); |
fprintf(fp,"where "); |
fprintf(fp,"where "); |
for (i=L; i<M; i++) { |
for (i=L; i<M; i++) { |
fprintf(fp," %s %s - %s %s = %s, ",TransD[i],TransX[i], |
fprintf(fp," %s %s - %s %s = ",TransD[i],TransX[i], |
TransX[i],TransD[i], |
TransX[i],TransD[i]); |
TransD[i]); |
f=ppSub(ppMult(cdd(1,i,1,ringp),cxx(1,i,1,ringp)), |
|
ppMult(cxx(1,i,1,ringp),cdd(1,i,1,ringp))); |
|
fprintf(fp," %s, ",POLYToString(f,'*',0)); |
} |
} |
fprintf(fp,"\n\n"); |
fprintf(fp,"\n\n"); |
} |
} |
Line 105 struct ring *ringp; |
|
Line 114 struct ring *ringp; |
|
fprintf(fp,"where "); |
fprintf(fp,"where "); |
for (i=C; i<L; i++) { |
for (i=C; i<L; i++) { |
fprintf(fp," %s %s = %s %s %s, ",TransD[i],TransX[i], |
fprintf(fp," %s %s = %s %s %s, ",TransD[i],TransX[i], |
TransX[0], |
TransX[0], |
TransX[i],TransD[i]); |
TransX[i],TransD[i]); |
} |
} |
fprintf(fp,"\n\n"); |
fprintf(fp,"\n\n"); |
} |
} |
Line 165 struct ring *ringp; |
|
Line 174 struct ring *ringp; |
|
mtype = "unknown"; |
mtype = "unknown"; |
} |
} |
fprintf(fp,"Multiplication function --%s(%xH).\n", |
fprintf(fp,"Multiplication function --%s(%xH).\n", |
mtype,(unsigned int) ringp->multiplication); |
mtype,(unsigned int) ringp->multiplication); |
if (ringp->schreyer) { |
if (ringp->schreyer) { |
fprintf(fp,"schreyer=1, gbListTower="); |
fprintf(fp,"schreyer=1, gbListTower="); |
printObjectList((struct object *)(ringp->gbListTower)); |
printObjectList((struct object *)(ringp->gbListTower)); |
Line 202 if (isD(i)) D_{itod(i)} |
|
Line 211 if (isD(i)) D_{itod(i)} |
|
*/ |
*/ |
|
|
void printOrder(ringp) |
void printOrder(ringp) |
struct ring *ringp; |
struct ring *ringp; |
{ |
{ |
int i,j; |
int i,j; |
FILE *fp; |
FILE *fp; |
Line 244 struct ring *ringp; |
|
Line 253 struct ring *ringp; |
|
fprintf(fp,"\n"); |
fprintf(fp,"\n"); |
|
|
/* print D: differential DE: differential, should be eliminated |
/* print D: differential DE: differential, should be eliminated |
E: difference |
E: difference |
Q: q-difference |
Q: q-difference |
C: commutative |
C: commutative |
*/ |
*/ |
if (strcmp(F_isSameComponent,"x")== 0 || strcmp(F_isSameComponent,"xd")==0) { |
if (strcmp(F_isSameComponent,"x")== 0 || strcmp(F_isSameComponent,"xd")==0) { |
for (i=0; i<N; i++) { |
for (i=0; i<N; i++) { |
Line 315 struct object oGetOrderMatrix(struct ring *ringp) |
|
Line 324 struct object oGetOrderMatrix(struct ring *ringp) |
|
|
|
|
|
int mmLarger_matrix(ff,gg) |
int mmLarger_matrix(ff,gg) |
POLY ff; POLY gg; |
POLY ff; POLY gg; |
{ |
{ |
int exp[2*N0]; /* exponents */ |
int exp[2*N0]; /* exponents */ |
int i,k; |
int i,k; |
Line 368 POLY ff; POLY gg; |
|
Line 377 POLY ff; POLY gg; |
|
|
|
/* This should be used in case of q */ |
/* This should be used in case of q */ |
int mmLarger_qmatrix(ff,gg) |
int mmLarger_qmatrix(ff,gg) |
POLY ff; POLY gg; |
POLY ff; POLY gg; |
{ |
{ |
int exp[2*N0]; /* exponents */ |
int exp[2*N0]; /* exponents */ |
int i,k; |
int i,k; |
Line 417 POLY ff; POLY gg; |
|
Line 426 POLY ff; POLY gg; |
|
|
|
/* x(N-1)>x(N-2)>....>D(N-1)>....>D(0) */ |
/* x(N-1)>x(N-2)>....>D(N-1)>....>D(0) */ |
mmLarger_pureLexicographic(f,g) |
mmLarger_pureLexicographic(f,g) |
POLY f; |
POLY f; |
POLY g; |
POLY g; |
{ |
{ |
int i,r; |
int i,r; |
int n; |
int n; |
|
|
|
|
|
|
void setFromTo(ringp) |
void setFromTo(ringp) |
struct ring *ringp; |
struct ring *ringp; |
{ |
{ |
int n; |
int n; |
int i,j,oasize; |
int i,j,oasize; |
Line 473 struct ring *ringp; |
|
Line 482 struct ring *ringp; |
|
ringp->from[i] = 0; ringp->to[i] = n; |
ringp->from[i] = 0; ringp->to[i] = n; |
for (j=0; j<n; j++) { |
for (j=0; j<n; j++) { |
if (ringp->order[i*n+j] != 0) { |
if (ringp->order[i*n+j] != 0) { |
ringp->from[i] = j; |
ringp->from[i] = j; |
break; |
break; |
} |
} |
} |
} |
for (j=n-1; j>=0; j--) { |
for (j=n-1; j>=0; j--) { |
if (ringp->order[i*n+j] != 0) { |
if (ringp->order[i*n+j] != 0) { |
ringp->to[i] = j+1; |
ringp->to[i] = j+1; |
break; |
break; |
} |
} |
} |
} |
} |
} |
Line 489 struct ring *ringp; |
|
Line 498 struct ring *ringp; |
|
/* It ignores h and should be used with mmLarger_tower */ |
/* It ignores h and should be used with mmLarger_tower */ |
/* cf. mmLarger_matrix. h always must be checked at last. */ |
/* cf. mmLarger_matrix. h always must be checked at last. */ |
static int mmLarger_matrix_schreyer(ff,gg) |
static int mmLarger_matrix_schreyer(ff,gg) |
POLY ff; POLY gg; |
POLY ff; POLY gg; |
{ |
{ |
int exp[2*N0]; /* exponents */ |
int exp[2*N0]; /* exponents */ |
int i,k; |
int i,k; |
Line 557 int mmLarger_tower(POLY f,POLY g) { |
|
Line 566 int mmLarger_tower(POLY f,POLY g) { |
|
} |
} |
if (!(f->m->ringp->schreyer) || !(g->m->ringp->schreyer)) |
if (!(f->m->ringp->schreyer) || !(g->m->ringp->schreyer)) |
return(mmLarger_matrix(f,g)); |
return(mmLarger_matrix(f,g)); |
/* modifiable: mmLarger_qmatrix */ |
/* modifiable: mmLarger_qmatrix */ |
gbList = (struct object *)(g->m->ringp->gbListTower); |
gbList = (struct object *)(g->m->ringp->gbListTower); |
if (gbList == NULL) return(mmLarger_matrix(f,g)); |
if (gbList == NULL) return(mmLarger_matrix(f,g)); |
/* modifiable: mmLarger_qmatrix */ |
/* modifiable: mmLarger_qmatrix */ |
if (gbList->tag != Slist) { |
if (gbList->tag != Slist) { |
warningOrder("mmLarger_tower(): gbList must be in Slist.\n"); |
warningOrder("mmLarger_tower(): gbList must be in Slist.\n"); |
return(1); |
return(1); |
} |
} |
if (klength(gbList) ==0) return(mmLarger_matrix(f,g)); |
if (klength(gbList) ==0) return(mmLarger_matrix(f,g)); |
/* modifiable: mmLarger_qmatrix */ |
/* modifiable: mmLarger_qmatrix */ |
|
|
r = mmLarger_tower3(f,g,gbList); |
r = mmLarger_tower3(f,g,gbList); |
/* printf("mmLarger_tower3(%s,%s) --> %d\n",POLYToString(head(f),'*',1),POLYToString(head(g),'*',1),r); */ |
/* printf("mmLarger_tower3(%s,%s) --> %d\n",POLYToString(head(f),'*',1),POLYToString(head(g),'*',1),r); */ |
Line 597 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
Line 606 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
n = f->m->ringp->n; |
n = f->m->ringp->n; |
nn = f->m->ringp->nn; |
nn = f->m->ringp->nn; |
/* critical and modifiable */ /* m e_u > m e_v <==> m g_u > m g_v */ |
/* critical and modifiable */ /* m e_u > m e_v <==> m g_u > m g_v */ |
/* or equal and u < v */ |
/* or equal and u < v */ |
fv = f->m->e[nn].x ; /* extract component (vector) number of f! */ |
fv = f->m->e[nn].x ; /* extract component (vector) number of f! */ |
gv = g->m->e[nn].x ; |
gv = g->m->e[nn].x ; |
if (fv == gv) { /* They have the same component number. */ |
if (fv == gv) { /* They have the same component number. */ |
Line 605 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
Line 614 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
} |
} |
|
|
if (gbList == NULL) return(mmLarger_matrix_schreyer(f,g)); |
if (gbList == NULL) return(mmLarger_matrix_schreyer(f,g)); |
/* modifiable: mmLarger_qmatrix */ |
/* modifiable: mmLarger_qmatrix */ |
if (gbList->tag != Slist) { |
if (gbList->tag != Slist) { |
warningOrder("mmLarger_tower(): gbList must be in Slist.\n"); |
warningOrder("mmLarger_tower(): gbList must be in Slist.\n"); |
return(1); |
return(1); |
} |
} |
if (klength(gbList) ==0) return(mmLarger_matrix(f,g)); |
if (klength(gbList) ==0) return(mmLarger_matrix(f,g)); |
/* modifiable: mmLarger_qmatrix */ |
/* modifiable: mmLarger_qmatrix */ |
gb = car(gbList); /* each entry must be monomials */ |
gb = car(gbList); /* each entry must be monomials */ |
if (gb.tag != Sarray) { |
if (gb.tag != Sarray) { |
warningOrder("mmLarger_tower3(): car(gbList) must be an array.\n"); |
warningOrder("mmLarger_tower3(): car(gbList) must be an array.\n"); |
Line 625 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
Line 634 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
if (fv >= t || gv >= t) { |
if (fv >= t || gv >= t) { |
warningOrder("mmLarger_tower3(): incompatible input and gbList.\n"); |
warningOrder("mmLarger_tower3(): incompatible input and gbList.\n"); |
printf("Length of gb is %d, f is %s, g is %s\n",t,KPOLYToString(f), |
printf("Length of gb is %d, f is %s, g is %s\n",t,KPOLYToString(f), |
KPOLYToString(g)); |
KPOLYToString(g)); |
|
KSexecuteString(" show_ring "); |
return(1); |
return(1); |
} |
} |
/* mpMult_poly is too expensive to call. @@@*/ |
/* mpMult_poly is too expensive to call. @@@*/ |
Line 639 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
Line 649 int mmLarger_tower3(POLY f,POLY g,struct object *gbLis |
|
} |
} |
|
|
static void warningOrder(s) |
static void warningOrder(s) |
char *s; |
char *s; |
{ |
{ |
fprintf(stderr,"Warning in order.c: %s\n",s); |
fprintf(stderr,"Warning in order.c: %s\n",s); |
} |
} |
|
|
static void errorOrder(s) |
static void errorOrder(s) |
char *s; |
char *s; |
{ |
{ |
fprintf(stderr,"order.c: %s\n",s); |
fprintf(stderr,"order.c: %s\n",s); |
exit(14); |
exit(14); |