=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/engine/f-itv.c,v retrieving revision 1.2 retrieving revision 1.6 diff -u -p -r1.2 -r1.6 --- OpenXM_contrib2/asir2000/engine/f-itv.c 2002/01/08 04:14:37 1.2 +++ OpenXM_contrib2/asir2000/engine/f-itv.c 2005/01/11 07:12:51 1.6 @@ -1,10 +1,10 @@ /* - * $OpenXM: OpenXM_contrib2/asir2000/engine/f-itv.c,v 1.1 2000/12/22 10:03:28 saito Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/engine/f-itv.c,v 1.5 2003/10/20 07:18:42 saito Exp $ */ #if defined(INTERVAL) #include "ca.h" #include "base.h" -#if PARI +#if defined(PARI) #include "genpari.h" #include "itv-pari.h" extern long prec; @@ -135,35 +135,11 @@ printexpr(CO, bi); printexpr(CO, bs); #endif -#if 1 addnum(0,ai,bi,&inf); addnum(0,as,bs,&sup); istoitv(inf,sup,(Itv *)&tmp); addulp((IntervalBigFloat)tmp, c); return; -#else - ltop = avma; - ritopa(ai,&pa); - ritopa(bi,&pb); - lbot = avma; - z = gerepile(ltop,lbot,PariAddDown(pa,pb)); - patori(z,&inf); cgiv(z); - - /* MUST check if ai, as, bi, bs are bigfloat. */ - - /* as + bs = ( - ( (-as) + (-bs) ) ) */ - chsgnbf(as,&mas); - chsgnbf(bs,&mbs); - ltop = avma; - ritopa(mas,&pa); - ritopa(mbs,&pb); - lbot = avma; - z = gerepile(ltop,lbot,PariAddDown(pa,pb)); - patori(z,&tmp); cgiv(z); - - chsgnbf(tmp,&sup); - istoitv(inf,sup,c); -#endif } } @@ -185,35 +161,10 @@ void subitvf(IntervalBigFloat a, IntervalBigFloat b, I ToBf(inf, (BF *)&ai); ToBf(sup, (BF *)&as); itvtois((Itv)b,&inf,&sup); ToBf(inf, (BF *)&bi); ToBf(sup, (BF *)&bs); -#if 1 subnum(0,ai,bs,&inf); subnum(0,as,bi,&sup); istoitv(inf,sup,(Itv *)&tmp); addulp((IntervalBigFloat)tmp, c); -#else - -/* MUST check if ai, as, bi, bs are bigfloat. */ - /* ai - bs = ai + (-bs) */ - chsgnbf(bs,&mbs); - ltop = avma; - ritopa(ai,&pa); - ritopa(mbs,&pb); - lbot = avma; - z = gerepile(ltop,lbot,PariAddDown(pa,pb)); - patori(z,&inf); cgiv(z); - - /* as - bi = ( - ( bi + (-as) ) ) */ - chsgnbf(as,&mas); - ltop = avma; - ritopa(mas,&pa); - ritopa(bi,&pb); - lbot = avma; - z = gerepile(ltop,lbot,PariAddDown(pa,pb)); - patori(z,&tmp); cgiv(z); - - chsgnbf(tmp,&sup); - istoitv(inf,sup,c); -#endif } } @@ -368,7 +319,7 @@ void pwritvf(Itv a, Num e, Itv *c) else if ( NID(a) <= N_B ) pwrnum(0,(Num)a,e,(Num *)c); else if ( !INT(e) ) { -#if PARI && 0 +#if defined(PARI) && 0 GEN pa,pe,z; int ltop,lbot; @@ -451,15 +402,23 @@ int cmpitvf(Itv a, Itv b) int s,t; if ( !a ) { - if ( !b || (NID(b)<=N_B) ) + if ( !b || (NID(b)<=N_B) ) { return compnum(0,(Num)a,(Num)b); - else - return -1; + } else { + 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 ) { - if ( !a || (NID(a)<=N_B) ) + if ( !a || (NID(a)<=N_B) ) { return compnum(0,(Num)a,(Num)b); - else - return initvp((Num)b,a); + } else { + 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 { itvtois(a,&ai,&as); itvtois(b,&bi,&bs); @@ -475,7 +434,6 @@ void miditvf(Itv a, Num *b) { Num ai,as; Num t; - Q TWO; if ( ! a ) *b = 0; else if ( (NID(a) <= N_B) )