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
72namespace std
73{
74
75#ifndef HAVE_STD_ISINF
76#if (HAVE_DECL_ISINF == 1) || defined(HAVE_ISINF)
77inline int isinf(double x) { return ::isinf(x); }
78#elif defined(FPCLASS)
79inline 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
86inline 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)
96inline int isnan(double x) { return ::isnan(x); }
97#else
98inline 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)
104inline int isfinite(double x) { return ::isfinite(x); }
105#elif defined(HAVE_FINITE)
106inline int isfinite(double x) { return ::finite(x); }
107#else
108inline 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
120double tgamma(double x);
121#endif
122
123#if !defined(HAVE_LGAMMA) || (HAVE_DECL_SIGNGAM != 1)
125double lgamma(double x);
127extern int signgam;
128#endif
129
130#ifndef HAVE_CBRT
132double cbrt(double x);
133#endif
134
135
136#ifndef HAVE_LOG1P
138inline double log1p(double x) { return std::log(1.0 + x); }
139#endif
140
141#ifndef HAVE_LOG2
143inline 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
153double expm1(double x);
154#endif // HAVE_EXPM1
155
156
157#ifndef HAVE_ERFC
159double erfc(double x);
160#endif
161
162#ifndef HAVE_ERF
164inline double erf(double x) { return (1.0 - ::erfc(x)); }
165#endif
166
167
168#ifndef HAVE_ASINH
170double asinh(double x);
171#endif
172
173#ifndef HAVE_ACOSH
175double acosh(double x);
176#endif
177
178#ifndef HAVE_ATANH
180double atanh(double x);
181#endif
182
183
184#ifndef HAVE_RINT
185double 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
std::complex< double > erf(const std::complex< double > &z)
Error function for complex argument.
Definition: error.cpp:154
vec erfc(const vec &x)
Complementary error function.
Definition: error.cpp:240
vec asinh(const vec &x)
Inverse sine hyperbolic function.
Definition: trig_hyp.cpp:36
vec acosh(const vec &x)
Inverse cosine hyperbolic function.
Definition: trig_hyp.cpp:40
vec atanh(const vec &x)
Inverse tan hyperbolic function.
Definition: trig_hyp.cpp:44
vec log2(const vec &x)
log-2 of the elements
Definition: log_exp.cpp:36
STL namespace.
SourceForge Logo

Generated on Tue Jan 24 2023 00:00:00 for IT++ by Doxygen 1.9.6