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

Diff for /OpenXM/src/kan96xx/Kan/ecart.c between version 1.10 and 1.15

version 1.10, 2003/08/20 05:18:35 version 1.15, 2003/08/26 05:52:43
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.9 2003/08/20 01:39:17 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/ecart.c,v 1.14 2003/08/26 05:06:01 takayama Exp $ */
 #include <stdio.h>  #include <stdio.h>
 #include "datatype.h"  #include "datatype.h"
 #include "extern2.h"  #include "extern2.h"
Line 36  static POLY reduction_ecart1(POLY r,struct gradedPolyS
Line 36  static POLY reduction_ecart1(POLY r,struct gradedPolyS
 static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset);  static POLY reduction_ecart1_mod(POLY r,struct gradedPolySet *gset);
 static POLY  ecartCheckSyz0(POLY cf,POLY r_0,POLY syz,  static POLY  ecartCheckSyz0(POLY cf,POLY r_0,POLY syz,
                             struct gradedPolySet *gg,POLY r);                              struct gradedPolySet *gg,POLY r);
 static int shouldReduceContent(POLY f,int ss);  
   
 extern int DebugReductionRed;  extern int DebugReductionRed;
 extern int TraceLift;  extern int TraceLift;
 struct ring *TraceLift_ringmod;  struct ring *TraceLift_ringmod;
 extern DoCancel;  extern DoCancel;
 int DebugReductionEcart = 0;  int DebugReductionEcart = 0;
   extern DebugContentReduction;
   
 /* This is used for goHomogenization */  /* This is used for goHomogenization */
 extern int DegreeShifto_size;  extern int DegreeShifto_size;
Line 248  POLY reduction_ecart(r,gset,needSyz,syzp)
Line 248  POLY reduction_ecart(r,gset,needSyz,syzp)
      struct syz0 *syzp; /* set */       struct syz0 *syzp; /* set */
 {  {
   POLY rn;    POLY rn;
     if (TraceLift && needSyz) {
       warningGradedSet("TraceLift cannot be used to get syzygy. TraceLift is turned off.\n");
       TraceLift = 0;
     }
   if (TraceLift) {    if (TraceLift) {
         if (EcartAutomaticHomogenization) {          if (EcartAutomaticHomogenization) {
           if (TraceLift_ringmod == NULL) {            if (TraceLift_ringmod == NULL) {
                 warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n");                  warningPoly("reduction_ecart: TraceLift_ringmod is not set.\n");
                 return reduction_ecart1(r,gset,needSyz,syzp);                  return reduction_ecart1(r,gset,needSyz,syzp);
           }            }
           rn = reduction_ecart1_mod(r,gset); /* BUG: syzygy is not obtained. */            rn = reduction_ecart1_mod(r,gset);
           if (rn == POLYNULL) return rn;            if (rn == POLYNULL) return rn;
           else return reduction_ecart1(r,gset,needSyz,syzp);            else return reduction_ecart1(r,gset,needSyz,syzp);
         }else{          }else{
Line 293  static POLY reduction_ecart0(r,gset,needSyz,syzp)
Line 297  static POLY reduction_ecart0(r,gset,needSyz,syzp)
   POLY cf_o;    POLY cf_o;
   POLY syz_o;    POLY syz_o;
   POLY r_0;    POLY r_0;
     int se;
     struct coeff *cont;
   
   extern struct ring *CurrentRingp;    extern struct ring *CurrentRingp;
   struct ring *rp;    struct ring *rp;
Line 312  static POLY reduction_ecart0(r,gset,needSyz,syzp)
Line 318  static POLY reduction_ecart0(r,gset,needSyz,syzp)
     }      }
   }    }
   
     if (DoCancel && (r != POLYNULL)) shouldReduceContent(r,1);
   
   if (DebugReductionEcart&1) printf("--------------------------------------\n");    if (DebugReductionEcart&1) printf("--------------------------------------\n");
   do {    do {
     if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1));      if (DebugReductionRed) printf("r=%s\n",POLYToString(r,'*',1));
Line 335  static POLY reduction_ecart0(r,gset,needSyz,syzp)
Line 343  static POLY reduction_ecart0(r,gset,needSyz,syzp)
       }        }
       if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */        if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */
       r = (*reduction1)(r,pp,needSyz,&cc,&cg);        r = (*reduction1)(r,pp,needSyz,&cc,&cg);
   
         if (DoCancel && (r != POLYNULL)) {
           if (shouldReduceContent(r,0)) {
             r = reduceContentOfPoly(r,&cont);
             shouldReduceContent(r,1);
             if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("CONT=%s ",coeffToString(cont));
           }
         }
   
   
       if (needSyz) {        if (needSyz) {
         if (ells.first) {          if (ells.first) {
           if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp));            if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp));
Line 364  static POLY reduction_ecart0(r,gset,needSyz,syzp)
Line 382  static POLY reduction_ecart0(r,gset,needSyz,syzp)
         }          }
       }        }
       if (r ISZERO) goto ss;        if (r ISZERO) goto ss;
       /*r = ecartDivideSv(r,&se); r = r/s^? Don't do this. */  
         /* r = r/s^? Don't do this?? */
         r = ecartDivideSv(r,&se);
             if (needSyz && (se > 0)) {
                   POLY tt;
                   tt = cxx(1,0,-se,rp);
                   cf = mpMult(tt,cf);
                   syz = cpMult(toSyzCoeff(tt),syz);
             }
   
     }      }
   }while (ell >= 0);    }while (ell >= 0);
   
Line 374  static POLY reduction_ecart0(r,gset,needSyz,syzp)
Line 401  static POLY reduction_ecart0(r,gset,needSyz,syzp)
     syzp->syz = syz; /* syz is in the SyzRingp */      syzp->syz = syz; /* syz is in the SyzRingp */
   }    }
   
     if (DoCancel && (r != POLYNULL)) {
       if (r->m->ringp->p == 0) {
             r = reduceContentOfPoly(r,&cont);
             if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("cont=%s ",coeffToString(cont));
       }
     }
   
   return(r);    return(r);
 }  }
   
Line 400  static POLY reduction_ecart1(r,gset,needSyz,syzp)
Line 434  static POLY reduction_ecart1(r,gset,needSyz,syzp)
   struct ecartPolyArray *gg;    struct ecartPolyArray *gg;
   POLY pp;    POLY pp;
   int ell;    int ell;
     POLY cf_o;
     POLY syz_o;
     POLY r_0;
   int se;    int se;
   struct coeff *cont;    struct coeff *cont;
   
Line 407  static POLY reduction_ecart1(r,gset,needSyz,syzp)
Line 444  static POLY reduction_ecart1(r,gset,needSyz,syzp)
   struct ring *rp;    struct ring *rp;
   extern struct ring *SmallRingp;    extern struct ring *SmallRingp;
   
     r_0 = r;
   gg = NULL;    gg = NULL;
   if (needSyz) {    if (needSyz) {
     if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; }      if (r ISZERO) { rp = CurrentRingp; } else { rp = r->m->ringp; }
Line 434  static POLY reduction_ecart1(r,gset,needSyz,syzp)
Line 472  static POLY reduction_ecart1(r,gset,needSyz,syzp)
     ell = ells.ell;      ell = ells.ell;
     if (ell > 0) {      if (ell > 0) {
       if (DebugReductionEcart & 2) printf("%");        if (DebugReductionEcart & 2) printf("%");
       gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL);            if (needSyz) {
                   gg = ecartPutPolyInG(r,gg,cf,syz);
             }else{
                   gg = ecartPutPolyInG(r,gg,POLYNULL,POLYNULL);
             }
     }      }
     if (ell >= 0) {      if (ell >= 0) {
       if (ells.first) {        if (ells.first) {
Line 446  static POLY reduction_ecart1(r,gset,needSyz,syzp)
Line 488  static POLY reduction_ecart1(r,gset,needSyz,syzp)
       if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */        if (ell > 0) r = mpMult(cxx(1,0,ell,rp),r); /* r = s^ell r */
       r = (*reduction1)(r,pp,needSyz,&cc,&cg);        r = (*reduction1)(r,pp,needSyz,&cc,&cg);
   
       if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */        if (DoCancel && (r != POLYNULL)) {
         if (shouldReduceContent(r,0)) {          if (shouldReduceContent(r,0)) {
           r = reduceContentOfPoly(r,&cont);            r = reduceContentOfPoly(r,&cont);
           shouldReduceContent(r,1);            shouldReduceContent(r,1);
           if (DebugReductionEcart || DebugReductionRed) printf("CONT=%d ",coeffToString(cont));            if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("CONT=%s ",coeffToString(cont));
         }          }
       }        }
   
       if (needSyz) {        if (needSyz) {
         if (ells.first) {          if (ells.first) {
                     if (ell > 0) cc = ppMult(cc,cxx(1,0,ell,rp));
           cf = ppMult(cc,cf);            cf = ppMult(cc,cf);
           syz = cpMult(toSyzCoeff(cc),syz);            syz = cpMult(toSyzCoeff(cc),syz);
           syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti));            syz = ppAddv(syz,toSyzPoly(cg,ells.grade,ells.gseti));
         }else{          }else{
           fprintf(stderr,"It has not yet implemented.\n");            if (ell >0) cc = ppMult(cc,cxx(1,0,ell,rp));
           exit(10);            cf_o = (gg->cf)[ells.ggi];
           /* BUG: not yet */            syz_o = (gg->syz)[ells.ggi];
             cf = ppMult(cc,cf);
             cf = ppAdd(cf,ppMult(cg,cf_o));
             syz = cpMult(toSyzCoeff(cc),syz);
             syz = ppAdd(syz,cpMult(toSyzCoeff(cg),syz_o));
             /* Note. 2003.07.19 */
         }          }
       }        }
   
         if (DebugReductionRed) {
           POLY tp;
           tp = ecartCheckSyz0(cf,r_0,syz,gset,r);
                   tp = goDeHomogenizeS(tp);
           if (tp != POLYNULL) {
             fprintf(stderr,"reduction_ecart1(): sygyzy is broken. Return the Current values.\n");
             fprintf(stderr,"%s\n",POLYToString(tp,'*',1));
             syzp->cf = cf;
             syzp->syz = syz;
             return r;
           }
         }
   
       if (r ISZERO) goto ss1;        if (r ISZERO) goto ss1;
       r = ecartDivideSv(r,&se); /* r = r/s^? */        r = ecartDivideSv(r,&se); /* r = r/s^? */
   
             if (needSyz && (se > 0)) { /* It may not necessary because of dehomo*/
                   POLY tt;
                   /*printf("!1/H!"); fflush(NULL);*/ /* misc-2003/ecart/t1.sm1 foo4 */
                   tt = cxx(1,0,-se,rp);
                   cf = mpMult(tt,cf);
                   syz = cpMult(toSyzCoeff(tt),syz);
             }
   
     }      }
   }while (ell >= 0);    }while (ell >= 0);
   
  ss1: ;   ss1: ;
   if (needSyz) {    if (needSyz) {
       /* dehomogenize the syzygy. BUG, this may be inefficient.  */
           cf = goDeHomogenizeS(cf);
           syz = goDeHomogenizeS(syz);
           /*printf("cf=%s\n",POLYToString(cf,'*',1));
             printf("syz=%s\n",POLYToString(syz,'*',1));*/
     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 */
     /* BUG: dehomogenize the syzygy */  
     fprintf(stderr,"It has not yet implemented.\n");  
     exit(10);  
   }    }
   
   r = goDeHomogenizeS(r);    r = goDeHomogenizeS(r);
   if (DoCancel && (r != POLYNULL)) { /* BUG: syzygy should be corrected. */    if (DoCancel && (r != POLYNULL)) {
     if (r->m->ringp->p == 0) {      if (r->m->ringp->p == 0) {
       if (coeffSizeMin(r) >= DoCancel) {            r = reduceContentOfPoly(r,&cont);
         r = reduceContentOfPoly(r,&cont);            if (DebugReductionEcart || DebugReductionRed || DebugContentReduction) printf("cont=%s ",coeffToString(cont));
         if (DebugReductionEcart || DebugReductionRed) printf("cont=%d ",coeffToString(cont));  
       }  
     }      }
   }    }
   
Line 637  static POLY reduction_ecart1_mod(r,gset)
Line 708  static POLY reduction_ecart1_mod(r,gset)
   return(r);    return(r);
 }  }
   
 static int shouldReduceContent(POLY f,int ss) {  
   static int prevSize = 1;  
   int size;  
   if (f == POLYNULL) return 0;  
   if (f->m->ringp->p != 0) return 0;  
   if (f->coeffp->tag != MP_INTEGER) return 0;  
   size = mpz_size(f->coeffp->val.bigp);  
   if (ss > 0) {  
         prevSize = size;  
         return 0;  
   }  
   if (size > 2*prevSize) {  
         return 1;  
   }else{  
         return 0;  
   }  
 }  

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.15

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