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

Diff for /OpenXM/src/kan96xx/Kan/sugar.c between version 1.2 and 1.3

version 1.2, 2000/01/16 07:55:41 version 1.3, 2001/05/04 01:06:25
Line 1 
Line 1 
 /* $OpenXM$ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/sugar.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 9 
Line 9 
 static int DebugReduction = 0;  static int DebugReduction = 0;
   
 POLY reduction_sugar(POLY f,struct gradedPolySet *gset,int needSyz,  POLY reduction_sugar(POLY f,struct gradedPolySet *gset,int needSyz,
                      struct syz0 *syzp,int sugarGrade)                       struct syz0 *syzp,int sugarGrade)
 {  {
   int reduced,reduced1,reduced2;    int reduced,reduced1,reduced2;
   int grd;    int grd;
Line 38  POLY reduction_sugar(POLY f,struct gradedPolySet *gset
Line 38  POLY reduction_sugar(POLY f,struct gradedPolySet *gset
     while (grd < gset->maxGrade) {      while (grd < gset->maxGrade) {
       set = gset->polys[grd];        set = gset->polys[grd];
       do {        do {
         reduced2 = 0; /* no */          reduced2 = 0; /* no */
         for (i=0; i<set->size; i++) {          for (i=0; i<set->size; i++) {
           if (f ISZERO) goto ss;            if (f ISZERO) goto ss;
           if ((*isReducible)(f,set->g[i])) {            if ((*isReducible)(f,set->g[i])) {
             tdegm = grade_gen(f) - grade_gen(set->g[i]);              tdegm = grade_gen(f) - grade_gen(set->g[i]);
             /* Reduce if and only if sugarGrade does not increase. */              /* Reduce if and only if sugarGrade does not increase. */
             if (tdegm+grd <= sugarGrade) {              if (tdegm+grd <= sugarGrade) {
               f = reduction1_sugar(f,set->g[i],needSyz,&cc,&cg,sugarGrade);                f = reduction1_sugar(f,set->g[i],needSyz,&cc,&cg,sugarGrade);
               if (needSyz) {                if (needSyz) {
                 cf = ppMult(cc,cf);                  cf = ppMult(cc,cf);
                 syz = cpMult(toSyzCoeff(cc),syz);                  syz = cpMult(toSyzCoeff(cc),syz);
                 syz = ppAddv(syz,toSyzPoly(cg,grd,i));                  syz = ppAddv(syz,toSyzPoly(cg,grd,i));
               }                }
               reduced = reduced1 = reduced2 = 1; /* yes */                reduced = reduced1 = reduced2 = 1; /* yes */
             }              }
           }            }
         }          }
       } while (reduced2 != 0);        } while (reduced2 != 0);
       grd++;        grd++;
     }      }
   }while (reduced1 != 0);    }while (reduced1 != 0);
   
   ss: ;   ss: ;
   if (needSyz) {    if (needSyz) {
     syzp->cf = cf;   /* cf is in the CurrentRingp */      syzp->cf = cf;   /* cf is in the CurrentRingp */
     syzp->syz = syz; /* syz is in the SyzRingp */      syzp->syz = syz; /* syz is in the SyzRingp */
Line 69  POLY reduction_sugar(POLY f,struct gradedPolySet *gset
Line 69  POLY reduction_sugar(POLY f,struct gradedPolySet *gset
 }  }
   
 POLY reduction1_sugar(f,g,needSyz,c,h,sugarGrade)  POLY reduction1_sugar(f,g,needSyz,c,h,sugarGrade)
 POLY f;       POLY f;
 POLY g;       POLY g;
 int needSyz;       int needSyz;
 POLY *c; /* set */       POLY *c; /* set */
 POLY *h; /* set */       POLY *h; /* set */
 int sugarGrade;       int sugarGrade;
 /* f must be reducible by g.  r = c*f + h*g */       /* f must be reducible by g.  r = c*f + h*g */
 {  {
   extern struct ring *CurrentRingp;    extern struct ring *CurrentRingp;
   struct ring *rp;    struct ring *rp;
Line 94  int sugarGrade;
Line 94  int sugarGrade;
   f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g));    f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g));
   if (DebugReduction) {    if (DebugReduction) {
     printf("c=%s, d=%s, g=%s:  f --> c*f + d*g.\n",      printf("c=%s, d=%s, g=%s:  f --> c*f + d*g.\n",
            POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1));             POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1));
     printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1));      printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1));
   }    }
   f = f2;    f = f2;
Line 111  int sugarGrade;
Line 111  int sugarGrade;
       sv = (*sp)(f,g);        sv = (*sp)(f,g);
       f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g));        f2 = ppAddv(cpMult((sv.a)->coeffp,f),ppMult(sv.b,g));
       if (DebugReduction) {        if (DebugReduction) {
         printf("! c=%s, d=%s, g=%s:  f --> c*f + d*g.\n",          printf("! c=%s, d=%s, g=%s:  f --> c*f + d*g.\n",
                POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1));                 POLYToString(sv.a,'*',1),POLYToString(sv.b,'*',1),POLYToString(g,'*',1));
         printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1));          printf("%s --> %s\n",POLYToString(f,'*',1),POLYToString(f2,'*',1));
       }        }
       f = f2;        f = f2;
       if (needSyz) {        if (needSyz) {
         *c = ppMult(sv.a,*c);          *c = ppMult(sv.a,*c);
         *h = ppAdd(ppMult(sv.a,*h),sv.b);          *h = ppAdd(ppMult(sv.a,*h),sv.b);
       }        }
     }else{      }else{
       break;        break;
Line 128  int sugarGrade;
Line 128  int sugarGrade;
 }  }
   
 int grade_sugar(f)  int grade_sugar(f)
 POLY f;       POLY f;
 {  {
   int r;    int r;
   int i,ans;    int i,ans;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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