=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/kanExport1.c,v retrieving revision 1.10 retrieving revision 1.22 diff -u -p -r1.10 -r1.22 --- OpenXM/src/kan96xx/Kan/kanExport1.c 2003/08/27 03:11:12 1.10 +++ OpenXM/src/kan96xx/Kan/kanExport1.c 2020/10/06 11:33:46 1.22 @@ -1,5 +1,6 @@ -/* $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.21 2005/07/03 11:08:53 ohara Exp $ */ #include +#include #include "datatype.h" #include "stackm.h" #include "extern.h" @@ -12,13 +13,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 +31,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 +74,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 +126,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; igb)); + putoa(rob,0,KsetAttribute(getoa(rob,0),KpoString("gb"),KpoInteger(grG->gb))); if (noZeroEntry) { return(rob); } @@ -313,6 +328,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: @@ -333,6 +349,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: @@ -342,7 +359,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); @@ -456,7 +474,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; @@ -495,7 +514,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); @@ -525,7 +544,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; @@ -556,7 +575,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; @@ -605,7 +624,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; @@ -665,7 +684,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; @@ -731,7 +751,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; @@ -786,12 +807,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; @@ -965,7 +986,7 @@ struct object oPrincipalPart(ob) struct object ob; { POLY f; - struct object rob; + struct object rob = OINIT; switch(ob.tag) { case Spoly: @@ -982,12 +1003,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; @@ -997,6 +1018,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); @@ -1100,7 +1122,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; @@ -1136,12 +1158,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; @@ -1151,6 +1173,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); @@ -1250,8 +1273,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) { @@ -1282,10 +1305,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; @@ -1331,7 +1354,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."); @@ -1366,4 +1389,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; }