version 1.3, 2003/02/14 22:29:09 |
version 1.7, 2009/03/27 14:42:29 |
|
|
/* |
/* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/p-itv.c,v 1.2 2002/01/08 04:14:37 kondoh Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/p-itv.c,v 1.6 2005/02/08 18:06:05 saito Exp $ |
*/ |
*/ |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
#include "ca.h" |
#include "ca.h" |
Line 50 void istoitv(Num inf, Num sup, Itv *rp) |
|
Line 50 void istoitv(Num inf, Num sup, Itv *rp) |
|
} else { |
} else { |
i = inf; |
i = inf; |
} |
} |
if ( type ) |
if ( type ) { |
NEWIntervalBigFloat((IntervalBigFloat)c); |
// NEWIntervalBigFloat((IntervalBigFloat)c); |
else |
c=MALLOC(sizeof(struct oIntervalBigFloat)); |
|
OID(c)=O_N; |
|
NID(c)=N_IntervalBigFloat; |
|
} else |
NEWItvP(c); |
NEWItvP(c); |
|
|
if ( compnum(0,i,s) >= 0 ) { |
if ( compnum(0,i,s) >= 0 ) { |
Line 260 void pwritvp(Itv a, Num e, Itv *c) |
|
Line 263 void pwritvp(Itv a, Num e, Itv *c) |
|
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 defined(PARI) && 0 |
#if defined(PARI) && 0 |
GEN pa,pe,z; |
gpui_ri((Obj)a,(Obj)c,(Obj *)c); |
int ltop,lbot; |
|
|
|
ltop = avma; ritopa(a,&pa); ritopa(e,&pe); lbot = avma; |
|
z = gerepile(ltop,lbot,gpui(pa,pe,prec)); |
|
patori(z,c); cgiv(z); |
|
#else |
#else |
error("pwritv : can't calculate a fractional power"); |
error("pwritv : can't calculate a fractional power"); |
#endif |
#endif |
Line 339 int cmpitvp(Itv a, Itv b) |
|
Line 337 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); |
Line 363 void miditvp(Itv a, Num *b) |
|
Line 369 void miditvp(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) ) |