[BACK]Return to interval.h CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / include

Annotation of OpenXM_contrib2/asir2000/include/interval.h, Revision 1.3

1.1       saito       1: /*
1.3     ! noro        2:  * $OpenXM: OpenXM_contrib2/asir2000/include/interval.h,v 1.2 2000/12/23 11:36:49 saito Exp $
1.1       saito       3: */
                      4: #ifndef        _INTERVAL_H
                      5: #define        _INTERVAL_H
                      6:
                      7: #define        PRINTF_G        0
                      8: #define        PRINTF_E        1
                      9:
                     10: #if defined(INTERVAL)
                     11:
                     12: #include <math.h>
                     13:
                     14: #ifdef sun
                     15: #if OSMajorVersion < 4 || (OSMajorVersion == 4 && OSMinorVersion < 1)
                     16: #include <sys/ieeefp.h>
                     17: #endif
                     18: #if defined(__svr4__)
                     19: #include       <ieeefp.h>
                     20: #define        FPNEAREST       fpsetround(FP_RN);
                     21: #define        FPPLUSINF       fpsetround(FP_RP);
                     22: #define        FPMINUSINF      fpsetround(FP_RM);
                     23: #define        FPTOZERO        fpsetround(FP_RZ);
                     24: #else
                     25: static char    *Interval_dummy;
                     26: #define        FPNEAREST       ieee_flags("clear", "direction", Interval_dummy, &Interval_dummy);
                     27: #define        FPPLUSINF       ieee_flags("set", "direction", "positive", &Interval_dummy);
                     28: #define        FPMINUSINF      ieee_flags("set", "direction", "negative", &Interval_dummy);
                     29: #define        FPTOZERO        ieee_flags("set", "direction", "tozero", &Interval_dummy);
                     30: #endif
                     31: #endif
                     32:
                     33: #ifdef linux
                     34: #include       <fpu_control.h>
1.2       saito      35: #if 1
                     36: #define        LINUX_FPU_RC_MASK                               0xf3ff
                     37: #define        LINUX_FPU_SETCW(c)                      {_FPU_GETCW(__fpu_control);\
                     38:                                _FPU_SETCW(__fpu_control & LINUX_FPU_RC_MASK | c);}
                     39: #define        FPNEAREST       LINUX_FPU_SETCW(_FPU_RC_NEAREST);
                     40: #define        FPPLUSINF       LINUX_FPU_SETCW(_FPU_RC_UP);
                     41: #define        FPMINUSINF      LINUX_FPU_SETCW(_FPU_RC_DOWN);
                     42: #define        FPTOZERO                LINUX_FPU_SETCW(_FPU_RC_ZERO);
                     43: #else
1.1       saito      44: #define        _FPU_DEFAULT_p_FPU_RC_UP        0x1b72
                     45: #define        _FPU_DEFAULT_p_FPU_RC_DOWN      0x1772
                     46: #define        _FPU_DEFAULT_p_FPU_RC_ZERO      0x1f72
                     47: #define        FPNEAREST       __setfpucw(_FPU_DEFAULT);
                     48: #define        FPPLUSINF       __setfpucw(_FPU_DEFAULT_p_FPU_RC_UP);
                     49: #define        FPMINUSINF      __setfpucw(_FPU_DEFAULT_p_FPU_RC_DOWN);
                     50: #define        FPTOZERO        __setfpucw(_FPU_DEFAULT_p_FPU_RC_ZERO);
1.2       saito      51: #endif
1.1       saito      52: #endif
                     53:
                     54: #if defined(__osf__)
                     55: #if 0
                     56: #include       <float.h>
                     57: #define        FPNEAREST       write_rnd(FP_RND_RN);
                     58: #define        FPPLUSINF       write_rnd(FP_RND_RP);
                     59: #define        FPMINUSINF      write_rnd(FP_RND_RM);
                     60: #define        FPTOZERO        write_rnd(FP_RND_RZ);
                     61: #else
                     62: #define        FPNEAREST
                     63: #define        FPPLUSINF
                     64: #define        FPMINUSINF
                     65: #define        FPTOZERO
                     66: #endif
                     67: #endif
                     68:
                     69: #if defined(__FreeBSD__)
                     70: #include       <floatingpoint.h>
                     71: #define        FPNEAREST       fpsetround(FP_RN);
                     72: #define        FPPLUSINF       fpsetround(FP_RP);
                     73: #define        FPMINUSINF      fpsetround(FP_RM);
                     74: #define        FPTOZERO        fpsetround(FP_RZ);
                     75: #endif
                     76:
                     77: /* no control function of floating point rounding */
                     78: #ifndef FPNEAREST
                     79: #define        FPNEAREST       fprintf(stderr, "Fpu control FPNEAREST is not supported in this machine yet.\n");
                     80: #endif
                     81: #ifndef FPMINUSINF
                     82: #define        FPMINUSINF      fprintf(stderr, "Fpu control FPMINUSINF is not supported in this machine yet.\n");
                     83: #endif
                     84: #ifndef FPPLUSINF
                     85: #define        FPPLUSINF       fprintf(stderr, "Fpu control FPPLUSINF is not supported in this machine yet.\n");
                     86: #endif
                     87: #ifndef FPTOZERO
                     88: #define        FPTOZERO        fprintf(stderr, "Fpu control FPZERO is not supported in this machine yet.\n");
                     89: #endif
                     90: #define FPCLEAR                FPNEAREST
                     91:
                     92: #define        MID_PRINTF_G    2
                     93: #define        MID_PRINTF_E    3
                     94:
                     95: #undef  N_C
                     96: #undef  N_M
                     97: #undef  N_LM
                     98: #undef  N_GF2N
                     99: #undef  N_GFPN
1.3     ! noro      100: #undef  N_GFS
1.1       saito     101: #define N_IP   (N_B+1)
                    102: #define N_ID   (N_B+2)
                    103: #define N_IT   (N_B+3)
                    104: #define N_IF   (N_B+4)
                    105: #define N_PRE_C        N_IF
                    106: #define N_C    (N_B+5)
                    107: #define N_M    (N_B+6)
                    108: #define N_LM   (N_B+7)
                    109: #define N_GF2N (N_B+8)
                    110: #define N_GFPN (N_B+9)
1.3     ! noro      111: #define N_GFS  (N_B+10)
1.1       saito     112:
                    113: /* data structures */
                    114: struct oItv {
                    115:         short  id;
                    116:         char   nid;
                    117:         char   pad;
                    118:         Num    inf;
                    119:         Num    sup;
                    120: };
                    121:
                    122: typedef struct oItv *Itv;
                    123:
                    124: struct oItvD {
                    125:         short  id;
                    126:         char   nid;
                    127:         char   pad;
                    128:         double inf;
                    129:         double sup;
                    130: };
                    131:
                    132: typedef struct oItvD *ItvD;
                    133:
                    134: struct oforth {
                    135:        short   sign;
                    136:        short   exp;
                    137:        double  u;
                    138:        double  l;
                    139: };
                    140:
                    141: typedef struct oforth *forth;
                    142:
                    143: struct oItvT {
                    144:         short  id;
                    145:         char   nid;
                    146:         char   pad;
                    147:         forth  inf;
                    148:         forth  sup;
                    149: };
                    150:
                    151: typedef struct oItvT *ItvT;
                    152:
                    153: struct oItvF {
                    154:         short  id;
                    155:         char   nid;
                    156:         char   pad;
                    157:         BF     inf;
                    158:         BF     sup;
                    159: };
                    160:
                    161: typedef struct oItvF *ItvF;
                    162:
                    163: extern int zerorewrite;
                    164:
                    165: /* general macros */
                    166: #define INF(p) ((p)->inf)
                    167: #define SUP(p) ((p)->sup)
                    168:
                    169: #define NEWItvP(q)     ((q)=(Itv)MALLOC(sizeof(struct oItv)),\
                    170:                                        OID(q)=O_N,NID(q)=N_IP)
                    171: #define NEWItvD(q)     ((q)=(ItvD)MALLOC(sizeof(struct oItvD)),\
                    172:                                        OID(q)=O_N,NID(q)=N_ID)
                    173: #define NEWItvT(q)     ((q)=(ItvD)MALLOC(sizeof(struct oItvT)),\
                    174:                                        OID(q)=O_N,NID(q)=N_IT)
                    175: #define NEWItvF(q)     ((q)=(ItvF)MALLOC(sizeof(struct oItvF)),\
                    176:                                        OID(q)=O_N,NID(q)=N_IF)
                    177: #define MKItvP(a,b,c)  (NEWItvP(c),(INF(c)=(a),SUP(c)=(b)))
                    178: #define MKItvD(a,b,c)  if((zerorewrite) && ((a)<=0.0) && ((b)>=0.0)) (c)=0;\
                    179:                        else (NEWItvD(c),(INF(c)=(a),SUP(c)=(b)))
                    180: #define MKItvT(a,b,c)  (NEWItvT(c),(INF(c)=(a),SUP(c)=(b)))
                    181: #define MKItvF(a,b,c)  (NEWItvF(c),(INF(c)=(a),SUP(c)=(b)))
                    182:
                    183: #define ToItvP(a,c)    (NEWItvP(c),INF(c)=(a),SUP(c)=(a))
                    184: #define ToItvD(a,c)    (NEWItvD(c),INF(c)=(ToReal(a)),SUP(c)=(ToReal(a)))
                    185: #define ToItvF(a,c)    (NEWItvF(c),INF(c)=(a),SUP(c)=(a))
                    186:
                    187: #define ITVP(a) (NID(a)==N_IP)
                    188: #define ITVD(a) (NID(a)==N_ID)
                    189: #define ITVT(a) (NID(a)==N_IT)
                    190: #define ITVF(a) (NID(a)==N_IF)
                    191:
                    192: /***    engine/itv.c    ***/
                    193: double  ToRealSup(Num);
                    194: double  ToRealInf(Num);
                    195: double  RatnToRealUp(Q);
                    196: double  NatToRealUp(N, int *);
                    197:
                    198: void   double2bf(double, BF *);
                    199: double bf2double(BF);
                    200:
                    201: void   itvtois(Itv, Num *, Num *);
                    202: void   istoitv(Num, Num, Itv *);
                    203:
                    204: #if 0
                    205: void    additv(Num, Num, Num *);
                    206: void    subitv(Num, Num, Num *);
                    207: void    mulitv(Num, Num, Num *);
                    208: int     initv(Num, double);
                    209: int     itvinitv(Itv, Itv);
                    210: void    divitv(Num, Num, Num *);
                    211: void    sqrtitv(Num, Num *);
                    212: void    pwritv(Num, Num, Num *);
                    213: void    pwritv0(Itv, int, Itv *);
                    214: void    chsgnitv(Num, Num *);
                    215: void    miditv(Itv, Num *);
                    216: int     cmpitv(Itv, Itv);
                    217: void    cupitv(Itv, Itv, Itv *);
                    218: void    capitv(Itv, Itv, Itv *);
                    219: void    widthitv(Itv, Num *);
                    220: void    distanceitv(Itv, Itv, Num *);
                    221: #endif
                    222:
                    223: void    additvp(Itv, Itv, Itv *);
                    224: void    subitvp(Itv, Itv, Itv *);
                    225: void    mulitvp(Itv, Itv, Itv *);
                    226: void    divitvp(Itv, Itv, Itv *);
                    227: void    chsgnitvp(Itv, Itv *);
                    228: int     cmpitvp(Itv, Itv);
                    229: void    pwritvp(Itv, Num, Itv *);
                    230: void    pwritv0p(Itv, int, Itv *);
                    231: void    cupitvp(Itv, Itv, Itv *);
                    232: void    capitvp(Itv, Itv, Itv *);
                    233: void    widthitvp(Itv, Num *);
                    234: void    distanceitvp(Itv, Itv, Num *);
                    235:
                    236: void   ToBf(Num, BF *);
                    237: void   double2bf(double, BF *);
                    238: double bf2double(BF);
                    239: void   addulp(ItvF, ItvF *);
                    240: void   getulp(BF, BF *);
                    241:
                    242: void    additvf(ItvF, ItvF, ItvF *);
                    243: void    subitvf(ItvF, ItvF, ItvF *);
                    244: void    mulitvf(ItvF, ItvF, ItvF *);
                    245: void    divitvf(ItvF, ItvF, ItvF *);
                    246: void    chsgnitvf(Itv, Itv *);
                    247: int     cmpitvf(Itv, Itv);
                    248: void    pwritvf(Itv, Num, Itv *);
                    249: void    pwritv0f(Itv, int, Itv *);
                    250:
                    251: /***    engine/d-itv.c    ***/
                    252: double ToRealDown(Num);
                    253: double ToRealUp(Num);
                    254: void   Num2double(Num, double *, double *);
                    255:
                    256: void    additvd(Num, Num, ItvD *);
                    257: void    subitvd(Num, Num, ItvD *);
                    258: void    mulitvd(Num, Num, ItvD *);
                    259: void    divitvd(Num, Num, ItvD *);
                    260: void    chsgnitvd(ItvD, ItvD *);
                    261: int     cmpitvd(ItvD, ItvD);
                    262: void    pwritvd(Num, Num, ItvD *);
                    263: void    pwritv0d(ItvD, int, ItvD *);
                    264: void    miditvd(ItvD, Num *);
                    265: void    cupitvd(ItvD, ItvD, ItvD *);
                    266: void    capitvd(ItvD, ItvD, ItvD *);
                    267: void    widthitvd(ItvD, Num *);
                    268: void    absitvd(ItvD, Num *);
                    269: void    distanceitvd(ItvD, ItvD, Num *);
                    270:
                    271: #endif /* end of INTERVAL */
                    272: #endif /* end of _INTERVAL_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>