[BACK]Return to indeterminate.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / Kan / Kclass

Diff for /OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c between version 1.4 and 1.6

version 1.4, 2001/04/12 06:48:27 version 1.6, 2001/09/01 01:37:48
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c,v 1.3 2000/02/28 14:10:30 takayama Exp $ */  /* $OpenXM: OpenXM/src/kan96xx/Kan/Kclass/indeterminate.c,v 1.5 2001/05/04 01:06:29 takayama Exp $ */
 /* Kclass/indeterminate.c    */  /* Kclass/indeterminate.c    */
 /* This file handles   indeterminate, tree, recursivePolynomial,  /* This file handles   indeterminate, tree, recursivePolynomial,
     polynomialInOneVariable      polynomialInOneVariable
Line 61  struct object KpoTree(struct object ob) {
Line 61  struct object KpoTree(struct object ob) {
     errorKan1("%s\n","Kclass/indeterminate.c, the length must 3 or more than 3. [name, cdname, arglist].");      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);    ob1 = getoa(ob,0); ob2 = getoa(ob,1); ob3 = getoa(ob,2);
   if (ob1.tag != Sdollar || ob2.tag != Sdollar || ob3.tag != Sarray) {    if (ob1.tag != Sdollar || ob2.tag != Sarray || ob3.tag != Sarray) {
     errorKan1("%s\n","Kclass/indeterminate.c, [string name, string cdname, list arglist].");      errorKan1("%s\n","Kclass/indeterminate.c, [string name, list attributes, list arglist].");
   }    }
   *newobp = ob;    *newobp = ob;
   rob.rc.voidp = newobp;    rob.rc.voidp = newobp;
Line 163  struct object KpoRecursivePolynomial(struct object ob)
Line 163  struct object KpoRecursivePolynomial(struct object ob)
 }  }
   
 static void  printBodyOfRecursivePolynomial(struct object body,  static void  printBodyOfRecursivePolynomial(struct object body,
                                             struct object vlist, FILE *fp)                                              struct object vlist, FILE *fp)
 {  {
   int i,j;    int i,j;
   int k;    int k;
Line 182  static void  printBodyOfRecursivePolynomial(struct obj
Line 182  static void  printBodyOfRecursivePolynomial(struct obj
   for (j=1; j<getoaSize(body); j = j+2) {    for (j=1; j<getoaSize(body); j = j+2) {
     k = KopInteger(getoa(body,j));      k = KopInteger(getoa(body,j));
     if (k != 0) {      if (k != 0) {
           if (getoa(vlist,i).tag == Sdollar) {        if (getoa(vlist,i).tag == Sdollar) {
                 fprintf(fp,"%s",KopString(getoa(vlist,i)));          fprintf(fp,"%s",KopString(getoa(vlist,i)));
           }else if (ectag(getoa(vlist,i)) == CLASSNAME_tree) {        }else if (ectag(getoa(vlist,i)) == CLASSNAME_tree) {
                 fprintClass(fp,getoa(vlist,i));          fprintClass(fp,getoa(vlist,i));
           }else{        }else{
                 errorKan1("%s\n","printBodyOfRecursivePolynomial: format error.");          errorKan1("%s\n","printBodyOfRecursivePolynomial: format error.");
           }        }
       if (k > 1) {        if (k > 1) {
         fprintf(fp,"^%d ",k);          fprintf(fp,"^%d ",k);
       }else if (k == 1) {        }else if (k == 1) {
       }else{        }else{
         fprintf(fp,"^(%d) ",k);          fprintf(fp,"^(%d) ",k);
       }        }
       fprintf(fp," * ");        fprintf(fp," * ");
     }      }
Line 210  static void  printBodyOfRecursivePolynomial(struct obj
Line 210  static void  printBodyOfRecursivePolynomial(struct obj
 void fprintRecursivePolynomial(FILE *fp,struct object op)  void fprintRecursivePolynomial(FILE *fp,struct object op)
 {  {
   /* old  code    /* old  code
   printObject(KopRecursivePolynomial(op),0,fp); return;       printObject(KopRecursivePolynomial(op),0,fp); return;
   */    */
   struct object ob;    struct object ob;
   struct object vlist;    struct object vlist;
Line 304  struct object polyToRecursivePoly(struct object p) {
Line 304  struct object polyToRecursivePoly(struct object p) {
   putoa(rob,0,vlist2); putoa(rob,1,ob1);    putoa(rob,0,vlist2); putoa(rob,1,ob1);
   /* format of rob    /* format of rob
      [ list of variables, poly or universalNumber or yyy to express       [ list of variables, poly or universalNumber or yyy to express
                           a recursive polynomial. ]       a recursive polynomial. ]
      format of yyy = CLASSNAME_polynomialInOneVariable       format of yyy = CLASSNAME_polynomialInOneVariable
      [Sinteger,    Sinteger, coeff obj, Sinteger, coeff obj, .....]       [Sinteger,    Sinteger, coeff obj, Sinteger, coeff obj, .....]
       name of var, exp,      coeff,     exp,      coeff       name of var, exp,      coeff,     exp,      coeff
     This format is checked by isRecursivePolynomial2().       This format is checked by isRecursivePolynomial2().
   */    */
   rob = KpoRecursivePolynomial(rob);    rob = KpoRecursivePolynomial(rob);
   if (isRecursivePolynomial2(rob)) {    if (isRecursivePolynomial2(rob)) {
Line 405  static int isRecursivePolynomial2a(struct object ob2, 
Line 405  static int isRecursivePolynomial2a(struct object ob2, 
     if (ectag(tmp) == CLASSNAME_polynomialInOneVariable) {      if (ectag(tmp) == CLASSNAME_polynomialInOneVariable) {
       if (isRecursivePolynomial2a(tmp,n)) {        if (isRecursivePolynomial2a(tmp,n)) {
       }else{        }else{
         fprintf(stderr,"isRecursivePolynomial2a: entry is not a polynomial in one variable.\n");          fprintf(stderr,"isRecursivePolynomial2a: entry is not a polynomial in one variable.\n");
         printObject(tmp,0,stderr); fprintf(stderr,"\n");          printObject(tmp,0,stderr); fprintf(stderr,"\n");
         return(0);          return(0);
       }        }
     }      }
   }    }
Line 442  int isRecursivePolynomial2(struct object ob) {
Line 442  int isRecursivePolynomial2(struct object ob) {
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
     tmp = getoa(ob1,i);      tmp = getoa(ob1,i);
     if (tmp.tag == Sdollar) {      if (tmp.tag == Sdollar) {
         }else if (ectag(tmp) == CLASSNAME_tree) {      }else if (ectag(tmp) == CLASSNAME_tree) {
         }else{      }else{
       fprintf(stderr,"%s [list vlist, body]. Element of the vlist must be a string or a tree.\n",s); printObject(ob,1,stderr);        fprintf(stderr,"%s [list vlist, body]. Element of the vlist must be a string or a tree.\n",s); printObject(ob,1,stderr);
       return(0);        return(0);
     }      }
Line 488  struct object recursivePolyToPoly(struct object rp) {
Line 488  struct object recursivePolyToPoly(struct object rp) {
   
 struct object KrvtReplace(struct object rp_o,struct object v_o, struct object t_o) {  struct object KrvtReplace(struct object rp_o,struct object v_o, struct object t_o) {
   /* rp_o : recursive polynomial.    /* rp_o : recursive polynomial.
          v_o  : variable name (indeterminate).       v_o  : variable name (indeterminate).
      t_o  : tree.       t_o  : tree.
   */    */
   struct object rp, vlist, newvlist, newrp;    struct object rp, vlist, newvlist, newrp;
   int i,m;    int i,m;
   /* Check the data types. */    /* Check the data types. */
   if (ectag(rp_o) != CLASSNAME_recursivePolynomial) {    if (ectag(rp_o) != CLASSNAME_recursivePolynomial) {
         errorKan1("%s\n","KrvtReplace() type mismatch in the first argument.");      errorKan1("%s\n","KrvtReplace() type mismatch in the first argument.");
   }    }
   if (ectag(v_o) != CLASSNAME_indeterminate) {    if (ectag(v_o) != CLASSNAME_indeterminate) {
         errorKan1("%s\n","KrvtReplace() type mismatch in the second argument.");      errorKan1("%s\n","KrvtReplace() type mismatch in the second argument.");
   }    }
   if (ectag(t_o) != CLASSNAME_tree) {    if (ectag(t_o) != CLASSNAME_tree) {
         errorKan1("%s\n","KrvtReplace() type mismatch in the third argument.");      errorKan1("%s\n","KrvtReplace() type mismatch in the third argument.");
   }    }
   
   rp = KopRecursivePolynomial(rp_o);    rp = KopRecursivePolynomial(rp_o);
Line 509  struct object KrvtReplace(struct object rp_o,struct ob
Line 509  struct object KrvtReplace(struct object rp_o,struct ob
   m = getoaSize(vlist);    m = getoaSize(vlist);
   newvlist = newObjectArray(m);    newvlist = newObjectArray(m);
   for (i=0; i<m; i++) {    for (i=0; i<m; i++) {
         if (KooEqualQ(getoa(vlist,i),KopIndeterminate(v_o))) {      if (KooEqualQ(getoa(vlist,i),KopIndeterminate(v_o))) {
           /* should be KooEqualQ(getoa(vlist,i),v_o). It's not a bug.        /* should be KooEqualQ(getoa(vlist,i),v_o). It's not a bug.
              Internal expression of vlist is an array of string           Internal expression of vlist is an array of string
                  (not indetermiante). */           (not indetermiante). */
           putoa(newvlist,i,t_o);        putoa(newvlist,i,t_o);
         }else{      }else{
           putoa(newvlist,i,getoa(vlist,i));        putoa(newvlist,i,getoa(vlist,i));
         }      }
   }    }
   newrp = newObjectArray(getoaSize(rp));    newrp = newObjectArray(getoaSize(rp));
   m = getoaSize(rp);    m = getoaSize(rp);
   putoa(newrp,0,newvlist);    putoa(newrp,0,newvlist);
   for (i=1; i<m; i++) {    for (i=1; i<m; i++) {
         putoa(newrp,i,getoa(rp,i));      putoa(newrp,i,getoa(rp,i));
   }    }
   return(KpoRecursivePolynomial(newrp));    return(KpoRecursivePolynomial(newrp));
 }  }
Line 558  struct object KreplaceRecursivePolynomial(struct objec
Line 558  struct object KreplaceRecursivePolynomial(struct objec
     if (ectag(getoa(trule,0)) != CLASSNAME_indeterminate) {      if (ectag(getoa(trule,0)) != CLASSNAME_indeterminate) {
       errorKan1("%s\n"," KreplaceRecursivePolynomial(): The second argument must be of the form [[a b] [c d] ....] where a,b,c,d,... are polynomials.");        errorKan1("%s\n"," KreplaceRecursivePolynomial(): The second argument must be of the form [[a b] [c d] ....] where a,b,c,d,... are polynomials.");
     }      }
         /* Do not check the second argument. */      /* Do not check the second argument. */
         /*      /*
     if (getoa(trule,1).tag != Spoly) {        if (getoa(trule,1).tag != Spoly) {
       errorKan1("%s\n"," KreplaceRecursivePolynomial(): The second argument must be of the form [[a b] [c d] ....] where a,b,c,d,... are polynomials.");        errorKan1("%s\n"," KreplaceRecursivePolynomial(): The second argument must be of the form [[a b] [c d] ....] where a,b,c,d,... are polynomials.");
     }        }
         */      */
   
   }    }
   
   rob = f;    rob = f;
   for (i=0; i<n; i++) {    for (i=0; i<n; i++) {
     trule = getoa(rule,i);      trule = getoa(rule,i);
         rob = KrvtReplace(rob,getoa(trule,0),getoa(trule,1));      rob = KrvtReplace(rob,getoa(trule,0),getoa(trule,1));
   }    }
   return(rob);    return(rob);
 }  }

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>