IT++ Logo
itcompat.h
Go to the documentation of this file.
1 
29 #ifndef ITCOMPAT_H
30 #define ITCOMPAT_H
31 
32 #ifndef _MSC_VER
33 # include <itpp/config.h>
34 #else
35 # include <itpp/config_msvc.h>
36 #endif
37 
39 
40 // Microsoft Visual C++ underscore prefixed functions
41 #if defined(_MSC_VER)
42 # include <cfloat>
43 # define finite(x) _finite(x)
44 # define isfinite(x) _finite(x)
45 # define isnan(x) _isnan(x)
46 # define fpclass(x) _fpclass(x)
47 # define FP_NINF _FPCLASS_NINF
48 # define FP_PINF _FPCLASS_PINF
49 # define jn(a, b) _jn(a, b)
50 # define yn(a, b) _yn(a, b)
51 # define j0(a) _j0(a)
52 # define j1(a) _j1(a)
53 #endif // defined(_MSC_VER)
54 
55 
56 // Solaris uses <ieeefp.h> for declaring isnan() and finite() functions
57 #if defined(HAVE_IEEEFP_H)
58 # include <ieeefp.h>
59 #endif
60 
61 // These definitions would collide with IT++ functions
62 #if defined(min)
63 # undef min
64 #endif
65 #if defined(max)
66 # undef max
67 #endif
68 #if defined(log2)
69 # undef log2
70 #endif
71 
72 namespace std
73 {
74 
75 #ifndef HAVE_STD_ISINF
76 #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
77 inline int isinf(double x) { return ::isinf(x); }
78 #elif defined(FPCLASS)
79 inline int isinf(double x)
80 {
81  if (::fpclass(a) == FP_NINF) return -1;
82  else if (::fpclass(a) == FP_PINF) return 1;
83  else return 0;
84 }
85 #else
86 inline int isinf(double x)
87 {
88  if ((x == x) && ((x - x) != 0.0)) return (x < 0.0 ? -1 : 1);
89  else return 0;
90 }
91 #endif // #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
92 #endif // #ifndef HAVE_STD_ISINF
93 
94 #ifndef HAVE_STD_ISNAN
95 #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
96 inline int isnan(double x) { return ::isnan(x); }
97 #else
98 inline int isnan(double x) { return ((x != x) ? 1 : 0); }
99 #endif // #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
100 #endif // #ifndef HAVE_STD_ISNAN
101 
102 #ifndef HAVE_STD_ISFINITE
103 #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
104 inline int isfinite(double x) { return ::isfinite(x); }
105 #elif defined(HAVE_FINITE)
106 inline int isfinite(double x) { return ::finite(x); }
107 #else
108 inline int isfinite(double x)
109 {
110  return ((!std::isnan(x) && !std::isinf(x)) ? 1 : 0);
111 }
112 #endif // #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
113 #endif // #ifndef HAVE_STD_ISFINITE
114 
115 } // namespace std
116 
117 
118 #ifndef HAVE_TGAMMA
119 
120 double tgamma(double x);
121 #endif
122 
123 #if !defined(HAVE_LGAMMA) || (HAVE_DECL_SIGNGAM != 1)
124 
125 double lgamma(double x);
127 extern int signgam;
128 #endif
129 
130 #ifndef HAVE_CBRT
131 
132 double cbrt(double x);
133 #endif
134 
135 
136 #ifndef HAVE_LOG1P
137 
138 inline double log1p(double x) { return std::log(1.0 + x); }
139 #endif
140 
141 #ifndef HAVE_LOG2
142 
143 inline double log2(double x)
144 {
145  static const double one_over_log2 = 1.0 / std::log(2.0);
146  return std::log(x) * one_over_log2;
147 }
148 #endif
149 
150 
151 #ifndef HAVE_EXPM1
152 
153 double expm1(double x);
154 #endif // HAVE_EXPM1
155 
156 
157 #ifndef HAVE_ERFC
158 
159 double erfc(double x);
160 #endif
161 
162 #ifndef HAVE_ERF
163 
164 inline double erf(double x) { return (1.0 - ::erfc(x)); }
165 #endif
166 
167 
168 #ifndef HAVE_ASINH
169 
170 double asinh(double x);
171 #endif
172 
173 #ifndef HAVE_ACOSH
174 
175 double acosh(double x);
176 #endif
177 
178 #ifndef HAVE_ATANH
179 
180 double atanh(double x);
181 #endif
182 
183 
184 #ifndef HAVE_RINT
185 double rint(double x);
186 #endif
187 
188 
189 // Represent GCC version in a concise form
190 #define GCC_VERSION (__GNUC__ * 10000 \
191  + __GNUC_MINOR__ * 100 \
192  + __GNUC_PATCHLEVEL__)
193 
195 
196 #endif // ITCOMPAT_H
SourceForge Logo

Generated on Sat May 25 2013 16:32:18 for IT++ by Doxygen 1.8.2