[BACK]Return to p-itv.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2018 / engine

Diff for /OpenXM_contrib2/asir2018/engine/p-itv.c between version 1.2 and 1.3

version 1.2, 2018/09/28 08:20:28 version 1.3, 2019/06/04 07:11:23
Line 1 
Line 1 
 /*  /*
  * $OpenXM: OpenXM_contrib2/asir2018/engine/p-itv.c,v 1.1 2018/09/19 05:45:07 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2018/engine/p-itv.c,v 1.2 2018/09/28 08:20:28 noro Exp $
 */  */
 #if defined(INTERVAL)  #if defined(INTERVAL)
 #include "ca.h"  #include "ca.h"
 #include "base.h"  #include "base.h"
   #if 0
 #if defined(PARI)  #if defined(PARI)
 #include "genpari.h"  #include "genpari.h"
 #endif  #endif
   #endif
   
   // in engine/bf.c
   Num tobf(Num,int);
   //int     initvp(Num , Itv );
   
   extern int mpfr_roundmode;
   
 extern int zerorewrite;  extern int zerorewrite;
   
 void itvtois(Itv a, Num *inf, Num *sup)  void itvtois(Itv a, Num *inf, Num *sup)
Line 25  void itvtois(Itv a, Num *inf, Num *sup)
Line 33  void itvtois(Itv a, Num *inf, Num *sup)
 void istoitv(Num inf, Num sup, Itv *rp)  void istoitv(Num inf, Num sup, Itv *rp)
 {  {
   Num  i, s;    Num  i, s;
     Num  ni, ns;
   Itv c;    Itv c;
   int  type=0;    int  type=0;
     int current_roundmode;
   
   if ( !inf && !sup ) {    if ( !inf && !sup ) {
     *rp = 0;      *rp = 0;
     return;      return;
   }    }
   if ( !sup ) {    if ( compnum(0,sup,inf) >= 0 ) {
       ns = sup; ni = inf;
     } else {
       ni = sup; ns = inf;
     }
   
     current_roundmode = mpfr_roundmode;
     if ( !ns ) {
     s = 0;      s = 0;
   }    }
   else if ( NID( sup )==N_B ) {    else if ( NID( ns )==N_B ) {
     type = 1;      type = 1;
     ToBf(sup, (BF *)&s);  
       mpfr_roundmode = MPFR_RNDU;
       s = tobf(ns, DEFAULTPREC);
       //ToBf(sup, (BF *)&s);
   } else {    } else {
     s = sup;      s = ns;
   }    }
   if ( !inf ) {    if ( !ni ) {
     i = 0;      i = 0;
   }    }
   else if ( NID( inf )==N_B ) {    else if ( NID( ni )==N_B ) {
     type = 1;      type = 1;
     ToBf(inf, (BF *)&i);  
       mpfr_roundmode = MPFR_RNDD;
       i = tobf(inf, DEFAULTPREC);
       //ToBf(inf, (BF *)&i);
   } else {    } else {
     i = inf;      i = ni;
   }    }
     mpfr_roundmode = current_roundmode;
   
   if ( type ) {    if ( type ) {
 //    NEWIntervalBigFloat((IntervalBigFloat)c);      IntervalBigFloat cc;
     c=MALLOC(sizeof(struct oIntervalBigFloat));      NEWIntervalBigFloat(cc);
     OID(c)=O_N;      c = (Itv)cc;
     NID(c)=N_IntervalBigFloat;    } else {
   } else  
     NEWItvP(c);      NEWItvP(c);
     }
     INF(c) = i; SUP(c) = s;
   
   if ( compnum(0,i,s) >= 0 ) {    if (zerorewrite && initvp(0,c) ) {
     INF(c) = s; SUP(c) = i;      *rp = 0;
       zerorewriteCount++;
   } else {    } else {
     INF(c) = i; SUP(c) = s;      *rp = c;
   }    }
   
   if (zerorewrite)  
     if ( initvp(0,c) ) {  
       *rp = 0;  
       return;  
     }  
   *rp = c;  
 }  }
   
 void additvp(Itv a, Itv b, Itv *c)  void additvp(Itv a, Itv b, Itv *c)
Line 268  void pwritvp(Itv a, Num e, Itv *c)
Line 288  void pwritvp(Itv a, Num e, Itv *c)
     error("pwritv : can't calculate a fractional power");      error("pwritv : can't calculate a fractional power");
 #endif  #endif
   } else {    } else {
     ei = ZTOS((Q)e);      ei = QTOS((Q)e);
     pwritv0p(a,ei,&t);      pwritv0p(a,ei,&t);
     if ( SGN((Q)e) < 0 )      if ( SGN((Q)e) < 0 )
       divnum(0,(Num)ONE,(Num)t,(Num *)c);        divnum(0,(Num)ONE,(Num)t,(Num *)c);
Line 286  void pwritv0p(Itv a, int e, Itv *c)
Line 306  void pwritv0p(Itv a, int e, Itv *c)
   if ( e == 1 )    if ( e == 1 )
     *c = a;      *c = a;
   else {    else {
     STOZ(e,ne);      STOQ(e,ne);
     if ( !(e%2) ) {      if ( !(e%2) ) {
       if ( initvp(0,a) ) {        if ( initvp(0,a) ) {
         Xmin = 0;          Xmin = 0;
Line 374  void miditvp(Itv a, Num *b)
Line 394  void miditvp(Itv a, Num *b)
   else if ( (NID(a) <= N_B) )    else if ( (NID(a) <= N_B) )
     *b = (Num)a;      *b = (Num)a;
   else {    else {
     STOZ(2,TWO);      STOQ(2,TWO);
     itvtois(a,&ai,&as);      itvtois(a,&ai,&as);
     addnum(0,ai,as,&t);      addnum(0,ai,as,&t);
     divnum(0,t,(Num)TWO,b);      divnum(0,t,(Num)TWO,b);

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

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