[BACK]Return to order.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan

Annotation of OpenXM/src/kan96xx/Kan/order.c, Revision 1.1.1.1

1.1       maekawa     1: #include <stdio.h>
                      2: #include "datatype.h"
                      3: #include "stackm.h"
                      4: #include "extern.h"
                      5: #include "extern2.h"
                      6:
                      7: /* The format of order.
                      8:    Example:   graded lexicographic order
                      9:    x_{N-1}  x_{N-2}  ...  x_0  D_{N-1}  ....  D_{0}
                     10:     1        1             1    1              1
                     11:     1        0             0    0              0
                     12:     0        1             0    0              0
                     13:     ..............................................
                     14:
                     15:    (ringp->order)[i][j] should be (ringp->order)[i*2*N+j].
                     16:    All order matrix is generated by functions in smacro.sm1
                     17: */
                     18:
                     19: static void warningOrder(char *s);
                     20: static void errorOrder(char *s);
                     21:
                     22: void setOrderByMatrix(order,n,c,l,omsize)
                     23: int order[];
                     24: int n,c,l,omsize;
                     25: {
                     26:   int i,j;
                     27:   int *Order;
                     28:   extern struct ring *CurrentRingp;
                     29:
                     30:   switch_mmLarger("default");
                     31:     /* q-case */
                     32:   if ( l-c > 0) {
                     33:     switch_mmLarger("qmatrix");
                     34:   }
                     35:
                     36:   Order = (int *)sGC_malloc(sizeof(int)*(2*n)*(omsize));
                     37:   if (Order == (int *)NULL) errorOrder("No memory.");
                     38:   CurrentRingp->order = Order;
                     39:   CurrentRingp->orderMatrixSize = omsize;
                     40:   for (i=0; i<omsize; i++) {
                     41:     for (j=0; j<2*n; j++) {
                     42:       Order[i*2*n+j] = order[i*2*n+j];
                     43:     }
                     44:   }
                     45: }
                     46:
                     47: void showRing(level,ringp)
                     48: int level;
                     49: struct ring *ringp;
                     50: {
                     51:   int i,j;
                     52:   FILE *fp;
                     53:   char tmp[100];
                     54:   int N,M,L,C,NN,MM,LL,CC;
                     55:   char **TransX,**TransD;
                     56:   int *Order;
                     57:   int P;
                     58:   char *mtype;
                     59:   extern char *F_isSameComponent;
                     60:   fp = stdout;
                     61:
                     62:   N=ringp->n; M = ringp->m; L = ringp->l; C = ringp->c;
                     63:   NN=ringp->nn; MM = ringp->mm; LL = ringp->ll; CC = ringp->cc;
                     64:   TransX = ringp->x; TransD = ringp->D;
                     65:   Order = ringp->order;
                     66:   P = ringp->p;
                     67:
                     68:
                     69:   fprintf(fp,"\n----------  the current ring ---- name: %s------\n",ringp->name);
                     70:   fprintf(fp,"Characteristic is %d. ",P);
                     71:   fprintf(fp,"N0=%d N=%d NN=%d M=%d MM=%d L=%d LL=%d C=%d CC=%d omsize=%d\n",N0,N,NN,M,MM,L,LL,C,CC,ringp->orderMatrixSize);
                     72:   fprintf(fp,"\n");
                     73:
                     74:   /* print identifier names */
                     75:   if (N-M >0) {
                     76:     fprintf(fp,"Differential variables: ");
                     77:     for (i=M; i<N; i++) fprintf(fp," %4s ",TransX[i]);
                     78:     for (i=M; i<N; i++) fprintf(fp," %4s ",TransD[i]);
                     79:     fprintf(fp,"\n");
                     80:     fprintf(fp,"where ");
                     81:     for (i=M; i<N; i++) {
                     82:       fprintf(fp," %s %s - %s %s = 1, ",TransD[i],TransX[i],
                     83:                                        TransX[i],TransD[i]);
                     84:     }
                     85:     fprintf(fp,"\n\n");
                     86:   }
                     87:   if (M-L >0) {
                     88:     fprintf(fp,"Difference  variables: ");
                     89:     for (i=L; i<M; i++) fprintf(fp," %4s ",TransX[i]);
                     90:     for (i=L; i<M; i++) fprintf(fp," %4s ",TransD[i]);
                     91:     fprintf(fp,"\n");
                     92:     fprintf(fp,"where ");
                     93:     for (i=L; i<M; i++) {
                     94:       fprintf(fp," %s %s - %s %s = %s, ",TransD[i],TransX[i],
                     95:                                         TransX[i],TransD[i],
                     96:                                         TransD[i]);
                     97:     }
                     98:     fprintf(fp,"\n\n");
                     99:   }
                    100:   if (L-C >0) {
                    101:     fprintf(fp,"q-Difference  variables: ");
                    102:     for (i=C; i<L; i++) fprintf(fp," %4s ",TransX[i]);
                    103:     for (i=C; i<L; i++) fprintf(fp," %4s ",TransD[i]);
                    104:     fprintf(fp,"\n");
                    105:     fprintf(fp,"where ");
                    106:     for (i=C; i<L; i++) {
                    107:       fprintf(fp," %s %s = %s %s %s, ",TransD[i],TransX[i],
                    108:                                       TransX[0],
                    109:                                       TransX[i],TransD[i]);
                    110:     }
                    111:     fprintf(fp,"\n\n");
                    112:   }
                    113:   if (C>0) {
                    114:     fprintf(fp,"Commutative  variables: ");
                    115:     for (i=0; i<C; i++) fprintf(fp," %4s ",TransX[i]);
                    116:     for (i=0; i<C; i++) fprintf(fp," %4s ",TransD[i]);
                    117:     fprintf(fp,"\n\n");
                    118:   }
                    119:
                    120:   if (strcmp(F_isSameComponent,"x") == 0) {
                    121:     fprintf(fp,"Integral or summation or graduation variables are : ");
                    122:     for (i=CC; i<C; i++) fprintf(fp," %4s ",TransX[i]);
                    123:     for (i=LL; i<L; i++) fprintf(fp," %4s ",TransX[i]);
                    124:     for (i=MM; i<M; i++) fprintf(fp," %4s ",TransX[i]);
                    125:     for (i=NN; i<N; i++) fprintf(fp," %4s ",TransX[i]);
                    126:     fprintf(fp,"\n");
                    127:   }else if (strcmp(F_isSameComponent,"xd") == 0) {
                    128:     fprintf(fp,"Graduation variables are : ");
                    129:     for (i=CC; i<C; i++) fprintf(fp," %4s ",TransX[i]);
                    130:     for (i=LL; i<L; i++) fprintf(fp," %4s ",TransX[i]);
                    131:     for (i=MM; i<M; i++) fprintf(fp," %4s ",TransX[i]);
                    132:     for (i=NN; i<N; i++) fprintf(fp," %4s ",TransX[i]);
                    133:     for (i=CC; i<C; i++) fprintf(fp," %4s ",TransD[i]);
                    134:     for (i=LL; i<L; i++) fprintf(fp," %4s ",TransD[i]);
                    135:     for (i=MM; i<M; i++) fprintf(fp," %4s ",TransD[i]);
                    136:     for (i=NN; i<N; i++) fprintf(fp," %4s ",TransD[i]);
                    137:     fprintf(fp,"\n");
                    138:   }else {
                    139:     fprintf(fp,"Unknown graduation variable specification.\n\n");
                    140:   }
                    141:   fprintf(fp,"The homogenization variable is : ");
                    142:   fprintf(fp," %4s ",TransD[0]);
                    143:   fprintf(fp,"\n");
                    144:
                    145:
                    146:
                    147:   fprintf(fp,"-------------------------------------------\n");
                    148:   fprintf(fp,"Output order : ");
                    149:   for (i=0; i<2*N; i++) {
                    150:     if (ringp->outputOrder[i] < N) {
                    151:       fprintf(fp,"%s ",TransX[ringp->outputOrder[i]]);
                    152:     }else{
                    153:       fprintf(fp,"%s ",TransD[(ringp->outputOrder[i])-N]);
                    154:     }
                    155:   }
                    156:   fprintf(fp,"\n");
                    157:
                    158:   if (ringp->multiplication == mpMult_poly) {
                    159:     mtype = "poly";
                    160:   }else if  (ringp->multiplication == mpMult_diff) {
                    161:     mtype = "diff";
                    162:   }else if  (ringp->multiplication == mpMult_difference) {
                    163:     mtype = "difference";
                    164:   }else {
                    165:     mtype = "unknown";
                    166:   }
                    167:   fprintf(fp,"Multiplication function --%s(%xH).\n",
                    168:          mtype,(unsigned int) ringp->multiplication);
                    169:   if (ringp->schreyer) {
                    170:     fprintf(fp,"schreyer=1, gbListTower=");
                    171:     printObjectList((struct object *)(ringp->gbListTower));
                    172:     fprintf(fp,"\n");
                    173:   }
                    174:
                    175:   if (level) printOrder(ringp);
                    176:
                    177:   if (ringp->next != (struct ring *)NULL) {
                    178:     fprintf(fp,"\n\n-------- The next ring is .... --------------\n");
                    179:     showRing(level,ringp->next);
                    180:   }
                    181: }
                    182:
                    183: /***************************************************************
                    184:    functions related to order
                    185: ******************************************************************/
                    186: #define xtoi(k) ((N-1)-(k))
                    187: #define dtoi(k) ((2*N-1)-(k))
                    188: #define itox(k) ((N-1)-(k))
                    189: #define itod(k) ((2*N-1)-(k))
                    190: #define isX(i) (i<N? 1: 0)
                    191: #define isD(i) (i<N? 0: 1)
                    192: /****************************************************
                    193: i : 0       1         N-1       N           2N-1
                    194: x :x_{N-1} x_{N-2}   x_0
                    195: d :                          D_{N-1}        D_{0}
                    196: if (isX(i))  x_{itox(i)}
                    197: if (isD(i))  D_{itod(i)}
                    198: ******************************************************/
                    199: /* xtoi(0):N-1   xtoi(1):N-2  ....
                    200:    dtoi(0):2N-1  dtoi(1):2N-2 ...
                    201:    itod(N):N-1   dtoi(N-1):N ...
                    202: */
                    203:
                    204: void printOrder(ringp)
                    205: struct ring *ringp;
                    206: {
                    207:   int i,j;
                    208:   FILE *fp;
                    209:   char tmp[100];
                    210:   int N,M,L,C,NN,MM,LL,CC;
                    211:   char **TransX,**TransD;
                    212:   int *Order;
                    213:   int P;
                    214:   int omsize;
                    215:   extern char *F_isSameComponent;
                    216:
                    217:   N=ringp->n; M = ringp->m; L = ringp->l; C = ringp->c;
                    218:   NN=ringp->nn; MM = ringp->mm; LL = ringp->ll; CC = ringp->cc;
                    219:   TransX = ringp->x; TransD = ringp->D;
                    220:   Order = ringp->order;
                    221:   P = ringp->p;
                    222:   omsize = ringp->orderMatrixSize;
                    223:
                    224:   fp = stdout;
                    225:
                    226:
                    227:   for (i=0; i<2*N; i++) printf("%4d",i);
                    228:   fprintf(fp,"\n");
                    229:
                    230:   /* print variables names */
                    231:   for (i=0; i<N; i++) {
                    232:     sprintf(tmp,"x%d",N-1-i);
                    233:     fprintf(fp,"%4s",tmp);
                    234:   }
                    235:   for (i=0; i<N; i++) {
                    236:     sprintf(tmp,"D%d",N-1-i);
                    237:     fprintf(fp,"%4s",tmp);
                    238:   }
                    239:   fprintf(fp,"\n");
                    240:
                    241:   /* print identifier names */
                    242:   for (i=0; i<N; i++) fprintf(fp,"%4s",TransX[itox(i)]);
                    243:   for (i=N; i<2*N; i++) fprintf(fp,"%4s",TransD[itod(i)]);
                    244:   fprintf(fp,"\n");
                    245:
                    246:   /* print D: differential     DE: differential, should be eliminated
                    247:            E: difference
                    248:           Q: q-difference
                    249:           C: commutative
                    250:   */
                    251:   if (strcmp(F_isSameComponent,"x")== 0 || strcmp(F_isSameComponent,"xd")==0) {
                    252:     for (i=0; i<N; i++) {
                    253:       if ((NN<=itox(i)) && (itox(i)<N)) fprintf(fp,"%4s","DE");
                    254:       if ((M<=itox(i)) && (itox(i)<NN)) fprintf(fp,"%4s","D");
                    255:       if ((MM<=itox(i)) && (itox(i)<M)) fprintf(fp,"%4s","EE");
                    256:       if ((L<=itox(i)) && (itox(i)<MM)) fprintf(fp,"%4s","E");
                    257:       if ((LL<=itox(i)) && (itox(i)<L)) fprintf(fp,"%4s","QE");
                    258:       if ((C<=itox(i)) && (itox(i)<LL)) fprintf(fp,"%4s","Q");
                    259:       if ((CC<=itox(i)) && (itox(i)<C)) fprintf(fp,"%4s","CE");
                    260:       if ((0<=itox(i)) && (itox(i)<CC)) fprintf(fp,"%4s","C");
                    261:     }
                    262:   }
                    263:   if (strcmp(F_isSameComponent,"x")==0) {
                    264:     for (i=N; i<2*N; i++) {
                    265:       if ((M<=itod(i)) && (itod(i)<N)) fprintf(fp,"%4s","D");
                    266:       if ((L<=itod(i)) && (itod(i)<M)) fprintf(fp,"%4s","E");
                    267:       if ((C<=itod(i)) && (itod(i)<L)) fprintf(fp,"%4s","Q");
                    268:       if ((0<=itod(i)) && (itod(i)<C)) fprintf(fp,"%4s","C");
                    269:     }
                    270:   }else if (strcmp(F_isSameComponent,"xd")==0) {
                    271:     for (i=N; i<2*N; i++) {
                    272:       if ((NN<=itod(i)) && (itod(i)<N)) fprintf(fp,"%4s","DE");
                    273:       if ((M<=itod(i)) && (itod(i)<NN)) fprintf(fp,"%4s","D");
                    274:       if ((MM<=itod(i)) && (itod(i)<M)) fprintf(fp,"%4s","EE");
                    275:       if ((L<=itod(i)) && (itod(i)<MM)) fprintf(fp,"%4s","E");
                    276:       if ((LL<=itod(i)) && (itod(i)<L)) fprintf(fp,"%4s","QE");
                    277:       if ((C<=itod(i)) && (itod(i)<LL)) fprintf(fp,"%4s","Q");
                    278:       if ((CC<=itod(i)) && (itod(i)<C)) fprintf(fp,"%4s","CE");
                    279:       if ((0<=itod(i)) && (itod(i)<CC)) fprintf(fp,"%4s","C");
                    280:     }
                    281:   } else {
                    282:     fprintf(fp,"Unknown graduation variable type.\n");
                    283:   }
                    284:   fprintf(fp,"\n");
                    285:
                    286:   for (i=0; i< omsize; i++) {
                    287:     for (j=0; j<2*N; j++) {
                    288:       fprintf(fp,"%4d", Order[i*2*N+j]);
                    289:     }
                    290:     fprintf(fp,"\n");
                    291:   }
                    292:   fprintf(fp,"\n");
                    293:
                    294: }
                    295:
                    296: struct object oGetOrderMatrix(struct ring *ringp)
                    297: {
                    298:   struct object rob,ob2;
                    299:   int n,i,j,m;
                    300:   int *om;
                    301:   n = ringp->n;
                    302:   m = ringp->orderMatrixSize;
                    303:   om = ringp->order;
                    304:   if (m<=0) m = 1;
                    305:   rob = newObjectArray(m);
                    306:   for (i=0; i<m; i++) {
                    307:     ob2 = newObjectArray(2*n);
                    308:     for (j=0; j<2*n; j++) {
                    309:       putoa(ob2,j,KpoInteger(om[2*n*i+j]));
                    310:     }
                    311:     putoa(rob,i,ob2);
                    312:   }
                    313:   return(rob);
                    314: }
                    315:
                    316:
                    317: int mmLarger_matrix(ff,gg)
                    318: POLY ff; POLY gg;
                    319: {
                    320:   int exp[2*N0]; /* exponents */
                    321:   int i,k;
                    322:   int sum,flag;
                    323:   int *Order;
                    324:   int N;
                    325:   MONOMIAL f,g;
                    326:   struct ring *rp;
                    327:   int in2;
                    328:   int *from, *to;
                    329:   int omsize;
                    330:
                    331:   if (ff == POLYNULL ) {
                    332:     if (gg == POLYNULL) return( 2 );
                    333:     else return( 0 );
                    334:   }
                    335:   if (gg == POLYNULL) {
                    336:     if (ff == POLYNULL) return( 2 );
                    337:     else return( 1 );
                    338:   }
                    339:   f = ff->m; g=gg->m;
                    340:
                    341:   rp = f->ringp;
                    342:   Order = rp->order;
                    343:   N = rp->n;
                    344:   from = rp->from;
                    345:   to = rp->to;
                    346:   omsize = rp->orderMatrixSize;
                    347:
                    348:   flag = 1;
                    349:   for (i=N-1,k=0; i>=0; i--,k++) {
                    350:     exp[k] = (f->e[i].x) - (g->e[i].x);
                    351:     exp[k+N] = (f->e[i].D) - (g->e[i].D);
                    352:     if ((exp[k] != 0) || (exp[k+N] != 0)) flag =0;
                    353:   }
                    354:   if (flag==1) return(2);
                    355:   /* exp > 0   <--->  f>g
                    356:      exp = 0   <--->  f=g
                    357:      exp < 0   <--->  f<g
                    358:   */
                    359:   for (i=0; i< omsize; i++) {
                    360:     sum = 0; in2 = i*2*N;
                    361:     /* for (k=0; k<2*N; k++) sum += exp[k]*Order[in2+k]; */
                    362:     for (k=from[i]; k<to[i]; k++) sum += exp[k]*Order[in2+k];
                    363:     if (sum > 0) return(1);
                    364:     if (sum < 0) return(0);
                    365:   }
                    366:   return(2);
                    367: }
                    368:
                    369: /* This should be used in case of q */
                    370: int mmLarger_qmatrix(ff,gg)
                    371: POLY ff; POLY gg;
                    372: {
                    373:   int exp[2*N0]; /* exponents */
                    374:   int i,k;
                    375:   int sum,flag;
                    376:   int *Order;
                    377:   int N;
                    378:   MONOMIAL f,g;
                    379:   int omsize;
                    380:
                    381:   if (ff == POLYNULL ) {
                    382:     if (gg == POLYNULL) return( 2 );
                    383:     else return( 0 );
                    384:   }
                    385:   if (gg == POLYNULL) {
                    386:     if (ff == POLYNULL) return( 2 );
                    387:     else return( 1 );
                    388:   }
                    389:   f = ff->m; g = gg->m;
                    390:   Order = f->ringp->order;
                    391:   N = f->ringp->n;
                    392:   omsize = f->ringp->orderMatrixSize;
                    393:
                    394:   flag = 1;
                    395:   for (i=N-1,k=0; i>=0; i--,k++) {
                    396:     exp[k] = (f->e[i].x) - (g->e[i].x);
                    397:     exp[k+N] = (f->e[i].D) - (g->e[i].D);
                    398:     if ((exp[k] != 0) || (exp[k+N] != 0)) flag =0;
                    399:   }
                    400:   if (flag==1) return(2);
                    401:   /* exp > 0   <--->  f>g
                    402:      exp = 0   <--->  f=g
                    403:      exp < 0   <--->  f<g
                    404:   */
                    405:   for (i=0; i< omsize; i++) {
                    406:     sum = 0;
                    407:     /* In case of q, you should do as follows */
                    408:     for (k=0; k<N-1; k++) sum += exp[k]*Order[i*2*N+k]; /* skip k= N-1 -->q */
                    409:     for (k=N; k<2*N-1; k++) sum += exp[k]*Order[i*2*N+k]; /* SKip k= 2*N-1 */
                    410:     if (sum > 0) return(1);
                    411:     else if (sum < 0) return(0);
                    412:   }
                    413:   if (exp[N-1] > 0) return(1);
                    414:   else if (exp[N-1] < 0) return(0);
                    415:   else return(2);
                    416: }
                    417:
                    418: /* x(N-1)>x(N-2)>....>D(N-1)>....>D(0) */
                    419: mmLarger_pureLexicographic(f,g)
                    420: POLY f;
                    421: POLY g;
                    422: {
                    423:   int i,r;
                    424:   int n;
                    425:   MONOMIAL fm,gm;
                    426:   /* Note that this function ignores the order matrix of the given
                    427:      ring. */
                    428:   if (f == POLYNULL ) {
                    429:     if (g == POLYNULL) return( 2 );
                    430:     else return( 0 );
                    431:   }
                    432:   if (g == POLYNULL) {
                    433:     if (f == POLYNULL) return( 2 );
                    434:     else return( 1 );
                    435:   }
                    436:
                    437:
                    438:   fm = f->m; gm = g->m;
                    439:   n = fm->ringp->n;
                    440:   for (i=n-1; i>=0; i--) {
                    441:     r = (fm->e[i].x) - (gm->e[i].x);
                    442:     if (r > 0) return(1);
                    443:     else if (r < 0) return(0);
                    444:     else ;
                    445:   }
                    446:
                    447:   for (i=n-1; i>=0; i--) {
                    448:     r = (fm->e[i].D) - (gm->e[i].D);
                    449:     if (r > 0) return(1);
                    450:     else if (r < 0) return(0);
                    451:     else ;
                    452:   }
                    453:
                    454:   return(2);
                    455:
                    456: }
                    457:
                    458:
                    459: void setFromTo(ringp)
                    460: struct ring *ringp;
                    461: {
                    462:   int n;
                    463:   int i,j,oasize;
                    464:   if (ringp->order == (int *)NULL) errorOrder("setFromTo(); no order matrix.");
                    465:   n = (ringp->n)*2;
                    466:   oasize = ringp->orderMatrixSize;
                    467:   ringp->from = (int *)sGC_malloc(sizeof(int)*oasize);
                    468:   ringp->to = (int *)sGC_malloc(sizeof(int)*oasize);
                    469:   if (ringp->from == (int *)NULL  || ringp->to == (int *)NULL) {
                    470:     errorOrder("setFromTo(): No memory.");
                    471:   }
                    472:   for (i=0; i<oasize; i++) {
                    473:     ringp->from[i] = 0; ringp->to[i] = n;
                    474:     for (j=0; j<n; j++) {
                    475:       if (ringp->order[i*n+j] != 0) {
                    476:        ringp->from[i] = j;
                    477:        break;
                    478:       }
                    479:     }
                    480:     for (j=n-1; j>=0; j--) {
                    481:       if (ringp->order[i*n+j] != 0) {
                    482:        ringp->to[i] = j+1;
                    483:        break;
                    484:       }
                    485:     }
                    486:   }
                    487: }
                    488:
                    489: /* It ignores h and should be used with mmLarger_tower */
                    490: /* cf. mmLarger_matrix.  h always must be checked at last. */
                    491: static int mmLarger_matrix_schreyer(ff,gg)
                    492: POLY ff; POLY gg;
                    493: {
                    494:   int exp[2*N0]; /* exponents */
                    495:   int i,k;
                    496:   int sum,flag;
                    497:   int *Order;
                    498:   int N;
                    499:   MONOMIAL f,g;
                    500:   struct ring *rp;
                    501:   int in2;
                    502:   int *from, *to;
                    503:   int omsize;
                    504:
                    505:   if (ff == POLYNULL ) {
                    506:     if (gg == POLYNULL) return( 2 );
                    507:     else return( 0 );
                    508:   }
                    509:   if (gg == POLYNULL) {
                    510:     if (ff == POLYNULL) return( 2 );
                    511:     else return( 1 );
                    512:   }
                    513:   f = ff->m; g=gg->m;
                    514:
                    515:   rp = f->ringp;
                    516:   Order = rp->order;
                    517:   N = rp->n;
                    518:   from = rp->from;
                    519:   to = rp->to;
                    520:   omsize = rp->orderMatrixSize;
                    521:
                    522:   flag = 1;
                    523:   for (i=N-1,k=0; i>0; i--,k++) {
                    524:     exp[k] = (f->e[i].x) - (g->e[i].x);
                    525:     exp[k+N] = (f->e[i].D) - (g->e[i].D);
                    526:     if ((exp[k] != 0) || (exp[k+N] != 0)) flag =0;
                    527:   }
                    528:   exp[N-1] = (f->e[0].x) - (g->e[0].x);
                    529:   exp[2*N-1] = 0;  /* f->e[0].D - g->e[0].D.  Ignore h! */
                    530:   if ((exp[N-1] != 0) || (exp[2*N-1] != 0)) flag =0;
                    531:
                    532:   if (flag==1) return(2);
                    533:   /* exp > 0   <--->  f>g
                    534:      exp = 0   <--->  f=g
                    535:      exp < 0   <--->  f<g
                    536:   */
                    537:   for (i=0; i< omsize; i++) {
                    538:     sum = 0; in2 = i*2*N;
                    539:     /* for (k=0; k<2*N; k++) sum += exp[k]*Order[in2+k]; */
                    540:     for (k=from[i]; k<to[i]; k++) sum += exp[k]*Order[in2+k];
                    541:     if (sum > 0) return(1);
                    542:     if (sum < 0) return(0);
                    543:   }
                    544:   return(2);
                    545: }
                    546:
                    547: int mmLarger_tower(POLY f,POLY g) {
                    548:   struct object *gbList;
                    549:   int r;
                    550:   if (f == POLYNULL) {
                    551:     if (g == POLYNULL)  return(2);
                    552:     else return(0);
                    553:   }
                    554:   if (g == POLYNULL) {
                    555:     if (f == POLYNULL) return(2);
                    556:     else return(1);
                    557:   }
                    558:   if (!(f->m->ringp->schreyer) || !(g->m->ringp->schreyer))
                    559:     return(mmLarger_matrix(f,g));
                    560:     /* modifiable: mmLarger_qmatrix */
                    561:   gbList = (struct object *)(g->m->ringp->gbListTower);
                    562:   if (gbList == NULL) return(mmLarger_matrix(f,g));
                    563:                       /* modifiable: mmLarger_qmatrix */
                    564:   if (gbList->tag != Slist) {
                    565:     warningOrder("mmLarger_tower(): gbList must be in Slist.\n");
                    566:     return(1);
                    567:   }
                    568:   if (klength(gbList) ==0) return(mmLarger_matrix(f,g));
                    569:                       /* modifiable: mmLarger_qmatrix */
                    570:
                    571:   r = mmLarger_tower3(f,g,gbList);
                    572:   /* printf("mmLarger_tower3(%s,%s) -->  %d\n",POLYToString(head(f),'*',1),POLYToString(head(g),'*',1),r); */
                    573:   if (r == 2) { /* Now, compare by h */
                    574:     if (f->m->e[0].D > g->m->e[0].D) return(1);
                    575:     else if (f->m->e[0].D < g->m->e[0].D) return(0);
                    576:     else return(2);
                    577:   }else{
                    578:     return(r);
                    579:   }
                    580: }
                    581:
                    582: int mmLarger_tower3(POLY f,POLY g,struct object *gbList)
                    583: { /* gbList is assumed to be Slist */
                    584:   int n,fv,gv,t,r,nn;
                    585:   POLY fm;
                    586:   POLY gm;
                    587:   struct object gb;
                    588:
                    589:   if (f == POLYNULL) {
                    590:     if (g == POLYNULL)  return(2);
                    591:     else return(0);
                    592:   }
                    593:   if (g == POLYNULL) {
                    594:     if (f == POLYNULL) return(2);
                    595:     else return(1);   /* It assumes the zero is the minimum element!! */
                    596:   }
                    597:   n = f->m->ringp->n;
                    598:   nn = f->m->ringp->nn;
                    599:   /* critical and modifiable */  /* m e_u > m e_v <==> m g_u > m g_v */
                    600:                                  /*                  or equal and u < v */
                    601:   fv = f->m->e[nn].x ; /* extract component (vector) number of f! */
                    602:   gv = g->m->e[nn].x ;
                    603:   if (fv == gv) { /* They have the same component number. */
                    604:     return(mmLarger_matrix_schreyer(f,g));
                    605:   }
                    606:
                    607:   if (gbList == NULL) return(mmLarger_matrix_schreyer(f,g));
                    608:                       /* modifiable: mmLarger_qmatrix */
                    609:   if (gbList->tag != Slist) {
                    610:     warningOrder("mmLarger_tower(): gbList must be in Slist.\n");
                    611:     return(1);
                    612:   }
                    613:   if (klength(gbList) ==0) return(mmLarger_matrix(f,g));
                    614:                       /* modifiable: mmLarger_qmatrix */
                    615:   gb = car(gbList);  /* each entry must be monomials */
                    616:   if (gb.tag != Sarray) {
                    617:     warningOrder("mmLarger_tower3(): car(gbList) must be an array.\n");
                    618:     return(1);
                    619:   }
                    620:   t = getoaSize(gb);
                    621:   if (t == 0) return(mmLarger_tower3(f,g,cdr(gbList)));
                    622:
                    623:   fm = pmCopy(head(f)); fm->m->e[nn].x = 0; /* f is not modified. */
                    624:   gm = pmCopy(head(g)); gm->m->e[nn].x = 0;
                    625:   if (fv >= t || gv >= t) {
                    626:     warningOrder("mmLarger_tower3(): incompatible input and gbList.\n");
                    627:     printf("Length of gb is %d, f is %s, g is %s\n",t,KPOLYToString(f),
                    628:           KPOLYToString(g));
                    629:     return(1);
                    630:   }
                    631:   /* mpMult_poly is too expensive to call. @@@*/
                    632:   r = mmLarger_tower3(mpMult_poly(fm,KopPOLY(getoa(gb,fv))),
                    633:                       mpMult_poly(gm,KopPOLY(getoa(gb,gv))),
                    634:                       cdr(gbList));
                    635:   if (r != 2) return(r);
                    636:   else if (fv == gv) return(2);
                    637:   else if (fv > gv) return(0); /* modifiable */
                    638:   else if (fv < gv) return(1); /* modifiable */
                    639: }
                    640:
                    641: static void warningOrder(s)
                    642: char *s;
                    643: {
                    644:   fprintf(stderr,"Warning in order.c: %s\n",s);
                    645: }
                    646:
                    647: static void errorOrder(s)
                    648: char *s;
                    649: {
                    650:   fprintf(stderr,"order.c: %s\n",s);
                    651:   exit(14);
                    652: }
                    653:
                    654:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>