[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.2

1.1       saito       1: /*
1.2     ! saito       2:  * $OpenXM: OpenXM_contrib2/asir2000/include/interval.h,v 1.1 2000/12/22 10:03:29 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
                    100: #define N_IP   (N_B+1)
                    101: #define N_ID   (N_B+2)
                    102: #define N_IT   (N_B+3)
                    103: #define N_IF   (N_B+4)
                    104: #define N_PRE_C        N_IF
                    105: #define N_C    (N_B+5)
                    106: #define N_M    (N_B+6)
                    107: #define N_LM   (N_B+7)
                    108: #define N_GF2N (N_B+8)
                    109: #define N_GFPN (N_B+9)
                    110:
                    111: /* data structures */
                    112: struct oItv {
                    113:         short  id;
                    114:         char   nid;
                    115:         char   pad;
                    116:         Num    inf;
                    117:         Num    sup;
                    118: };
                    119:
                    120: typedef struct oItv *Itv;
                    121:
                    122: struct oItvD {
                    123:         short  id;
                    124:         char   nid;
                    125:         char   pad;
                    126:         double inf;
                    127:         double sup;
                    128: };
                    129:
                    130: typedef struct oItvD *ItvD;
                    131:
                    132: struct oforth {
                    133:        short   sign;
                    134:        short   exp;
                    135:        double  u;
                    136:        double  l;
                    137: };
                    138:
                    139: typedef struct oforth *forth;
                    140:
                    141: struct oItvT {
                    142:         short  id;
                    143:         char   nid;
                    144:         char   pad;
                    145:         forth  inf;
                    146:         forth  sup;
                    147: };
                    148:
                    149: typedef struct oItvT *ItvT;
                    150:
                    151: struct oItvF {
                    152:         short  id;
                    153:         char   nid;
                    154:         char   pad;
                    155:         BF     inf;
                    156:         BF     sup;
                    157: };
                    158:
                    159: typedef struct oItvF *ItvF;
                    160:
                    161: extern int zerorewrite;
                    162:
                    163: /* general macros */
                    164: #define INF(p) ((p)->inf)
                    165: #define SUP(p) ((p)->sup)
                    166:
                    167: #define NEWItvP(q)     ((q)=(Itv)MALLOC(sizeof(struct oItv)),\
                    168:                                        OID(q)=O_N,NID(q)=N_IP)
                    169: #define NEWItvD(q)     ((q)=(ItvD)MALLOC(sizeof(struct oItvD)),\
                    170:                                        OID(q)=O_N,NID(q)=N_ID)
                    171: #define NEWItvT(q)     ((q)=(ItvD)MALLOC(sizeof(struct oItvT)),\
                    172:                                        OID(q)=O_N,NID(q)=N_IT)
                    173: #define NEWItvF(q)     ((q)=(ItvF)MALLOC(sizeof(struct oItvF)),\
                    174:                                        OID(q)=O_N,NID(q)=N_IF)
                    175: #define MKItvP(a,b,c)  (NEWItvP(c),(INF(c)=(a),SUP(c)=(b)))
                    176: #define MKItvD(a,b,c)  if((zerorewrite) && ((a)<=0.0) && ((b)>=0.0)) (c)=0;\
                    177:                        else (NEWItvD(c),(INF(c)=(a),SUP(c)=(b)))
                    178: #define MKItvT(a,b,c)  (NEWItvT(c),(INF(c)=(a),SUP(c)=(b)))
                    179: #define MKItvF(a,b,c)  (NEWItvF(c),(INF(c)=(a),SUP(c)=(b)))
                    180:
                    181: #define ToItvP(a,c)    (NEWItvP(c),INF(c)=(a),SUP(c)=(a))
                    182: #define ToItvD(a,c)    (NEWItvD(c),INF(c)=(ToReal(a)),SUP(c)=(ToReal(a)))
                    183: #define ToItvF(a,c)    (NEWItvF(c),INF(c)=(a),SUP(c)=(a))
                    184:
                    185: #define ITVP(a) (NID(a)==N_IP)
                    186: #define ITVD(a) (NID(a)==N_ID)
                    187: #define ITVT(a) (NID(a)==N_IT)
                    188: #define ITVF(a) (NID(a)==N_IF)
                    189:
                    190: /***    engine/itv.c    ***/
                    191: double  ToRealSup(Num);
                    192: double  ToRealInf(Num);
                    193: double  RatnToRealUp(Q);
                    194: double  NatToRealUp(N, int *);
                    195:
                    196: void   double2bf(double, BF *);
                    197: double bf2double(BF);
                    198:
                    199: void   itvtois(Itv, Num *, Num *);
                    200: void   istoitv(Num, Num, Itv *);
                    201:
                    202: #if 0
                    203: void    additv(Num, Num, Num *);
                    204: void    subitv(Num, Num, Num *);
                    205: void    mulitv(Num, Num, Num *);
                    206: int     initv(Num, double);
                    207: int     itvinitv(Itv, Itv);
                    208: void    divitv(Num, Num, Num *);
                    209: void    sqrtitv(Num, Num *);
                    210: void    pwritv(Num, Num, Num *);
                    211: void    pwritv0(Itv, int, Itv *);
                    212: void    chsgnitv(Num, Num *);
                    213: void    miditv(Itv, Num *);
                    214: int     cmpitv(Itv, Itv);
                    215: void    cupitv(Itv, Itv, Itv *);
                    216: void    capitv(Itv, Itv, Itv *);
                    217: void    widthitv(Itv, Num *);
                    218: void    distanceitv(Itv, Itv, Num *);
                    219: #endif
                    220:
                    221: void    additvp(Itv, Itv, Itv *);
                    222: void    subitvp(Itv, Itv, Itv *);
                    223: void    mulitvp(Itv, Itv, Itv *);
                    224: void    divitvp(Itv, Itv, Itv *);
                    225: void    chsgnitvp(Itv, Itv *);
                    226: int     cmpitvp(Itv, Itv);
                    227: void    pwritvp(Itv, Num, Itv *);
                    228: void    pwritv0p(Itv, int, Itv *);
                    229: void    cupitvp(Itv, Itv, Itv *);
                    230: void    capitvp(Itv, Itv, Itv *);
                    231: void    widthitvp(Itv, Num *);
                    232: void    distanceitvp(Itv, Itv, Num *);
                    233:
                    234: void   ToBf(Num, BF *);
                    235: void   double2bf(double, BF *);
                    236: double bf2double(BF);
                    237: void   addulp(ItvF, ItvF *);
                    238: void   getulp(BF, BF *);
                    239:
                    240: void    additvf(ItvF, ItvF, ItvF *);
                    241: void    subitvf(ItvF, ItvF, ItvF *);
                    242: void    mulitvf(ItvF, ItvF, ItvF *);
                    243: void    divitvf(ItvF, ItvF, ItvF *);
                    244: void    chsgnitvf(Itv, Itv *);
                    245: int     cmpitvf(Itv, Itv);
                    246: void    pwritvf(Itv, Num, Itv *);
                    247: void    pwritv0f(Itv, int, Itv *);
                    248:
                    249: /***    engine/d-itv.c    ***/
                    250: double ToRealDown(Num);
                    251: double ToRealUp(Num);
                    252: void   Num2double(Num, double *, double *);
                    253:
                    254: void    additvd(Num, Num, ItvD *);
                    255: void    subitvd(Num, Num, ItvD *);
                    256: void    mulitvd(Num, Num, ItvD *);
                    257: void    divitvd(Num, Num, ItvD *);
                    258: void    chsgnitvd(ItvD, ItvD *);
                    259: int     cmpitvd(ItvD, ItvD);
                    260: void    pwritvd(Num, Num, ItvD *);
                    261: void    pwritv0d(ItvD, int, ItvD *);
                    262: void    miditvd(ItvD, Num *);
                    263: void    cupitvd(ItvD, ItvD, ItvD *);
                    264: void    capitvd(ItvD, ItvD, ItvD *);
                    265: void    widthitvd(ItvD, Num *);
                    266: void    absitvd(ItvD, Num *);
                    267: void    distanceitvd(ItvD, ItvD, Num *);
                    268:
                    269: #endif /* end of INTERVAL */
                    270: #endif /* end of _INTERVAL_H */

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