version 1.4, 2019/10/17 03:03:12 |
version 1.5, 2019/11/12 10:53:22 |
|
|
/* |
/* |
* $OpenXM: OpenXM_contrib2/asir2018/engine/d-itv.c,v 1.3 2019/06/04 07:11:23 kondoh Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/d-itv.c,v 1.4 2019/10/17 03:03:12 kondoh Exp $ |
*/ |
*/ |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
#include <float.h> |
#include <float.h> |
Line 255 double addulpd(double d) |
|
Line 255 double addulpd(double d) |
|
return (-sup); |
return (-sup); |
} |
} |
|
|
double ToRealDown(Num a) |
double toRealDown(Num a) |
{ |
{ |
double inf; |
double inf; |
|
|
Line 269 double ToRealDown(Num a) |
|
Line 269 double ToRealDown(Num a) |
|
inf = mpfr_get_d(BDY((BF)a),MPFR_RNDD); |
inf = mpfr_get_d(BDY((BF)a),MPFR_RNDD); |
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 296 double ToRealUp(Num a) |
|
Line 299 double ToRealUp(Num a) |
|
sup = mpfr_get_d(BDY((BF)a),MPFR_RNDU); |
sup = mpfr_get_d(BDY((BF)a),MPFR_RNDU); |
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)INF((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 311 double ToRealUp(Num a) |
|
Line 317 double ToRealUp(Num a) |
|
|
|
void Num2double(Num a, double *inf, double *sup) |
void Num2double(Num a, double *inf, double *sup) |
{ |
{ |
|
*inf = 0.0; |
|
*sup = 0.0; |
|
if (a && NUM(a) ) |
switch ( NID(a) ) { |
switch ( NID(a) ) { |
case N_Q: |
case N_Q: |
*inf = Q2doubleDown((Q)a); |
*inf = Q2doubleDown((Q)a); |
Line 325 void Num2double(Num a, double *inf, double *sup) |
|
Line 334 void Num2double(Num a, double *inf, double *sup) |
|
*sup = mpfr_get_d(BDY((BF)a), MPFR_RNDU); |
*sup = mpfr_get_d(BDY((BF)a), MPFR_RNDU); |
break; |
break; |
case N_IP: |
case N_IP: |
*inf = ToRealDown(INF((Itv)a)); |
*inf = toRealDown(INF((Itv)a)); |
*sup = ToRealUp(SUP((Itv)a)); |
*sup = toRealUp(SUP((Itv)a)); |
break; |
break; |
case N_IntervalDouble: |
case N_IntervalDouble: |
*inf = INF((IntervalDouble)a); |
*inf = INF((IntervalDouble)a); |
Line 334 void Num2double(Num a, double *inf, double *sup) |
|
Line 343 void Num2double(Num a, double *inf, double *sup) |
|
break; |
break; |
case N_A: |
case N_A: |
default: |
default: |
*inf = 0.0; |
|
*sup = 0.0; |
|
error("Num2double: not supported operands."); |
error("Num2double: not supported operands."); |
break; |
break; |
} |
} |
Line 717 void absitvd(IntervalDouble a, Num *b) |
|
Line 724 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) |