IT++ Logo
itcompat.h
Go to the documentation of this file.
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 // Microsoft Visual C++ underscore prefixed functions
00041 #if defined(_MSC_VER)
00042 #  include <cfloat>
00043 #  define finite(x) _finite(x)
00044 #  define isfinite(x) _finite(x)
00045 #  define isnan(x) _isnan(x)
00046 #  define fpclass(x) _fpclass(x)
00047 #  define FP_NINF _FPCLASS_NINF
00048 #  define FP_PINF _FPCLASS_PINF
00049 #  define jn(a, b) _jn(a, b)
00050 #  define yn(a, b) _yn(a, b)
00051 #  define j0(a) _j0(a)
00052 #  define j1(a) _j1(a)
00053 #endif // defined(_MSC_VER)
00054 
00055 
00056 // Solaris uses <ieeefp.h> for declaring isnan() and finite() functions
00057 #if defined(HAVE_IEEEFP_H)
00058 #  include <ieeefp.h>
00059 #endif
00060 
00061 // These definitions would collide with IT++ functions
00062 #if defined(min)
00063 #  undef min
00064 #endif
00065 #if defined(max)
00066 #  undef max
00067 #endif
00068 #if defined(log2)
00069 #  undef log2
00070 #endif
00071 
00072 namespace std
00073 {
00074 
00075 #ifndef HAVE_STD_ISINF
00076 #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
00077 inline int isinf(double x) { return ::isinf(x); }
00078 #elif defined(FPCLASS)
00079 inline int isinf(double x)
00080 {
00081   if (::fpclass(a) == FP_NINF) return -1;
00082   else if (::fpclass(a) == FP_PINF) return 1;
00083   else return 0;
00084 }
00085 #else
00086 inline int isinf(double x)
00087 {
00088   if ((x == x) && ((x - x) != 0.0)) return (x < 0.0 ? -1 : 1);
00089   else return 0;
00090 }
00091 #endif // #if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
00092 #endif // #ifndef HAVE_STD_ISINF
00093 
00094 #ifndef HAVE_STD_ISNAN
00095 #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
00096 inline int isnan(double x) { return ::isnan(x); }
00097 #else
00098 inline int isnan(double x) { return ((x != x) ? 1 : 0); }
00099 #endif // #if (HAVE_DECL_ISNAN == 1) || defined(HAVE_ISNAN)
00100 #endif // #ifndef HAVE_STD_ISNAN
00101 
00102 #ifndef HAVE_STD_ISFINITE
00103 #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
00104 inline int isfinite(double x) { return ::isfinite(x); }
00105 #elif defined(HAVE_FINITE)
00106 inline int isfinite(double x) { return ::finite(x); }
00107 #else
00108 inline int isfinite(double x)
00109 {
00110   return ((!std::isnan(x) && !std::isinf(x)) ? 1 : 0);
00111 }
00112 #endif // #if (HAVE_DECL_ISFINITE == 1) || defined(HAVE_ISFINITE)
00113 #endif // #ifndef HAVE_STD_ISFINITE
00114 
00115 } // namespace std
00116 
00117 
00118 #ifndef HAVE_TGAMMA
00119 
00120 double tgamma(double x);
00121 #endif
00122 
00123 #if !defined(HAVE_LGAMMA) || (HAVE_DECL_SIGNGAM != 1)
00124 
00125 double lgamma(double x);
00127 extern int signgam;
00128 #endif
00129 
00130 #ifndef HAVE_CBRT
00131 
00132 double cbrt(double x);
00133 #endif
00134 
00135 
00136 #ifndef HAVE_LOG1P
00137 
00138 inline double log1p(double x) { return std::log(1.0 + x); }
00139 #endif
00140 
00141 #ifndef HAVE_LOG2
00142 
00143 inline double log2(double x)
00144 {
00145   static const double one_over_log2 = 1.0 / std::log(2.0);
00146   return std::log(x) * one_over_log2;
00147 }
00148 #endif
00149 
00150 
00151 #ifndef HAVE_EXPM1
00152 
00153 double expm1(double x);
00154 #endif // HAVE_EXPM1
00155 
00156 
00157 #ifndef HAVE_ERFC
00158 
00159 double erfc(double x);
00160 #endif
00161 
00162 #ifndef HAVE_ERF
00163 
00164 inline double erf(double x) { return (1.0 - ::erfc(x)); }
00165 #endif
00166 
00167 
00168 #ifndef HAVE_ASINH
00169 
00170 double asinh(double x);
00171 #endif
00172 
00173 #ifndef HAVE_ACOSH
00174 
00175 double acosh(double x);
00176 #endif
00177 
00178 #ifndef HAVE_ATANH
00179 
00180 double atanh(double x);
00181 #endif
00182 
00183 
00184 #ifndef HAVE_RINT
00185 double rint(double x);
00186 #endif
00187 
00188 
00189 // Represent GCC version in a concise form
00190 #define GCC_VERSION (__GNUC__ * 10000           \
00191                      + __GNUC_MINOR__ * 100     \
00192                      + __GNUC_PATCHLEVEL__)
00193 
00195 
00196 #endif // ITCOMPAT_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SourceForge Logo

Generated on Sat Jul 9 2011 15:21:29 for IT++ by Doxygen 1.7.4