[BACK]Return to itvnum.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / builtin

Diff for /OpenXM_contrib2/asir2018/builtin/itvnum.c between version 1.2 and 1.3

version 1.2, 2018/09/28 08:20:27 version 1.3, 2019/06/04 07:11:23
Line 1 
Line 1 
 /*  /*
  * $OpenXM: OpenXM_contrib2/asir2018/builtin/itvnum.c,v 1.1 2018/09/19 05:45:06 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2018/builtin/itvnum.c,v 1.2 2018/09/28 08:20:27 noro Exp $
  */   */
   
 #include "ca.h"  #include "ca.h"
Line 9 
Line 9 
 #include "../plot/ifplot.h"  #include "../plot/ifplot.h"
 #endif  #endif
   
 #if defined(INTERVAL)  // in engine/bf.c
   Num tobf(Num,int);
   
   #if defined(INTERVAL)
 static void Pitv(NODE, Obj *);  static void Pitv(NODE, Obj *);
 static void Pitvd(NODE, Obj *);  static void Pitvd(NODE, Obj *);
 static void Pitvbf(NODE, Obj *);  static void Pitvbf(NODE, Obj *);
Line 24  static void Pcup(NODE, Obj *);
Line 26  static void Pcup(NODE, Obj *);
 static void Pcap(NODE, Obj *);  static void Pcap(NODE, Obj *);
 static void Pwidth(NODE, Obj *);  static void Pwidth(NODE, Obj *);
 static void Pdistance(NODE, Obj *);  static void Pdistance(NODE, Obj *);
 static void Pitvversion(Q *);  static void Pitvversion(NODE, Q *);
 void miditvp(Itv,Num *);  static void PzeroRewriteMode(NODE, Obj *);
 void absitvp(Itv,Num *);  static void PzeroRewriteCountClear(NODE, Obj *);
 int initvd(Num,IntervalDouble);  static void PzeroRewriteCount(NODE, Obj *);
 int initvp(Num,Itv);  //void miditvp(Itv,Num *);
 int itvinitvp(Itv,Itv);  //void absitvp(Itv,Num *);
   //int initvd(Num,IntervalDouble);
   //int initvp(Num,Itv);
   //int itvinitvp(Itv,Itv);
 #endif  #endif
 static void Pprintmode(NODE, Obj *);  static void Pprintmode(NODE, Obj *);
   
Line 61  struct ftab interval_tab[] = {
Line 66  struct ftab interval_tab[] = {
   {"width",Pwidth,1},    {"width",Pwidth,1},
   {"diam",Pwidth,1},    {"diam",Pwidth,1},
   {"distance",Pdistance,2},    {"distance",Pdistance,2},
   {"iversion",Pitvversion,0},    {"iversion",Pitvversion,-1},
     {"intvalversion",Pitvversion,-1},
     {"zerorewritemode",PzeroRewriteMode,-1},
     {"zeroRewriteMode",PzeroRewriteMode,-1},
     {"zeroRewriteCountClear",PzeroRewriteCountClear,-1},
     {"zeroRewriteCount",PzeroRewriteCount,-1},
 /* plot time check */  /* plot time check */
   {"ifcheck",Pifcheck,-7},    {"ifcheck",Pifcheck,-7},
 #endif  #endif
   {0,0,0},    {0,0,0},
 };  };
   
   extern int mpfr_roundmode;
   
 #if defined(INTERVAL)  #if defined(INTERVAL)
   
 /* plot time check */  /* plot time check */
Line 93  Pifcheck(NODE arg, Obj *rp)
Line 105  Pifcheck(NODE arg, Obj *rp)
   int width, height, ix, iy;    int width, height, ix, iy;
   int id;    int id;
   
   STOZ(-2,m2); STOZ(2,p2);    STOQ(-2,m2); STOQ(2,p2);
   STOZ(1,one);    STOQ(1,one);
   MKNODE(n,p2,0); MKNODE(defrange,m2,n);    MKNODE(n,p2,0); MKNODE(defrange,m2,n);
   poly = 0; vl = 0; geom = 0; ri = 0;    poly = 0; vl = 0; geom = 0; ri = 0;
   v[0] = v[1] = 0;    v[0] = v[1] = 0;
Line 164  Pifcheck(NODE arg, Obj *rp)
Line 176  Pifcheck(NODE arg, Obj *rp)
     can->width = 300;      can->width = 300;
     can->height = 300;      can->height = 300;
   } else {    } else {
     can->width = ZTOS((Q)BDY(BDY(geom)));      can->width = QTOS((Q)BDY(BDY(geom)));
     can->height = ZTOS((Q)BDY(NEXT(BDY(geom))));      can->height = QTOS((Q)BDY(NEXT(BDY(geom))));
     width = can->width;      width = can->width;
     height = can->height;      height = can->height;
   }    }
Line 235  void ccalc(double **tab,struct canvas *can,int nox)
Line 247  void ccalc(double **tab,struct canvas *can,int nox)
 /* end plot time check */  /* end plot time check */
   
 static void  static void
 Pitvversion(Q *rp)  Pitvversion(NODE arg, Q *rp)
 {  {
   STOZ(ASIR_VERSION, *rp);    STOQ(INT_ASIR_VERSION, *rp);
 }  }
   
 extern int  bigfloat;  extern int  bigfloat;
Line 288  static void
Line 300  static void
 Pitvbf(NODE arg, Obj *rp)  Pitvbf(NODE arg, Obj *rp)
 {  {
   Num  a, i, s;    Num  a, i, s;
   Itv  c;    IntervalBigFloat  c;
   BF  ii,ss;    Num  ii,ss;
     Real di, ds;
   double  inf, sup;    double  inf, sup;
     int current_roundmode;
   
   asir_assert(ARG0(arg),O_N,"intvalbf");    asir_assert(ARG0(arg),O_N,"intvalbf");
   a = (Num)ARG0(arg);    a = (Num)ARG0(arg);
   if ( argc(arg) > 1 ) {    if ( argc(arg) > 1 ) {
     asir_assert(ARG1(arg),O_N,"intvalbf");      asir_assert(ARG1(arg),O_N,"intvalbf");
   
     i = (Num)ARG0(arg);      i = (Num)ARG0(arg);
     s = (Num)ARG1(arg);      s = (Num)ARG1(arg);
     ToBf(i, &ii);      current_roundmode = mpfr_roundmode;
     ToBf(s, &ss);      mpfr_roundmode = MPFR_RNDD;
     istoitv((Num)ii,(Num)ss,&c);      ii = tobf(i, DEFAULTPREC);
       mpfr_roundmode = MPFR_RNDU;
       ss = tobf(s, DEFAULTPREC);
       istoitv(ii,ss,(Itv *)&c);
   //    MKIntervalBigFloat((BF)ii,(BF)ss,c);
   //    ToBf(s, &ss);
       mpfr_roundmode = current_roundmode;
   } else {    } else {
     if ( ! a ) {      if ( ! a ) {
       *rp = 0;        *rp = 0;
Line 308  Pitvbf(NODE arg, Obj *rp)
Line 329  Pitvbf(NODE arg, Obj *rp)
     }      }
     else if ( NID(a) == N_IP ) {      else if ( NID(a) == N_IP ) {
       itvtois((Itv)a, &i, &s);        itvtois((Itv)a, &i, &s);
       ToBf(i, &ii);        current_roundmode = mpfr_roundmode;
       ToBf(s, &ss);        mpfr_roundmode = MPFR_RNDD;
       istoitv((Num)ii,(Num)ss,&c);        ii = tobf(i, DEFAULTPREC);
         mpfr_roundmode = MPFR_RNDU;
         ss = tobf(s, DEFAULTPREC);
         istoitv(ii,ss,(Itv *)&c);
   //      MKIntervalBigFloat((BF)ii,(BF)ss,c);
         mpfr_roundmode = current_roundmode;
     }      }
     else if ( NID(a) == N_IntervalBigFloat) {      else if ( NID(a) == N_IntervalBigFloat) {
       *rp = (Obj)a;        *rp = (Obj)a;
Line 319  Pitvbf(NODE arg, Obj *rp)
Line 345  Pitvbf(NODE arg, Obj *rp)
     else if ( NID(a) == N_IntervalDouble ) {      else if ( NID(a) == N_IntervalDouble ) {
       inf = INF((IntervalDouble)a);        inf = INF((IntervalDouble)a);
       sup = SUP((IntervalDouble)a);        sup = SUP((IntervalDouble)a);
       double2bf(inf, (BF *)&i);        current_roundmode = mpfr_roundmode;
       double2bf(sup, (BF *)&s);        //double2bf(inf, (BF *)&i);
       istoitv(i,s,&c);        //double2bf(sup, (BF *)&s);
         mpfr_roundmode = MPFR_RNDD;
         MKReal(inf,di);
         ii = tobf((Num)di, DEFAULTPREC);
         mpfr_roundmode = MPFR_RNDU;
         MKReal(sup,ds);
         ss = tobf((Num)ds, DEFAULTPREC);
         istoitv(ii,ss,(Itv *)&c);
   //      MKIntervalBigFloat((BF)ii,(BF)ss,c);
         mpfr_roundmode = current_roundmode;
     }      }
     else {      else {
       ToBf(a, (BF *)&i);        current_roundmode = mpfr_roundmode;
       istoitv(i,i,&c);        mpfr_roundmode = MPFR_RNDD;
         ii = tobf(a, DEFAULTPREC);
         mpfr_roundmode = MPFR_RNDU;
         ss = tobf(a, DEFAULTPREC);
         //ToBf(a, (BF *)&i);
         istoitv(ii,ss,(Itv *)&c);
   //      MKIntervalBigFloat((BF)ii,(BF)ss,c);
         mpfr_roundmode = current_roundmode;
     }      }
   }    }
   if ( c && OID( c ) == O_N && NID( c ) == N_IntervalBigFloat )  //  if ( c && OID( c ) == O_N && NID( c ) == N_IntervalBigFloat )
     addulp((IntervalBigFloat)c, (IntervalBigFloat *)rp);  //    addulp((IntervalBigFloat)c, (IntervalBigFloat *)rp);
   else *rp = (Obj)c;  //  else *rp = (Obj)c;
     *rp = (Obj)c;
 }  }
   
 static void  static void
Line 591  Obj *rp;
Line 634  Obj *rp;
   } else {    } else {
     s = ! compnum(0,(Num)ARG0(arg),(Num)ARG1(arg));      s = ! compnum(0,(Num)ARG0(arg),(Num)ARG1(arg));
   }    }
   STOZ(s,q);    STOQ(s,q);
   *rp = (Obj)q;    *rp = (Obj)q;
 }  }
   
Line 609  Obj *rp;
Line 652  Obj *rp;
   else *rp = (Obj)ONE;    else *rp = (Obj)ONE;
 }  }
   
   static void
   PzeroRewriteMode(NODE arg, Obj *rp)
   {
     Q  a, r;
   
     STOQ(zerorewrite,r);
     *rp = (Obj)r;
   
     if (arg) {
       a = (Q)ARG0(arg);
       if(!a) {
         zerorewrite = 0;
       } else if ( (NUM(a)&&INT(a)) ){
         zerorewrite = 1;
       }
     }
   }
   
   static void
   PzeroRewriteCountClear(NODE arg, Obj *rp)
   {
     Q  a, r;
   
     STOQ(zerorewriteCount,r);
     *rp = (Obj)r;
   
     if (arg) {
       a = (Q)ARG0(arg);
       if(a &&(NUM(a)&&INT(a))){
         zerorewriteCount = 0;
       }
     }
   }
   
   static void
   PzeroRewriteCount(NODE arg, Obj *rp)
   {
     Q  r;
   
     STOQ(zerorewriteCount,r);
     *rp = (Obj)r;
   }
   
   
 #endif  #endif
 extern int  printmode;  extern int  printmode;
   
Line 637  static void
Line 724  static void
 Pprintmode(NODE arg, Obj *rp)  Pprintmode(NODE arg, Obj *rp)
 {  {
   int  l;    int  l;
   Z  a, r;    Q  a, r;
   
   a = (Z)ARG0(arg);    a = (Q)ARG0(arg);
   if(!a||(NUM(a)&&INT(a))){    if(!a||(NUM(a)&&INT(a))){
     l=ZTOS(a);      l=QTOS(a);
     if ( l < 0 ) l = 0;      if ( l < 0 ) l = 0;
 #if defined(INTERVAL)  #if defined(INTERVAL)
     else if ( l > MID_PRINTF_E ) l = 0;      else if ( l > MID_PRINTF_E ) l = 0;
 #else  #else
     else if ( l > PRINTF_E ) l = 0;      else if ( l > PRINTF_E ) l = 0;
 #endif  #endif
     STOZ(printmode,r);      STOQ(printmode,r);
     *rp = (Obj)r;      *rp = (Obj)r;
     printmode = l;      printmode = l;
     pprintmode();      pprintmode();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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