version 1.9, 2003/08/24 05:19:42 |
version 1.18, 2005/06/16 05:07:23 |
|
|
/* $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.17 2005/06/09 04:09:22 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
|
|
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 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 133 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,"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 239 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 256 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); |
|
|
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 274 struct object Kgroebner(ob) |
|
Line 279 struct object Kgroebner(ob) |
|
fflush(stdout); |
fflush(stdout); |
} |
} |
mp = getSyzygy(grG,grP->next,&grBases,&backwardMat); |
mp = getSyzygy(grG,grP->next,&grBases,&backwardMat); |
|
if (mp == NULL) errorKan1("%s\n","Internal error in getSyzygy(). BUG of sm1."); |
if (KanGBmessage) printf("Done.\n"); |
if (KanGBmessage) printf("Done.\n"); |
|
|
putoa(rob,0,gradedPolySetToArray(grG,0)); |
putoa(rob,0,gradedPolySetToArray(grG,0)); |
Line 341 struct object Kgroebner(ob) |
|
Line 347 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 356 static struct object paddingVector(struct object ob, i |
|
Line 362 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 411 struct object polySetToArray(ps,keepRedundant) |
|
Line 417 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 437 struct object gradedPolySetToGradedArray(gps,keepRedun |
|
Line 443 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 455 struct object gradedPolySetToArray(gps,keepRedundant) |
|
Line 462 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 494 struct object syzPolyToArray(size,f,grG) |
|
Line 502 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 524 struct object getBackwardArray(grG) |
|
Line 532 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 555 POLY arrayToPOLY(ob) |
|
Line 563 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 604 struct object POLYToArray(ff) |
|
Line 612 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 664 struct object homogenizeObject(ob,gradep) |
|
Line 672 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 730 struct object homogenizeObject_vec(ob,gradep) |
|
Line 739 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 785 void KresetDegreeShift() { |
|
Line 795 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 964 struct object oPrincipalPart(ob) |
|
Line 974 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 981 struct object oInitW(ob,oWeight) |
|
Line 991 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 996 struct object oInitW(ob,oWeight) |
|
Line 1006 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 1099 POLY objArrayToPOLY(struct object ob) { |
|
Line 1110 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 1135 struct object KordWsAll(ob,oWeight) |
|
Line 1146 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 1150 struct object KordWsAll(ob,oWeight) |
|
Line 1161 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 1249 int validOutputOrder(int ord[],int n) { |
|
Line 1261 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 1281 struct object KsetOutputOrder(struct object ob, struct |
|
Line 1293 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 1330 struct object KvectorToSchreyer_es(struct object obarr |
|
Line 1342 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 1365 int objToInteger(struct object ob) { |
|
Line 1377 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; |
} |
} |