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