[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.22 and 1.26

version 1.22, 2004/05/13 04:38:28 version 1.26, 2004/08/23 08:33:55
Line 1 
Line 1 
 /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.21 2004/02/28 13:39:42 takayama Exp $  */  /* $OpenXM: OpenXM/src/kan96xx/Kan/kanExport0.c,v 1.25 2004/08/22 12:52:34 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 1001  struct object KdataConversion(obj,key)
Line 1030  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:
Line 1094  struct object KdataConversion(obj,key)
Line 1131  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 1232  struct object KpoUniversalNumber(u)
Line 1272  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 2428  struct object KgbExtension(struct object obj)
Line 2478  struct object KgbExtension(struct object obj)
     obj1 = getoa(obj,1);      obj1 = getoa(obj,1);
     obj2 = getoa(obj,2);      obj2 = getoa(obj,2);
     rob  = KordWsAll(obj1,obj2);      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 2463  struct object KmpzExtension(struct object obj)
Line 2525  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 2479  struct object KmpzExtension(struct object obj)
Line 2547  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 2537  struct object KmpzExtension(struct object obj)
Line 2611  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 2558  struct object KmpzExtension(struct object obj)
Line 2635  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 2589  struct object KmpzExtension(struct object obj)
Line 2672  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 2607  struct object KmpzExtension(struct object obj)
Line 2699  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.");
   }    }

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.26

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