Structural deformable models
airnan.h
Go to the documentation of this file.
1 #ifndef _AIRNAN_H_
2 #define _AIRNAN_H_
3 
4 /* ---- begin of: stuff taken from Gordon Kindlman's teem/air lib */
5 #ifdef IRIX
6 #define TEEM_QNANHIBIT 0
7 #else
8 #define TEEM_QNANHIBIT 1
9 #endif
10 
11 /*
12 make/cygwin.mk:TEEM_ENDIAN = 1234
13 make/darwin.mk:TEEM_ENDIAN = 4321
14 make/irix6.mk:TEEM_ENDIAN = 4321
15 make/linux.mk:TEEM_ENDIAN = 1234
16 make/solaris.mk:TEEM_ENDIAN = 4321
17 */
18 #define TEEM_ENDIAN 1234
19 
20 #ifdef WIN32
21 typedef signed __int64 airLLong;
22 typedef unsigned __int64 airULLong;
23 #else
24 typedef signed long long airLLong;
25 typedef unsigned long long airULLong;
26 #endif
27 
28 /* ---- begin of: stuff taken from Gordon Kindlman's teem/air lib */
29 /* 754.c: IEEE-754 related stuff values */
30 typedef union {
31  unsigned int i;
32  float f;
33 } airFloat;
34 typedef union {
36  double d;
37 } airDouble;
38 
39 /*
40 ** _airFloat, _airDouble
41 **
42 ** these unions facilitate converting amonst
43 ** i: unsigned integral type
44 ** c: (sign,exp,frac) triples of unsigned integral components
45 ** v: the floating point numbers these bit-patterns represent
46 */
47 typedef union {
48  unsigned int i;
49  struct {
50 #if TEEM_ENDIAN == 1234
51  unsigned int frac : 23;
52  unsigned int exp : 8;
53  unsigned int sign : 1;
54 #else
55  unsigned int sign : 1;
56  unsigned int exp : 8;
57  unsigned int frac : 23;
58 #endif
59  } c;
60  float v;
61 } _airFloat;
62 
63 /*
64 ** The hex numbers in braces are examples of C's "initial member of a union"
65 ** aggregate initialization. We'd be totally out of luck without this.
66 */
67 
68 #if TEEM_QNANHIBIT == 1
69 static const int airMyQNaNHiBit = 1;
70 static const airFloat airFloatNaN = {0x7fffffff};
71 static const airFloat airFloatQNaN = {0x7fffffff};
72 static const airFloat airFloatSNaN = {0x7fbfffff};
73 #else
74 static const int airMyQNaNHiBit = 0;
75 static const airFloat airFloatNaN = {0x7fbfffff};
76 static const airFloat airFloatQNaN = {0x7fbfffff};
77 static const airFloat airFloatSNaN = {0x7fffffff};
78 #endif
79 
80 #define AIR_NAN (airFloatNaN.f) /* same as airFloatQNaN.f */
81 #define AIR_QNAN (airFloatQNaN.f)
82 
83 /*
84 ******** airIsNaN()
85 **
86 ** returns 1 if input is either kind of NaN, 0 otherwise. It is okay
87 ** to only have a a float version of this function, as opposed to
88 ** having one for float and one for double, because Section 6.2 of the
89 ** 754 spec tells us that that NaN is to be preserved across precision
90 ** changes.
91 */
92 inline int
93 airIsNaN(float g) {
94  _airFloat f;
95 
96  f.v = g;
97  return (255 == f.c.exp && f.c.frac);
98 }
99 
100 /* ---- end of: stuff taken from Gordon Kindlman's teem/air lib */
101 
102 #endif
unsigned int i
Definition: airnan.h:31
float f
Definition: airnan.h:32
struct _airFloat::@0 c
double d
Definition: airnan.h:36
unsigned int i
Definition: airnan.h:48
signed long long airLLong
Definition: airnan.h:24
static const airFloat airFloatNaN
Definition: airnan.h:70
static const int airMyQNaNHiBit
Definition: airnan.h:69
unsigned int exp
Definition: airnan.h:52
int airIsNaN(float g)
Definition: airnan.h:93
unsigned int frac
Definition: airnan.h:51
static const airFloat airFloatQNaN
Definition: airnan.h:71
airULLong i
Definition: airnan.h:35
float v
Definition: airnan.h:60
unsigned long long airULLong
Definition: airnan.h:25
static const airFloat airFloatSNaN
Definition: airnan.h:72