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

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

version 1.2, 2000/01/16 07:55:38 version 1.3, 2001/05/04 01:06:23
Line 1 
Line 1 
 /* $OpenXM$ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/gbGM.c,v 1.2 2000/01/16 07:55:38 takayama Exp $ */
 /* gbGM.c  GM=Gebauer and Moller  /* gbGM.c  GM=Gebauer and Moller
 */   */
   
 #include <stdio.h>  #include <stdio.h>
 #include "datatype.h"  #include "datatype.h"
Line 42  struct polySet_gm enlargePolySet_gm(struct polySet_gm 
Line 42  struct polySet_gm enlargePolySet_gm(struct polySet_gm 
 struct pairSet deletePair_gm(struct pairSet d,int index);  struct pairSet deletePair_gm(struct pairSet d,int index);
 int minPair_gm(struct pairSet d);  int minPair_gm(struct pairSet d);
 struct pairSet updatePair_gm(struct pairSet d,int t,  struct pairSet updatePair_gm(struct pairSet d,int t,
                              struct polySet_gm g,POLY gt);                               struct polySet_gm g,POLY gt);
 struct polySet_gm markRedundant_gm(struct polySet_gm g,int j);  struct polySet_gm markRedundant_gm(struct polySet_gm g,int j);
 /*  /*
 struct gradedPolySet *groebner_gm(struct arrayOfPOLY f,    struct gradedPolySet *groebner_gm(struct arrayOfPOLY f,
                                   int needBack,    int needBack,
                                   int needSyz, struct pair **grP);    int needSyz, struct pair **grP);
 */  */
 void outputPairSet(struct pairSet d);  void outputPairSet(struct pairSet d);
 void outputPolySet_gm(struct polySet_gm g);  void outputPolySet_gm(struct polySet_gm g);
Line 71  int CountI[2*N0];
Line 71  int CountI[2*N0];
 #endif  #endif
   
 struct polySet_gm newPolySet_gm(n)  struct polySet_gm newPolySet_gm(n)
 int n;       int n;
 {  {
   struct polySet_gm g;    struct polySet_gm g;
   int i;    int i;
Line 87  int n;
Line 87  int n;
 }  }
   
 struct pairSet newPairSet(n)  struct pairSet newPairSet(n)
 int n;       int n;
 {  {
   struct pairSet g;    struct pairSet g;
   int i;    int i;
Line 103  int n;
Line 103  int n;
 }  }
   
 int pairSetSize(d)  int pairSetSize(d)
 struct pairSet d;       struct pairSet d;
 {  {
   int s,i;    int s,i;
   s = 0;    s = 0;
Line 114  struct pairSet d;
Line 114  struct pairSet d;
 }  }
   
 struct pairSet pairSetJoin(a,b)  struct pairSet pairSetJoin(a,b)
 struct pairSet a,b;       struct pairSet a,b;
 {  {
   int m,n,k,i;    int m,n,k,i;
   struct pairSet ans;    struct pairSet ans;
Line 138  struct pairSet a,b;
Line 138  struct pairSet a,b;
 }  }
   
 struct polySet_gm enlargePolySet_gm(g)  struct polySet_gm enlargePolySet_gm(g)
 struct polySet_gm g;       struct polySet_gm g;
 {  {
   int i;    int i;
   struct polySet_gm ans;    struct polySet_gm ans;
Line 154  struct polySet_gm g;
Line 154  struct polySet_gm g;
 }  }
   
 struct pairSet deletePair_gm(d,index)  struct pairSet deletePair_gm(d,index)
 struct pairSet d;       struct pairSet d;
 int index;       int index;
 /* delete d[index] */       /* delete d[index] */
 {  {
   int i;    int i;
   d.del[index] = 0;    d.del[index] = 0;
Line 168  int index;
Line 168  int index;
 }  }
   
 int minPair_gm(d)  int minPair_gm(d)
 struct pairSet d;       struct pairSet d;
 {  {
   POLY min;    POLY min;
   int index,i;    int index,i;
Line 184  struct pairSet d;
Line 184  struct pairSet d;
 }  }
   
 struct pairSet updatePair_gm(d,t,g,gt)  struct pairSet updatePair_gm(d,t,g,gt)
 struct pairSet d;       struct pairSet d;
 int t;       int t;
 struct polySet_gm g;       struct polySet_gm g;
 POLY gt;       POLY gt;
 {  {
   int i,j,k;    int i,j,k;
   struct pairSet new;    struct pairSet new;
Line 217  POLY gt;
Line 217  POLY gt;
   }    }
 #ifdef DEBUG  #ifdef DEBUG
   /*printf("\nnew is ...");    /*printf("\nnew is ...");
   outputPairSet(new);*/      outputPairSet(new);*/
 #endif  #endif
   
   /* Candel in D=d all (i,j) such that B_t(i,j) */    /* Candel in D=d all (i,j) such that B_t(i,j) */
Line 227  POLY gt;
Line 227  POLY gt;
       /* check T(it) != T(i,j) != T(j,t) */        /* check T(it) != T(i,j) != T(j,t) */
       i = d.p[k].i; j = d.p[k].j;        i = d.p[k].i; j = d.p[k].j;
       if ((new.del[i] == 1) || (new.del[j] == 1)) {        if ((new.del[i] == 1) || (new.del[j] == 1)) {
         /* fprintf(stderr,"Warning in updatepair_gm(): i=%d, j=%d; rewriting new.\n",i,j); */          /* fprintf(stderr,"Warning in updatepair_gm(): i=%d, j=%d; rewriting new.\n",i,j); */
         if (new.del[i] == 1) {          if (new.del[i] == 1) {
           new.p[i].lcm = (*lcm)(g.g[i],gt);            new.p[i].lcm = (*lcm)(g.g[i],gt);
         }          }
         if (new.del[j] == 1) {          if (new.del[j] == 1) {
           new.p[j].lcm = (*lcm)(g.g[j],gt);            new.p[j].lcm = (*lcm)(g.g[j],gt);
         }          }
       }        }
       if (((*mmLarger)((new.p[i].lcm),(new.p[j].lcm)) != 2) &&        if (((*mmLarger)((new.p[i].lcm),(new.p[j].lcm)) != 2) &&
           ((*mmLarger)((new.p[i].lcm),(d.p[k].lcm)) != 2) &&            ((*mmLarger)((new.p[i].lcm),(d.p[k].lcm)) != 2) &&
           ((*mmLarger)((new.p[j].lcm),(d.p[k].lcm)) != 2)) {            ((*mmLarger)((new.p[j].lcm),(d.p[k].lcm)) != 2)) {
         /* delete T(i,j) in d */          /* delete T(i,j) in d */
         d.del[k] = 1;          d.del[k] = 1;
         if (Verbose >= 2) printf("B%d(%d,%d) ",t,i,j);          if (Verbose >= 2) printf("B%d(%d,%d) ",t,i,j);
         Criterion2B++;          Criterion2B++;
       }        }
     }      }
   }    }
Line 251  POLY gt;
Line 251  POLY gt;
   for (i=0; i<g.size; i++) {    for (i=0; i<g.size; i++) {
     for (j=i+1; j<g.size; j++) {      for (j=i+1; j<g.size; j++) {
       if ((g.del[i] == 0) && (g.del[j] == 0)) {        if ((g.del[i] == 0) && (g.del[j] == 0)) {
         it = new.p[i].lcm;          it = new.p[i].lcm;
         jt = new.p[j].lcm;          jt = new.p[j].lcm;
         switch ( (*mmLarger)(it,jt)) {          switch ( (*mmLarger)(it,jt)) {
         case 2:          case 2:
           /* F(j,t), i<j */            /* F(j,t), i<j */
           new.del[j] = 1;            new.del[j] = 1;
           if (Verbose >= 2) printf("F%d(%d,%d) ",i,j,t);            if (Verbose >= 2) printf("F%d(%d,%d) ",i,j,t);
           Criterion2F++;            Criterion2F++;
           break;            break;
         case 1:          case 1:
           /* g[i] > g[j],  M(i,t) */            /* g[i] > g[j],  M(i,t) */
           if ((*isReducible)(it,jt)) {            if ((*isReducible)(it,jt)) {
             new.del[i] = 1;              new.del[i] = 1;
             if (Verbose >=2) printf("M%d(%d,%d) ",j,i,t);              if (Verbose >=2) printf("M%d(%d,%d) ",j,i,t);
             Criterion2M++;              Criterion2M++;
           }            }
           break;            break;
         case 0: /* M(j,t) */          case 0: /* M(j,t) */
           if ((*isReducible)(jt,it)) {            if ((*isReducible)(jt,it)) {
             new.del[j] = 1;              new.del[j] = 1;
             if (Verbose >=2) printf("M%d(%d,%d) ",i,j,t);              if (Verbose >=2) printf("M%d(%d,%d) ",i,j,t);
             Criterion2M++;              Criterion2M++;
           }            }
           break;            break;
   
         }          }
       }        }
     }      }
   }    }
Line 285  POLY gt;
Line 285  POLY gt;
   if (UseCriterion1) {    if (UseCriterion1) {
     for (i=0; i<g.size; i++) {      for (i=0; i<g.size; i++) {
       if (new.del[i] == 0) {        if (new.del[i] == 0) {
         if (criterion1(g.g[i],gt,new.p[i].lcm)) {          if (criterion1(g.g[i],gt,new.p[i].lcm)) {
           new.del[i] = 1;            new.del[i] = 1;
           if (Verbose >=2) printf("1(%d,%d) ",i,t);            if (Verbose >=2) printf("1(%d,%d) ",i,t);
           Criterion1++;            Criterion1++;
         }          }
       }        }
     }      }
   }    }
Line 305  POLY gt;
Line 305  POLY gt;
   
   
 struct polySet_gm markRedundant_gm(g,j)  struct polySet_gm markRedundant_gm(g,j)
 struct polySet_gm g;       struct polySet_gm g;
 int j;       int j;
 /* compare only with g[j] */       /* compare only with g[j] */
 {  {
   int i;    int i;
   for (i=0; i<g.size; i++) {    for (i=0; i<g.size; i++) {
     if ((g.del[i] == 0) && (i != j)) {      if ((g.del[i] == 0) && (i != j)) {
       if (g.del[j] == 0) {        if (g.del[j] == 0) {
         switch((*mmLarger)((g.g[i]),(g.g[j]))) {          switch((*mmLarger)((g.g[i]),(g.g[j]))) {
         case 2:          case 2:
           g.del[j] = 1;            g.del[j] = 1;
           break;            break;
         case 1:          case 1:
           if ((*isReducible)((g.g[i]),(g.g[j]))) {            if ((*isReducible)((g.g[i]),(g.g[j]))) {
             g.del[i] = 1;              g.del[i] = 1;
           }            }
           break;            break;
         case 0:          case 0:
           if ((*isReducible)((g.g[j]),(g.g[i]))) {            if ((*isReducible)((g.g[j]),(g.g[i]))) {
             g.del[j] = 1;              g.del[j] = 1;
           }            }
           break;            break;
         }          }
       }        }
     }      }
   }    }
 #ifdef DEBUG  #ifdef DEBUG
   /*printf("\nend of markRedundant_gm...");    /*printf("\nend of markRedundant_gm...");
   outputPolySet_gm(g);*/      outputPolySet_gm(g);*/
 #endif  #endif
   return(enlargePolySet_gm(g));    return(enlargePolySet_gm(g));
 }  }
Line 341  int j;
Line 341  int j;
   
   
 struct gradedPolySet *groebner_gm(f,needBack,needSyz,grP,countDown,forceReduction)  struct gradedPolySet *groebner_gm(f,needBack,needSyz,grP,countDown,forceReduction)
 struct arrayOfPOLY *f;       struct arrayOfPOLY *f;
 int needBack;       int needBack;
 int needSyz;       int needSyz;
 struct pair **grP;       struct pair **grP;
 int countDown;       int countDown;
 int forceReduction;       int forceReduction;
 {  {
   int r;    int r;
   struct pair_gm top;    struct pair_gm top;
Line 414  int forceReduction;
Line 414  int forceReduction;
   
     if (!(h ISZERO)) {      if (!(h ISZERO)) {
       if (ReduceLowerTerms) {        if (ReduceLowerTerms) {
         h = mReductionCdrBySet(h,g.g,g.size);          h = mReductionCdrBySet(h,g.g,g.size);
       }        }
       d = updatePair_gm(d,r,g,h);        d = updatePair_gm(d,r,g,h);
       g.g[r] = h; g.del[r] = 0;        g.g[r] = h; g.del[r] = 0;
Line 460  int forceReduction;
Line 460  int forceReduction;
   
   
 void outputPairSet(d)  void outputPairSet(d)
 struct pairSet d;       struct pairSet d;
 { int i;  { int i;
   printf("\nOutput struct pairSet. ");   printf("\nOutput struct pairSet. ");
   printf(".size=%d, .lim=%d :\n",d.size,d.lim);   printf(".size=%d, .lim=%d :\n",d.size,d.lim);
   for (i=0; i<d.size; i++) {   for (i=0; i<d.size; i++) {
     printf("%d[%d] i=%d,j=%d, lcm=%s  ",i,d.del[i],d.p[i].i,d.p[i].j,     printf("%d[%d] i=%d,j=%d, lcm=%s  ",i,d.del[i],d.p[i].i,d.p[i].j,
            POLYToString(d.p[i].lcm,' ',0));            POLYToString(d.p[i].lcm,' ',0));
   }   }
   printf("\n"); fflush(stdout);   printf("\n"); fflush(stdout);
 }  }
   
 void outputPolySet_gm(g)  void outputPolySet_gm(g)
 struct polySet_gm g;       struct polySet_gm g;
 { int i;  { int i;
   printf("\nOutput struct polySet_gm. ");   printf("\nOutput struct polySet_gm. ");
   printf(".size=%d, .lim=%d :\n",g.size,g.lim);   printf(".size=%d, .lim=%d :\n",g.size,g.lim);
   for (i=0; i<g.size; i++) {   for (i=0; i<g.size; i++) {
     printf("%d[%d] %s\n",i,g.del[i],POLYToString(g.g[i],' ',0));     printf("%d[%d] %s\n",i,g.del[i],POLYToString(g.g[i],' ',0));
   }   }
   printf("\n"); fflush(stdout);   printf("\n"); fflush(stdout);
 }  }
   
 int criterion1(f0,g0,lc0)  int criterion1(f0,g0,lc0)
 POLY f0;       POLY f0;
 POLY g0;       POLY g0;
 POLY lc0;       POLY lc0;
 {  {
   /* This is used only for commutative case. */    /* This is used only for commutative case. */
   register int i;    register int i;
Line 506  POLY lc0;
Line 506  POLY lc0;
   
   
 POLY mReductionBySet(f,s,size)  POLY mReductionBySet(f,s,size)
 POLY f;       POLY f;
 POLY *s;       POLY *s;
 int size;       int size;
 {  {
   int reduced1;    int reduced1;
   int i;    int i;
Line 518  int size;
Line 518  int size;
     for (i=0; i<size; i++) {      for (i=0; i<size; i++) {
       if (f ISZERO) goto ss;        if (f ISZERO) goto ss;
       if ((*isReducible)(f,s[i])) {        if ((*isReducible)(f,s[i])) {
         f = (*reduction1)(f,s[i],0,&cc,&cg);          f = (*reduction1)(f,s[i],0,&cc,&cg);
         reduced1 = 1;          reduced1 = 1;
       }        }
     }      }
   } while (reduced1 != 0);    } while (reduced1 != 0);
Line 528  int size;
Line 528  int size;
 }  }
   
 POLY mReductionCdrBySet(f,s,size)  POLY mReductionCdrBySet(f,s,size)
 POLY f;       POLY f;
 POLY *s;       POLY *s;
 int size;       int size;
 {  {
   int reduced1;    int reduced1;
   int i;    int i;
Line 541  int size;
Line 541  int size;
     for (i=0; i<size; i++) {      for (i=0; i<size; i++) {
       if (f ISZERO) goto ss;        if (f ISZERO) goto ss;
       if ((fs=(*isCdrReducible)(f,s[i])) != ZERO) {        if ((fs=(*isCdrReducible)(f,s[i])) != ZERO) {
         f = (*reduction1Cdr)(f,fs,s[i],0,&cc,&cg);          f = (*reduction1Cdr)(f,fs,s[i],0,&cc,&cg);
         reduced1 = 1;          reduced1 = 1;
       }        }
     }      }
   } while (reduced1 != 0);    } while (reduced1 != 0);
Line 552  int size;
Line 552  int size;
   
   
 void errorGBGM(s)  void errorGBGM(s)
 char *s;       char *s;
 {  {
   fprintf(stderr,"Fatal error in yaGbasis.c: %s \n",s);    fprintf(stderr,"Fatal error in yaGbasis.c: %s \n",s);
   exit(10);    exit(10);

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

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