]> git.donarmstrong.com Git - rsem.git/blob - boost/math/tools/config.hpp
Updated boost to v1.55.0
[rsem.git] / boost / math / tools / config.hpp
1 //  Copyright (c) 2006-7 John Maddock
2 //  Use, modification and distribution are subject to the
3 //  Boost Software License, Version 1.0. (See accompanying file
4 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifndef BOOST_MATH_TOOLS_CONFIG_HPP
7 #define BOOST_MATH_TOOLS_CONFIG_HPP
8
9 #ifdef _MSC_VER
10 #pragma once
11 #endif
12
13 #include <boost/config.hpp>
14 #include <boost/cstdint.hpp> // for boost::uintmax_t
15 #include <boost/detail/workaround.hpp>
16 #include <algorithm>  // for min and max
17 #include <boost/config/no_tr1/cmath.hpp>
18 #include <climits>
19 #include <cfloat>
20 #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__))
21 #  include <math.h>
22 #endif
23
24 #include <boost/math/tools/user.hpp>
25
26 #if (defined(__CYGWIN__) || defined(__FreeBSD__) || defined(__NetBSD__) \
27    || (defined(__hppa) && !defined(__OpenBSD__)) || (defined(__NO_LONG_DOUBLE_MATH) && (DBL_MANT_DIG != LDBL_MANT_DIG))) \
28    && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
29 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
30 #endif
31 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x582))
32 //
33 // Borland post 5.8.2 uses Dinkumware's std C lib which
34 // doesn't have true long double precision.  Earlier
35 // versions are problematic too:
36 //
37 #  define BOOST_MATH_NO_REAL_CONCEPT_TESTS
38 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
39 #  define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
40 #  include <float.h>
41 #endif
42 #ifdef __IBMCPP__
43 //
44 // For reasons I don't unserstand, the tests with IMB's compiler all
45 // pass at long double precision, but fail with real_concept, those tests
46 // are disabled for now.  (JM 2012).
47 #  define BOOST_MATH_NO_REAL_CONCEPT_TESTS
48 #endif
49 #if (defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)) && ((LDBL_MANT_DIG == 106) || (__LDBL_MANT_DIG__ == 106)) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
50 //
51 // Darwin's rather strange "double double" is rather hard to
52 // support, it should be possible given enough effort though...
53 //
54 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
55 #endif
56 #if defined(unix) && defined(__INTEL_COMPILER) && (__INTEL_COMPILER <= 1000) && !defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
57 //
58 // Intel compiler prior to version 10 has sporadic problems
59 // calling the long double overloads of the std lib math functions:
60 // calling ::powl is OK, but std::pow(long double, long double) 
61 // may segfault depending upon the value of the arguments passed 
62 // and the specific Linux distribution.
63 //
64 // We'll be conservative and disable long double support for this compiler.
65 //
66 // Comment out this #define and try building the tests to determine whether
67 // your Intel compiler version has this issue or not.
68 //
69 #  define BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
70 #endif
71 #if defined(unix) && defined(__INTEL_COMPILER)
72 //
73 // Intel compiler has sporadic issues compiling std::fpclassify depending on
74 // the exact OS version used.  Use our own code for this as we know it works
75 // well on Intel processors:
76 //
77 #define BOOST_MATH_DISABLE_STD_FPCLASSIFY
78 #endif
79
80 #if defined(BOOST_MSVC) && !defined(_WIN32_WCE)
81    // Better safe than sorry, our tests don't support hardware exceptions:
82 #  define BOOST_MATH_CONTROL_FP _control87(MCW_EM,MCW_EM)
83 #endif
84
85 #ifdef __IBMCPP__
86 #  define BOOST_MATH_NO_DEDUCED_FUNCTION_POINTERS
87 #endif
88
89 #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901))
90 #  define BOOST_MATH_USE_C99
91 #endif
92
93 #if (defined(__hpux) && !defined(__hppa))
94 #  define BOOST_MATH_USE_C99
95 #endif
96
97 #if defined(__GNUC__) && defined(_GLIBCXX_USE_C99)
98 #  define BOOST_MATH_USE_C99
99 #endif
100
101 #if defined(_LIBCPP_VERSION) && !defined(_MSC_VER)
102 #  define BOOST_MATH_USE_C99
103 #endif
104
105 #if defined(__CYGWIN__) || defined(__HP_aCC) || defined(BOOST_INTEL) \
106   || defined(BOOST_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) \
107   || (defined(__GNUC__) && !defined(BOOST_MATH_USE_C99))\
108   || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
109 #  define BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY
110 #endif
111
112 #if defined(BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS) || BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
113
114 #  include "boost/type.hpp"
115 #  include "boost/non_type.hpp"
116
117 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)         boost::type<t>* = 0
118 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)    boost::type<t>*
119 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)  boost::non_type<t, v>* = 0
120 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)  boost::non_type<t, v>*
121
122 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)         \
123              , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
124 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)    \
125              , BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
126 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)  \
127              , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
128 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)  \
129              , BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
130
131 #else
132
133 // no workaround needed: expand to nothing
134
135 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE(t)
136 #  define BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
137 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
138 #  define BOOST_MATH_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
139
140 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE(t)
141 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_TYPE_SPEC(t)
142 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE(t, v)
143 #  define BOOST_MATH_APPEND_EXPLICIT_TEMPLATE_NON_TYPE_SPEC(t, v)
144
145
146 #endif // defined BOOST_NO_EXPLICIT_FUNCTION_TEMPLATE_ARGUMENTS
147
148 #if (defined(__SUNPRO_CC) || defined(__hppa) || defined(__GNUC__)) && !defined(BOOST_MATH_SMALL_CONSTANT)
149 // Sun's compiler emits a hard error if a constant underflows,
150 // as does aCC on PA-RISC, while gcc issues a large number of warnings:
151 #  define BOOST_MATH_SMALL_CONSTANT(x) 0
152 #else
153 #  define BOOST_MATH_SMALL_CONSTANT(x) x
154 #endif
155
156
157 #if BOOST_WORKAROUND(BOOST_MSVC, < 1400)
158 //
159 // Define if constants too large for a float cause "bad"
160 // values to be stored in the data, rather than infinity
161 // or a suitably large value.
162 //
163 #  define BOOST_MATH_BUGGY_LARGE_FLOAT_CONSTANTS
164 #endif
165 //
166 // Tune performance options for specific compilers:
167 //
168 #ifdef BOOST_MSVC
169 #  define BOOST_MATH_POLY_METHOD 2
170 #elif defined(BOOST_INTEL)
171 #  define BOOST_MATH_POLY_METHOD 2
172 #  define BOOST_MATH_RATIONAL_METHOD 2
173 #elif defined(__GNUC__)
174 #  define BOOST_MATH_POLY_METHOD 3
175 #  define BOOST_MATH_RATIONAL_METHOD 3
176 #  define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
177 #  define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
178 #endif
179
180 #if defined(BOOST_NO_LONG_LONG) && !defined(BOOST_MATH_INT_TABLE_TYPE)
181 #  define BOOST_MATH_INT_TABLE_TYPE(RT, IT) RT
182 #  define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##.0L
183 #endif
184
185 //
186 // The maximum order of polynomial that will be evaluated 
187 // via an unrolled specialisation:
188 //
189 #ifndef BOOST_MATH_MAX_POLY_ORDER
190 #  define BOOST_MATH_MAX_POLY_ORDER 17
191 #endif 
192 //
193 // Set the method used to evaluate polynomials and rationals:
194 //
195 #ifndef BOOST_MATH_POLY_METHOD
196 #  define BOOST_MATH_POLY_METHOD 1
197 #endif 
198 #ifndef BOOST_MATH_RATIONAL_METHOD
199 #  define BOOST_MATH_RATIONAL_METHOD 0
200 #endif 
201 //
202 // decide whether to store constants as integers or reals:
203 //
204 #ifndef BOOST_MATH_INT_TABLE_TYPE
205 #  define BOOST_MATH_INT_TABLE_TYPE(RT, IT) IT
206 #endif
207 #ifndef BOOST_MATH_INT_VALUE_SUFFIX
208 #  define BOOST_MATH_INT_VALUE_SUFFIX(RV, SUF) RV##SUF
209 #endif
210 //
211 // Test whether to support __float128:
212 //
213 #if defined(_GLIBCXX_USE_FLOAT128) && defined(BOOST_GCC) && !defined(__STRICT_ANSI__)
214 //
215 // Only enable this when the compiler really is GCC as clang and probably 
216 // intel too don't support __float128 yet :-(
217 //
218 #  define BOOST_MATH_USE_FLOAT128
219 #endif
220 //
221 // Check for WinCE with no iostream support:
222 //
223 #if defined(_WIN32_WCE) && !defined(__SGI_STL_PORT)
224 #  define BOOST_MATH_NO_LEXICAL_CAST
225 #endif
226
227 //
228 // Helper macro for controlling the FP behaviour:
229 //
230 #ifndef BOOST_MATH_CONTROL_FP
231 #  define BOOST_MATH_CONTROL_FP
232 #endif
233 //
234 // Helper macro for using statements:
235 //
236 #define BOOST_MATH_STD_USING_CORE \
237    using std::abs;\
238    using std::acos;\
239    using std::cos;\
240    using std::fmod;\
241    using std::modf;\
242    using std::tan;\
243    using std::asin;\
244    using std::cosh;\
245    using std::frexp;\
246    using std::pow;\
247    using std::tanh;\
248    using std::atan;\
249    using std::exp;\
250    using std::ldexp;\
251    using std::sin;\
252    using std::atan2;\
253    using std::fabs;\
254    using std::log;\
255    using std::sinh;\
256    using std::ceil;\
257    using std::floor;\
258    using std::log10;\
259    using std::sqrt;
260
261 #define BOOST_MATH_STD_USING BOOST_MATH_STD_USING_CORE
262
263 namespace boost{ namespace math{
264 namespace tools
265 {
266
267 template <class T>
268 inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c)
269 {
270    return (std::max)((std::max)(a, b), c);
271 }
272
273 template <class T>
274 inline T max BOOST_PREVENT_MACRO_SUBSTITUTION(T a, T b, T c, T d)
275 {
276    return (std::max)((std::max)(a, b), (std::max)(c, d));
277 }
278
279 } // namespace tools
280
281 template <class T>
282 void suppress_unused_variable_warning(const T&)
283 {
284 }
285
286 }} // namespace boost namespace math
287
288 #if ((defined(__linux__) && !defined(__UCLIBC__)) || defined(__QNX__) || defined(__IBMCPP__)) && !defined(BOOST_NO_FENV_H)
289
290    #include <boost/detail/fenv.hpp>
291
292 #  ifdef FE_ALL_EXCEPT
293
294 namespace boost{ namespace math{
295    namespace detail
296    {
297    struct fpu_guard
298    {
299       fpu_guard()
300       {
301          fegetexceptflag(&m_flags, FE_ALL_EXCEPT);
302          feclearexcept(FE_ALL_EXCEPT);
303       }
304       ~fpu_guard()
305       {
306          fesetexceptflag(&m_flags, FE_ALL_EXCEPT);
307       }
308    private:
309       fexcept_t m_flags;
310    };
311
312    } // namespace detail
313    }} // namespaces
314
315 #    define BOOST_FPU_EXCEPTION_GUARD boost::math::detail::fpu_guard local_guard_object;
316 #    define BOOST_MATH_INSTRUMENT_FPU do{ fexcept_t cpu_flags; fegetexceptflag(&cpu_flags, FE_ALL_EXCEPT); BOOST_MATH_INSTRUMENT_VARIABLE(cpu_flags); } while(0); 
317
318 #  else
319
320 #    define BOOST_FPU_EXCEPTION_GUARD
321 #    define BOOST_MATH_INSTRUMENT_FPU
322
323 #  endif
324
325 #else // All other platforms.
326 #  define BOOST_FPU_EXCEPTION_GUARD
327 #  define BOOST_MATH_INSTRUMENT_FPU
328 #endif
329
330 #ifdef BOOST_MATH_INSTRUMENT
331
332 #  include <iostream>
333 #  include <iomanip>
334 #  include <typeinfo>
335
336 #  define BOOST_MATH_INSTRUMENT_CODE(x) \
337       std::cout << std::setprecision(35) << __FILE__ << ":" << __LINE__ << " " << x << std::endl;
338 #  define BOOST_MATH_INSTRUMENT_VARIABLE(name) BOOST_MATH_INSTRUMENT_CODE(BOOST_STRINGIZE(name) << " = " << name)
339
340 #else
341
342 #  define BOOST_MATH_INSTRUMENT_CODE(x)
343 #  define BOOST_MATH_INSTRUMENT_VARIABLE(name)
344
345 #endif
346
347 #endif // BOOST_MATH_TOOLS_CONFIG_HPP
348
349
350
351
352