version 1.2, 2018/09/28 08:20:28 |
version 1.3, 2019/06/04 07:11:23 |
|
|
/* |
/* |
* $OpenXM: OpenXM_contrib2/asir2018/engine/d-itv.c,v 1.1 2018/09/19 05:45:07 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/d-itv.c,v 1.2 2018/09/28 08:20:28 noro Exp $ |
*/ |
*/ |
#if defined(INTERVAL) |
#if defined(INTERVAL) |
#include <float.h> |
#include <float.h> |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
|
#if 0 |
#if defined(PARI) |
#if defined(PARI) |
#include "genpari.h" |
#include "genpari.h" |
#endif |
#endif |
|
#endif |
|
|
#if defined(ITVDEBUG) |
#if defined(ITVDEBUG) |
void printbinint(int d) |
void printbinint(int d) |
Line 179 static double Q2doubleUp(Q a) |
|
Line 181 static double Q2doubleUp(Q a) |
|
} |
} |
} |
} |
|
|
|
#if 0 |
static double PARI2doubleDown(BF a) |
static double PARI2doubleDown(BF a) |
{ |
{ |
GEN p; |
//GEN p; |
|
Num p; |
double d; |
double d; |
|
|
ritopa(a, &p); |
ritopa(a, &p); |
Line 194 static double PARI2doubleUp(BF a) |
|
Line 198 static double PARI2doubleUp(BF a) |
|
{ |
{ |
return PARI2doubleDown(a); |
return PARI2doubleDown(a); |
} |
} |
|
#endif |
|
|
double subulpd(double d) |
double subulpd(double d) |
{ |
{ |
Line 227 double ToRealDown(Num a) |
|
Line 232 double ToRealDown(Num a) |
|
case N_R: |
case N_R: |
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; |
|
error("ToRealDown: not supported operands."); |
|
break; |
case N_IP: |
case N_IP: |
inf = ToRealDown(INF((Itv)a)); |
inf = ToRealDown(INF((Itv)a)); |
break; |
break; |
Line 253 double ToRealUp(Num a) |
|
Line 261 double ToRealUp(Num a) |
|
case N_R: |
case N_R: |
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; |
|
error("ToRealUp: not supported operands."); |
|
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: |
Line 280 void Num2double(Num a, double *inf, double *sup) |
|
Line 291 void Num2double(Num a, double *inf, double *sup) |
|
*sup = BDY((Real)a); |
*sup = BDY((Real)a); |
break; |
break; |
case N_B: |
case N_B: |
*inf = PARI2doubleDown((BF)a); |
//*inf = PARI2doubleDown((BF)a); |
*sup = PARI2doubleUp((BF)a); |
//*sup = PARI2doubleUp((BF)a); |
|
*inf = mpfr_get_d(BDY((BF)a), MPFR_RNDD); |
|
*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)); |
Line 498 void pwritvd(Num a, Num e, IntervalDouble *c) |
|
Line 511 void pwritvd(Num a, Num e, IntervalDouble *c) |
|
error("pwritvd : can't calculate a fractional power"); |
error("pwritvd : can't calculate a fractional power"); |
#endif |
#endif |
} else { |
} else { |
ei = ZTOS((Q)e); |
ei = QTOS((Q)e); |
|
if (ei<0) ei = -ei; |
pwritv0d((IntervalDouble)a,ei,&t); |
pwritv0d((IntervalDouble)a,ei,&t); |
if ( SGN((Q)e) < 0 ) |
if ( SGN((Q)e) < 0 ) |
divnum(0,(Num)ONE,(Num)t,(Num *)c); |
divnum(0,(Num)ONE,(Num)t,(Num *)c); |