| version 1.15, 2018/03/29 01:32:53 |
version 1.16, 2019/06/04 07:11:22 |
|
|
| /* |
/* |
| * $OpenXM: OpenXM_contrib2/asir2000/include/interval.h,v 1.14 2016/06/29 08:16:11 ohara Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/include/interval.h,v 1.15 2018/03/29 01:32:53 noro Exp $ |
| */ |
*/ |
| #ifndef _INTERVAL_H |
#ifndef _INTERVAL_H |
| #define _INTERVAL_H |
#define _INTERVAL_H |
| |
|
| |
#define INT_ASIR_VERSION 20181218 |
| |
|
| #define PRINTF_G 0 |
#define PRINTF_G 0 |
| #define PRINTF_E 1 |
#define PRINTF_E 1 |
| |
|
| Line 30 static char *Interval_dummy; |
|
| Line 32 static char *Interval_dummy; |
|
| #endif |
#endif |
| #endif |
#endif |
| |
|
| |
#if 0 |
| #ifdef linux |
#ifdef linux |
| #include <fpu_control.h> |
#include <fpu_control.h> |
| #if 1 |
#if 1 |
| Line 99 static char *Interval_dummy; |
|
| Line 102 static char *Interval_dummy; |
|
| #define FPMINUSINF _controlfp(_RC_DOWN,_MCW_RC); |
#define FPMINUSINF _controlfp(_RC_DOWN,_MCW_RC); |
| #define FPTOZERO _controlfp(_RC_CHOP,_MCW_RC); |
#define FPTOZERO _controlfp(_RC_CHOP,_MCW_RC); |
| #endif |
#endif |
| |
#endif |
| |
#include <fenv.h> |
| |
|
| |
#define FPNEAREST fesetround(FE_TONEAREST); |
| |
#define FPPLUSINF fesetround(FE_UPWARD); |
| |
#define FPMINUSINF fesetround(FE_DOWNWARD); |
| |
#define FPTOZERO fesetround(FE_TOWARDZERO); |
| |
|
| |
|
| /* no control function of floating point rounding */ |
/* no control function of floating point rounding */ |
| #ifndef FPNEAREST |
#ifndef FPNEAREST |
| #define FPNEAREST fprintf(stderr, "Fpu control FPNEAREST is not supported in this machine yet.\n"); |
#define FPNEAREST fprintf(stderr, "Fpu control FPNEAREST is not supported in this machine yet.\n"); |
| Line 118 static char *Interval_dummy; |
|
| Line 129 static char *Interval_dummy; |
|
| #define MID_PRINTF_G 2 |
#define MID_PRINTF_G 2 |
| #define MID_PRINTF_E 3 |
#define MID_PRINTF_E 3 |
| |
|
| |
#define DEFAULTPREC 0 /* for mpfr */ |
| |
|
| /* data structures */ |
/* data structures */ |
| struct oItv { |
struct oItv { |
| short id; |
short id; |
| Line 169 struct oIntervalBigFloat { |
|
| Line 182 struct oIntervalBigFloat { |
|
| typedef struct oIntervalBigFloat *IntervalBigFloat; |
typedef struct oIntervalBigFloat *IntervalBigFloat; |
| |
|
| extern int zerorewrite; |
extern int zerorewrite; |
| |
extern int zerorewriteCount; |
| |
|
| /* general macros */ |
/* general macros */ |
| #define INF(p) ((p)->inf) |
#define INF(p) ((p)->inf) |
| Line 183 extern int zerorewrite; |
|
| Line 197 extern int zerorewrite; |
|
| #define NEWIntervalBigFloat(q) ((q)=(IntervalBigFloat)MALLOC(sizeof(struct oIntervalBigFloat)),\ |
#define NEWIntervalBigFloat(q) ((q)=(IntervalBigFloat)MALLOC(sizeof(struct oIntervalBigFloat)),\ |
| OID(q)=O_N,NID(q)=N_IntervalBigFloat) |
OID(q)=O_N,NID(q)=N_IntervalBigFloat) |
| #define MKItvP(a,b,c) (NEWItvP(c),(INF(c)=(a),SUP(c)=(b))) |
#define MKItvP(a,b,c) (NEWItvP(c),(INF(c)=(a),SUP(c)=(b))) |
| #define MKIntervalDouble(a,b,c) if((zerorewrite) && ((a)<=0.0) && ((b)>=0.0)) (c)=0;\ |
#define MKIntervalDouble(a,b,c) if((zerorewrite) && ((a)<=0.0) && ((b)>=0.0)) {(c)=0;zerorewriteCount++;}\ |
| else (NEWIntervalDouble(c),(INF(c)=(a),SUP(c)=(b))) |
else (NEWIntervalDouble(c),(INF(c)=(a),SUP(c)=(b))) |
| #define MKIntervalQuad(a,b,c) (NEWIntervalQuad(c),(INF(c)=(a),SUP(c)=(b))) |
#define MKIntervalQuad(a,b,c) (NEWIntervalQuad(c),(INF(c)=(a),SUP(c)=(b))) |
| #define MKIntervalBigFloat(a,b,c) (NEWIntervalBigFloat(c),(INF(c)=(a),SUP(c)=(b))) |
#define MKIntervalBigFloat(a,b,c) (NEWIntervalBigFloat(c),(INF(c)=(a),SUP(c)=(b))) |
| |
|
| Line 197 extern int zerorewrite; |
|
| Line 211 extern int zerorewrite; |
|
| #define ITVQ(a) (NID(a)==N_IntervalQuad) |
#define ITVQ(a) (NID(a)==N_IntervalQuad) |
| #define ITVF(a) (NID(a)==N_IntervalBigFloat) |
#define ITVF(a) (NID(a)==N_IntervalBigFloat) |
| |
|
| /*** engine/itv.c ***/ |
#if 0 |
| double ToRealSup(Num); |
double ToRealSup(Num); |
| double ToRealInf(Num); |
double ToRealInf(Num); |
| double RatnToRealUp(Q); |
double RatnToRealUp(Q); |
| Line 206 double NatToRealUp(N, int *); |
|
| Line 220 double NatToRealUp(N, int *); |
|
| void double2bf(double, BF *); |
void double2bf(double, BF *); |
| double bf2double(BF); |
double bf2double(BF); |
| |
|
| void itvtois(Itv, Num *, Num *); |
|
| void istoitv(Num, Num, Itv *); |
|
| |
|
| #if 0 |
|
| void additv(Num, Num, Num *); |
void additv(Num, Num, Num *); |
| void subitv(Num, Num, Num *); |
void subitv(Num, Num, Num *); |
| void mulitv(Num, Num, Num *); |
void mulitv(Num, Num, Num *); |
| Line 228 void widthitv(Itv, Num *); |
|
| Line 239 void widthitv(Itv, Num *); |
|
| void distanceitv(Itv, Itv, Num *); |
void distanceitv(Itv, Itv, Num *); |
| #endif |
#endif |
| |
|
| |
/*** engine/p-itv.c ***/ |
| |
void itvtois(Itv, Num *, Num *); |
| |
void istoitv(Num, Num, Itv *); |
| |
|
| void additvp(Itv, Itv, Itv *); |
void additvp(Itv, Itv, Itv *); |
| void subitvp(Itv, Itv, Itv *); |
void subitvp(Itv, Itv, Itv *); |
| void mulitvp(Itv, Itv, Itv *); |
void mulitvp(Itv, Itv, Itv *); |
| void divitvp(Itv, Itv, Itv *); |
void divitvp(Itv, Itv, Itv *); |
| void chsgnitvp(Itv, Itv *); |
|
| int cmpitvp(Itv, Itv); |
|
| void pwritvp(Itv, Num, Itv *); |
void pwritvp(Itv, Num, Itv *); |
| void pwritv0p(Itv, int, Itv *); |
void pwritv0p(Itv, int, Itv *); |
| |
void chsgnitvp(Itv, Itv *); |
| |
int initvp(Num , Itv ); |
| |
int itvinitvp(Itv, Itv); |
| |
int cmpitvp(Itv, Itv); |
| |
void miditvp(Itv, Num *); |
| void cupitvp(Itv, Itv, Itv *); |
void cupitvp(Itv, Itv, Itv *); |
| void capitvp(Itv, Itv, Itv *); |
void capitvp(Itv, Itv, Itv *); |
| void widthitvp(Itv, Num *); |
void widthitvp(Itv, Num *); |
| |
void absitvp(Itv, Num *); |
| void distanceitvp(Itv, Itv, Num *); |
void distanceitvp(Itv, Itv, Num *); |
| |
|
| void ToBf(Num, BF *); |
|
| void double2bf(double, BF *); |
|
| double bf2double(BF); |
|
| void addulp(IntervalBigFloat, IntervalBigFloat *); |
|
| void getulp(BF, BF *); |
|
| |
|
| |
/*** engine/f-itv.c ***/ |
| |
|
| |
//void ToBf(Num, BF *); |
| |
//void double2bf(double, BF *); |
| |
//double bf2double(BF); |
| |
//void addulp(IntervalBigFloat, IntervalBigFloat *); |
| |
//void getulp(BF, BF *); |
| |
|
| void additvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
void additvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
| void subitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
void subitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
| void mulitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
void mulitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
| void divitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
void divitvf(IntervalBigFloat, IntervalBigFloat, IntervalBigFloat *); |
| void chsgnitvf(Itv, Itv *); |
void chsgnitvf(IntervalBigFloat, IntervalBigFloat *); |
| |
int initvf(Num, Itv); |
| |
int itvinitvf(Itv, Itv); |
| int cmpitvf(Itv, Itv); |
int cmpitvf(Itv, Itv); |
| void pwritvf(Itv, Num, Itv *); |
void pwritvf(Itv, Num, Itv *); |
| void pwritv0f(Itv, int, Itv *); |
void pwritv0f(Itv, int, Itv *); |
| |
void miditvf(Itv, Num *); |
| |
void cupitvf(Itv, Itv, Itv *); |
| |
void capitvf(Itv, Itv, Itv *); |
| |
void widthitvf(Itv, Num *); |
| |
void absitvf(Itv, Num *); |
| |
void distanceitvf(Itv, Itv, Num *); |
| |
|
| /*** engine/d-itv.c ***/ |
/*** engine/d-itv.c ***/ |
| double ToRealDown(Num); |
double ToRealDown(Num); |
| Line 266 void subitvd(Num, Num, IntervalDouble *); |
|
| Line 296 void subitvd(Num, Num, IntervalDouble *); |
|
| void mulitvd(Num, Num, IntervalDouble *); |
void mulitvd(Num, Num, IntervalDouble *); |
| void divitvd(Num, Num, IntervalDouble *); |
void divitvd(Num, Num, IntervalDouble *); |
| void chsgnitvd(IntervalDouble, IntervalDouble *); |
void chsgnitvd(IntervalDouble, IntervalDouble *); |
| |
int initvd(Num, IntervalDouble); |
| int cmpitvd(IntervalDouble, IntervalDouble); |
int cmpitvd(IntervalDouble, IntervalDouble); |
| void pwritvd(Num, Num, IntervalDouble *); |
void pwritvd(Num, Num, IntervalDouble *); |
| void pwritv0d(IntervalDouble, int, IntervalDouble *); |
void pwritv0d(IntervalDouble, int, IntervalDouble *); |