version 1.9, 2019/06/04 07:11:22 |
version 1.10, 2019/11/12 10:52:04 |
|
|
/* |
/* |
* $OpenXM: OpenXM_contrib2/asir2000/engine/d-itv.c,v 1.8 2018/03/29 01:32:51 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/engine/d-itv.c,v 1.9 2019/06/04 07:11:22 kondoh Exp $ |
*/ |
*/ |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
#include <float.h> |
#include <float.h> |
Line 221 double addulpd(double d) |
|
Line 221 double addulpd(double d) |
|
return (-sup); |
return (-sup); |
} |
} |
|
|
double ToRealDown(Num a) |
double toRealDown(Num a) |
{ |
{ |
double inf; |
double inf; |
|
|
Line 233 double ToRealDown(Num a) |
|
Line 233 double ToRealDown(Num a) |
|
inf = subulpd(BDY((Real)a)); break; |
inf = subulpd(BDY((Real)a)); break; |
case N_B: |
case N_B: |
//inf = PARI2doubleDown((BF)a); break; |
//inf = PARI2doubleDown((BF)a); break; |
inf = 0; |
inf = mpfr_get_d(BDY((BF)a),MPFR_RNDD);; |
error("ToRealDown: not supported operands."); |
//error("toRealDown: not supported operands."); |
break; |
break; |
case N_IP: |
case N_IP: |
inf = ToRealDown(INF((Itv)a)); |
inf = toRealDown(INF((Itv)a)); |
break; |
break; |
case N_IntervalDouble: |
case N_IntervalDouble: |
inf = INF((IntervalDouble)a); break; |
inf = INF((IntervalDouble)a); break; |
|
case N_IntervalBigFloat: |
|
inf = mpfr_get_d(BDY((BF)INF((IntervalBigFloat)a)),MPFR_RNDD);; |
|
break; |
case N_A: |
case N_A: |
default: |
default: |
inf = 0.0; |
inf = 0.0; |
error("ToRealDown: not supported operands."); |
error("toRealDown: not supported operands."); |
break; |
break; |
} |
} |
return inf; |
return inf; |
} |
} |
|
|
double ToRealUp(Num a) |
double toRealUp(Num a) |
{ |
{ |
double sup; |
double sup; |
|
|
Line 262 double ToRealUp(Num a) |
|
Line 265 double ToRealUp(Num a) |
|
sup = addulpd(BDY((Real)a)); break; |
sup = addulpd(BDY((Real)a)); break; |
case N_B: |
case N_B: |
//sup = PARI2doubleUp((BF)a); break; |
//sup = PARI2doubleUp((BF)a); break; |
sup = 0; |
sup = mpfr_get_d(BDY((BF)a),MPFR_RNDU);; |
error("ToRealUp: not supported operands."); |
//error("toRealUp: not supported operands."); |
break; |
break; |
case N_IP: |
case N_IP: |
sup = ToRealUp(SUP((Itv)a)); break; |
sup = toRealUp(SUP((Itv)a)); break; |
case N_IntervalDouble: |
case N_IntervalDouble: |
sup = SUP((IntervalDouble)a); break; |
sup = SUP((IntervalDouble)a); break; |
|
case N_IntervalBigFloat: |
|
sup = mpfr_get_d(BDY((BF)SUP((IntervalBigFloat)a)),MPFR_RNDU);; |
|
break; |
case N_A: |
case N_A: |
default: |
default: |
sup = 0.0; |
sup = 0.0; |
error("ToRealUp: not supported operands."); |
error("toRealUp: not supported operands."); |
break; |
break; |
} |
} |
return sup; |
return sup; |
Line 281 double ToRealUp(Num a) |
|
Line 287 double ToRealUp(Num a) |
|
|
|
void Num2double(Num a, double *inf, double *sup) |
void Num2double(Num a, double *inf, double *sup) |
{ |
{ |
switch ( NID(a) ) { |
*inf = 0.0; |
case N_Q: |
*sup = 0.0; |
*inf = Q2doubleDown((Q)a); |
if ( a && NUM(a) ) { |
*sup = Q2doubleUp((Q)a); |
switch ( NID(a) ) { |
break; |
case N_Q: |
case N_R: |
*inf = Q2doubleDown((Q)a); |
*inf = BDY((Real)a); |
*sup = Q2doubleUp((Q)a); |
*sup = BDY((Real)a); |
break; |
break; |
case N_R: |
case N_B: |
*inf = BDY((Real)a); |
//*inf = PARI2doubleDown((BF)a); |
*sup = BDY((Real)a); |
//*sup = PARI2doubleUp((BF)a); |
break; |
*inf = mpfr_get_d(BDY((BF)a), MPFR_RNDD); |
case N_B: |
*sup = mpfr_get_d(BDY((BF)a), MPFR_RNDU); |
//*inf = PARI2doubleDown((BF)a); |
break; |
//*sup = PARI2doubleUp((BF)a); |
case N_IP: |
*inf = mpfr_get_d(BDY((BF)a), MPFR_RNDD); |
*inf = ToRealDown(INF((Itv)a)); |
*sup = mpfr_get_d(BDY((BF)a), MPFR_RNDU); |
*sup = ToRealUp(SUP((Itv)a)); |
break; |
break; |
case N_IP: |
case N_IntervalDouble: |
*inf = toRealDown(INF((Itv)a)); |
*inf = INF((IntervalDouble)a); |
*sup = toRealUp(SUP((Itv)a)); |
*sup = SUP((IntervalDouble)a); |
break; |
break; |
case N_IntervalDouble: |
case N_A: |
*inf = INF((IntervalDouble)a); |
default: |
*sup = SUP((IntervalDouble)a); |
*inf = 0.0; |
break; |
*sup = 0.0; |
case N_A: |
error("Num2double: not supported operands."); |
default: |
break; |
*inf = 0.0; |
|
*sup = 0.0; |
|
error("Num2double: not supported operands."); |
|
break; |
|
} |
} |
} |
} |
} |
|
|
Line 687 void absitvd(IntervalDouble a, Num *b) |
|
Line 697 void absitvd(IntervalDouble a, Num *b) |
|
MKReal(t,rp); |
MKReal(t,rp); |
*b = (Num)rp; |
*b = (Num)rp; |
} |
} |
|
} |
|
|
|
void absintvald(IntervalDouble a, IntervalDouble *b) |
|
{ |
|
double ai,as,inf,sup; |
|
|
|
ai = INF(a); |
|
as = SUP(a); |
|
if ( as < 0 ) { |
|
sup = -ai; |
|
inf = -as; |
|
} else if (ai < 0) { |
|
inf = 0.0; |
|
sup = MAX(as, -ai); |
|
} else { |
|
inf = ai; |
|
sup = as; |
|
} |
|
MKIntervalDouble(inf,sup,*b); |
} |
} |
|
|
void distanceitvd(IntervalDouble a, IntervalDouble b, Num *c) |
void distanceitvd(IntervalDouble a, IntervalDouble b, Num *c) |