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

Diff for /OpenXM_contrib2/asir2000/engine/f-itv.c between version 1.1 and 1.4

version 1.1, 2000/12/22 10:03:28 version 1.4, 2003/07/25 12:34:47
Line 1 
Line 1 
 /*  /*
  * $OpenXM: $   * $OpenXM: OpenXM_contrib2/asir2000/engine/f-itv.c,v 1.3 2003/02/14 22:29:08 ohara Exp $
 */  */
 #if defined(INTERVAL)  #if defined(INTERVAL)
 #include "ca.h"  #include "ca.h"
 #include "base.h"  #include "base.h"
 #if PARI  #if defined(PARI)
 #include "genpari.h"  #include "genpari.h"
 #include "itv-pari.h"  #include "itv-pari.h"
 extern long prec;  extern long prec;
Line 94  void getulp(BF a, BF *au)
Line 94  void getulp(BF a, BF *au)
         cgiv(b);          cgiv(b);
 }  }
   
 void addulp(ItvF a, ItvF *c)  void addulp(IntervalBigFloat a, IntervalBigFloat *c)
 {  {
         Num     ai, as, aiu, asu, inf, sup;          Num     ai, as, aiu, asu, inf, sup;
   
Line 110  void addulp(ItvF a, ItvF *c)
Line 110  void addulp(ItvF a, ItvF *c)
         istoitv(inf,sup, (Itv *)c);          istoitv(inf,sup, (Itv *)c);
 }  }
   
 void additvf(ItvF a, ItvF b, ItvF *c)  void additvf(IntervalBigFloat a, IntervalBigFloat b, IntervalBigFloat *c)
 {  {
         Num     ai,as,bi,bs,mas,mbs,tmp;          Num     ai,as,bi,bs,mas,mbs,tmp;
         Num     inf,sup;          Num     inf,sup;
Line 139  printexpr(CO, bs);
Line 139  printexpr(CO, bs);
                 addnum(0,ai,bi,&inf);                  addnum(0,ai,bi,&inf);
                 addnum(0,as,bs,&sup);                  addnum(0,as,bs,&sup);
                 istoitv(inf,sup,(Itv *)&tmp);                  istoitv(inf,sup,(Itv *)&tmp);
                 addulp((ItvF)tmp, c);                  addulp((IntervalBigFloat)tmp, c);
                 return;                  return;
 #else  #else
                 ltop = avma;                  ltop = avma;
Line 167  printexpr(CO, bs);
Line 167  printexpr(CO, bs);
         }          }
 }  }
   
 void subitvf(ItvF a, ItvF b, ItvF *c)  void subitvf(IntervalBigFloat a, IntervalBigFloat b, IntervalBigFloat *c)
 {  {
         Num     ai,as,bi,bs,mas, mbs;          Num     ai,as,bi,bs,mas, mbs;
         Num     inf,sup,tmp;          Num     inf,sup,tmp;
Line 189  void subitvf(ItvF a, ItvF b, ItvF *c)
Line 189  void subitvf(ItvF a, ItvF b, ItvF *c)
                 subnum(0,ai,bs,&inf);                  subnum(0,ai,bs,&inf);
                 subnum(0,as,bi,&sup);                  subnum(0,as,bi,&sup);
                 istoitv(inf,sup,(Itv *)&tmp);                  istoitv(inf,sup,(Itv *)&tmp);
                 addulp((ItvF)tmp, c);                  addulp((IntervalBigFloat)tmp, c);
 #else  #else
   
 /* MUST check if ai, as, bi, bs are bigfloat. */  /* MUST check if ai, as, bi, bs are bigfloat. */
Line 217  void subitvf(ItvF a, ItvF b, ItvF *c)
Line 217  void subitvf(ItvF a, ItvF b, ItvF *c)
         }          }
 }  }
   
 void mulitvf(ItvF a, ItvF b, ItvF *c)  void mulitvf(IntervalBigFloat a, IntervalBigFloat b, IntervalBigFloat *c)
 {  {
         Num     ai,as,bi,bs,a1,a2,b1,b2,c1,c2,p,t,tmp;          Num     ai,as,bi,bs,a1,a2,b1,b2,c1,c2,p,t,tmp;
         Num     inf, sup;          Num     inf, sup;
Line 278  void mulitvf(ItvF a, ItvF b, ItvF *c)
Line 278  void mulitvf(ItvF a, ItvF b, ItvF *c)
                         subnum(0,0,c1,&t);                          subnum(0,0,c1,&t);
                         istoitv(c2,t,(Itv *)&tmp);                          istoitv(c2,t,(Itv *)&tmp);
                 }                  }
                 addulp((ItvF)tmp, c);                  addulp((IntervalBigFloat)tmp, c);
         }          }
 }  }
   
Line 302  int     itvinitvf(Itv a, Itv b)
Line 302  int     itvinitvf(Itv a, Itv b)
         else return 0;          else return 0;
 }  }
   
 void divitvf(ItvF a, ItvF b, ItvF *c)  void divitvf(IntervalBigFloat a, IntervalBigFloat b, IntervalBigFloat *c)
 {  {
         Num     ai,as,bi,bs,a1,a2,b1,b2,c1,c2,t,tmp;          Num     ai,as,bi,bs,a1,a2,b1,b2,c1,c2,t,tmp;
         Num     inf, sup;          Num     inf, sup;
Line 352  void divitvf(ItvF a, ItvF b, ItvF *c)
Line 352  void divitvf(ItvF a, ItvF b, ItvF *c)
                         subnum(0,0,c1,&t);                          subnum(0,0,c1,&t);
                         istoitv(c2,t,(Itv *)&tmp);                          istoitv(c2,t,(Itv *)&tmp);
                 }                  }
                 addulp((ItvF)tmp, c);                  addulp((IntervalBigFloat)tmp, c);
         }          }
 }  }
   
Line 368  void pwritvf(Itv a, Num e, Itv *c)
Line 368  void pwritvf(Itv a, Num e, Itv *c)
         else if ( NID(a) <= N_B )          else if ( NID(a) <= N_B )
                 pwrnum(0,(Num)a,e,(Num *)c);                  pwrnum(0,(Num)a,e,(Num *)c);
         else if ( !INT(e) ) {          else if ( !INT(e) ) {
 #if PARI && 0  #if defined(PARI) && 0
                 GEN pa,pe,z;                  GEN pa,pe,z;
                 int ltop,lbot;                  int ltop,lbot;
   
Line 392  void pwritv0f(Itv a, int e, Itv *c)
Line 392  void pwritv0f(Itv a, int e, Itv *c)
 {  {
         Num inf, sup;          Num inf, sup;
         Num ai,Xmin,Xmax;          Num ai,Xmin,Xmax;
         ItvF tmp;          IntervalBigFloat tmp;
         Q       ne;          Q       ne;
   
         if ( e == 1 )          if ( e == 1 )
Line 426  void pwritv0f(Itv a, int e, Itv *c)
Line 426  void pwritv0f(Itv a, int e, Itv *c)
                 if ( ! Xmax )   sup = 0;                  if ( ! Xmax )   sup = 0;
                 else            pwrbf(Xmax,(Num)ne,&sup);                  else            pwrbf(Xmax,(Num)ne,&sup);
                 istoitv(inf,sup,(Itv *)&tmp);                  istoitv(inf,sup,(Itv *)&tmp);
                 addulp(tmp, (ItvF *)c);                  addulp(tmp, (IntervalBigFloat *)c);
         }          }
 }  }
   
Line 451  int cmpitvf(Itv a, Itv b)
Line 451  int cmpitvf(Itv a, Itv b)
         int     s,t;          int     s,t;
   
         if ( !a ) {          if ( !a ) {
                 if ( !b || (NID(b)<=N_B) )                  if ( !b || (NID(b)<=N_B) ) {
                         return compnum(0,(Num)a,(Num)b);                          return compnum(0,(Num)a,(Num)b);
                 else                  } else {
                         return -1;                          itvtois(b,&bi,&bs);
                           if ( compnum(0,(Num)a,bs) > 0 ) return 1;
                           else if ( compnum(0,bi,(Num)a) > 0 ) return -1;
                           else  return 0;
                   }
         } else if ( !b ) {          } else if ( !b ) {
                 if ( !a || (NID(a)<=N_B) )                  if ( !a || (NID(a)<=N_B) ) {
                         return compnum(0,(Num)a,(Num)b);                          return compnum(0,(Num)a,(Num)b);
                 else                  } else {
                         return initvp((Num)b,a);                          itvtois(a,&ai,&as);
                           if ( compnum(0,ai,(Num)b) > 0 ) return 1;
                           else if ( compnum(0,(Num)b,as) > 0 ) return -1;
                           else  return 0;
                   }
         } else {          } else {
                 itvtois(a,&ai,&as);                  itvtois(a,&ai,&as);
                 itvtois(b,&bi,&bs);                  itvtois(b,&bi,&bs);
                 s = compnum(0,ai,bi);                  s = compnum(0,ai,bs) ;
                 t = compnum(0,as,bs);                  t = compnum(0,bi,as) ;
                 if ( !s && !t ) return 0;                  if ( s > 0 ) return 1;
                 else  return -1;                  else if ( t > 0 ) return -1;
                   else  return 0;
         }          }
 }  }
   

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

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