version 1.15, 2004/08/31 05:30:20 |
version 1.22, 2020/10/06 11:33:46 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.14 2004/08/31 04:45:42 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport1.c,v 1.21 2005/07/03 11:08:53 ohara Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <string.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
#include "extern.h" |
#include "extern.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; |
|
|
|
static struct object paddingVector(struct object ob, int table[], int m); |
|
static struct object unitVector(int pos, int size,struct ring *r); |
|
|
/** :kan, :ring */ |
/** :kan, :ring */ |
struct object Kreduction(f,set) |
struct object Kreduction(f,set) |
struct object f; |
struct object f; |
Line 27 struct object Kreduction(f,set) |
|
Line 31 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 74 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; /* see @s/2005/06/16-note.pdf */ |
|
|
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); |
struct object paddingVector(struct object ob, int table[], int m); |
static struct object unitVector(int pos, int size,struct ring *r); |
struct object unitVector(int pos, int size,struct ring *r); |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
|
|
StopDegree = 0x7fff; |
StopDegree = 0x7fff; |
Line 118 struct object Kgroebner(ob) |
|
Line 126 struct object Kgroebner(ob) |
|
if (ob2.tag != Sarray) { |
if (ob2.tag != Sarray) { |
errorKan1("%s\n","Kgroebner(): The options must be given by an array."); |
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<getoaSize(ob2); i++) { |
for (i=0; i<getoaSize(ob2); i++) { |
ob2c = getoa(ob2,i); |
ob2c = getoa(ob2,i); |
if (ob2c.tag == Sdollar) { |
if (ob2c.tag == Sdollar) { |
Line 130 struct object Kgroebner(ob) |
|
Line 139 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 251 struct object Kgroebner(ob) |
|
Line 264 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 296 struct object Kgroebner(ob) |
|
Line 309 struct object Kgroebner(ob) |
|
} |
} |
|
|
/* To handle zero entries in the input. */ |
/* 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) { |
if (noZeroEntry) { |
return(rob); |
return(rob); |
} |
} |
Line 313 struct object Kgroebner(ob) |
|
Line 328 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 349 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 359 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 374 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 429 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 455 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 474 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 514 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 544 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 575 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 624 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 684 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 751 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 807 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 986 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 1003 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 1101 POLY objArrayToPOLY(struct object ob) { |
|
Line 1122 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 1137 struct object KordWsAll(ob,oWeight) |
|
Line 1158 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 1252 int validOutputOrder(int ord[],int n) { |
|
Line 1273 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 1284 struct object KsetOutputOrder(struct object ob, struct |
|
Line 1305 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 1333 struct object KvectorToSchreyer_es(struct object obarr |
|
Line 1354 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 1375 struct object KgetExponents(struct object obPoly,struc |
|
Line 1396 struct object KgetExponents(struct object obPoly,struc |
|
POLY f; |
POLY f; |
POLY ff; |
POLY ff; |
MONOMIAL tf; |
MONOMIAL tf; |
struct object rob; |
struct object rob = OINIT; |
struct object tob; |
struct object tob = OINIT; |
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; |
extern struct ring *CurrentRingp; |
extern struct ring *CurrentRingp; |
Line 1405 struct object KgetExponents(struct object obPoly,struc |
|
Line 1426 struct object KgetExponents(struct object obPoly,struc |
|
} |
} |
|
|
/* type == 0 x,y,Dx,Dy (no commutative, no vector) |
/* type == 0 x,y,Dx,Dy (no commutative, no vector) |
type == 1 x,y,h,Dx,Dy,H (commutative & no vector) |
type == 1 x,y,Dx,Dy,h,H (commutative & no vector) |
type == 2 x,y,Dx,Dy,h (commutative & no vector) |
type == 2 x,y,Dx,Dy,h (commutative & no vector) |
*/ |
*/ |
if (f ISZERO) { |
if (f ISZERO) { |
Line 1444 struct object KgetExponents(struct object obPoly,struc |
|
Line 1465 struct object KgetExponents(struct object obPoly,struc |
|
}else{ |
}else{ |
errorKan1("%s\n","KgetExponent, unknown type."); |
errorKan1("%s\n","KgetExponent, unknown type."); |
} |
} |
hsize = size/2; |
if (type == 1 || type == 2) { |
|
hsize = (size-cc)/2; |
|
}else{ |
|
hsize = size/2; |
|
} |
if (f ISZERO) { |
if (f ISZERO) { |
tob = newObjectArray(size); |
tob = newObjectArray(size); |
for (i=0; i<size; i++) { |
for (i=0; i<size; i++) { |
Line 1485 struct object KgetExponents(struct object obPoly,struc |
|
Line 1510 struct object KgetExponents(struct object obPoly,struc |
|
} |
} |
if (type == 1) { |
if (type == 1) { |
for (i=cc-1; i>=0; i--) { |
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)); |
putoa(tob,hsize+r,KpoInteger(tf->e[i].x)); |
putoa(tob,r,KpoInteger(tf->e[i].D)); |
|
r++; |
r++; |
} |
} |
}else if (type == 2) { |
}else if (type == 2) { |