=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/kanExport0.c,v retrieving revision 1.28 retrieving revision 1.49 diff -u -p -r1.28 -r1.49 --- OpenXM/src/kan96xx/Kan/kanExport0.c 2004/08/31 04:45:42 1.28 +++ OpenXM/src/kan96xx/Kan/kanExport0.c 2015/10/08 11:49:37 1.49 @@ -1,5 +1,7 @@ -/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.27 2004/08/28 07:28:54 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.48 2012/09/16 01:53:08 takayama Exp $ */ #include +#include +#include #include "datatype.h" #include "stackm.h" #include "extern.h" @@ -30,7 +32,8 @@ struct object KooAdd(ob1,ob2) POLY r; int s,i; objectp f1,f2,g1,g2; - struct object nn,dd; + struct object nn = OINIT; + struct object dd = OINIT; switch (Lookup[ob1.tag][ob2.tag]) { case SintegerSinteger: @@ -161,7 +164,8 @@ struct object KooSub(ob1,ob2) int s,i; objectp f1,f2,g1,g2; extern struct coeff *UniversalZero; - struct object nn,dd; + struct object nn = OINIT; + struct object dd = OINIT; switch (Lookup[ob1.tag][ob2.tag]) { case SintegerSinteger: @@ -292,7 +296,8 @@ struct object KooMult(ob1,ob2) POLY r; int i,s; objectp f1,f2,g1,g2; - struct object dd,nn; + struct object dd = OINIT; + struct object nn = OINIT; switch (Lookup[ob1.tag][ob2.tag]) { @@ -438,7 +443,7 @@ struct object KoNegate(obj) { struct object rob = NullObject; extern struct ring SmallRing; - struct object tob; + struct object tob = OINIT; switch(obj.tag) { case Sinteger: rob = obj; @@ -480,7 +485,7 @@ struct object KoInverse(obj) struct object rob = NullObject; extern struct coeff *UniversalOne; objectp onep; - struct object tob; + struct object tob = OINIT; switch(obj.tag) { case Spoly: tob.tag = SuniversalNumber; @@ -546,11 +551,11 @@ struct object KaoMult(aa,bb) POLY tmp; POLY fik; POLY gkj; - struct object rob; + struct object rob = OINIT; int r1,r2; int rsize; - struct object tob; - struct object ob1; + struct object tob = OINIT; + struct object ob1 = OINIT; extern struct ring SmallRing; m = getoaSize(aa); m2 = getoaSize(bb); @@ -610,7 +615,9 @@ struct object KaoMult(aa,bb) r1 = isMatrix(aa,m,n); r2 = isMatrix(bb,m2,n2); if (r1 == -1 || r2 == -1) { /* Object multiplication. Elements are not polynomials. */ - struct object ofik,ogkj,otmp; + struct object ofik = OINIT; + struct object ogkj = OINIT; + struct object otmp = OINIT; rob = newObjectArray(m); for (i=0; im2?m2:m1); i++) { rr=KooGreater(getoa(obj1,i),getoa(obj2,i)); @@ -856,7 +871,7 @@ struct object KooLess(obj1,obj2) case Sarray: { int i,m1,m2; - struct object rr; + struct object rr = OINIT; m1 = getoaSize(obj1); m2 = getoaSize(obj2); for (i=0; i< (m1>m2?m2:m1); i++) { rr=KooLess(getoa(obj1,i),getoa(obj2,i)); @@ -882,11 +897,12 @@ struct object KdataConversion(obj,key) { char tmps[128]; /* Assume that double is not more than 128 digits */ char intstr[100]; /* Assume that int is not more than 100 digits */ - struct object rob; + struct object rob = OINIT; extern struct ring *CurrentRingp; extern struct ring SmallRing; int flag; - struct object rob1,rob2; + struct object rob1 = OINIT; + struct object rob2 = OINIT; char *s; int i; double f; @@ -919,7 +935,12 @@ struct object KdataConversion(obj,key) return(rob); }else if (strcmp(key,"poly") == 0) { rob = KpoPOLY(ZERO); + return rob; + }else if (strcmp(key,"array") == 0) { + rob = newObjectArray(0); + return rob; }else{ + /* fprintf(stderr,"key=%s\n",key); */ warningKan("Sorry. The data conversion from null to this data type has not supported yet.\n"); } break; @@ -1015,7 +1036,7 @@ struct object KdataConversion(obj,key) if (strcmp(key,"array") == 0) { return(rob); }else if (strcmp(key,"list") == 0) { - rob = *( arrayToList(obj) ); + rob = KarrayToList(obj); return(rob); }else if (strcmp(key,"arrayOfPOLY")==0) { rob = KpoArrayOfPOLY(arrayToArrayOfPOLY(obj)); @@ -1029,6 +1050,9 @@ struct object KdataConversion(obj,key) }else if (strcmp(key,"null") == 0) { rob = NullObject; return(rob); + }else if (strcmp(key,"byteArray") == 0) { + rob = newByteArray(getoaSize(obj),obj); + return(rob); }else { { /* Automatically maps the elements. */ int n,i; @@ -1108,7 +1132,7 @@ struct object KdataConversion(obj,key) break; case Slist: if (strcmp(key,"array") == 0) { - rob = listToArray(&obj); + rob = KlistToArray(obj); return(rob); } break; @@ -1206,23 +1230,31 @@ struct object KdataConversion(obj,key) warningKan("Sorryl This type of data conversion of ringp has not supported yet.\n"); } break; + case SbyteArray: + if (strcmp(key,"array") == 0) { + rob = byteArrayToArray(obj); + return(rob); + } else { + warningKan("Sorryl This type of data conversion of ringp has not supported yet.\n"); + } + break; default: warningKan("Sorry. This type of data conversion has not supported yet.\n"); } return(NullObject); } -/* cf. macro to_int */ -struct object Kto_int(struct object ob) { +/* cf. macro to_int32 */ +struct object Kto_int32(struct object ob) { int n,i; - struct object otmp; - struct object rob; + struct object otmp = OINIT; + struct object rob = OINIT; if (ob.tag == SuniversalNumber) return KdataConversion(ob,"integer"); if (ob.tag == Sarray) { n = getoaSize(ob); rob = newObjectArray(n); for (i=0; in; a = aa->array; r = newObjectArray(size); @@ -1323,8 +1355,8 @@ struct object arrayOfPOLYToArray(aa) struct object matrixOfPOLYToArray(pmat) struct matrixOfPOLY *pmat; { - struct object r; - struct object tmp; + struct object r = OINIT; + struct object tmp = OINIT; int i,j; int m,n; POLY *mat; @@ -1347,7 +1379,7 @@ struct arrayOfPOLY *arrayToArrayOfPOLY(oa) POLY *a; int size; int i; - struct object tmp; + struct object tmp = OINIT; struct arrayOfPOLY *ap; if (oa.tag != Sarray) errorKan1("KarrayToArrayOfPOLY(): %s", @@ -1375,7 +1407,8 @@ struct matrixOfPOLY *arrayToMatrixOfPOLY(oa) int i,j; struct matrixOfPOLY *ma; - struct object tmp,tmp2; + struct object tmp = OINIT; + struct object tmp2 = OINIT; if (oa.tag != Sarray) errorKan1("KarrayToMatrixOfPOLY(): %s", "Argument is not array\n"); m = getoaSize(oa); @@ -1413,8 +1446,8 @@ int objArrayToOrderMatrix(oA,order,n,oasize) { int size; int k,j; - struct object tmpOa; - struct object obj; + struct object tmpOa = OINIT; + struct object obj = OINIT; if (oA.tag != Sarray) { warningKan("The argument should be of the form [ [...] [...] ... [...]]."); return(-1); @@ -1499,10 +1532,10 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) ob4 = Order matrix ob5 = [(keyword) value (keyword) value ....] */ -#define RP_LIMIT 500 +#define RP_LIMIT 5000 { int i; - struct object ob; + struct object ob = OINIT; int c,l,m,n; int cc,ll,mm,nn; int p; @@ -1525,7 +1558,7 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) extern char *F_mpMult; char *fmp_mult_saved; char *mpMultName = NULL; - struct object rob; + struct object rob = OINIT; struct ring *savedCurrentRingp; /* To get the ring structure. */ @@ -1597,7 +1630,7 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) } } - ob4 = Kto_int(ob4); /* order matrix */ + ob4 = Kto_int32(ob4); /* order matrix */ oasize = getoaSize(ob4); order = (int *)sGC_malloc(sizeof(int)*((2*n)*oasize+1)); if (order == (int *)NULL) errorKan1("%s\n","No memory."); @@ -1627,6 +1660,7 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) newRingp->cc = cc; newRingp->x = xvars; newRingp->D = dvars; + newRingp->Dsmall = makeDsmall(dvars,n); /* You don't need to set order and orderMatrixSize here. It was set by setOrder(). */ setFromTo(newRingp); @@ -1642,6 +1676,8 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) newRingp->degreeShiftSize = 0; newRingp->degreeShiftN = 0; newRingp->degreeShift = NULL; + newRingp->partialEcart = 0; + newRingp->partialEcartGlobalVarX = NULL; if (ob5.tag != Sarray || (getoaSize(ob5) % 2) != 0) { errorKan1("%s\n","[(keyword) value (keyword) value ....] should be given."); @@ -1698,8 +1734,8 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) errorKan1("%s\n","An array of array should be given. (degreeShift)"); } { - struct object ods; - struct object ods2; + struct object ods = OINIT; + struct object ods2 = OINIT; int dssize,k,j,nn; ods=getoa(ob5,i+1); if ((getoaSize(ods) < 1) || (getoa(ods,0).tag != Sarray)) { @@ -1722,6 +1758,36 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) } } } + } 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 = OINIT; + struct object ovv = OINIT; + 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; jpartialEcartGlobalVarX)[j] = -1; + for (j=0; jpartialEcartGlobalVarX)[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 { @@ -1776,8 +1842,8 @@ int KsetUpRing(ob1,ob2,ob3,ob4,ob5) struct object KsetVariableNames(struct object ob,struct ring *rp) { int n,i; - struct object ox; - struct object otmp; + struct object ox = OINIT; + struct object otmp = OINIT; char **xvars; char **dvars; if (ob.tag != Sarray) { @@ -1822,7 +1888,7 @@ struct object KswitchFunction(ob1,ob2) struct object ob1,ob2; { char *ans ; - struct object rob; + struct object rob = OINIT; int needWarningForAvoidTheSameRing = 0; extern int AvoidTheSameRing; if ((ob1.tag != Sdollar) || (ob2.tag != Sdollar)) { @@ -1864,14 +1930,14 @@ struct object KoReplace(of,rule) struct object of; struct object rule; { - struct object rob; + struct object rob = OINIT; POLY f; POLY lRule[N0*2]; POLY rRule[N0*2]; POLY r; int i; int n; - struct object trule; + struct object trule = OINIT; if (rule.tag != Sarray) { @@ -1927,7 +1993,7 @@ struct object Kparts(f,v) { POLY ff; POLY vv; - struct object obj; + struct object obj = OINIT; struct matrixOfPOLY *co; /* check the data type */ if (f.tag != Spoly || v.tag != Spoly) @@ -1944,7 +2010,7 @@ struct object Kparts2(f,v) { POLY ff; POLY vv; - struct object obj; + struct object obj = OINIT; struct matrixOfPOLY *co; /* check the data type */ if (f.tag != Spoly || v.tag != Spoly) @@ -1992,7 +2058,8 @@ struct object Ksp(ob1,ob2) struct object ob1,ob2; { struct spValue sv; - struct object rob,cob; + struct object rob = OINIT; + struct object cob = OINIT; POLY f; if (ob1.tag != Spoly || ob2.tag != Spoly) errorKan1("%s\n","Ksp(): The arguments must be polynomials."); @@ -2022,7 +2089,7 @@ struct object Keval(obj) { char *key; int size; - struct object rob; + struct object rob = OINIT; rob = NullObject; if (obj.tag != Sarray) @@ -2067,8 +2134,8 @@ char *KremoveSpace(str) struct object KtoRecords(ob) struct object ob; { - struct object obj; - struct object tmp; + struct object obj = OINIT; + struct object tmp = OINIT; int i; int size; char **argv; @@ -2164,7 +2231,7 @@ int KtoArgvbyCurryBrace(str,argv,limit) } struct object KstringToArgv(struct object ob) { - struct object rob; + struct object rob = OINIT; char *s; int n,wc,i,inblank; char **argv; @@ -2204,6 +2271,56 @@ struct object KstringToArgv(struct object ob) { return(rob); } +struct object KstringToArgv2(struct object ob,struct object oseparator) { + struct object rob = OINIT; + char *s; + int n,wc,i,inblank; + char **argv; + int separator; + if (ob.tag != Sdollar) + errorKan1("%s\n","KstringToArgv2(): the argument must be a string."); + if (oseparator.tag == Sinteger) { + separator = KopInteger(oseparator); + }else if (oseparator.tag == Sdollar) { + s = KopString(oseparator); + separator=s[0]; + }else { + errorKan1("%s\n","KstringToArgv2(ob,separator):the argument must be strings."); + } + 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 0) { + ba = (unsigned char *) sGC_malloc(size); + if (ba == NULL) errorKan1("%s\n","No more memory."); + } + rob.tag = SbyteArray; rob.lc.bytes = ba; rob.rc.ival = size; + if (obj.tag == SbyteArray) { + n = getByteArraySize(obj); + ba2 = KopByteArray(obj); + for (i=0; i<(n 0) { + ba = (unsigned char *) sGC_malloc(size); + if (ba == NULL) errorKan1("%s\n","No more memory."); + } + rob.tag = SbyteArray; rob.lc.bytes = ba; rob.rc.ival = size; + for (i=0; i