00001
00029 #ifndef ITCOMPAT_H
00030 #define ITCOMPAT_H
00031
00032 #ifndef _MSC_VER
00033 # include <itpp/config.h>
00034 #else
00035 # include <itpp/config_msvc.h>
00036 #endif
00037
00039
00040 #ifndef NO_INT_SIZE_CHECK
00041 #if (SIZEOF_SHORT != 2) || (SIZEOF_UNSIGNED_SHORT != 2) \
00042 || (SIZEOF_INT != 4) || (SIZEOF_UNSIGNED_INT != 4)
00043 # error \
00044 This platform uses different sizes for "short" and "int" standard \
00045 types than expected 2 and 4 bytes, respectively. This causes \
00046 incompatibilities of some parts of IT++ with most of 32- and 64-bit \
00047 platforms. Especially binary I/O operations will be incompatible. \
00048 Please report this problem to IT++ developers. If you are OK with it \
00049 you can add "-DNO_INT_SIZE_CHECK" to your CPPFLAGS and recompile the \
00050 library.
00051 #endif
00052 #endif // ifndef NO_INT_SIZE_CHECK
00053
00054 #if defined(HAVE_STDINT_H)
00055 # include <stdint.h>
00056 #elif defined(HAVE_INTTYPES_H)
00057 # include <inttypes.h>
00058 #else
00059
00060
00061 typedef signed char int8_t;
00062 typedef unsigned char uint8_t;
00063 typedef signed short int16_t;
00064 typedef unsigned short uint16_t;
00065 typedef signed int int32_t;
00066 typedef unsigned int uint32_t;
00067
00068 #if defined(_MSC_VER)
00069 typedef __int64 int64_t;
00070 typedef unsigned __int64 uint64_t;
00071 #elif (SIZEOF_LONG == 8) && (SIZEOF_UNSIGNED_LONG == 8)
00072 typedef signed long int64_t;
00073 typedef unsigned long uint64_t;
00074 #elif (SIZEOF_LONG_LONG == 8) && (SIZEOF_UNSIGNED_LONG_LONG == 8)
00075 typedef signed long long int64_t;
00076 typedef unsigned long long uint64_t;
00077 #else
00078 # error \
00079 64-bit integer type not detected on this platform. \
00080 Please report the problem to IT++ developers.
00081 #endif // defined(_MSC_VER)
00082
00083 #endif // defined(HAVE_STDINT_H)
00084
00085
00086
00087 #if defined(_MSC_VER)
00088 # include <cfloat>
00089 # define finite(x) _finite(x)
00090 # define isfinite(x) _finite(x)
00091 # define isnan(x) _isnan(x)
00092 # define fpclass(x) _fpclass(x)
00093 # define FP_NINF _FPCLASS_NINF
00094 # define FP_PINF _FPCLASS_PINF
00095 # define jn(a, b) _jn(a, b)
00096 # define yn(a, b) _yn(a, b)
00097 # define j0(a) _j0(a)
00098 # define j1(a) _j1(a)
00099 #endif // defined(_MSC_VER)
00100
00101
00102
00103 #if defined(HAVE_IEEEFP_H)
00104 # include <ieeefp.h>
00105 #endif
00106
00107 namespace std
00108 {
00109
00110 #ifndef HAVE_STD_ISINF
00111 #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
00112 inline int isinf(double x) { return ::isinf(x); }
00113 #elif defined(FPCLASS)
00114 inline int isinf(double x)
00115 {
00116 if (::fpclass(a) == FP_NINF) return -1;
00117 else if (::fpclass(a) == FP_PINF) return 1;
00118 else return 0;
00119 }
00120 #else
00121 inline int isinf(double x)
00122 {
00123 if ((x == x) && ((x - x) != 0.0)) return (x < 0.0 ? -1 : 1);
00124 else return 0;
00125 }
00126 #endif // #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
00127 #endif // #ifndef HAVE_STD_ISINF
00128
00129 #ifndef HAVE_STD_ISNAN
00130 #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
00131 inline int isnan(double x) { return ::isnan(x); }
00132 #else
00133 inline int isnan(double x) { return ((x != x) ? 1 : 0); }
00134 #endif // #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
00135 #endif // #ifndef HAVE_STD_ISNAN
00136
00137 #ifndef HAVE_STD_ISFINITE
00138 #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
00139 inline int isfinite(double x) { return ::isfinite(x); }
00140 #elif defined(HAVE_FINITE)
00141 inline int isfinite(double x) { return ::finite(x); }
00142 #else
00143 inline int isfinite(double x)
00144 {
00145 return ((!std::isnan(x) && !std::isinf(x)) ? 1 : 0);
00146 }
00147 #endif // #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
00148 #endif // #ifndef HAVE_STD_ISFINITE
00149
00150 }
00151
00152
00153 #ifndef HAVE_TGAMMA
00155 double tgamma(double x);
00156 #endif
00157
00158 #if !defined(HAVE_LGAMMA) || (HAVE_DECL_SIGNGAM != 1)
00160 double lgamma(double x);
00162 extern int signgam;
00163 #endif
00164
00165 #ifndef HAVE_CBRT
00167 double cbrt(double x);
00168 #endif
00169
00170
00171 #ifndef HAVE_LOG1P
00173 inline double log1p(double x) { return std::log(1.0 + x); }
00174 #endif
00175
00176 #ifndef HAVE_LOG2
00177 #undef log2 // This is required at least for Cygwin
00179 inline double log2(double x)
00180 {
00181 static const double one_over_log2 = 1.0 / std::log(2.0);
00182 return std::log(x) * one_over_log2;
00183 }
00184 #endif
00185
00186
00187 #ifndef HAVE_EXPM1
00189 double expm1(double x);
00190 #endif // HAVE_EXPM1
00191
00192
00193 #ifndef HAVE_ERFC
00195 double erfc(double x);
00196 #endif
00197
00198 #ifndef HAVE_ERF
00200 inline double erf(double x) { return (1.0 - ::erfc(x)); }
00201 #endif
00202
00203
00204 #ifndef HAVE_ASINH
00206 double asinh(double x);
00207 #endif
00208
00209 #ifndef HAVE_ACOSH
00211 double acosh(double x);
00212 #endif
00213
00214 #ifndef HAVE_ATANH
00216 double atanh(double x);
00217 #endif
00218
00219
00220 #ifndef HAVE_RINT
00221 double rint(double x);
00222 #endif
00223
00224
00225
00226 #define GCC_VERSION (__GNUC__ * 10000 \
00227 + __GNUC_MINOR__ * 100 \
00228 + __GNUC_PATCHLEVEL__)
00229
00231
00232 #endif // ITCOMPAT_H