version 1.1, 2000/12/22 10:03:28 |
version 1.4, 2003/07/25 12:34:48 |
|
|
/* |
/* |
* $OpenXM: $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/p-itv.c,v 1.3 2003/02/14 22:29:09 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" |
#endif |
#endif |
|
|
Line 51 void istoitv(Num inf, Num sup, Itv *rp) |
|
Line 51 void istoitv(Num inf, Num sup, Itv *rp) |
|
i = inf; |
i = inf; |
} |
} |
if ( type ) |
if ( type ) |
NEWItvF((ItvF)c); |
NEWIntervalBigFloat((IntervalBigFloat)c); |
else |
else |
NEWItvP(c); |
NEWItvP(c); |
|
|
Line 82 void additvp(Itv a, Itv b, Itv *c) |
|
Line 82 void additvp(Itv a, Itv b, Itv *c) |
|
addnum(0,(Num)a,(Num)b,(Num *)c); |
addnum(0,(Num)a,(Num)b,(Num *)c); |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
additvd((Num)a,(Num)b,(ItvD *)c); |
additvd((Num)a,(Num)b,(IntervalDouble *)c); |
else { |
else { |
itvtois(a,&ai,&as); |
itvtois(a,&ai,&as); |
itvtois(b,&bi,&bs); |
itvtois(b,&bi,&bs); |
Line 105 void subitvp(Itv a, Itv b, Itv *c) |
|
Line 105 void subitvp(Itv a, Itv b, Itv *c) |
|
subnum(0,(Num)a,(Num)b,(Num *)c); |
subnum(0,(Num)a,(Num)b,(Num *)c); |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
subitvd((Num)a,(Num)b,(ItvD *)c); |
subitvd((Num)a,(Num)b,(IntervalDouble *)c); |
else { |
else { |
itvtois(a,&ai,&as); |
itvtois(a,&ai,&as); |
itvtois(b,&bi,&bs); |
itvtois(b,&bi,&bs); |
Line 126 void mulitvp(Itv a, Itv b, Itv *c) |
|
Line 126 void mulitvp(Itv a, Itv b, Itv *c) |
|
mulnum(0,(Num)a,(Num)b,(Num *)c); |
mulnum(0,(Num)a,(Num)b,(Num *)c); |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
mulitvd((Num)a,(Num)b,(ItvD *)c); |
mulitvd((Num)a,(Num)b,(IntervalDouble *)c); |
else { |
else { |
itvtois(a,&ai,&as); |
itvtois(a,&ai,&as); |
itvtois(b,&bi,&bs); |
itvtois(b,&bi,&bs); |
Line 208 void divitvp(Itv a, Itv b, Itv *c) |
|
Line 208 void divitvp(Itv a, Itv b, Itv *c) |
|
divnum(0,(Num)a,(Num)b,(Num *)c); |
divnum(0,(Num)a,(Num)b,(Num *)c); |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
else if ( (NID(a) == N_IP) && (NID(b) == N_R ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
||(NID(a) == N_R ) && (NID(b) == N_IP) ) |
divitvd((Num)a,(Num)b,(ItvD *)c); |
divitvd((Num)a,(Num)b,(IntervalDouble *)c); |
else { |
else { |
itvtois(a,&ai,&as); |
itvtois(a,&ai,&as); |
itvtois(b,&bi,&bs); |
itvtois(b,&bi,&bs); |
Line 259 void pwritvp(Itv a, Num e, Itv *c) |
|
Line 259 void pwritvp(Itv a, Num e, Itv *c) |
|
else if ( NID(a) <= N_B ) |
else if ( NID(a) <= N_B ) |
pwrnum(0,(Num)a,(Num)e,(Num *)c); |
pwrnum(0,(Num)a,(Num)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 339 int cmpitvp(Itv a, Itv b) |
|
Line 339 int cmpitvp(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; |
} |
} |
} |
} |
|
|