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

Annotation of OpenXM/src/kan96xx/Kan/ecart.c, Revision 1.8

1.8     ! takayama    1: /* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.7 2003/07/30 09:00:52 takayama Exp $ */
1.1       takayama    2: #include <stdio.h>
                      3: #include "datatype.h"
                      4: #include "extern2.h"
                      5: #include "gradedset.h"
                      6:
                      7: #define outofmemory(a) if (a == NULL) {fprintf(stderr,"ecart.c: out of memory.\n"); exit(10);}
                      8: /* Local structures */
                      9: struct ecartReducer {
                     10:   int ell; /* s^\ell */
                     11:   int first; /* first =1 ==> gset else gg */
                     12:   int grade;  int gseti;  /* if first==1,  gradedPolySet */
                     13:   int ggi;                /* if first==0   ecartPoly [] */
                     14: };
                     15: struct ecartPolyArray {
                     16:   int size;
                     17:   int limit;
                     18:   POLY *pa;
1.5       takayama   19:   POLY *cf;
                     20:   POLY *syz;
1.1       takayama   21: };
                     22:
                     23: static struct ecartReducer ecartFindReducer(POLY r,struct gradedPolySet *gset,struct ecartPolyArray *epa);
1.8     ! takayama   24: static struct ecartReducer ecartFindReducer_mod(POLY r,struct gradedPolySet *gset,struct ecartPolyArray *epa);
1.1       takayama   25: static int ecartCheckPoly(POLY f);  /* check if it does not contain s-variables */
                     26: static int ecartCheckEnv();         /* check if the environment is OK for ecart div*/
1.5       takayama   27: static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray,POLY cf, POLY syz);
1.1       takayama   28: static int ecartGetEll(POLY r,POLY g);
1.5       takayama   29: static POLY ecartDivideSv(POLY r,int *d);
                     30: /* No automatic homogenization and s is used as a standart var. */
                     31: static POLY reduction_ecart0(POLY r,struct gradedPolySet *gset,
                     32:                              int needSyz, struct syz0 *syzp);
                     33: /* Automatic homogenization and s->1 */
                     34: static POLY reduction_ecart1(POLY r,struct gradedPolySet *gset,
                     35:                              int needSyz, struct syz0 *syzp);
1.8     ! takayama   36: static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset);
1.5       takayama   37: static POLY  ecartCheckSyz0(POLY cf,POLY r_0,POLY syz,
                     38:                             struct gradedPolySet *gg,POLY r);
1.1       takayama   39:
1.8     ! takayama   40: extern int DebugReductionRed;
        !            41: extern int TraceLift;
        !            42: struct ring *TraceLift_ringmod;
1.6       takayama   43: int DebugReductionEcart = 0;
1.1       takayama   44:
                     45: /* This is used for goHomogenization */
                     46: extern int DegreeShifto_size;
                     47: extern int *DegreeShifto_vec;
                     48:
1.3       takayama   49: /* It is used reduction_ecart() and ecartFindReducer()
                     50:    to determine if we homogenize in this function */
                     51: extern int EcartAutomaticHomogenization;
                     52:
1.1       takayama   53: #define LARGE 0x7fffffff
                     54:
                     55:
1.5       takayama   56: static POLY ecartDivideSv(POLY r,int *d) {
1.1       takayama   57:   POLY f;
                     58:   int k;
1.5       takayama   59:   *d = 0;
1.1       takayama   60:   if (r == POLYNULL) return r;
                     61:   f = r; k = LARGE;
                     62:   while (r != POLYNULL) {
                     63:     if (r->m->e[0].x < k) {
                     64:       k = r->m->e[0].x;
                     65:     }
                     66:     r = r->next;
                     67:   }
                     68:   if (k > 0) {
1.5       takayama   69:     *d = k;
1.1       takayama   70:     f = r;
                     71:     while (r != POLYNULL) {
                     72:       r->m->e[0].x -= k;
                     73:       r = r->next;
                     74:     }
                     75:   }
                     76:   return f;
                     77: }
                     78:
                     79: static int ecartGetEll(POLY f,POLY g) {
                     80:   int n,i,p;
                     81:   MONOMIAL tf;
                     82:   MONOMIAL tg;
                     83:
                     84:   if (f ISZERO) return(-1);
                     85:   if (g ISZERO) return(-1);
                     86:
                     87:   checkRingIsR(f,g);
                     88:
                     89:   if (!isSameComponent_x(f,g)) return(-1);
                     90:   tf = f->m; tg = g->m; n = tf->ringp->n;
                     91:   for (i=1; i<n; i++) {
                     92:     if (tf->e[i].x < tg->e[i].x) return(-1);
                     93:     if (tf->e[i].D < tg->e[i].D) return(-1);
                     94:   }
                     95:   if (tf->e[0].D < tg->e[0].D) return(-1);  /*  h  */
1.2       takayama   96:   p = tf->e[0].x - tg->e[0].x;  /* H,  s */
1.1       takayama   97:   if (p >=0 ) return 0;
                     98:   else return(-p);
                     99: }
                    100:
                    101:
                    102: #define EP_SIZE 10
1.5       takayama  103: static struct ecartPolyArray *ecartPutPolyInG(POLY g,struct ecartPolyArray *eparray,POLY cf,POLY syz)
1.1       takayama  104: {
                    105:   struct ecartPolyArray *a;
                    106:   POLY *ep;
                    107:   int i;
                    108:   if (eparray == (struct ecartPolyArray *)NULL) {
                    109:     a = (struct ecartPolyArray *) sGC_malloc(sizeof(struct ecartPolyArray));
                    110:     outofmemory(a);
                    111:     ep = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE);
                    112:     outofmemory(ep);
1.5       takayama  113:     a->cf = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE);
                    114:     outofmemory(a->cf);
                    115:     a->syz = (POLY *) sGC_malloc(sizeof(POLY)*EP_SIZE);
                    116:     outofmemory(a->syz);
1.1       takayama  117:     a->limit = EP_SIZE;
                    118:     a->size = 0;
                    119:     a->pa = ep;
                    120:     eparray = a;
                    121:   }
                    122:   if (eparray->size >= eparray->limit) {
                    123:     a = (struct ecartPolyArray *) sGC_malloc(sizeof(struct ecartPolyArray));
                    124:     outofmemory(a);
                    125:     ep = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2));
                    126:     outofmemory(ep);
1.5       takayama  127:     a->cf = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2));
                    128:     outofmemory(a->cf);
                    129:     a->syz = (POLY *) sGC_malloc(sizeof(POLY)*((eparray->limit)*2));
                    130:     outofmemory(a->syz);
1.1       takayama  131:     a->limit = (eparray->limit)*2;
                    132:     a->size = eparray->size;
                    133:     a->pa = ep;
                    134:     for (i=0; i<eparray->size; i++) {
                    135:       (a->pa)[i] = (eparray->pa)[i];
1.5       takayama  136:       (a->cf)[i] = (eparray->cf)[i];
                    137:       (a->syz)[i] = (eparray->syz)[i];
1.1       takayama  138:     }
                    139:     eparray  = a;
                    140:   }
                    141:   i = eparray->size;
                    142:   (eparray->pa)[i] = g;
1.5       takayama  143:   (eparray->cf)[i] = cf;
                    144:   (eparray->syz)[i] = syz;
1.1       takayama  145:   (eparray->size)++;
                    146:   return eparray;
                    147: }
                    148:
                    149: static struct ecartReducer ecartFindReducer(POLY r,struct gradedPolySet *gset,
                    150:                                             struct ecartPolyArray *epa)
                    151: {
                    152:   int grd;
                    153:   struct polySet *set;
                    154:   int minGrade = 0;
                    155:   int minGseti = 0;
                    156:   int minGgi   = 0;
                    157:   int ell1 = LARGE;
                    158:   int ell2 = LARGE;
                    159:   int ell;
                    160:   int i;
                    161:   struct ecartReducer er;
                    162:   /* Try to find a reducer in gset; */
                    163:   grd = 0;
                    164:   while (grd < gset->maxGrade) {
                    165:     set = gset->polys[grd];
                    166:     for (i=0; i<set->size; i++) {
1.2       takayama  167:       if (set->gh[i] == POLYNULL) {
                    168:         /* goHomogenize set->gh[i] */
1.4       takayama  169:           if (EcartAutomaticHomogenization) {
                    170:               set->gh[i] = goHomogenize11(set->g[i],DegreeShifto_vec,DegreeShifto_size,-1,1);
                    171:           }else{
                    172:               set->gh[i] = set->g[i];
                    173:           }
1.2       takayama  174:       }
                    175:       ell = ecartGetEll(r,set->gh[i]);
1.1       takayama  176:       if ((ell>=0) && (ell < ell1)) {
                    177:         ell1 = ell;
                    178:         minGrade = grd; minGseti=i;
                    179:       }
                    180:     }
                    181:     grd++;
                    182:   }
                    183:   if (epa != NULL) {
                    184:     /* Try to find in the second group. */
                    185:     for (i=0; i< epa->size; i++) {
                    186:       ell = ecartGetEll(r,(epa->pa)[i]);
                    187:       if ((ell>=0) && (ell < ell2)) {
                    188:         ell2 = ell;
                    189:         minGgi = i;
                    190:       }
                    191:     }
                    192:   }
                    193:
1.6       takayama  194:   if (DebugReductionRed || (DebugReductionEcart&1)) {
1.1       takayama  195:     printf("ecartFindReducer(): ell1=%d, ell2=%d, minGrade=%d, minGseti=%d, minGgi=%d\n",ell1,ell2,minGrade,minGseti,minGgi);
                    196:   }
                    197:   if (ell1 <= ell2) {
                    198:     if (ell1 == LARGE) {
                    199:       er.ell = -1;
                    200:       return er;
                    201:     }else{
                    202:       er.ell = ell1;
                    203:       er.first = 1;
                    204:       er.grade = minGrade;
                    205:       er.gseti = minGseti;
                    206:       return er;
                    207:     }
                    208:   }else{
                    209:       er.ell = ell2;
                    210:       er.first = 0;
                    211:       er.ggi = minGgi;
                    212:       return er;
                    213:   }
                    214: }
                    215:
1.5       takayama  216: static POLY  ecartCheckSyz0(POLY cf,POLY r_0,POLY syz,
                    217:                            struct gradedPolySet *gg,POLY r)
                    218: {
                    219:   POLY f;
                    220:   int grd,i;
                    221:   POLY q;
                    222:   struct coeff *c;
                    223:   f = ppMult(cf,r_0);
                    224:   while (syz != POLYNULL) {
                    225:     grd = syz->m->e[0].x;
                    226:     i = syz->m->e[0].D;
                    227:     c = syz->coeffp;
                    228:     if (c->tag == POLY_COEFF) {
                    229:       q = c->val.f;
                    230:     }else{
                    231:       q = POLYNULL;
                    232:     }
                    233:     f = ppAdd(f,ppMult(q,((gg->polys[grd])->g)[i]));
                    234:                                 /* not gh, works only for _ecart0 */
                    235:     syz = syz->next;
                    236:   }
                    237:   f = ppSub(f,r);
                    238:   return f;
                    239: }
                    240:
                    241:
                    242: POLY reduction_ecart(r,gset,needSyz,syzp)
                    243:      POLY r;
                    244:      struct gradedPolySet *gset;
                    245:      int needSyz;
                    246:      struct syz0 *syzp; /* set */
                    247: {
1.8     ! takayama  248:   POLY rn;
        !           249:   if (TraceLift) {
        !           250:        if (EcartAutomaticHomogenization) {
        !           251:          if (TraceLift_ringmod == NULL) {
        !           252:                warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n");
        !           253:                return reduction_ecart1(r,gset,needSyz,syzp);
        !           254:          }
        !           255:          rn = reduction_ecart1_mod(r,gset);
        !           256:          if (rn == POLYNULL) return rn;
        !           257:          else return reduction_ecart1(r,gset,needSyz,syzp);
        !           258:        }else{
        !           259:          return reduction_ecart0(r,gset,needSyz,syzp);
        !           260:        }
1.5       takayama  261:   }else{
1.8     ! takayama  262:        if (EcartAutomaticHomogenization) {
        !           263:          return reduction_ecart1(r,gset,needSyz,syzp);
        !           264:        }else{
        !           265:          return reduction_ecart0(r,gset,needSyz,syzp);
        !           266:        }
1.5       takayama  267:   }
                    268: }
                    269:
1.1       takayama  270: /*
                    271:   r and gset are assumed to be (0,1)-homogenized (h-homogenized)
1.5       takayama  272:   Polynomials r and gset are assumed
1.3       takayama  273:   to be double homogenized (h-homogenized and s(H)-homogenized)
1.1       takayama  274:  */
1.5       takayama  275: static POLY reduction_ecart0(r,gset,needSyz,syzp)
1.1       takayama  276:      POLY r;
                    277:      struct gradedPolySet *gset;
                    278:      int needSyz;
                    279:      struct syz0 *syzp; /* set */
                    280: {
                    281:   int reduced,reduced1,reduced2;
                    282:   int grd;
                    283:   struct polySet *set;
                    284:   POLY cf,syz;
                    285:   int i;
                    286:   POLY cc,cg;
                    287:   struct ecartReducer ells;
                    288:   struct ecartPolyArray *gg;
                    289:   POLY pp;
                    290:   int ell;
1.5       takayama  291:   POLY cf_o;
                    292:   POLY syz_o;
                    293:   POLY r_0;
1.1       takayama  294:
                    295:   extern struct ring *CurrentRingp;
                    296:   struct ring *rp;
                    297:
1.5       takayama  298:   r_0 = r;
1.1       takayama  299:   gg = NULL;
                    300:   if (needSyz) {
                    301:     if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; }
                    302:     cf = cxx(1,0,0,rp);
                    303:     syz = ZERO;
                    304:   }
                    305:
                    306:   if (r != POLYNULL) {
1.4       takayama  307:     rp = r->m->ringp;
                    308:     if (! rp->weightedHomogenization) {
                    309:       errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]");
                    310:     }
1.1       takayama  311:   }
                    312:
1.6       takayama  313:   if (DebugReductionEcart&1) printf("--------------------------------------\n");
1.5       takayama  314:   do {
                    315:     if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1));
1.6       takayama  316:     if (DebugReductionEcart & 1) printf("r=%s+...\n",POLYToString(head(r),'*',1));
1.5       takayama  317:     ells = ecartFindReducer(r,gset,gg);
                    318:     ell = ells.ell;
                    319:     if (ell > 0) {
1.6       takayama  320:       if (DebugReductionEcart & 2) printf("*");
1.5       takayama  321:       if (needSyz) {
                    322:         gg = ecartPutPolyInG(r,gg,cf,syz);
                    323:       }else{
                    324:         gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL);
                    325:       }
                    326:     }
                    327:     if (ell >= 0) {
                    328:       if (ells.first) {
                    329:         pp = ((gset->polys[ells.grade])->gh)[ells.gseti];
                    330:       }else{
1.6       takayama  331:         if (DebugReductionEcart & 4) printf("#");
1.5       takayama  332:         pp = (gg->pa)[ells.ggi];
                    333:       }
                    334:       if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */
                    335:       r = (*reduction1)(r,pp,needSyz,&cc,&cg);
                    336:       if (needSyz) {
                    337:         if (ells.first) {
                    338:           if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp));
                    339:           cf = ppMult(cc,cf);
                    340:           syz = cpMult(toSyzCoeff(cc),syz);
                    341:           syz = ppAdd(syz,toSyzPoly(cg,ells.grade,ells.gseti));
                    342:         }else{
                    343:           if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp));
                    344:           cf_o = (gg->cf)[ells.ggi];
                    345:           syz_o = (gg->syz)[ells.ggi];
                    346:           cf = ppMult(cc,cf);
                    347:           cf = ppAdd(cf,ppMult(cg,cf_o));
                    348:           syz = cpMult(toSyzCoeff(cc),syz);
                    349:           syz = ppAdd(syz,cpMult(toSyzCoeff(cg),syz_o));
1.6       takayama  350:           /* Note. 2003.07.19 */
1.5       takayama  351:         }
                    352:         if (DebugReductionRed) {
1.6       takayama  353:           POLY tp;
                    354:           tp = ecartCheckSyz0(cf,r_0,syz,gset,r);
                    355:           if (tp != POLYNULL) {
                    356:             fprintf(stderr,"reduction_ecart0(): sygyzy is broken. Return the Current values.\n");
                    357:             fprintf(stderr,"%s\n",POLYToString(tp,'*',1));
                    358:             syzp->cf = cf;
                    359:             syzp->syz = syz;
                    360:             return r;
                    361:           }
1.5       takayama  362:         }
                    363:       }
                    364:       if (r ISZERO) goto ss;
                    365:       /*r = ecartDivideSv(r,&se); r = r/s^? Don't do this. */
                    366:     }
                    367:   }while (ell >= 0);
                    368:
                    369:  ss: ;
                    370:   if (needSyz) {
                    371:     syzp->cf = cf;   /* cf is in the CurrentRingp */
                    372:     syzp->syz = syz; /* syz is in the SyzRingp */
                    373:   }
                    374:
                    375:   return(r);
                    376: }
                    377:
                    378: /*
                    379:   r and gset are assumed to be (0,1)-homogenized (h-homogenized)
                    380:   r and gset are not assumed
                    381:   to be double homogenized (h-homogenized and s(H)-homogenized)
                    382:   They are automatically s(H)-homogenized, and s is set to 1
                    383:   when this function returns.
                    384:  */
                    385: static POLY reduction_ecart1(r,gset,needSyz,syzp)
                    386:      POLY r;
                    387:      struct gradedPolySet *gset;
                    388:      int needSyz;
                    389:      struct syz0 *syzp; /* set */
                    390: {
                    391:   int reduced,reduced1,reduced2;
                    392:   int grd;
                    393:   struct polySet *set;
                    394:   POLY cf,syz;
                    395:   int i;
                    396:   POLY cc,cg;
                    397:   struct ecartReducer ells;
                    398:   struct ecartPolyArray *gg;
                    399:   POLY pp;
                    400:   int ell;
                    401:   int se;
                    402:
                    403:   extern struct ring *CurrentRingp;
                    404:   struct ring *rp;
                    405:
                    406:   gg = NULL;
                    407:   if (needSyz) {
                    408:     if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; }
                    409:     cf = cxx(1,0,0,rp);
                    410:     syz = ZERO;
                    411:   }
                    412:
                    413:   if (r != POLYNULL) {
                    414:     rp = r->m->ringp;
                    415:     if (! rp->weightedHomogenization) {
                    416:       errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]");
                    417:     }
1.3       takayama  418:   }
1.5       takayama  419:
                    420:   r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1);
1.1       takayama  421:   /* 1 means homogenize only s */
                    422:
1.7       takayama  423:   if (DebugReductionEcart&1) printf("=======================================\n");
1.1       takayama  424:   do {
1.7       takayama  425:     if (DebugReductionRed) printf("(ecart1(d)) r=%s\n",POLYToString(r,'*',1));
                    426:     if (DebugReductionEcart & 1) printf("r=%s+,,,\n",POLYToString(head(r),'*',1));
                    427:
1.1       takayama  428:     ells = ecartFindReducer(r,gset,gg);
                    429:     ell = ells.ell;
                    430:     if (ell > 0) {
1.7       takayama  431:       if (DebugReductionEcart & 2) printf("%");
1.5       takayama  432:       gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL);
1.1       takayama  433:     }
                    434:     if (ell >= 0) {
                    435:       if (ells.first) {
                    436:         pp = ((gset->polys[ells.grade])->gh)[ells.gseti];
                    437:       }else{
1.7       takayama  438:         if (DebugReductionEcart & 4) printf("+");
1.1       takayama  439:         pp = (gg->pa)[ells.ggi];
                    440:       }
                    441:       if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */
                    442:       r = (*reduction1)(r,pp,needSyz,&cc,&cg);
                    443:       if (needSyz) {
                    444:         if (ells.first) {
                    445:           cf = ppMult(cc,cf);
                    446:           syz = cpMult(toSyzCoeff(cc),syz);
                    447:           syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti));
                    448:         }else{
1.6       takayama  449:           fprintf(stderr,"It has not yet implemented.\n");
                    450:           exit(10);
1.1       takayama  451:           /* BUG: not yet */
                    452:         }
                    453:       }
1.5       takayama  454:       if (r ISZERO) goto ss1;
                    455:       r = ecartDivideSv(r,&se); /* r = r/s^? */
1.1       takayama  456:     }
                    457:   }while (ell >= 0);
                    458:
1.5       takayama  459:  ss1: ;
1.1       takayama  460:   if (needSyz) {
                    461:     syzp->cf = cf;   /* cf is in the CurrentRingp */
                    462:     syzp->syz = syz; /* syz is in the SyzRingp */
                    463:     /* BUG: dehomogenize the syzygy */
1.6       takayama  464:     fprintf(stderr,"It has not yet implemented.\n");
                    465:     exit(10);
1.1       takayama  466:   }
1.8     ! takayama  467:
        !           468:   r = goDeHomogenizeS(r);
        !           469:
        !           470:   return(r);
        !           471: }
        !           472:
        !           473: /* Functions for trace lift  */
        !           474: static struct ecartReducer ecartFindReducer_mod(POLY r,
        !           475:                                                 struct gradedPolySet *gset,
        !           476:                                                 struct ecartPolyArray *epa)
        !           477: {
        !           478:   int grd;
        !           479:   struct polySet *set;
        !           480:   int minGrade = 0;
        !           481:   int minGseti = 0;
        !           482:   int minGgi   = 0;
        !           483:   int ell1 = LARGE;
        !           484:   int ell2 = LARGE;
        !           485:   int ell;
        !           486:   int i;
        !           487:   struct ecartReducer er;
        !           488:   /* Try to find a reducer in gset; */
        !           489:   grd = 0;
        !           490:   while (grd < gset->maxGrade) {
        !           491:     set = gset->polys[grd];
        !           492:     for (i=0; i<set->size; i++) {
        !           493:       if (set->gh[i] == POLYNULL) {
        !           494:         /* goHomogenize set->gh[i] */
        !           495:           if (EcartAutomaticHomogenization) {
        !           496:               set->gh[i] = goHomogenize11(set->g[i],DegreeShifto_vec,DegreeShifto_size,-1,1);
        !           497:           }else{
        !           498:               set->gh[i] = set->g[i];
        !           499:           }
        !           500:       }
        !           501:          if (TraceLift && (set->gmod[i] == POLYNULL)) {
        !           502:                set->gmod[i] = modulop(set->gh[i],TraceLift_ringmod);
        !           503:          }
        !           504:          if (TraceLift) {
        !           505:                ell = ecartGetEll(r,set->gmod[i]);
        !           506:          }else{
        !           507:                ell = ecartGetEll(r,set->gh[i]);
        !           508:          }
        !           509:       if ((ell>=0) && (ell < ell1)) {
        !           510:         ell1 = ell;
        !           511:         minGrade = grd; minGseti=i;
        !           512:       }
        !           513:     }
        !           514:     grd++;
        !           515:   }
        !           516:   if (epa != NULL) {
        !           517:     /* Try to find in the second group. */
        !           518:     for (i=0; i< epa->size; i++) {
        !           519:       ell = ecartGetEll(r,(epa->pa)[i]);
        !           520:       if ((ell>=0) && (ell < ell2)) {
        !           521:         ell2 = ell;
        !           522:         minGgi = i;
        !           523:       }
        !           524:     }
        !           525:   }
        !           526:
        !           527:   if (DebugReductionRed || (DebugReductionEcart&1)) {
        !           528:     printf("ecartFindReducer_mod(): ell1=%d, ell2=%d, minGrade=%d, minGseti=%d, minGgi=%d, p=%d\n",ell1,ell2,minGrade,minGseti,minGgi,TraceLift_ringmod->p);
        !           529:   }
        !           530:   if (ell1 <= ell2) {
        !           531:     if (ell1 == LARGE) {
        !           532:       er.ell = -1;
        !           533:       return er;
        !           534:     }else{
        !           535:       er.ell = ell1;
        !           536:       er.first = 1;
        !           537:       er.grade = minGrade;
        !           538:       er.gseti = minGseti;
        !           539:       return er;
        !           540:     }
        !           541:   }else{
        !           542:       er.ell = ell2;
        !           543:       er.first = 0;
        !           544:       er.ggi = minGgi;
        !           545:       return er;
        !           546:   }
        !           547: }
        !           548:
        !           549: static POLY reduction_ecart1_mod(r,gset)
        !           550:      POLY r;
        !           551:      struct gradedPolySet *gset;
        !           552: {
        !           553:   int reduced,reduced1,reduced2;
        !           554:   int grd;
        !           555:   struct polySet *set;
        !           556:   int i;
        !           557:   POLY cc,cg;
        !           558:   struct ecartReducer ells;
        !           559:   struct ecartPolyArray *gg;
        !           560:   POLY pp;
        !           561:   int ell;
        !           562:   int se;
        !           563:
        !           564:   extern struct ring *CurrentRingp;
        !           565:   struct ring *rp;
        !           566:
        !           567:   gg = NULL;
        !           568:
        !           569:   if (r != POLYNULL) {
        !           570:     rp = r->m->ringp;
        !           571:     if (! rp->weightedHomogenization) {
        !           572:       errorKan1("%s\n","ecart.c: the given ring must be declared with [(weightedHomogenization) 1]");
        !           573:     }
        !           574:   }
        !           575:
        !           576:   r = goHomogenize11(r,DegreeShifto_vec,DegreeShifto_size,-1,1);
        !           577:   /* 1 means homogenize only s */
        !           578:   /*printf("r=%s (mod 0)\n",POLYToString(head(r),'*',1));
        !           579:        KshowRing(TraceLift_ringmod); **/
        !           580:
        !           581:   r = modulop(r,TraceLift_ringmod);
        !           582:   rp = r->m->ringp; /* reset rp */
        !           583:
        !           584:   /* printf("r=%s (mod p)\n",POLYToString(head(r),'*',1)); **/
        !           585:
        !           586:   if (DebugReductionEcart&1) printf("=====================================mod\n");
        !           587:   do {
        !           588:     if (DebugReductionRed) printf("(ecart1_mod(d)) r=%s\n",POLYToString(r,'*',1));
        !           589:     if (DebugReductionEcart & 1) printf("r=%s+,,,\n",POLYToString(head(r),'*',1));
        !           590:
        !           591:     ells = ecartFindReducer_mod(r,gset,gg);
        !           592:     ell = ells.ell;
        !           593:     if (ell > 0) {
        !           594:       if (DebugReductionEcart & 2) printf("%");
        !           595:       gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL);
        !           596:     }
        !           597:     if (ell >= 0) {
        !           598:       if (ells.first) {
        !           599:         pp = ((gset->polys[ells.grade])->gmod)[ells.gseti];
        !           600:       }else{
        !           601:         if (DebugReductionEcart & 4) printf("+");
        !           602:         pp = (gg->pa)[ells.ggi];
        !           603:       }
        !           604:       if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */
        !           605:       r = (*reduction1)(r,pp,0,&cc,&cg);
        !           606:       if (r ISZERO) goto ss1;
        !           607:       r = ecartDivideSv(r,&se); /* r = r/s^? */
        !           608:     }
        !           609:   }while (ell >= 0);
        !           610:
        !           611:  ss1: ;
1.5       takayama  612:
1.1       takayama  613:   r = goDeHomogenizeS(r);
1.5       takayama  614:
1.1       takayama  615:   return(r);
                    616: }

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