=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/kanExport1.c,v retrieving revision 1.1.1.1 retrieving revision 1.7 diff -u -p -r1.1.1.1 -r1.7 --- OpenXM/src/kan96xx/Kan/kanExport1.c 1999/10/08 02:12:02 1.1.1.1 +++ OpenXM/src/kan96xx/Kan/kanExport1.c 2003/08/22 11:47:03 1.7 @@ -1,3 +1,4 @@ +/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.6 2003/08/21 12:28:57 takayama Exp $ */ #include #include "datatype.h" #include "stackm.h" @@ -11,10 +12,14 @@ static int Message = 1; extern int KanGBmessage; +struct object DegreeShifto; +int DegreeShifto_size = 0; +int *DegreeShifto_vec = NULL; + /** :kan, :ring */ struct object Kreduction(f,set) -struct object f; -struct object set; + struct object f; + struct object set; { POLY r; struct gradedPolySet *grG; @@ -38,6 +43,7 @@ struct object set; }else{ r = (*reduction)(f.lc.poly,grG,1,&syz); } + /* outputGradedPolySet(grG,0); */ if (flag) { rob = newObjectArray(3); putoa(rob,0,KpoPOLY(r)); @@ -54,7 +60,7 @@ struct object set; } struct object Kgroebner(ob) -struct object ob; + struct object ob; { int needSyz = 0; int needBack = 0; @@ -112,45 +118,45 @@ struct object ob; for (i=0; isize; }else{ for (j=0; jsize; j++) { - if (ps->del[j] == 0) ++size; + if (ps->del[j] == 0) ++size; } } } @@ -470,8 +476,8 @@ int keepRedundant; ps = gps->polys[i]; for (j=0; jsize; j++) { if (keepRedundant || (ps->del[j] == 0)) { - putoa(ob,k,KpoPOLY(ps->g[j])); - k++; + putoa(ob,k,KpoPOLY(ps->g[j])); + k++; } } } @@ -481,9 +487,9 @@ int keepRedundant; /* serial == -1 : It's not in the marix input. */ struct object syzPolyToArray(size,f,grG) -int size; -POLY f; -struct gradedPolySet *grG; + int size; + POLY f; + struct gradedPolySet *grG; { struct object ob; int i,g0,i0,serial; @@ -495,7 +501,7 @@ struct gradedPolySet *grG; while (f != POLYNULL) { g0 = srGrade(f); - i0 = srIndex(f); + i0 = srIndex(f); serial = grG->polys[g0]->serial[i0]; if (serial < 0) { errorKan1("%s\n","syzPolyToArray(): invalid serial[i] of grG."); @@ -510,7 +516,7 @@ struct gradedPolySet *grG; } struct object getBackwardArray(grG) -struct gradedPolySet *grG; + struct gradedPolySet *grG; { /* use serial, del. cf. getBackwardTransformation(). */ int inputSize,outputSize; @@ -533,8 +539,8 @@ struct gradedPolySet *grG; ps = grG->polys[i]; for (j=0; jsize; j++) { if (ps->del[j] == 0) { - putoa(ob,k,syzPolyToArray(inputSize,ps->syz[j]->syz,grG)); - k++; + putoa(ob,k,syzPolyToArray(inputSize,ps->syz[j]->syz,grG)); + k++; } } } @@ -543,7 +549,7 @@ struct gradedPolySet *grG; POLY arrayToPOLY(ob) -struct object ob; + struct object ob; { int size,i; struct object f; @@ -563,15 +569,15 @@ struct object ob; if (ff != ZERO) { tf = ff->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; + 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 (n-nn >0) ee = cxx(1,n-1,i,tf->ringp); else if (m-mm >0) ee = cxx(1,m-1,i,tf->ringp); @@ -585,7 +591,7 @@ struct object ob; } struct object POLYToArray(ff) -POLY ff; + POLY ff; { static int nn,mm,ll,cc,n,m,l,c; @@ -639,7 +645,7 @@ POLY ff; } static int isThereh(f) -POLY f; + POLY f; { POLY t; if (f == 0) return(0); @@ -652,8 +658,8 @@ POLY f; } struct object homogenizeObject(ob,gradep) -struct object ob; -int *gradep; + struct object ob; + int *gradep; { struct object rob,ob1; int maxg; @@ -683,6 +689,7 @@ int *gradep; rob = newObjectArray(size); flag = 0; ob1 = getoa(ob,0); + if (ob1.tag == Sdollar) return(homogenizeObject_go(ob,gradep)); ob1 = homogenizeObject(ob1,&gr); maxg = gr; getoa(rob,0) = ob1; @@ -690,7 +697,7 @@ int *gradep; ob1 = getoa(ob,i); ob1 = homogenizeObject(ob1,&gr); if (gr > maxg) { - maxg = gr; + maxg = gr; } getoa(rob,i) = ob1; } @@ -699,12 +706,12 @@ int *gradep; rp = oRingp(rob); if (rp == (struct ring *)NULL) rp = CurrentRingp; for (i=0; i gr) { - f = cdd(1,0,maxg-gr-i,rp); /* h^{maxg-gr-i} */ - getoa(rob,i) = KooMult(KpoPOLY(f),getoa(rob,i)); - } + gr = oGrade(getoa(rob,i)); + /**printf("maxg=%d, gr=%d(i=%d) ",maxg,gr,i); fflush(stdout);**/ + if (maxg > gr) { + f = cdd(1,0,maxg-gr-i,rp); /* h^{maxg-gr-i} */ + getoa(rob,i) = KooMult(KpoPOLY(f),getoa(rob,i)); + } } } *gradep = maxg; @@ -717,8 +724,8 @@ int *gradep; } struct object homogenizeObject_vec(ob,gradep) -struct object ob; -int *gradep; + struct object ob; + int *gradep; { struct object rob,ob1; int maxg; @@ -744,13 +751,14 @@ int *gradep; if (size == 0) { errorKan1("%s\n","homogenizeObject_vec() is called for the empty array."); } + if (getoa(ob,0).tag == Sdollar) return(homogenizeObject_go(ob,gradep)); rob = newObjectArray(size); for (i=0; i gr? maxg: gr); + maxg = (maxg > gr? maxg: gr); } putoa(rob,i,ob1); } @@ -763,8 +771,81 @@ int *gradep; } } +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; + int *ds; + POLY f; + rob = NullObject; + if (ob.tag != Sarray) errorKan1("%s\n","homogenizeObject_go(): Invalid argument data type."); + + size = getoaSize(ob); + if (size == 0) errorKan1("%s\n","homogenizeObject_go(): the first argument must be a string."); + ob0 = getoa(ob,0); + if (ob0.tag != Sdollar) { + errorKan1("%s\n","homogenizeObject_go(): the first argument must be a string."); + } + if (strcmp(KopString(ob0),"degreeShift") == 0) { + if (size < 2) + errorKan1("%s\n","homogenizeObject_go(): [(degreeShift) shift-vector obj] or [(degreeShift) shift-vector] or [(degreeShift) (value)] homogenize"); + ob1 = getoa(ob,1); + if (ob1.tag != Sarray) { + if (DegreeShifto_size != 0) { + return DegreeShifto; + }else{ + rob = NullObject; + return rob; + } + } + dssize = getoaSize(ob1); + ds = (int *)sGC_malloc(sizeof(int)*(dssize>0?dssize:1)); + for (i=0; i= 2*N0) errorKan1("%s\n","oInitW(): the size of the second argument is invalid."); for (i=0; im->ringp; + n = ringp->n; + } + t = (*mpMult)(cxx(1,n-1,i,ringp),t); + f = ppAddv(f,t); + } + } + return f; +} + +struct object POLYtoObjArray(POLY f,int size) { + struct object rob; + POLY *pa; + int d,n,i; + POLY t; + if (size < 0) errorKan1("%s\n","POLYtoObjArray() invalid size."); + rob = newObjectArray(size); + pa = (POLY *) sGC_malloc(sizeof(POLY)*(size+1)); + if (pa == NULL) errorKan1("%s\n","POLYtoObjArray() no more memory."); + for (i=0; im->ringp->n; + while (f != POLYNULL) { + d = f->m->e[n-1].x; + if (d >= size) errorKan1("%s\n","POLYtoObjArray() size is too small."); + t = newCell(f->coeffp,monomialCopy(f->m)); + i = t->m->e[n-1].x; + t->m->e[n-1].x = 0; + pa[i] = ppAddv(pa[i],t); /* slow to add from the top. */ + f = f->next; + } + for (i=0; i