Install gcc-4.4.0-tdm-1-core-2.tar.gz
[msysgit.git] / mingw / lib / gcc / mingw32 / 4.3.3 / include / c++ / tr1 / special_function_util.h
bloba07a193679b55d858fc3c5cc68f78c1561bd73fa
1 // Special functions -*- C++ -*-
3 // Copyright (C) 2006
4 // Free Software Foundation, Inc.
5 //
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20 // USA.
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 /** @file tr1/special_function_util.h
32 * This is an internal header file, included by other library headers.
33 * You should not attempt to use it directly.
37 // ISO C++ 14882 TR1: 5.2 Special functions
40 // Written by Edward Smith-Rowland based on numerous mathematics books.
42 #ifndef _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H
43 #define _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H 1
45 namespace std
47 namespace tr1
50 namespace __detail
53 /// A class to encapsulate type dependent floating point
54 /// constants. Not everything will be able to be expressed as
55 /// type logic.
56 template<typename _Tp>
57 struct __floating_point_constant
59 static const _Tp __value;
63 /// A structure for numeric constants.
64 template<typename _Tp>
65 struct __numeric_constants
67 /// Constant @f$ \pi @f$.
68 static _Tp __pi() throw()
69 { return static_cast<_Tp>(3.1415926535897932384626433832795029L); }
70 /// Constant @f$ \pi / 2 @f$.
71 static _Tp __pi_2() throw()
72 { return static_cast<_Tp>(1.5707963267948966192313216916397514L); }
73 /// Constant @f$ \pi / 3 @f$.
74 static _Tp __pi_3() throw()
75 { return static_cast<_Tp>(1.0471975511965977461542144610931676L); }
76 /// Constant @f$ \pi / 4 @f$.
77 static _Tp __pi_4() throw()
78 { return static_cast<_Tp>(0.7853981633974483096156608458198757L); }
79 /// Constant @f$ 1 / \pi @f$.
80 static _Tp __1_pi() throw()
81 { return static_cast<_Tp>(0.3183098861837906715377675267450287L); }
82 /// Constant @f$ 2 / \sqrt(\pi) @f$.
83 static _Tp __2_sqrtpi() throw()
84 { return static_cast<_Tp>(1.1283791670955125738961589031215452L); }
85 /// Constant @f$ \sqrt(2) @f$.
86 static _Tp __sqrt2() throw()
87 { return static_cast<_Tp>(1.4142135623730950488016887242096981L); }
88 /// Constant @f$ \sqrt(3) @f$.
89 static _Tp __sqrt3() throw()
90 { return static_cast<_Tp>(1.7320508075688772935274463415058723L); }
91 /// Constant @f$ \sqrt(\pi/2) @f$.
92 static _Tp __sqrtpio2() throw()
93 { return static_cast<_Tp>(1.2533141373155002512078826424055226L); }
94 /// Constant @f$ 1 / sqrt(2) @f$.
95 static _Tp __sqrt1_2() throw()
96 { return static_cast<_Tp>(0.7071067811865475244008443621048490L); }
97 /// Constant @f$ \log(\pi) @f$.
98 static _Tp __lnpi() throw()
99 { return static_cast<_Tp>(1.1447298858494001741434273513530587L); }
100 /// Constant Euler's constant @f$ \gamma_E @f$.
101 static _Tp __gamma_e() throw()
102 { return static_cast<_Tp>(0.5772156649015328606065120900824024L); }
103 /// Constant Euler-Mascheroni @f$ e @f$
104 static _Tp __euler() throw()
105 { return static_cast<_Tp>(2.7182818284590452353602874713526625L); }
109 #if _GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
111 /// This is a wrapper for the isnan function. Otherwise, for NaN,
112 /// all comparisons result in false. If/when we build a std::isnan
113 /// out of intrinsics, this will disappear completely in favor of
114 /// std::isnan.
115 template<typename _Tp>
116 inline bool __isnan(const _Tp __x)
118 return std::isnan(__x);
121 #else
123 template<typename _Tp>
124 inline bool __isnan(const _Tp __x)
126 return __builtin_isnan(__x);
129 template<>
130 inline bool __isnan<float>(const float __x)
132 return __builtin_isnanf(__x);
135 template<>
136 inline bool __isnan<long double>(const long double __x)
138 return __builtin_isnanl(__x);
141 #endif
143 } // namespace __detail
148 #endif // _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H