abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
epd.h
Go to the documentation of this file.
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 ABC__bdd__epd__epd_h
52 #define ABC__bdd__epd__epd_h
53 
55 
56 /*---------------------------------------------------------------------------*/
57 /* Constant declarations */
58 /*---------------------------------------------------------------------------*/
59 
60 #define EPD_MAX_BIN 1023
61 #define EPD_MAX_DEC 308
62 #define EPD_EXP_INF 0x7ff
63 
64 /*---------------------------------------------------------------------------*/
65 /* Structure declarations */
66 /*---------------------------------------------------------------------------*/
67 
68 /**Struct**********************************************************************
69 
70  Synopsis [IEEE double struct.]
71 
72  Description [IEEE double struct.]
73 
74  SeeAlso []
75 
76 ******************************************************************************/
77 #ifdef EPD_BIG_ENDIAN
78 struct IeeeDoubleStruct { /* BIG_ENDIAN */
79  unsigned int sign: 1;
80  unsigned int exponent: 11;
81  unsigned int mantissa0: 20;
82  unsigned int mantissa1: 32;
83 };
84 #else
85 struct IeeeDoubleStruct { /* LITTLE_ENDIAN */
86  unsigned int mantissa1: 32;
87  unsigned int mantissa0: 20;
88  unsigned int exponent: 11;
89  unsigned int sign: 1;
90 };
91 #endif
92 
93 /**Struct**********************************************************************
94 
95  Synopsis [IEEE double NaN struct.]
96 
97  Description [IEEE double NaN struct.]
98 
99  SeeAlso []
100 
101 ******************************************************************************/
102 #ifdef EPD_BIG_ENDIAN
103 struct IeeeNanStruct { /* BIG_ENDIAN */
104  unsigned int sign: 1;
105  unsigned int exponent: 11;
106  unsigned int quiet_bit: 1;
107  unsigned int mantissa0: 19;
108  unsigned int mantissa1: 32;
109 };
110 #else
111 struct IeeeNanStruct { /* LITTLE_ENDIAN */
112  unsigned int mantissa1: 32;
113  unsigned int mantissa0: 19;
114  unsigned int quiet_bit: 1;
115  unsigned int exponent: 11;
116  unsigned int sign: 1;
117 };
118 #endif
119 
120 /**Struct**********************************************************************
121 
122  Synopsis [Extended precision double to keep very large value.]
123 
124  Description [Extended precision double to keep very large value.]
125 
126  SeeAlso []
127 
128 ******************************************************************************/
129 union EpTypeUnion {
130  double value;
133 };
134 
137  int exponent;
138 };
139 
140 /*---------------------------------------------------------------------------*/
141 /* Type declarations */
142 /*---------------------------------------------------------------------------*/
143 typedef struct EpDoubleStruct EpDouble;
145 typedef struct IeeeNanStruct IeeeNan;
146 typedef union EpTypeUnion EpType;
147 
148 /**AutomaticStart*************************************************************/
149 
150 /*---------------------------------------------------------------------------*/
151 /* Function prototypes */
152 /*---------------------------------------------------------------------------*/
153 
154 extern EpDouble *EpdAlloc(void);
155 extern int EpdCmp(const char *key1, const char *key2);
156 extern void EpdFree(EpDouble *epd);
157 extern void EpdGetString(EpDouble *epd, char *str);
158 extern void EpdConvert(double value, EpDouble *epd);
159 extern void EpdMultiply(EpDouble *epd1, double value);
160 extern void EpdMultiply2(EpDouble *epd1, EpDouble *epd2);
161 extern void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2);
162 extern void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
163 extern void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
164 extern void EpdDivide(EpDouble *epd1, double value);
165 extern void EpdDivide2(EpDouble *epd1, EpDouble *epd2);
166 extern void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
167 extern void EpdAdd(EpDouble *epd1, double value);
168 extern void EpdAdd2(EpDouble *epd1, EpDouble *epd2);
169 extern void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
170 extern void EpdSubtract(EpDouble *epd1, double value);
171 extern void EpdSubtract2(EpDouble *epd1, EpDouble *epd2);
172 extern void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3);
173 extern void EpdPow2(int n, EpDouble *epd);
174 extern void EpdPow2Decimal(int n, EpDouble *epd);
175 extern void EpdNormalize(EpDouble *epd);
176 extern void EpdNormalizeDecimal(EpDouble *epd);
177 extern void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent);
178 extern int EpdGetExponent(double value);
179 extern int EpdGetExponentDecimal(double value);
180 extern void EpdMakeInf(EpDouble *epd, int sign);
181 extern void EpdMakeZero(EpDouble *epd, int sign);
182 extern void EpdMakeNan(EpDouble *epd);
183 extern void EpdCopy(EpDouble *from, EpDouble *to);
184 extern int EpdIsInf(EpDouble *epd);
185 extern int EpdIsZero(EpDouble *epd);
186 extern int EpdIsNan(EpDouble *epd);
187 extern int EpdIsNanOrInf(EpDouble *epd);
188 extern int IsInfDouble(double value);
189 extern int IsNanDouble(double value);
190 extern int IsNanOrInfDouble(double value);
191 
192 /**AutomaticEnd***************************************************************/
193 
195 
196 #endif /* _EPD */
int IsNanOrInfDouble(double value)
Definition: epd.c:1333
void EpdMultiply(EpDouble *epd1, double value)
Definition: epd.c:205
double value
Definition: epd.h:130
void EpdDivide(EpDouble *epd1, double value)
Definition: epd.c:386
void EpdFree(EpDouble *epd)
Definition: epd.c:117
int EpdIsNan(EpDouble *epd)
Definition: epd.c:1240
unsigned int sign
Definition: epd.h:89
int EpdIsInf(EpDouble *epd)
Definition: epd.c:1201
unsigned int mantissa1
Definition: epd.h:86
void EpdMultiply2(EpDouble *epd1, EpDouble *epd2)
Definition: epd.c:246
int IsNanDouble(double value)
Definition: epd.c:1305
void EpdMakeInf(EpDouble *epd, int sign)
Definition: epd.c:1115
struct IeeeNanStruct nan
Definition: epd.h:132
bool sign(Lit p)
Definition: SolverTypes.h:61
void EpdMakeNan(EpDouble *epd)
Definition: epd.c:1159
int EpdCmp(const char *key1, const char *key2)
Definition: epd.c:93
unsigned int mantissa0
Definition: epd.h:87
void EpdDivide3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:490
int EpdGetExponent(double value)
Definition: epd.c:1068
void EpdGetValueAndDecimalExponent(EpDouble *epd, double *value, int *exponent)
Definition: epd.c:1034
unsigned int exponent
Definition: epd.h:115
union EpTypeUnion type
Definition: epd.h:136
unsigned int sign
Definition: epd.h:116
void EpdSubtract(EpDouble *epd1, double value)
Definition: epd.c:726
unsigned int mantissa0
Definition: epd.h:113
int EpdIsZero(EpDouble *epd)
Definition: epd.c:1219
unsigned int quiet_bit
Definition: epd.h:114
void EpdGetString(EpDouble *epd, char *str)
Definition: epd.c:135
void EpdConvert(double value, EpDouble *epd)
Definition: epd.c:185
void EpdAdd2(EpDouble *epd1, EpDouble *epd2)
Definition: epd.c:598
void EpdMultiply3Decimal(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:355
void EpdSubtract2(EpDouble *epd1, EpDouble *epd2)
Definition: epd.c:788
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Definition: abc_global.h:105
struct IeeeDoubleStruct bits
Definition: epd.h:131
int IsInfDouble(double value)
Definition: epd.c:1276
void EpdNormalizeDecimal(EpDouble *epd)
Definition: epd.c:1007
#define ABC_NAMESPACE_HEADER_END
Definition: abc_global.h:106
unsigned int exponent
Definition: epd.h:88
void EpdMultiply3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:321
void EpdAdd3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:660
unsigned int mantissa1
Definition: epd.h:112
void EpdPow2(int n, EpDouble *epd)
Definition: epd.c:917
void EpdPow2Decimal(int n, EpDouble *epd)
Definition: epd.c:946
int EpdIsNanOrInf(EpDouble *epd)
Definition: epd.c:1258
void EpdSubtract3(EpDouble *epd1, EpDouble *epd2, EpDouble *epd3)
Definition: epd.c:850
void EpdNormalize(EpDouble *epd)
Definition: epd.c:977
void EpdMakeZero(EpDouble *epd, int sign)
Definition: epd.c:1137
EpDouble * EpdAlloc(void)
Definition: epd.c:72
int value
int EpdGetExponentDecimal(double value)
Definition: epd.c:1091
int exponent
Definition: epd.h:137
void EpdCopy(EpDouble *from, EpDouble *to)
Definition: epd.c:1182
void EpdDivide2(EpDouble *epd1, EpDouble *epd2)
Definition: epd.c:439
void EpdMultiply2Decimal(EpDouble *epd1, EpDouble *epd2)
Definition: epd.c:285
void EpdAdd(EpDouble *epd1, double value)
Definition: epd.c:536