version 1.11, 2003/06/26 08:14:46 |
version 1.34, 2004/09/13 11:24:11 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.10 2002/11/04 10:53:55 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.33 2004/09/11 01:00:42 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
#include "datatype.h" |
#include "datatype.h" |
#include "stackm.h" |
#include "stackm.h" |
Line 19 int SerialCurrent = -1; /* Current Serial number of t |
|
Line 19 int SerialCurrent = -1; /* Current Serial number of t |
|
|
|
int ReverseOutputOrder = 1; |
int ReverseOutputOrder = 1; |
int WarningNoVectorVariable = 1; |
int WarningNoVectorVariable = 1; |
|
extern int QuoteMode; |
|
|
/** :arithmetic **/ |
/** :arithmetic **/ |
struct object KooAdd(ob1,ob2) |
struct object KooAdd(ob1,ob2) |
Line 142 struct object KooAdd(ob1,ob2) |
|
Line 143 struct object KooAdd(ob1,ob2) |
|
|
|
|
|
default: |
default: |
warningKan("KooAdd() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = addTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooAdd() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 270 struct object KooSub(ob1,ob2) |
|
Line 275 struct object KooSub(ob1,ob2) |
|
break; |
break; |
|
|
default: |
default: |
warningKan("KooSub() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = minusTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooSub() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 412 struct object KooMult(ob1,ob2) |
|
Line 421 struct object KooMult(ob1,ob2) |
|
break; |
break; |
|
|
default: |
default: |
warningKan("KooMult() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = timesTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooMult() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 451 struct object KoNegate(obj) |
|
Line 464 struct object KoNegate(obj) |
|
break; |
break; |
|
|
default: |
default: |
warningKan("KoNegate() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = unaryminusTree(obj); |
|
}else{ |
|
warningKan("KoNegate() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 653 struct object KooDiv(ob1,ob2) |
|
Line 670 struct object KooDiv(ob1,ob2) |
|
|
|
|
|
default: |
default: |
warningKan("KooDiv() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = divideTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooDiv() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 776 struct object KooGreater(obj1,obj2) |
|
Line 797 struct object KooGreater(obj1,obj2) |
|
if ( KopDouble(obj1) > KopDouble(obj2) ) return(KpoInteger(1)); |
if ( KopDouble(obj1) > KopDouble(obj2) ) return(KpoInteger(1)); |
else return(KpoInteger(0)); |
else return(KpoInteger(0)); |
break; |
break; |
|
case Sarray: |
|
{ |
|
int i,m1,m2; |
|
struct object rr; |
|
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
|
for (i=0; i< (m1>m2?m2:m1); i++) { |
|
rr=KooGreater(getoa(obj1,i),getoa(obj2,i)); |
|
if (KopInteger(rr) == 1) return rr; |
|
rr=KooGreater(getoa(obj2,i),getoa(obj1,i)); |
|
if (KopInteger(rr) == 1) return KpoInteger(0); |
|
} |
|
if (m1 > m2) return KpoInteger(1); |
|
else return KpoInteger(0); |
|
} |
|
break; |
default: |
default: |
errorKan1("%s\n","KooGreater() has not supported these objects yet."); |
errorKan1("%s\n","KooGreater() has not supported these objects yet."); |
break; |
break; |
Line 817 struct object KooLess(obj1,obj2) |
|
Line 853 struct object KooLess(obj1,obj2) |
|
if ( KopDouble(obj1) < KopDouble(obj2) ) return(KpoInteger(1)); |
if ( KopDouble(obj1) < KopDouble(obj2) ) return(KpoInteger(1)); |
else return(KpoInteger(0)); |
else return(KpoInteger(0)); |
break; |
break; |
|
case Sarray: |
|
{ |
|
int i,m1,m2; |
|
struct object rr; |
|
m1 = getoaSize(obj1); m2 = getoaSize(obj2); |
|
for (i=0; i< (m1>m2?m2:m1); i++) { |
|
rr=KooLess(getoa(obj1,i),getoa(obj2,i)); |
|
if (KopInteger(rr) == 1) return rr; |
|
rr=KooLess(getoa(obj2,i),getoa(obj1,i)); |
|
if (KopInteger(rr) == 1) return KpoInteger(0); |
|
} |
|
if (m1 < m2) return KpoInteger(1); |
|
else return KpoInteger(0); |
|
} |
|
break; |
default: |
default: |
errorKan1("%s\n","KooLess() has not supported these objects yet."); |
errorKan1("%s\n","KooLess() has not supported these objects yet."); |
break; |
break; |
Line 868 struct object KdataConversion(obj,key) |
|
Line 919 struct object KdataConversion(obj,key) |
|
return(rob); |
return(rob); |
}else if (strcmp(key,"poly") == 0) { |
}else if (strcmp(key,"poly") == 0) { |
rob = KpoPOLY(ZERO); |
rob = KpoPOLY(ZERO); |
|
return rob; |
|
}else if (strcmp(key,"array") == 0) { |
|
rob = newObjectArray(0); |
|
return rob; |
}else{ |
}else{ |
warningKan("Sorry. The data conversion from null to this data type has not supported yet.\n"); |
warningKan("Sorry. The data conversion from null to this data type has not supported yet.\n"); |
} |
} |
Line 893 struct object KdataConversion(obj,key) |
|
Line 948 struct object KdataConversion(obj,key) |
|
strcpy(rob.lc.str,intstr); |
strcpy(rob.lc.str,intstr); |
return(rob); |
return(rob); |
}else if (strcmp(key,"universalNumber")==0) { |
}else if (strcmp(key,"universalNumber")==0) { |
rob.tag = SuniversalNumber; |
rob = KintToUniversalNumber(obj.lc.ival); |
rob.lc.universalNumber = intToCoeff(obj.lc.ival,&SmallRing); |
|
return(rob); |
return(rob); |
}else if (strcmp(key,"double") == 0) { |
}else if (strcmp(key,"double") == 0) { |
rob = KpoDouble((double) (obj.lc.ival)); |
rob = KpoDouble((double) (obj.lc.ival)); |
Line 965 struct object KdataConversion(obj,key) |
|
Line 1019 struct object KdataConversion(obj,key) |
|
if (strcmp(key,"array") == 0) { |
if (strcmp(key,"array") == 0) { |
return(rob); |
return(rob); |
}else if (strcmp(key,"list") == 0) { |
}else if (strcmp(key,"list") == 0) { |
rob = *( arrayToList(obj) ); |
rob = KarrayToList(obj); |
return(rob); |
return(rob); |
}else if (strcmp(key,"arrayOfPOLY")==0) { |
}else if (strcmp(key,"arrayOfPOLY")==0) { |
rob = KpoArrayOfPOLY(arrayToArrayOfPOLY(obj)); |
rob = KpoArrayOfPOLY(arrayToArrayOfPOLY(obj)); |
Line 980 struct object KdataConversion(obj,key) |
|
Line 1034 struct object KdataConversion(obj,key) |
|
rob = NullObject; |
rob = NullObject; |
return(rob); |
return(rob); |
}else { |
}else { |
warningKan("Sorry. This type of data conversion has not supported yet.\n"); |
{ /* Automatically maps the elements. */ |
|
int n,i; |
|
n = getoaSize(obj); |
|
rob = newObjectArray(n); |
|
for (i=0; i<n; i++) { |
|
putoa(rob,i,KdataConversion(getoa(obj,i),key)); |
|
} |
|
return(rob); |
|
} |
} |
} |
break; |
break; |
case Spoly: |
case Spoly: |
if (strcmp(key,"poly")==0) { |
if ((strcmp(key,"poly")==0) || (strcmp(key,"numerator")==0)) { |
rob = obj; |
rob = obj; |
return(rob); |
return(rob); |
}else if (strcmp(key,"integer")==0) { |
}else if (strcmp(key,"integer")==0) { |
Line 1050 struct object KdataConversion(obj,key) |
|
Line 1112 struct object KdataConversion(obj,key) |
|
break; |
break; |
case Slist: |
case Slist: |
if (strcmp(key,"array") == 0) { |
if (strcmp(key,"array") == 0) { |
rob = listToArray(&obj); |
rob = KlistToArray(obj); |
return(rob); |
return(rob); |
} |
} |
break; |
break; |
case SuniversalNumber: |
case SuniversalNumber: |
if (strcmp(key,"universalNumber")==0) { |
if ((strcmp(key,"universalNumber")==0) || (strcmp(key,"numerator")==0)) { |
|
rob = obj; |
return(rob); |
return(rob); |
}else if (strcmp(key,"integer")==0) { |
}else if (strcmp(key,"integer")==0) { |
rob = KpoInteger(coeffToInt(obj.lc.universalNumber)); |
rob = KpoInteger(coeffToInt(obj.lc.universalNumber)); |
Line 1073 struct object KdataConversion(obj,key) |
|
Line 1136 struct object KdataConversion(obj,key) |
|
}else if (strcmp(key,"double") == 0) { |
}else if (strcmp(key,"double") == 0) { |
rob = KpoDouble( toDouble0(obj) ); |
rob = KpoDouble( toDouble0(obj) ); |
return(rob); |
return(rob); |
|
}else if (strcmp(key,"denominator") == 0) { |
|
rob = KintToUniversalNumber(1); |
|
return(rob); |
}else{ |
}else{ |
warningKan("Sorry. This type of data conversion of universalNumber has not supported yet.\n"); |
warningKan("Sorry. This type of data conversion of universalNumber has not supported yet.\n"); |
} |
} |
Line 1137 struct object KdataConversion(obj,key) |
|
Line 1203 struct object KdataConversion(obj,key) |
|
if (strcmp(key,"orderMatrix")==0) { |
if (strcmp(key,"orderMatrix")==0) { |
rob = oGetOrderMatrix(KopRingp(obj)); |
rob = oGetOrderMatrix(KopRingp(obj)); |
return(rob); |
return(rob); |
|
}else if (strcmp(key,"oxRingStructure")==0) { |
|
rob = oRingToOXringStructure(KopRingp(obj)); |
|
return(rob); |
}else{ |
}else{ |
warningKan("Sorryl This type of data conversion of ringp has not supported yet.\n"); |
warningKan("Sorryl This type of data conversion of ringp has not supported yet.\n"); |
} |
} |
Line 1146 struct object KdataConversion(obj,key) |
|
Line 1215 struct object KdataConversion(obj,key) |
|
} |
} |
return(NullObject); |
return(NullObject); |
} |
} |
|
|
|
/* cf. macro to_int32 */ |
|
struct object Kto_int32(struct object ob) { |
|
int n,i; |
|
struct object otmp; |
|
struct object rob; |
|
if (ob.tag == SuniversalNumber) return KdataConversion(ob,"integer"); |
|
if (ob.tag == Sarray) { |
|
n = getoaSize(ob); |
|
rob = newObjectArray(n); |
|
for (i=0; i<n; i++) { |
|
otmp = Kto_int32(getoa(ob,i)); |
|
putoa(rob,i,otmp); |
|
} |
|
return rob; |
|
} |
|
return ob; |
|
} |
/* conversion functions between primitive data and objects. |
/* conversion functions between primitive data and objects. |
If it's not time critical, it is recommended to use these functions */ |
If it's not time critical, it is recommended to use these functions */ |
struct object KpoInteger(k) |
struct object KpoInteger(k) |
Line 1200 struct object KpoRingp(ringp) |
|
Line 1286 struct object KpoRingp(ringp) |
|
return(obj); |
return(obj); |
} |
} |
|
|
|
struct object KpoUniversalNumber(u) |
|
struct coeff *u; |
|
{ |
|
struct object obj; |
|
obj.tag = SuniversalNumber; |
|
obj.lc.universalNumber = u; |
|
return(obj); |
|
} |
|
struct object KintToUniversalNumber(n) |
|
int n; |
|
{ |
|
struct object rob; |
|
extern struct ring SmallRing; |
|
rob.tag = SuniversalNumber; |
|
rob.lc.universalNumber = intToCoeff(n,&SmallRing); |
|
return(rob); |
|
} |
|
|
/*** conversion 2. Data conversions on arrays and matrices. ****/ |
/*** conversion 2. Data conversions on arrays and matrices. ****/ |
struct object arrayOfPOLYToArray(aa) |
struct object arrayOfPOLYToArray(aa) |
struct arrayOfPOLY *aa; |
struct arrayOfPOLY *aa; |
Line 1496 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1600 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
outputVars[i] = i; |
outputVars[i] = i; |
} |
} |
} |
} |
|
|
|
ob4 = Kto_int32(ob4); /* order matrix */ |
oasize = getoaSize(ob4); |
oasize = getoaSize(ob4); |
order = (int *)sGC_malloc(sizeof(int)*((2*n)*oasize+1)); |
order = (int *)sGC_malloc(sizeof(int)*((2*n)*oasize+1)); |
if (order == (int *)NULL) errorKan1("%s\n","No memory."); |
if (order == (int *)NULL) errorKan1("%s\n","No memory."); |
Line 1539 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1644 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
newRingp->outputOrder = outputVars; |
newRingp->outputOrder = outputVars; |
newRingp->weightedHomogenization = 0; |
newRingp->weightedHomogenization = 0; |
newRingp->degreeShiftSize = 0; |
newRingp->degreeShiftSize = 0; |
|
newRingp->degreeShiftN = 0; |
|
newRingp->degreeShift = NULL; |
|
newRingp->partialEcart = 0; |
|
newRingp->partialEcartGlobalVarX = NULL; |
|
|
if (ob5.tag != Sarray || (getoaSize(ob5) % 2) != 0) { |
if (ob5.tag != Sarray || (getoaSize(ob5) % 2) != 0) { |
errorKan1("%s\n","[(keyword) value (keyword) value ....] should be given."); |
errorKan1("%s\n","[(keyword) value (keyword) value ....] should be given."); |
Line 1592 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
Line 1701 int KsetUpRing(ob1,ob2,ob3,ob4,ob5) |
|
newRingp->weightedHomogenization = KopInteger(getoa(ob5,i+1)); |
newRingp->weightedHomogenization = KopInteger(getoa(ob5,i+1)); |
} else if (strcmp(KopString(getoa(ob5,i)),"degreeShift") == 0) { |
} else if (strcmp(KopString(getoa(ob5,i)),"degreeShift") == 0) { |
if (getoa(ob5,i+1).tag != Sarray) { |
if (getoa(ob5,i+1).tag != Sarray) { |
errorKan1("%s\n","An array should be given. (degreeShift)"); |
errorKan1("%s\n","An array of array should be given. (degreeShift)"); |
} |
} |
{ |
{ |
struct object ods; |
struct object ods; |
int dssize,k; |
struct object ods2; |
|
int dssize,k,j,nn; |
ods=getoa(ob5,i+1); |
ods=getoa(ob5,i+1); |
dssize = getoaSize(ods); |
if ((getoaSize(ods) < 1) || (getoa(ods,0).tag != Sarray)) { |
|
errorKan1("%s\n", "An array of array should be given. (degreeShift)"); |
|
} |
|
nn = getoaSize(ods); |
|
dssize = getoaSize(getoa(ods,0)); |
newRingp->degreeShiftSize = dssize; |
newRingp->degreeShiftSize = dssize; |
newRingp->degreeShift = (int *) sGC_malloc(sizeof(int)*(dssize+1)); |
newRingp->degreeShiftN = nn; |
|
newRingp->degreeShift = (int *) sGC_malloc(sizeof(int)*(dssize*nn+1)); |
if (newRingp->degreeShift == NULL) errorKan1("%s\n","No more memory."); |
if (newRingp->degreeShift == NULL) errorKan1("%s\n","No more memory."); |
for (k=0; k<dssize; k++) { |
for (j=0; j<nn; j++) { |
if (getoa(ods,k).tag == SuniversalNumber) { |
ods2 = getoa(ods,j); |
(newRingp->degreeShift)[k] = coeffToInt(getoa(ods,k).lc.universalNumber); |
for (k=0; k<dssize; k++) { |
}else{ |
if (getoa(ods2,k).tag == SuniversalNumber) { |
(newRingp->degreeShift)[k] = KopInteger(getoa(ods,k)); |
(newRingp->degreeShift)[j*dssize+k] = coeffToInt(getoa(ods2,k).lc.universalNumber); |
|
}else{ |
|
(newRingp->degreeShift)[j*dssize+k] = KopInteger(getoa(ods2,k)); |
|
} |
} |
} |
} |
} |
} |
} |
|
} else if (strcmp(KopString(getoa(ob5,i)),"partialEcartGlobalVarX") == 0) { |
|
if (getoa(ob5,i+1).tag != Sarray) { |
|
errorKan1("%s\n","An array of array should be given. (partialEcart)"); |
|
} |
|
{ |
|
struct object odv; |
|
struct object ovv; |
|
int k,j,nn; |
|
char *vname; |
|
odv=getoa(ob5,i+1); |
|
nn = getoaSize(odv); |
|
newRingp->partialEcart = nn; |
|
newRingp->partialEcartGlobalVarX = (int *) sGC_malloc(sizeof(int)*nn+1); |
|
if (newRingp->partialEcartGlobalVarX == NULL) errorKan1("%s\n","No more memory."); |
|
for (j=0; j<nn; j++) |
|
(newRingp->partialEcartGlobalVarX)[j] = -1; |
|
for (j=0; j<nn; j++) { |
|
ovv = getoa(odv,j); |
|
if (ovv.tag != Sdollar) errorKan1("%s\n","partialEcartGlobalVarX: string is expected."); |
|
vname = KopString(ovv); |
|
for (k=0; k<n; k++) { |
|
if (strcmp(vname,xvars[k]) == 0) { |
|
(newRingp->partialEcartGlobalVarX)[j] = k; break; |
|
}else{ |
|
if (k == n-1) errorKan1("%s\n","partialEcartGlobalVarX: no such variable."); |
|
} |
|
} |
|
} |
|
} |
|
|
|
switch_function("grade","module1v"); |
|
/* Warning: grading is changed to module1v!! */ |
} else { |
} else { |
errorKan1("%s\n","Unknown keyword to set_up_ring@"); |
errorKan1("%s\n","Unknown keyword to set_up_ring@"); |
} |
} |
Line 2049 int KtoArgvbyCurryBrace(str,argv,limit) |
|
Line 2199 int KtoArgvbyCurryBrace(str,argv,limit) |
|
return(argc); |
return(argc); |
} |
} |
|
|
|
struct object KstringToArgv(struct object ob) { |
|
struct object rob; |
|
char *s; |
|
int n,wc,i,inblank; |
|
char **argv; |
|
if (ob.tag != Sdollar) |
|
errorKan1("%s\n","KstringToArgv(): the argument must be a string."); |
|
n = strlen(KopString(ob)); |
|
s = (char *) sGC_malloc(sizeof(char)*(n+2)); |
|
if (s == NULL) errorKan1("%s\n","KstringToArgv(): No memory."); |
|
strcpy(s,KopString(ob)); |
|
inblank = 1; wc = 0; |
|
for (i=0; i<n; i++) { |
|
if (inblank && (s[i] > ' ')) { |
|
wc++; inblank = 0; |
|
}else if ((!inblank) && (s[i] <= ' ')) { |
|
inblank = 1; |
|
} |
|
} |
|
argv = (char **) sGC_malloc(sizeof(char *)*(wc+2)); |
|
argv[0] = NULL; |
|
inblank = 1; wc = 0; |
|
for (i=0; i<n; i++) { |
|
if (inblank && (s[i] > ' ')) { |
|
argv[wc] = &(s[i]); argv[wc+1]=NULL; |
|
wc++; inblank = 0; |
|
}else if ((inblank == 0) && (s[i] <= ' ')) { |
|
inblank = 1; s[i] = 0; |
|
}else if (inblank && (s[i] <= ' ')) { |
|
s[i] = 0; |
|
} |
|
} |
|
|
|
rob = newObjectArray(wc); |
|
for (i=0; i<wc; i++) { |
|
putoa(rob,i,KpoString(argv[i])); |
|
/* printf("%s\n",argv[i]); */ |
|
} |
|
return(rob); |
|
} |
|
|
static void checkDuplicateName(xvars,dvars,n) |
static void checkDuplicateName(xvars,dvars,n) |
char *xvars[]; |
char *xvars[]; |
char *dvars[]; |
char *dvars[]; |
Line 2071 static void checkDuplicateName(xvars,dvars,n) |
|
Line 2261 static void checkDuplicateName(xvars,dvars,n) |
|
} |
} |
} |
} |
|
|
|
struct object KooPower(struct object ob1,struct object ob2) { |
|
struct object rob; |
|
/* Bug. It has not yet been implemented. */ |
|
if (QuoteMode) { |
|
rob = powerTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooDiv2() has not supported yet these objects.\n"); |
|
} |
|
return(rob); |
|
} |
|
|
|
|
|
|
Line 2133 struct object KooDiv2(ob1,ob2) |
|
Line 2333 struct object KooDiv2(ob1,ob2) |
|
break; |
break; |
|
|
default: |
default: |
warningKan("KooDiv2() has not supported yet these objects.\n"); |
if (QuoteMode) { |
|
rob = divideTree(ob1,ob2); |
|
}else{ |
|
warningKan("KooDiv2() has not supported yet these objects.\n"); |
|
} |
break; |
break; |
} |
} |
return(rob); |
return(rob); |
Line 2189 struct object KgbExtension(struct object obj) |
|
Line 2393 struct object KgbExtension(struct object obj) |
|
POLY f; |
POLY f; |
int m,i; |
int m,i; |
struct pairOfPOLY pf; |
struct pairOfPOLY pf; |
|
struct coeff *cont; |
|
|
if (obj.tag != Sarray) errorKan1("%s\n","KgbExtension(): The argument must be an array."); |
if (obj.tag != Sarray) errorKan1("%s\n","KgbExtension(): The argument must be an array."); |
size = getoaSize(obj); |
size = getoaSize(obj); |
Line 2268 struct object KgbExtension(struct object obj) |
|
Line 2473 struct object KgbExtension(struct object obj) |
|
errorKan1("%s\n","The datatype of the argument mismatch: [(isConstant) polynomial] gbext"); |
errorKan1("%s\n","The datatype of the argument mismatch: [(isConstant) polynomial] gbext"); |
} |
} |
return(KpoInteger(isConstant(KopPOLY(obj1)))); |
return(KpoInteger(isConstant(KopPOLY(obj1)))); |
|
}else if (strcmp(key,"isConstantAll")==0) { |
|
if (size != 2) errorKan1("%s\n","[(isConstantAll) poly ] gbext bool"); |
|
obj1 = getoa(obj,1); |
|
if (obj1.tag != Spoly) { |
|
errorKan1("%s\n","The datatype of the argument mismatch: [(isConstantAll) polynomial] gbext"); |
|
} |
|
return(KpoInteger(isConstantAll(KopPOLY(obj1)))); |
}else if (strcmp(key,"schreyerSkelton") == 0) { |
}else if (strcmp(key,"schreyerSkelton") == 0) { |
if (size != 2) errorKan1("%s\n","[(schreyerSkelton) array_of_poly ] gbext array"); |
if (size != 2) errorKan1("%s\n","[(schreyerSkelton) array_of_poly ] gbext array"); |
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
Line 2302 struct object KgbExtension(struct object obj) |
|
Line 2514 struct object KgbExtension(struct object obj) |
|
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
if (obj1.tag != Spoly) errorKan1("%s\n","[(isOrdered) poly] gbext poly"); |
if (obj1.tag != Spoly) errorKan1("%s\n","[(isOrdered) poly] gbext poly"); |
return(KisOrdered(obj1)); |
return(KisOrdered(obj1)); |
|
}else if (strcmp(key,"reduceContent")==0) { |
|
if (size != 2) errorKan1("%s\n","[(reduceContent) poly1 ] gbext."); |
|
obj1 = getoa(obj,1); |
|
if (obj1.tag != Spoly) |
|
errorKan1("%s\n","[(reduceContent) poly1 ] gbext."); |
|
f1 = KopPOLY(obj1); |
|
rob = newObjectArray(2); |
|
f1 = reduceContentOfPoly(f1,&cont); |
|
putoa(rob,0,KpoPOLY(f1)); |
|
if (f1 == POLYNULL) { |
|
putoa(rob,1,KpoPOLY(f1)); |
|
}else{ |
|
putoa(rob,1,KpoPOLY(newCell(cont,newMonomial(f1->m->ringp)))); |
|
} |
|
}else if (strcmp(key,"ord_ws_all")==0) { |
|
if (size != 3) errorKan1("%s\n","[(ord_ws_all) fv wv] gbext"); |
|
obj1 = getoa(obj,1); |
|
obj2 = getoa(obj,2); |
|
rob = KordWsAll(obj1,obj2); |
|
}else if (strcmp(key,"exponents")==0) { |
|
if (size == 3) { |
|
obj1 = getoa(obj,1); |
|
obj2 = getoa(obj,2); |
|
rob = KgetExponents(obj1,obj2); |
|
}else if (size == 2) { |
|
obj1 = getoa(obj,1); |
|
obj2 = KpoInteger(2); |
|
rob = KgetExponents(obj1,obj2); |
|
}else{ |
|
errorKan1("%s\n","[(exponents) f type] gbext"); |
|
} |
}else { |
}else { |
errorKan1("%s\n","gbext : unknown tag."); |
errorKan1("%s\n","gbext : unknown tag."); |
} |
} |
Line 2337 struct object KmpzExtension(struct object obj) |
|
Line 2580 struct object KmpzExtension(struct object obj) |
|
if (size != 3) errorKan1("%s\n","[(gcd) universalNumber universalNumber] mpzext."); |
if (size != 3) errorKan1("%s\n","[(gcd) universalNumber universalNumber] mpzext."); |
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
obj2 = getoa(obj,2); |
obj2 = getoa(obj,2); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
|
if (obj2.tag != SuniversalNumber) { |
|
obj2 = KdataConversion(obj2,"universalNumber"); |
|
} |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
errorKan1("%s\n","[(gcd) universalNumber universalNumber] mpzext."); |
errorKan1("%s\n","[(gcd) universalNumber universalNumber] mpzext."); |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
Line 2353 struct object KmpzExtension(struct object obj) |
|
Line 2602 struct object KmpzExtension(struct object obj) |
|
if (size != 3) errorKan1("%s\n","[(tdiv_qr) universalNumber universalNumber] mpzext."); |
if (size != 3) errorKan1("%s\n","[(tdiv_qr) universalNumber universalNumber] mpzext."); |
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
obj2 = getoa(obj,2); |
obj2 = getoa(obj,2); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
|
if (obj2.tag != SuniversalNumber) { |
|
obj2 = KdataConversion(obj2,"universalNumber"); |
|
} |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
errorKan1("%s\n","[(tdiv_qr) universalNumber universalNumber] mpzext."); |
errorKan1("%s\n","[(tdiv_qr) universalNumber universalNumber] mpzext."); |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
Line 2411 struct object KmpzExtension(struct object obj) |
|
Line 2666 struct object KmpzExtension(struct object obj) |
|
/* One arg functions */ |
/* One arg functions */ |
if (size != 2) errorKan1("%s\n","[key num] mpzext"); |
if (size != 2) errorKan1("%s\n","[key num] mpzext"); |
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
if (obj1.tag != SuniversalNumber) |
if (obj1.tag != SuniversalNumber) |
errorKan1("%s\n","[key num] mpzext : num must be a universalNumber."); |
errorKan1("%s\n","[key num] mpzext : num must be a universalNumber."); |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber)) |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber)) |
Line 2432 struct object KmpzExtension(struct object obj) |
|
Line 2690 struct object KmpzExtension(struct object obj) |
|
if (size != 3) errorKan1("%s\n","[key num1 num2] mpzext."); |
if (size != 3) errorKan1("%s\n","[key num1 num2] mpzext."); |
obj1 = getoa(obj,1); |
obj1 = getoa(obj,1); |
obj2 = getoa(obj,2); |
obj2 = getoa(obj,2); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
|
if (obj2.tag != SuniversalNumber) { |
|
obj2 = KdataConversion(obj2,"universalNumber"); |
|
} |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
errorKan1("%s\n","[key num1 num2] mpzext."); |
errorKan1("%s\n","[key num1 num2] mpzext."); |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
Line 2463 struct object KmpzExtension(struct object obj) |
|
Line 2727 struct object KmpzExtension(struct object obj) |
|
/* three args */ |
/* three args */ |
if (size != 4) errorKan1("%s\n","[key num1 num2 num3] mpzext"); |
if (size != 4) errorKan1("%s\n","[key num1 num2 num3] mpzext"); |
obj1 = getoa(obj,1); obj2 = getoa(obj,2); obj3 = getoa(obj,3); |
obj1 = getoa(obj,1); obj2 = getoa(obj,2); obj3 = getoa(obj,3); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
|
if (obj2.tag != SuniversalNumber) { |
|
obj2 = KdataConversion(obj2,"universalNumber"); |
|
} |
|
if (obj3.tag != SuniversalNumber) { |
|
obj3 = KdataConversion(obj3,"universalNumber"); |
|
} |
if (obj1.tag != SuniversalNumber || |
if (obj1.tag != SuniversalNumber || |
obj2.tag != SuniversalNumber || |
obj2.tag != SuniversalNumber || |
obj3.tag != SuniversalNumber ) { |
obj3.tag != SuniversalNumber ) { |
Line 2481 struct object KmpzExtension(struct object obj) |
|
Line 2754 struct object KmpzExtension(struct object obj) |
|
mpz_powm(r1,f,g,h); |
mpz_powm(r1,f,g,h); |
rob.tag = SuniversalNumber; |
rob.tag = SuniversalNumber; |
rob.lc.universalNumber = mpintToCoeff(r1,SmallRingp); |
rob.lc.universalNumber = mpintToCoeff(r1,SmallRingp); |
|
} else if (strcmp(key,"lcm")==0) { |
|
if (size != 3) errorKan1("%s\n","[(lcm) universalNumber universalNumber] mpzext."); |
|
obj1 = getoa(obj,1); |
|
obj2 = getoa(obj,2); |
|
if (obj1.tag != SuniversalNumber) { |
|
obj1 = KdataConversion(obj1,"universalNumber"); |
|
} |
|
if (obj2.tag != SuniversalNumber) { |
|
obj2 = KdataConversion(obj2,"universalNumber"); |
|
} |
|
if (obj1.tag != SuniversalNumber || obj2.tag != SuniversalNumber) |
|
errorKan1("%s\n","[lcm num1 num2] mpzext."); |
|
if (! is_this_coeff_MP_INT(obj1.lc.universalNumber) || |
|
! is_this_coeff_MP_INT(obj2.lc.universalNumber)) { |
|
errorKan1("%s\n","[(lcm) universalNumber universalNumber] mpzext."); |
|
} |
|
f = coeff_to_MP_INT(obj1.lc.universalNumber); |
|
g = coeff_to_MP_INT(obj2.lc.universalNumber); |
|
r1 = newMP_INT(); |
|
mpz_lcm(r1,f,g); |
|
rob.tag = SuniversalNumber; |
|
rob.lc.universalNumber = mpintToCoeff(r1,SmallRingp); |
}else { |
}else { |
errorKan1("%s\n","mpzExtension(): Unknown tag."); |
errorKan1("%s\n","mpzExtension(): Unknown tag."); |
} |
} |
Line 2687 struct object KdefaultPolyRing(struct object ob) { |
|
Line 2982 struct object KdefaultPolyRing(struct object ob) { |
|
} |
} |
|
|
|
|
|
struct object Krest(struct object ob) { |
|
struct object rob; |
|
struct object *op; |
|
int n,i; |
|
if (ob.tag == Sarray) { |
|
n = getoaSize(ob); |
|
if (n == 0) return ob; |
|
rob = newObjectArray(n-1); |
|
for (i=1; i<n; i++) { |
|
putoa(rob,i-1,getoa(ob,i)); |
|
} |
|
return rob; |
|
}else if ((ob.tag == Slist) || (ob.tag == Snull)) { |
|
return Kcdr(ob); |
|
}else{ |
|
errorKan1("%s\n","Krest(ob): ob must be an array or a list."); |
|
} |
|
} |
|
struct object Kjoin(struct object ob1, struct object ob2) { |
|
struct object rob; |
|
int n1,n2,i; |
|
if ((ob1.tag == Sarray) && (ob2.tag == Sarray)) { |
|
n1 = getoaSize(ob1); n2 = getoaSize(ob2); |
|
rob = newObjectArray(n1+n2); |
|
for (i=0; i<n1; i++) { |
|
putoa(rob,i,getoa(ob1,i)); |
|
} |
|
for (i=n1; i<n1+n2; i++) { |
|
putoa(rob,i,getoa(ob2,i-n1)); |
|
} |
|
return rob; |
|
}else if ((ob1.tag == Slist) || (ob1.tag == Snull)) { |
|
if ((ob2.tag == Slist) || (ob2.tag == Snull)) { |
|
return KvJoin(ob1,ob2); |
|
}else{ |
|
errorKan1("%s\n","Kjoin: both argument must be a list."); |
|
} |
|
}else{ |
|
errorKan1("%s\n","Kjoin: arguments must be arrays."); |
|
} |
|
} |
|
|
|
struct object Kget(struct object ob1, struct object ob2) { |
|
struct object rob; |
|
struct object tob; |
|
int i,j,size,n; |
|
if (ob2.tag == Sinteger) { |
|
i =ob2.lc.ival; |
|
}else if (ob2.tag == SuniversalNumber) { |
|
i = KopInteger(KdataConversion(ob2,"integer")); |
|
}else if (ob2.tag == Sarray) { |
|
n = getoaSize(ob2); |
|
if (n == 0) return ob1; |
|
rob = ob1; |
|
for (i=0; i<n; i++) { |
|
rob=Kget(rob,getoa(ob2,i)); |
|
} |
|
return rob; |
|
} |
|
if (ob1.tag == Sarray) { |
|
size = getoaSize(ob1); |
|
if ((0 <= i) && (i<size)) { |
|
return(getoa(ob1,i)); |
|
}else{ |
|
errorKan1("%s\n","Kget: Index is out of bound. (get)\n"); |
|
} |
|
}else if (ob1.tag == Slist) { |
|
rob = NullObject; |
|
if (i < 0) errorKan1("%s\n","Kget: Index is negative. (get)"); |
|
for (j=0; j<i; j++) { |
|
rob = Kcdr(ob1); |
|
if ((ob1.tag == Snull) && (rob.tag == Snull)) { |
|
errorKan1("%s\n","Kget: Index is out of bound. (get) cdr of null list.\n"); |
|
} |
|
ob1 = rob; |
|
} |
|
return Kcar(ob1); |
|
}else errorKan1("%s\n","Kget: argument must be an array or a list."); |
|
} |
|
|
/****************************************************************** |
/****************************************************************** |
error handler |
error handler |
Line 2713 errorKan1(str,message) |
|
Line 3085 errorKan1(str,message) |
|
if (ErrorMessageMode != 1) { |
if (ErrorMessageMode != 1) { |
fprintf(stderr,"\nERROR(kanExport[0|1].c): "); |
fprintf(stderr,"\nERROR(kanExport[0|1].c): "); |
fprintf(stderr,str,message); |
fprintf(stderr,str,message); |
|
(void) traceShowStack(); traceClearStack(); |
} |
} |
/* fprintf(stderr,"Hello "); */ |
/* fprintf(stderr,"Hello "); */ |
if (GotoP) { |
if (GotoP) { |
Line 2728 errorKan1(str,message) |
|
Line 3101 errorKan1(str,message) |
|
longjmp(EnvOfStackMachine,1); |
longjmp(EnvOfStackMachine,1); |
#endif |
#endif |
} |
} |
|
|
|
|
warningKan(str) |
warningKan(str) |
char *str; |
char *str; |