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

Diff for /OpenXM/src/kan96xx/Kan/kanExport1.c between version 1.10 and 1.19

version 1.10, 2003/08/27 03:11:12 version 1.19, 2005/06/16 06:54:55
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.9 2003/08/24 05:19:42 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.18 2005/06/16 05:07:23 takayama Exp $ */
 #include <stdio.h>  #include <stdio.h>
 #include "datatype.h"  #include "datatype.h"
 #include "stackm.h"  #include "stackm.h"
Line 12 
Line 12 
 static int Message = 1;  static int Message = 1;
 extern int KanGBmessage;  extern int KanGBmessage;
   
 struct object DegreeShifto;  struct object DegreeShifto = OINIT;
 int DegreeShifto_size = 0;  int DegreeShifto_size = 0;
 int *DegreeShifto_vec = NULL;  int *DegreeShifto_vec = NULL;
 struct object DegreeShiftD;  struct object DegreeShiftD = OINIT;
 int DegreeShiftD_size = 0;  int DegreeShiftD_size = 0;
 int *DegreeShiftD_vec = NULL;  int *DegreeShiftD_vec = NULL;
   
Line 27  struct object Kreduction(f,set)
Line 27  struct object Kreduction(f,set)
   POLY r;    POLY r;
   struct gradedPolySet *grG;    struct gradedPolySet *grG;
   struct syz0 syz;    struct syz0 syz;
   struct object rob;    struct object rob = OINIT;
   int flag;    int flag;
   extern int ReduceLowerTerms;    extern int ReduceLowerTerms;
   
Line 70  struct object Kgroebner(ob)
Line 70  struct object Kgroebner(ob)
   int needInput = 0;    int needInput = 0;
   int countDown = 0;    int countDown = 0;
   int cdflag = 0;    int cdflag = 0;
   struct object ob1,ob2,ob2c;    struct object ob1 = OINIT;
     struct object ob2 = OINIT;
     struct object ob2c = OINIT;
   int i;    int i;
   struct gradedPolySet *grG;    struct gradedPolySet *grG;
   struct pair *grP;    struct pair *grP;
   struct arrayOfPOLY *a;    struct arrayOfPOLY *a;
   struct object rob;    struct object rob = OINIT;
   struct gradedPolySet *grBases;    struct gradedPolySet *grBases;
   struct matrixOfPOLY *mp;    struct matrixOfPOLY *mp;
   struct matrixOfPOLY *backwardMat;    struct matrixOfPOLY *backwardMat;
   struct object ob1New;    struct object ob1New = OINIT;
   extern char *F_groebner;    extern char *F_groebner;
   extern int CheckHomogenization;    extern int CheckHomogenization;
   extern int StopDegree;    extern int StopDegree;
   int sdflag = 0;    int sdflag = 0;
   int forceReduction = 0;    int forceReduction = 0;
     int reduceOnly = 0;
     int gbCheck = 0;
   
   int ob1Size, ob2Size, noZeroEntry;    int ob1Size, ob2Size, noZeroEntry;
   int *ob1ToOb2;    int *ob1ToOb2;
   int *ob1ZeroPos;    int *ob1ZeroPos;
   int method;    int method;
   int j,k;    int j,k;
   struct object rob2;    struct object rob2 = OINIT;
   struct object rob3;    struct object rob3 = OINIT;
   struct object rob4;    struct object rob4 = OINIT;
   struct ring *myring;    struct ring *myring;
   POLY f;    POLY f;
   struct object orgB;    struct object orgB = OINIT;
   struct object newB;    struct object newB = OINIT;
   struct object orgC;    struct object orgC = OINIT;
   struct object newC;    struct object newC = OINIT;
   static struct object paddingVector(struct object ob, int table[], int m);    static struct object paddingVector(struct object ob, int table[], int m);
   static struct object unitVector(int pos, int size,struct ring *r);    static struct object unitVector(int pos, int size,struct ring *r);
   extern struct ring *CurrentRingp;    extern struct ring *CurrentRingp;
Line 130  struct object Kgroebner(ob)
Line 134  struct object Kgroebner(ob)
           needSyz = needBack = 1;            needSyz = needBack = 1;
         }else if (strcmp(ob2c.lc.str,"forceReduction")==0) {          }else if (strcmp(ob2c.lc.str,"forceReduction")==0) {
           forceReduction = 1;            forceReduction = 1;
           }else if (strcmp(ob2c.lc.str,"reduceOnly")==0) {
             reduceOnly = 1;
           }else if (strcmp(ob2c.lc.str,"gbCheck")==0) {
             gbCheck = 1;
         }else if (strcmp(ob2c.lc.str,"countDown")==0) {          }else if (strcmp(ob2c.lc.str,"countDown")==0) {
           countDown = 1; cdflag = 1;            countDown = 1; cdflag = 1;
           if (needSyz) {            if (needSyz) {
Line 234  struct object Kgroebner(ob)
Line 242  struct object Kgroebner(ob)
   }    }
   /* Assume ob1Size , ob2Size > 0 */    /* Assume ob1Size , ob2Size > 0 */
   ob2 = newObjectArray(ob2Size);    ob2 = newObjectArray(ob2Size);
   ob1ToOb2 =   (int *)GC_malloc(sizeof(int)*ob1Size);    ob1ToOb2 =   (int *)sGC_malloc(sizeof(int)*ob1Size);
   ob1ZeroPos = (int *)GC_malloc(sizeof(int)*(ob1Size-ob2Size+1));    ob1ZeroPos = (int *)sGC_malloc(sizeof(int)*(ob1Size-ob2Size+1));
   if (ob1ToOb2 == NULL || ob1ZeroPos == NULL) errorKan1("%s\n","No more memory.");    if (ob1ToOb2 == NULL || ob1ZeroPos == NULL) errorKan1("%s\n","No more memory.");
   j = 0; k = 0;    j = 0; k = 0;
   for (i=0; i<ob1Size; i++) {    for (i=0; i<ob1Size; i++) {
Line 251  struct object Kgroebner(ob)
Line 259  struct object Kgroebner(ob)
   }    }
   
   a = arrayToArrayOfPOLY(ob2);    a = arrayToArrayOfPOLY(ob2);
   grG = (*groebner)(a,needBack,needSyz,&grP,countDown,forceReduction);    grG = (*groebner)(a,needBack,needSyz,&grP,countDown,forceReduction,reduceOnly,gbCheck);
   
   if (strcmp(F_groebner,"gm") == 0 && (needBack || needSyz)) {    if (strcmp(F_groebner,"gm") == 0 && (needBack || needSyz)) {
     warningKan("The options needBack and needSyz are ignored.");      warningKan("The options needBack and needSyz are ignored.");
Line 297  struct object Kgroebner(ob)
Line 305  struct object Kgroebner(ob)
   
   /* To handle zero entries in the input. */    /* To handle zero entries in the input. */
   if (noZeroEntry) {    if (noZeroEntry) {
       rob=KsetAttribute(rob,KpoString("gb"),KpoInteger(grG->gb));
     return(rob);      return(rob);
   }    }
   method = getoaSize(rob);    method = getoaSize(rob);
   switch(method) {    switch(method) {
   case 1:    case 1:
       rob=KsetAttribute(rob,KpoString("gb"),KpoInteger(grG->gb));
     return(rob);      return(rob);
     break;      break;
   case 2:    case 2:
Line 313  struct object Kgroebner(ob)
Line 323  struct object Kgroebner(ob)
     rob2 = newObjectArray(2);      rob2 = newObjectArray(2);
     putoa(rob2,0,getoa(rob,0));      putoa(rob2,0,getoa(rob,0));
     putoa(rob2,1,newB);      putoa(rob2,1,newB);
       rob2=KsetAttribute(rob2,KpoString("gb"),KpoInteger(grG->gb));
     return(rob2);      return(rob2);
     break;      break;
   case 3:    case 3:
Line 333  struct object Kgroebner(ob)
Line 344  struct object Kgroebner(ob)
     putoa(rob2,0,getoa(rob,0));      putoa(rob2,0,getoa(rob,0));
     putoa(rob2,1,newB);      putoa(rob2,1,newB);
     putoa(rob2,2,newC);      putoa(rob2,2,newC);
       rob2=KsetAttribute(rob2,KpoString("gb"),KpoInteger(grG->gb));
     return(rob2);      return(rob2);
     break;      break;
   default:    default:
Line 342  struct object Kgroebner(ob)
Line 354  struct object Kgroebner(ob)
   
 static struct object paddingVector(struct object ob, int table[], int m)  static struct object paddingVector(struct object ob, int table[], int m)
 {  {
   struct object rob;    struct object rob = OINIT;
   int i;    int i;
   rob = newObjectArray(m);    rob = newObjectArray(m);
   for (i=0; i<m; i++) {    for (i=0; i<m; i++) {
Line 357  static struct object paddingVector(struct object ob, i
Line 369  static struct object paddingVector(struct object ob, i
   
 static struct object unitVector(int pos, int size,struct ring *r)  static struct object unitVector(int pos, int size,struct ring *r)
 {  {
   struct object rob;    struct object rob = OINIT;
   int i;    int i;
   POLY one;    POLY one;
   rob = newObjectArray(size);    rob = newObjectArray(size);
Line 412  struct object polySetToArray(ps,keepRedundant)
Line 424  struct object polySetToArray(ps,keepRedundant)
      int keepRedundant;       int keepRedundant;
 {  {
   int n,i,j;    int n,i,j;
   struct object ob;    struct object ob = OINIT;
   if (ps == (struct polySet *)NULL) return(newObjectArray(0));    if (ps == (struct polySet *)NULL) return(newObjectArray(0));
   n = 0;    n = 0;
   if (keepRedundant) {    if (keepRedundant) {
Line 438  struct object gradedPolySetToGradedArray(gps,keepRedun
Line 450  struct object gradedPolySetToGradedArray(gps,keepRedun
      struct gradedPolySet *gps;       struct gradedPolySet *gps;
      int keepRedundant;       int keepRedundant;
 {  {
   struct object ob,vec;    struct object ob = OINIT;
     struct object vec = OINIT;
   int i;    int i;
   if (gps == (struct gradedPolySet *)NULL) return(NullObject);    if (gps == (struct gradedPolySet *)NULL) return(NullObject);
   ob = newObjectArray(gps->maxGrade +1);    ob = newObjectArray(gps->maxGrade +1);
Line 456  struct object gradedPolySetToArray(gps,keepRedundant)
Line 469  struct object gradedPolySetToArray(gps,keepRedundant)
      struct gradedPolySet *gps;       struct gradedPolySet *gps;
      int keepRedundant;       int keepRedundant;
 {  {
   struct object ob,vec;    struct object ob = OINIT;
     struct object vec = OINIT;
   struct polySet *ps;    struct polySet *ps;
   int k;    int k;
   int i,j;    int i,j;
Line 495  struct object syzPolyToArray(size,f,grG)
Line 509  struct object syzPolyToArray(size,f,grG)
      POLY f;       POLY f;
      struct gradedPolySet *grG;       struct gradedPolySet *grG;
 {  {
   struct object ob;    struct object ob = OINIT;
   int i,g0,i0,serial;    int i,g0,i0,serial;
   
   ob = newObjectArray(size);    ob = newObjectArray(size);
Line 525  struct object getBackwardArray(grG)
Line 539  struct object getBackwardArray(grG)
   /* use serial, del.  cf. getBackwardTransformation(). */    /* use serial, del.  cf. getBackwardTransformation(). */
   int inputSize,outputSize;    int inputSize,outputSize;
   int i,j,k;    int i,j,k;
   struct object ob;    struct object ob = OINIT;
   struct polySet *ps;    struct polySet *ps;
   
   inputSize = 0; outputSize = 0;    inputSize = 0; outputSize = 0;
Line 556  POLY arrayToPOLY(ob)
Line 570  POLY arrayToPOLY(ob)
      struct object ob;       struct object ob;
 {  {
   int size,i;    int size,i;
   struct object f;    struct object f = OINIT;
   POLY r;    POLY r;
   static int nn,mm,ll,cc,n,m,l,c;    static int nn,mm,ll,cc,n,m,l,c;
   static struct ring *cr = (struct ring *)NULL;    static struct ring *cr = (struct ring *)NULL;
Line 605  struct object POLYToArray(ff)
Line 619  struct object POLYToArray(ff)
   int k,i,matn,size;    int k,i,matn,size;
   struct matrixOfPOLY *mat;    struct matrixOfPOLY *mat;
   POLY ex,sizep;    POLY ex,sizep;
   struct object ob;    struct object ob = OINIT;
   
   if (ff != ZERO) {    if (ff != ZERO) {
     tf = ff->m;      tf = ff->m;
Line 665  struct object homogenizeObject(ob,gradep)
Line 679  struct object homogenizeObject(ob,gradep)
      struct object ob;       struct object ob;
      int *gradep;       int *gradep;
 {  {
   struct object rob,ob1;    struct object rob = OINIT;
     struct object ob1 = OINIT;
   int maxg;    int maxg;
   int gr,flag,i,d,size;    int gr,flag,i,d,size;
   struct ring *rp;    struct ring *rp;
Line 731  struct object homogenizeObject_vec(ob,gradep)
Line 746  struct object homogenizeObject_vec(ob,gradep)
      struct object ob;       struct object ob;
      int *gradep;       int *gradep;
 {  {
   struct object rob,ob1;    struct object rob = OINIT;
     struct object ob1 = OINIT;
   int maxg;    int maxg;
   int gr,i,size;    int gr,i,size;
   POLY f;    POLY f;
Line 786  void KresetDegreeShift() {
Line 802  void KresetDegreeShift() {
   
 struct object homogenizeObject_go(struct object ob,int *gradep) {  struct object homogenizeObject_go(struct object ob,int *gradep) {
   int size,i,dssize,j;    int size,i,dssize,j;
   struct object ob0;    struct object ob0 = OINIT;
   struct object ob1;    struct object ob1 = OINIT;
   struct object ob2;    struct object ob2 = OINIT;
   struct object rob;    struct object rob = OINIT;
   struct object tob;    struct object tob = OINIT;
   struct object ob1t;    struct object ob1t = OINIT;
   int *ds;    int *ds;
   POLY f;    POLY f;
   int onlyS;    int onlyS;
Line 965  struct object oPrincipalPart(ob)
Line 981  struct object oPrincipalPart(ob)
      struct object ob;       struct object ob;
 {  {
   POLY f;    POLY f;
   struct object rob;    struct object rob = OINIT;
   
   switch(ob.tag) {    switch(ob.tag) {
   case Spoly:    case Spoly:
Line 982  struct object oInitW(ob,oWeight)
Line 998  struct object oInitW(ob,oWeight)
      struct object oWeight;       struct object oWeight;
 {  {
   POLY f;    POLY f;
   struct object rob;    struct object rob = OINIT;
   int w[2*N0];    int w[2*N0];
   int n,i;    int n,i;
   struct object ow;    struct object ow = OINIT;
   int shiftvec;    int shiftvec;
   struct object oShift;    struct object oShift = OINIT;
   int *s;    int *s;
   int ssize,m;    int ssize,m;
   
Line 997  struct object oInitW(ob,oWeight)
Line 1013  struct object oInitW(ob,oWeight)
   if (oWeight.tag != Sarray) {    if (oWeight.tag != Sarray) {
     errorKan1("%s\n","oInitW(): the second argument must be array.");      errorKan1("%s\n","oInitW(): the second argument must be array.");
   }    }
     oWeight = Kto_int32(oWeight);
   n = getoaSize(oWeight);    n = getoaSize(oWeight);
   if (n == 0) {    if (n == 0) {
         m = getoaSize(ob);          m = getoaSize(ob);
Line 1100  POLY objArrayToPOLY(struct object ob) {
Line 1117  POLY objArrayToPOLY(struct object ob) {
 }  }
   
 struct object POLYtoObjArray(POLY f,int size) {  struct object POLYtoObjArray(POLY f,int size) {
   struct object rob;    struct object rob = OINIT;
   POLY *pa;    POLY *pa;
   int d,n,i;    int d,n,i;
   POLY t;    POLY t;
Line 1136  struct object KordWsAll(ob,oWeight)
Line 1153  struct object KordWsAll(ob,oWeight)
      struct object oWeight;       struct object oWeight;
 {  {
   POLY f;    POLY f;
   struct object rob;    struct object rob = OINIT;
   int w[2*N0];    int w[2*N0];
   int n,i;    int n,i;
   struct object ow;    struct object ow = OINIT;
   int shiftvec;    int shiftvec;
   struct object oShift;    struct object oShift = OINIT;
   int *s;    int *s;
   int ssize,m;    int ssize,m;
   
Line 1151  struct object KordWsAll(ob,oWeight)
Line 1168  struct object KordWsAll(ob,oWeight)
   if (oWeight.tag != Sarray) {    if (oWeight.tag != Sarray) {
     errorKan1("%s\n","ordWsAll(): the second argument must be array.");      errorKan1("%s\n","ordWsAll(): the second argument must be array.");
   }    }
     oWeight = Kto_int32(oWeight);
   n = getoaSize(oWeight);    n = getoaSize(oWeight);
   if (n == 0) {    if (n == 0) {
         m = getoaSize(ob);          m = getoaSize(ob);
Line 1250  int validOutputOrder(int ord[],int n) {
Line 1268  int validOutputOrder(int ord[],int n) {
 struct object KsetOutputOrder(struct object ob, struct ring *rp)  struct object KsetOutputOrder(struct object ob, struct ring *rp)
 {  {
   int n,i;    int n,i;
   struct object ox;    struct object ox = OINIT;
   struct object otmp;    struct object otmp = OINIT;
   int *xxx;    int *xxx;
   int *ddd;    int *ddd;
   if (ob.tag  != Sarray) {    if (ob.tag  != Sarray) {
Line 1282  struct object KsetOutputOrder(struct object ob, struct
Line 1300  struct object KsetOutputOrder(struct object ob, struct
   
 struct object KschreyerSkelton(struct object g)  struct object KschreyerSkelton(struct object g)
 {  {
   struct object rob;    struct object rob = OINIT;
   struct object ij;    struct object ij = OINIT;
   struct object ab;    struct object ab = OINIT;
   struct object tt;    struct object tt = OINIT;
   struct arrayOfPOLY *ap;    struct arrayOfPOLY *ap;
   struct arrayOfMonomialSyz ans;    struct arrayOfMonomialSyz ans;
   int k;    int k;
Line 1331  struct object KvectorToSchreyer_es(struct object obarr
Line 1349  struct object KvectorToSchreyer_es(struct object obarr
   int nn;    int nn;
   POLY f;    POLY f;
   POLY g;    POLY g;
   struct object ob;    struct object ob = OINIT;
   struct ring *rp;    struct ring *rp;
   if (obarray.tag != Sarray) {    if (obarray.tag != Sarray) {
     errorKan1("%s\n","KvectorToSchreyer_es(): argument must be an array of polynomials.");      errorKan1("%s\n","KvectorToSchreyer_es(): argument must be an array of polynomials.");
Line 1366  int objToInteger(struct object ob) {
Line 1384  int objToInteger(struct object ob) {
   }else {    }else {
     errorKan1("%s\n","objToInteger(): invalid argument.");      errorKan1("%s\n","objToInteger(): invalid argument.");
   }    }
   }
   
   struct object KgetExponents(struct object obPoly,struct object otype) {
     int type,asize,i;
     POLY f;
     POLY ff;
     MONOMIAL tf;
     struct object rob = OINIT;
     struct object tob = OINIT;
     static int nn,mm,ll,cc,n,m,l,c;
     static struct ring *cr = (struct ring *)NULL;
     extern struct ring *CurrentRingp;
     int size,hsize,fsize,p,r;
   
     if (otype.tag == Sinteger) {
       type = KopInteger(otype);
     }else if (otype.tag == SuniversalNumber) {
       type = coeffToInt(KopUniversalNumber(otype));
     }else {
       errorKan1("%s\n","KgetExponents(): invalid translation type.");
     }
   
     if (obPoly.tag == Spoly) {
       f = KopPOLY(obPoly);
     }else if (obPoly.tag == Sarray) {
       asize = getoaSize(obPoly);
       rob = newObjectArray(asize);
       for (i=0; i<asize; i++) {
         tob = KgetExponents(getoa(obPoly,i),otype);
         putoa(rob,i,tob);
       }
           return rob;
     }else{
       errorKan1("%s\n","KgetExponents(): argument must be a polynomial.");
     }
   
     /* type == 0    x,y,Dx,Dy     (no commutative, no vector)
        type == 1    x,y,Dx,Dy,h,H (commutative & no vector)
        type == 2    x,y,Dx,Dy,h   (commutative & no vector)
     */
     if (f ISZERO) {
       cr = CurrentRingp;
     }else{
       tf = f->m;
     }
     if (tf->ringp != cr) {
       n = tf->ringp->n;
       m = tf->ringp->m;
       l = tf->ringp->l;
       c = tf->ringp->c;
       nn = tf->ringp->nn;
       mm = tf->ringp->mm;
       ll = tf->ringp->ll;
       cc = tf->ringp->cc;
       cr = tf->ringp;
     }
     if (type == 0) {
       size = 0;
       for (i=c; i<ll; i++) size += 2;
       for (i=l; i<mm; i++) size += 2;
       for (i=m; i<nn; i++) size += 2;
     }else if (type == 1) {
       size = 0;
       for (i=0; i<cc; i++) size += 2;
       for (i=c; i<ll; i++) size += 2;
       for (i=l; i<mm; i++) size += 2;
       for (i=m; i<nn; i++) size += 2;
     }else if (type == 2) {
       size = 0;
       for (i=0; i<cc; i++) size += 1;
       for (i=c; i<ll; i++) size += 2;
       for (i=l; i<mm; i++) size += 2;
       for (i=m; i<nn; i++) size += 2;
     }else{
       errorKan1("%s\n","KgetExponent, unknown type.");
     }
     if (type == 1 || type == 2) {
       hsize = (size-cc)/2;
     }else{
       hsize = size/2;
     }
     if (f ISZERO) {
       tob = newObjectArray(size);
       for (i=0; i<size; i++) {
         putoa(tob,i,KpoInteger(0));
       }
       rob = newObjectArray(1);
       putoa(rob,0,tob);
       return rob;
     }
     fsize = 0;
     ff = f;
     while (ff != POLYNULL) {
       fsize++;
       ff = ff->next;
     }
     rob = newObjectArray(fsize);
   
     ff = f;
     p = 0;
     while (ff != POLYNULL) {
       r = 0;
       tob = newObjectArray(size);
           tf = ff->m;
       for (i=ll-1; i>=c; i--) {
         putoa(tob,r,KpoInteger(tf->e[i].x));
         putoa(tob,hsize+r,KpoInteger(tf->e[i].D));
         r++;
       }
       for (i=mm-1; i>=l; i--) {
         putoa(tob,r,KpoInteger(tf->e[i].x));
         putoa(tob,hsize+r,KpoInteger(tf->e[i].D));
         r++;
       }
       for (i=nn-1; i>=m; i--) {
         putoa(tob,r,KpoInteger(tf->e[i].x));
         putoa(tob,hsize+r,KpoInteger(tf->e[i].D));
         r++;
       }
       if (type == 1) {
         for (i=cc-1; i>=0; i--) {
           putoa(tob,hsize+r,KpoInteger(tf->e[i].D));
           r++;
           putoa(tob,hsize+r,KpoInteger(tf->e[i].x));
           r++;
         }
       }else if (type == 2) {
         for (i=cc-1; i>=0; i--) {
           putoa(tob,hsize+r,KpoInteger(tf->e[i].D));
           r++;
         }
           }
   
       putoa(rob,p,tob);
       p++;
       ff = ff->next;
     }
     return rob;
 }  }

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

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