source: vis_dev/glu-2.3/src/epd/epd.h @ 91

Last change on this file since 91 was 13, checked in by cecile, 13 years ago

library glu 2.3

File size: 7.0 KB
Line 
1/**CHeaderFile*****************************************************************
2
3  FileName    [epd.h]
4
5  PackageName [epd]
6
7  Synopsis    [The University of Colorado extended double precision package.]
8
9  Description [arithmetic functions with extended double precision.]
10
11  SeeAlso     []
12
13  Author      [In-Ho Moon]
14
15  Copyright   [Copyright (c) 1995-2004, Regents of the University of Colorado
16
17  All rights reserved.
18
19  Redistribution and use in source and binary forms, with or without
20  modification, are permitted provided that the following conditions
21  are met:
22
23  Redistributions of source code must retain the above copyright
24  notice, this list of conditions and the following disclaimer.
25
26  Redistributions in binary form must reproduce the above copyright
27  notice, this list of conditions and the following disclaimer in the
28  documentation and/or other materials provided with the distribution.
29
30  Neither the name of the University of Colorado nor the names of its
31  contributors may be used to endorse or promote products derived from
32  this software without specific prior written permission.
33
34  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
37  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
38  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
39  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
40  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
41  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
42  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
43  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
44  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45  POSSIBILITY OF SUCH DAMAGE.]
46
47  Revision    [$Id: epd.h,v 1.9 2004/08/13 18:20:30 fabio Exp $]
48
49******************************************************************************/
50
51#ifndef _EPD
52#define _EPD
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58/*---------------------------------------------------------------------------*/
59/* Constant declarations                                                     */
60/*---------------------------------------------------------------------------*/
61
62#define EPD_MAX_BIN     1023
63#define EPD_MAX_DEC     308
64#define EPD_EXP_INF     0x7ff
65
66/*---------------------------------------------------------------------------*/
67/* Structure declarations                                                    */
68/*---------------------------------------------------------------------------*/
69
70/**Struct**********************************************************************
71
72  Synopsis    [IEEE double struct.]
73
74  Description [IEEE double struct.]
75
76  SeeAlso     []
77
78******************************************************************************/
79#ifdef  EPD_BIG_ENDIAN
80struct IeeeDoubleStruct {       /* BIG_ENDIAN */
81  unsigned int sign: 1;
82  unsigned int exponent: 11;
83  unsigned int mantissa0: 20;
84  unsigned int mantissa1: 32;
85};
86#else
87struct IeeeDoubleStruct {       /* LITTLE_ENDIAN */
88  unsigned int mantissa1: 32;
89  unsigned int mantissa0: 20;
90  unsigned int exponent: 11;
91  unsigned int sign: 1;
92};
93#endif
94
95/**Struct**********************************************************************
96
97  Synopsis    [IEEE double NaN struct.]
98
99  Description [IEEE double NaN struct.]
100
101  SeeAlso     []
102
103******************************************************************************/
104#ifdef  EPD_BIG_ENDIAN
105struct IeeeNanStruct {  /* BIG_ENDIAN */
106  unsigned int sign: 1;
107  unsigned int exponent: 11;
108  unsigned int quiet_bit: 1;
109  unsigned int mantissa0: 19;
110  unsigned int mantissa1: 32;
111};
112#else
113struct IeeeNanStruct {  /* LITTLE_ENDIAN */
114  unsigned int mantissa1: 32;
115  unsigned int mantissa0: 19;
116  unsigned int quiet_bit: 1;
117  unsigned int exponent: 11;
118  unsigned int sign: 1;
119};
120#endif
121
122/**Struct**********************************************************************
123
124  Synopsis    [Extended precision double to keep very large value.]
125
126  Description [Extended precision double to keep very large value.]
127
128  SeeAlso     []
129
130******************************************************************************/
131union EpTypeUnion {
132  double                        value;
133  struct IeeeDoubleStruct       bits;
134  struct IeeeNanStruct          nan;
135};
136
137struct EpDoubleStruct {
138  union EpTypeUnion             type;
139  int                           exponent;
140};
141
142/*---------------------------------------------------------------------------*/
143/* Type declarations                                                         */
144/*---------------------------------------------------------------------------*/
145typedef struct EpDoubleStruct EpDouble;
146typedef struct IeeeDoubleStruct IeeeDouble;
147typedef struct IeeeNanStruct IeeeNan;
148typedef union EpTypeUnion EpType;
149
150/**AutomaticStart*************************************************************/
151
152/*---------------------------------------------------------------------------*/
153/* Function prototypes                                                       */
154/*---------------------------------------------------------------------------*/
155
156extern EpDouble *EpdAlloc(void);
157extern int EpdCmp(const char *key1, const char *key2);
158extern void EpdFree(EpDouble *epd);
159extern void EpdGetString(EpDouble *epd, char *str);
160extern void EpdConvert(double value, EpDouble *epd);
161extern void EpdMultiply(EpDouble *epd1, double value);
162extern void EpdMultiply2(EpDouble *epd1, EpDouble *epd2);
163extern void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2);
164extern void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
165extern void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
166extern void EpdDivide(EpDouble *epd1, double value);
167extern void EpdDivide2(EpDouble *epd1, EpDouble *epd2);
168extern void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
169extern void EpdAdd(EpDouble *epd1, double value);
170extern void EpdAdd2(EpDouble *epd1, EpDouble *epd2);
171extern void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
172extern void EpdSubtract(EpDouble *epd1, double value);
173extern void EpdSubtract2(EpDouble *epd1, EpDouble *epd2);
174extern void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
175extern void EpdPow2(int n, EpDouble *epd);
176extern void EpdPow2Decimal(int n, EpDouble *epd);
177extern void EpdNormalize(EpDouble *epd);
178extern void EpdNormalizeDecimal(EpDouble *epd);
179extern void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent);
180extern int EpdGetExponent(double value);
181extern int EpdGetExponentDecimal(double value);
182extern void EpdMakeInf(EpDouble *epd, int sign);
183extern void EpdMakeZero(EpDouble *epd, int sign);
184extern void EpdMakeNan(EpDouble *epd);
185extern void EpdCopy(EpDouble *from, EpDouble *to);
186extern int EpdIsInf(EpDouble *epd);
187extern int EpdIsZero(EpDouble *epd);
188extern int EpdIsNan(EpDouble *epd);
189extern int EpdIsNanOrInf(EpDouble *epd);
190extern int IsInfDouble(double value);
191extern int IsNanDouble(double value);
192extern int IsNanOrInfDouble(double value);
193
194/**AutomaticEnd***************************************************************/
195
196#ifdef __cplusplus
197}
198#endif
199
200#endif /* _EPD */
Note: See TracBrowser for help on using the repository browser.