=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/kanExport1.c,v retrieving revision 1.9 retrieving revision 1.21 diff -u -p -r1.9 -r1.21 --- OpenXM/src/kan96xx/Kan/kanExport1.c 2003/08/24 05:19:42 1.9 +++ OpenXM/src/kan96xx/Kan/kanExport1.c 2005/07/03 11:08:53 1.21 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.8 2003/08/23 02:28:38 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.20 2005/06/16 08:40:04 takayama Exp $ */ #include #include "datatype.h" #include "stackm.h" @@ -12,13 +12,16 @@ static int Message = 1; extern int KanGBmessage; -struct object DegreeShifto; +struct object DegreeShifto = OINIT; int DegreeShifto_size = 0; int *DegreeShifto_vec = NULL; -struct object DegreeShiftD; +struct object DegreeShiftD = OINIT; int DegreeShiftD_size = 0; int *DegreeShiftD_vec = NULL; +static struct object paddingVector(struct object ob, int table[], int m); +static struct object unitVector(int pos, int size,struct ring *r); + /** :kan, :ring */ struct object Kreduction(f,set) struct object f; @@ -27,7 +30,7 @@ struct object Kreduction(f,set) POLY r; struct gradedPolySet *grG; struct syz0 syz; - struct object rob; + struct object rob = OINIT; int flag; extern int ReduceLowerTerms; @@ -70,38 +73,42 @@ struct object Kgroebner(ob) int needInput = 0; int countDown = 0; int cdflag = 0; - struct object ob1,ob2,ob2c; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object ob2c = OINIT; int i; struct gradedPolySet *grG; struct pair *grP; struct arrayOfPOLY *a; - struct object rob; + struct object rob = OINIT; struct gradedPolySet *grBases; struct matrixOfPOLY *mp; struct matrixOfPOLY *backwardMat; - struct object ob1New; + struct object ob1New = OINIT; extern char *F_groebner; extern int CheckHomogenization; extern int StopDegree; int sdflag = 0; int forceReduction = 0; + int reduceOnly = 0; + int gbCheck = 0; /* see @s/2005/06/16-note.pdf */ int ob1Size, ob2Size, noZeroEntry; int *ob1ToOb2; int *ob1ZeroPos; int method; int j,k; - struct object rob2; - struct object rob3; - struct object rob4; + struct object rob2 = OINIT; + struct object rob3 = OINIT; + struct object rob4 = OINIT; struct ring *myring; POLY f; - struct object orgB; - struct object newB; - struct object orgC; - struct object newC; - static struct object paddingVector(struct object ob, int table[], int m); - static struct object unitVector(int pos, int size,struct ring *r); + struct object orgB = OINIT; + struct object newB = OINIT; + struct object orgC = OINIT; + struct object newC = OINIT; + struct object paddingVector(struct object ob, int table[], int m); + struct object unitVector(int pos, int size,struct ring *r); extern struct ring *CurrentRingp; StopDegree = 0x7fff; @@ -118,6 +125,7 @@ struct object Kgroebner(ob) if (ob2.tag != Sarray) { errorKan1("%s\n","Kgroebner(): The options must be given by an array."); } + /* Note: If you add a new option, change /configureGroebnerOption, too */ for (i=0; i 0 */ ob2 = newObjectArray(ob2Size); - ob1ToOb2 = (int *)GC_malloc(sizeof(int)*ob1Size); - ob1ZeroPos = (int *)GC_malloc(sizeof(int)*(ob1Size-ob2Size+1)); + ob1ToOb2 = (int *)sGC_malloc(sizeof(int)*ob1Size); + ob1ZeroPos = (int *)sGC_malloc(sizeof(int)*(ob1Size-ob2Size+1)); if (ob1ToOb2 == NULL || ob1ZeroPos == NULL) errorKan1("%s\n","No more memory."); j = 0; k = 0; for (i=0; inext,&grBases,&backwardMat); + if (mp == NULL) errorKan1("%s\n","Internal error in getSyzygy(). BUG of sm1."); if (KanGBmessage) printf("Done.\n"); putoa(rob,0,gradedPolySetToArray(grG,0)); @@ -295,6 +308,8 @@ struct object Kgroebner(ob) } /* To handle zero entries in the input. */ + rob=KsetAttribute(rob,KpoString("gb"),KpoInteger(grG->gb)); + putoa(rob,0,KsetAttribute(getoa(rob,0),KpoString("gb"),KpoInteger(grG->gb))); if (noZeroEntry) { return(rob); } @@ -312,6 +327,7 @@ struct object Kgroebner(ob) rob2 = newObjectArray(2); putoa(rob2,0,getoa(rob,0)); putoa(rob2,1,newB); + rob2=KsetAttribute(rob2,KpoString("gb"),KpoInteger(grG->gb)); return(rob2); break; case 3: @@ -332,6 +348,7 @@ struct object Kgroebner(ob) putoa(rob2,0,getoa(rob,0)); putoa(rob2,1,newB); putoa(rob2,2,newC); + rob2=KsetAttribute(rob2,KpoString("gb"),KpoInteger(grG->gb)); return(rob2); break; default: @@ -341,7 +358,7 @@ struct object Kgroebner(ob) static struct object paddingVector(struct object ob, int table[], int m) { - struct object rob; + struct object rob = OINIT; int i; rob = newObjectArray(m); for (i=0; imaxGrade +1); @@ -455,7 +473,8 @@ struct object gradedPolySetToArray(gps,keepRedundant) struct gradedPolySet *gps; int keepRedundant; { - struct object ob,vec; + struct object ob = OINIT; + struct object vec = OINIT; struct polySet *ps; int k; int i,j; @@ -494,7 +513,7 @@ struct object syzPolyToArray(size,f,grG) POLY f; struct gradedPolySet *grG; { - struct object ob; + struct object ob = OINIT; int i,g0,i0,serial; ob = newObjectArray(size); @@ -524,7 +543,7 @@ struct object getBackwardArray(grG) /* use serial, del. cf. getBackwardTransformation(). */ int inputSize,outputSize; int i,j,k; - struct object ob; + struct object ob = OINIT; struct polySet *ps; inputSize = 0; outputSize = 0; @@ -555,7 +574,7 @@ POLY arrayToPOLY(ob) struct object ob; { int size,i; - struct object f; + struct object f = OINIT; POLY r; static int nn,mm,ll,cc,n,m,l,c; static struct ring *cr = (struct ring *)NULL; @@ -604,7 +623,7 @@ struct object POLYToArray(ff) int k,i,matn,size; struct matrixOfPOLY *mat; POLY ex,sizep; - struct object ob; + struct object ob = OINIT; if (ff != ZERO) { tf = ff->m; @@ -664,7 +683,8 @@ struct object homogenizeObject(ob,gradep) struct object ob; int *gradep; { - struct object rob,ob1; + struct object rob = OINIT; + struct object ob1 = OINIT; int maxg; int gr,flag,i,d,size; struct ring *rp; @@ -730,7 +750,8 @@ struct object homogenizeObject_vec(ob,gradep) struct object ob; int *gradep; { - struct object rob,ob1; + struct object rob = OINIT; + struct object ob1 = OINIT; int maxg; int gr,i,size; POLY f; @@ -785,12 +806,12 @@ void KresetDegreeShift() { struct object homogenizeObject_go(struct object ob,int *gradep) { int size,i,dssize,j; - struct object ob0; - struct object ob1; - struct object ob2; - struct object rob; - struct object tob; - struct object ob1t; + struct object ob0 = OINIT; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object rob = OINIT; + struct object tob = OINIT; + struct object ob1t = OINIT; int *ds; POLY f; int onlyS; @@ -964,7 +985,7 @@ struct object oPrincipalPart(ob) struct object ob; { POLY f; - struct object rob; + struct object rob = OINIT; switch(ob.tag) { case Spoly: @@ -981,12 +1002,12 @@ struct object oInitW(ob,oWeight) struct object oWeight; { POLY f; - struct object rob; + struct object rob = OINIT; int w[2*N0]; int n,i; - struct object ow; + struct object ow = OINIT; int shiftvec; - struct object oShift; + struct object oShift = OINIT; int *s; int ssize,m; @@ -996,6 +1017,7 @@ struct object oInitW(ob,oWeight) if (oWeight.tag != Sarray) { errorKan1("%s\n","oInitW(): the second argument must be array."); } + oWeight = Kto_int32(oWeight); n = getoaSize(oWeight); if (n == 0) { m = getoaSize(ob); @@ -1099,7 +1121,7 @@ POLY objArrayToPOLY(struct object ob) { } struct object POLYtoObjArray(POLY f,int size) { - struct object rob; + struct object rob = OINIT; POLY *pa; int d,n,i; POLY t; @@ -1135,12 +1157,12 @@ struct object KordWsAll(ob,oWeight) struct object oWeight; { POLY f; - struct object rob; + struct object rob = OINIT; int w[2*N0]; int n,i; - struct object ow; + struct object ow = OINIT; int shiftvec; - struct object oShift; + struct object oShift = OINIT; int *s; int ssize,m; @@ -1150,6 +1172,7 @@ struct object KordWsAll(ob,oWeight) if (oWeight.tag != Sarray) { errorKan1("%s\n","ordWsAll(): the second argument must be array."); } + oWeight = Kto_int32(oWeight); n = getoaSize(oWeight); if (n == 0) { m = getoaSize(ob); @@ -1249,8 +1272,8 @@ int validOutputOrder(int ord[],int n) { struct object KsetOutputOrder(struct object ob, struct ring *rp) { int n,i; - struct object ox; - struct object otmp; + struct object ox = OINIT; + struct object otmp = OINIT; int *xxx; int *ddd; if (ob.tag != Sarray) { @@ -1281,10 +1304,10 @@ struct object KsetOutputOrder(struct object ob, struct struct object KschreyerSkelton(struct object g) { - struct object rob; - struct object ij; - struct object ab; - struct object tt; + struct object rob = OINIT; + struct object ij = OINIT; + struct object ab = OINIT; + struct object tt = OINIT; struct arrayOfPOLY *ap; struct arrayOfMonomialSyz ans; int k; @@ -1330,7 +1353,7 @@ struct object KvectorToSchreyer_es(struct object obarr int nn; POLY f; POLY g; - struct object ob; + struct object ob = OINIT; struct ring *rp; if (obarray.tag != Sarray) { errorKan1("%s\n","KvectorToSchreyer_es(): argument must be an array of polynomials."); @@ -1365,4 +1388,142 @@ int objToInteger(struct object ob) { }else { 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; im; + } + 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; inext; + } + 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; }