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

Diff for /OpenXM/src/kan96xx/Kan/kanExport0.c between version 1.24 and 1.31

version 1.24, 2004/08/22 02:00:24 version 1.31, 2004/09/09 03:14:46
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.23 2004/07/30 11:21:55 takayama Exp $  */  /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.30 2004/09/04 11:25:58 takayama Exp $  */
 #include <stdio.h>  #include <stdio.h>
 #include "datatype.h"  #include "datatype.h"
 #include "stackm.h"  #include "stackm.h"
Line 797  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 838  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 914  struct object KdataConversion(obj,key)
Line 944  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 1085  struct object KdataConversion(obj,key)
Line 1114  struct object KdataConversion(obj,key)
     break;      break;
   case SuniversalNumber:    case SuniversalNumber:
     if ((strcmp(key,"universalNumber")==0) || (strcmp(key,"numerator")==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 1102  struct object KdataConversion(obj,key)
Line 1132  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 1178  struct object KdataConversion(obj,key)
Line 1211  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 1240  struct object KpoUniversalNumber(u)
Line 1290  struct object KpoUniversalNumber(u)
   obj.lc.universalNumber = u;    obj.lc.universalNumber = u;
   return(obj);    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 1536  int KsetUpRing(ob1,ob2,ob3,ob4,ob5)
Line 1596  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 2885  struct object KdefaultPolyRing(struct object ob) {
Line 2946  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) {
       errorKan1("%s\n","Krest: it has not yet been implemented.");
     }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{
       errorKan1("%s\n","Kjoin: arguments must be arrays.");
     }
   }
   
   
   
Line 2911  errorKan1(str,message)
Line 3007  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) {

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.31

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