version 1.3, 2003/02/14 22:29:08 |
version 1.6, 2005/01/11 07:12:51 |
|
|
/* |
/* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/f-itv.c,v 1.2 2002/01/08 04:14:37 kondoh Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/f-itv.c,v 1.5 2003/10/20 07:18:42 saito Exp $ |
*/ |
*/ |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
#include "ca.h" |
#include "ca.h" |
Line 135 printexpr(CO, bi); |
|
Line 135 printexpr(CO, bi); |
|
printexpr(CO, bs); |
printexpr(CO, bs); |
#endif |
#endif |
|
|
#if 1 |
|
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((IntervalBigFloat)tmp, c); |
addulp((IntervalBigFloat)tmp, c); |
return; |
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 |
|
} |
} |
} |
} |
|
|
Line 185 void subitvf(IntervalBigFloat a, IntervalBigFloat b, I |
|
Line 161 void subitvf(IntervalBigFloat a, IntervalBigFloat b, I |
|
ToBf(inf, (BF *)&ai); ToBf(sup, (BF *)&as); |
ToBf(inf, (BF *)&ai); ToBf(sup, (BF *)&as); |
itvtois((Itv)b,&inf,&sup); |
itvtois((Itv)b,&inf,&sup); |
ToBf(inf, (BF *)&bi); ToBf(sup, (BF *)&bs); |
ToBf(inf, (BF *)&bi); ToBf(sup, (BF *)&bs); |
#if 1 |
|
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((IntervalBigFloat)tmp, c); |
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 |
|
} |
} |
} |
} |
|
|
Line 451 int cmpitvf(Itv a, Itv b) |
|
Line 402 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); |
Line 475 void miditvf(Itv a, Num *b) |
|
Line 434 void miditvf(Itv a, Num *b) |
|
{ |
{ |
Num ai,as; |
Num ai,as; |
Num t; |
Num t; |
Q TWO; |
|
|
|
if ( ! a ) *b = 0; |
if ( ! a ) *b = 0; |
else if ( (NID(a) <= N_B) ) |
else if ( (NID(a) <= N_B) ) |