=================================================================== RCS file: /home/cvs/OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c,v retrieving revision 1.1.1.1 retrieving revision 1.8 diff -u -p -r1.1.1.1 -r1.8 --- OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c 1999/10/08 02:12:02 1.1.1.1 +++ OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c 2005/06/16 05:07:23 1.8 @@ -1,5 +1,6 @@ +/* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c,v 1.7 2003/11/21 02:10:37 takayama Exp $ */ /* Kclass/indeterminate.c */ -/* This file handles indeterminate, tree, recursivePolynomial, +/* This file handles indeterminate, recursivePolynomial, polynomialInOneVariable */ #include @@ -13,7 +14,7 @@ /* Data conversion function : see KclassDataConversion*/ struct object KpoIndeterminate(struct object ob) { - struct object rob; + struct object rob = OINIT; struct object *newobp; rob.tag = Sclass; rob.lc.ival = CLASSNAME_indeterminate; @@ -29,7 +30,7 @@ struct object KpoIndeterminate(struct object ob) { /* The second constructor. */ struct object KnewIndeterminate(char *s) { - struct object ob; + struct object ob = OINIT; ob = KpoString(s); /* We do not clone s */ return(KpoIndeterminate(ob)); @@ -42,112 +43,11 @@ void fprintIndeterminate(FILE *fp,struct object op) printObject(KopIndeterminate(op),0,fp); } - +/* Functions for trees are moved to tree.c */ /* ---------------------------------------------------- */ -/* Data conversion function : see KclassDataConversion*/ -struct object KpoTree(struct object ob) { - struct object rob; - struct object ob1,ob2,ob3; - struct object *newobp; - rob.tag = Sclass; - rob.lc.ival = CLASSNAME_tree; - newobp = (struct object *) sGC_malloc(sizeof(struct object)); - if (newobp == NULL) errorKan1("%s\n","Kclass/indeterminate.c, no more memory."); - if (ob.tag != Sarray) { - errorKan1("%s\n","Kclass/indeterminate.c, only properly formatted list object can be transformed into tree. [name, cdname, arglist]."); - } - if (getoaSize(ob) < 3) { - errorKan1("%s\n","Kclass/indeterminate.c, the length must 3 or more than 3. [name, cdname, arglist]."); - } - ob1 = getoa(ob,0); ob2 = getoa(ob,1); ob3 = getoa(ob,2); - if (ob1.tag != Sdollar || ob2.tag != Sdollar || ob3.tag != Sarray) { - errorKan1("%s\n","Kclass/indeterminate.c, [string name, string cdname, list arglist]."); - } - *newobp = ob; - rob.rc.voidp = newobp; - return(rob); -} - -/* Printing function : see fprintClass */ -void fprintTree(FILE *fp,struct object op) -{ - printObject(KopTree(op),0,fp); -} - -int isTreeAdd(struct object ob) { - struct object name; - if (ob.tag != Sclass) { - return(0); - } - if (ectag(ob) != CLASSNAME_tree) { - return(0); - } - ob = KopTree(ob); - if (ob.tag != Sarray) { - errorKan1("%s\n","CLASSNAME_tree is broken. Should be array."); - } - name = getoa(ob,0); - if (name.tag != Sdollar) { - errorKan1("%s\n","CLASSNAME_tree is broken. Should be string."); - } - if (strcmp(KopString(name),"add") == 0) { - return(1); - }else{ - return(0); - } -} - -struct object addTree(struct object ob1, struct object ob2) -{ - struct object rob,aob; - struct object ob3,ob4; - int i; - if (isTreeAdd(ob1) && !isTreeAdd(ob2)) { - ob1 = KopTree(ob1); - ob3 = getoa(ob1,2); - aob = newObjectArray(getoaSize(ob3)+1); - for (i=0; i 1) { - fprintf(fp,"^%d ",k); + fprintf(fp,"^%d ",k); }else if (k == 1) { }else{ - fprintf(fp,"^(%d) ",k); + fprintf(fp,"^(%d) ",k); } fprintf(fp," * "); } @@ -203,11 +109,11 @@ static void printBodyOfRecursivePolynomial(struct obj void fprintRecursivePolynomial(FILE *fp,struct object op) { /* old code - printObject(KopRecursivePolynomial(op),0,fp); return; + printObject(KopRecursivePolynomial(op),0,fp); return; */ - struct object ob; - struct object vlist; - struct object body; + struct object ob = OINIT; + struct object vlist = OINIT; + struct object body = OINIT; ob = KopRecursivePolynomial(op); if (ob.tag != Sarray) { printObject(ob,0,fp); return; @@ -224,7 +130,7 @@ void fprintRecursivePolynomial(FILE *fp,struct object /*------------------------------------------*/ struct object KpoPolynomialInOneVariable(struct object ob) { - struct object rob; + struct object rob = OINIT; struct object *newobp; rob.tag = Sclass; rob.lc.ival = CLASSNAME_polynomialInOneVariable; @@ -248,8 +154,12 @@ struct object polyToRecursivePoly(struct object p) { int vx[N0], vd[N0]; int i,j,k,n,count; POLY f; - struct object vlist,vlist2; - struct object ob1,ob2,ob3,ob4; + struct object vlist = OINIT; + struct object vlist2 = OINIT; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object ob3 = OINIT; + struct object ob4 = OINIT; int vn; if (p.tag != Spoly) return(rob); @@ -297,11 +207,11 @@ struct object polyToRecursivePoly(struct object p) { putoa(rob,0,vlist2); putoa(rob,1,ob1); /* format of rob [ list of variables, poly or universalNumber or yyy to express - a recursive polynomial. ] - format of yyy = CLASSNAME_polynomialInOneVariable + a recursive polynomial. ] + format of yyy = CLASSNAME_polynomialInOneVariable [Sinteger, Sinteger, coeff obj, Sinteger, coeff obj, .....] - name of var, exp, coeff, exp, coeff - This format is checked by isRecursivePolynomial2(). + name of var, exp, coeff, exp, coeff + This format is checked by isRecursivePolynomial2(). */ rob = KpoRecursivePolynomial(rob); if (isRecursivePolynomial2(rob)) { @@ -321,9 +231,9 @@ struct object polyToRecursivePoly2(struct object p,str struct object rob = NullObject; POLY f; POLY vv; - struct object v; - struct object c; - struct object e; + struct object v = OINIT; + struct object c = OINIT; + struct object e = OINIT; int i; @@ -356,7 +266,7 @@ struct object polyToRecursivePoly2(struct object p,str static int isRecursivePolynomial2a(struct object ob2, int n) { char *s = "Format error (isRecursivePolynomial2a) : "; - struct object tmp; + struct object tmp = OINIT; int i; if (ectag(ob2) == CLASSNAME_polynomialInOneVariable) { ob2 = KopPolynomialInOneVariable(ob2); @@ -398,9 +308,9 @@ static int isRecursivePolynomial2a(struct object ob2, if (ectag(tmp) == CLASSNAME_polynomialInOneVariable) { if (isRecursivePolynomial2a(tmp,n)) { }else{ - fprintf(stderr,"isRecursivePolynomial2a: entry is not a polynomial in one variable.\n"); - printObject(tmp,0,stderr); fprintf(stderr,"\n"); - return(0); + fprintf(stderr,"isRecursivePolynomial2a: entry is not a polynomial in one variable.\n"); + printObject(tmp,0,stderr); fprintf(stderr,"\n"); + return(0); } } } @@ -410,7 +320,9 @@ static int isRecursivePolynomial2a(struct object ob2, int isRecursivePolynomial2(struct object ob) { /* This checks only the top level */ char *s = "Format error (isRecursivePolynomial2) : "; - struct object ob1, ob2,tmp; + struct object ob1 = OINIT; + struct object ob2 = OINIT; + struct object tmp = OINIT; int i; int n; if (ob.tag != Sclass) return(0); @@ -434,8 +346,10 @@ int isRecursivePolynomial2(struct object ob) { n = getoaSize(ob1); for (i=0; i