STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
special_function_util.h
Go to the documentation of this file.
1 // Special functions -*- C++ -*-
2 
3 // Copyright (C) 2006-2013 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
9 // any later version.
10 
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
19 
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
24 
30 //
31 // ISO C++ 14882 TR1: 5.2 Special functions
32 //
33 
34 // Written by Edward Smith-Rowland based on numerous mathematics books.
35 
36 #ifndef _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H
37 #define _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H 1
38 
39 namespace std _GLIBCXX_VISIBILITY(default)
40 {
41 namespace tr1
42 {
43  namespace __detail
44  {
45  _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 
50  template<typename _Tp>
51  struct __floating_point_constant
52  {
53  static const _Tp __value;
54  };
55 
56 
58  template<typename _Tp>
59  struct __numeric_constants
60  {
62  static _Tp __pi() throw()
63  { return static_cast<_Tp>(3.1415926535897932384626433832795029L); }
65  static _Tp __pi_2() throw()
66  { return static_cast<_Tp>(1.5707963267948966192313216916397514L); }
68  static _Tp __pi_3() throw()
69  { return static_cast<_Tp>(1.0471975511965977461542144610931676L); }
71  static _Tp __pi_4() throw()
72  { return static_cast<_Tp>(0.7853981633974483096156608458198757L); }
74  static _Tp __1_pi() throw()
75  { return static_cast<_Tp>(0.3183098861837906715377675267450287L); }
77  static _Tp __2_sqrtpi() throw()
78  { return static_cast<_Tp>(1.1283791670955125738961589031215452L); }
80  static _Tp __sqrt2() throw()
81  { return static_cast<_Tp>(1.4142135623730950488016887242096981L); }
83  static _Tp __sqrt3() throw()
84  { return static_cast<_Tp>(1.7320508075688772935274463415058723L); }
86  static _Tp __sqrtpio2() throw()
87  { return static_cast<_Tp>(1.2533141373155002512078826424055226L); }
89  static _Tp __sqrt1_2() throw()
90  { return static_cast<_Tp>(0.7071067811865475244008443621048490L); }
92  static _Tp __lnpi() throw()
93  { return static_cast<_Tp>(1.1447298858494001741434273513530587L); }
95  static _Tp __gamma_e() throw()
96  { return static_cast<_Tp>(0.5772156649015328606065120900824024L); }
98  static _Tp __euler() throw()
99  { return static_cast<_Tp>(2.7182818284590452353602874713526625L); }
100  };
101 
102 
103 #if _GLIBCXX_USE_C99_MATH && !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
104 
109  template<typename _Tp>
110  inline bool __isnan(_Tp __x)
111  { return std::isnan(__x); }
112 
113 #else
114 
115  template<typename _Tp>
116  inline bool __isnan(const _Tp __x)
117  { return __builtin_isnan(__x); }
118 
119  template<>
120  inline bool __isnan<float>(float __x)
121  { return __builtin_isnanf(__x); }
122 
123  template<>
124  inline bool __isnan<long double>(long double __x)
125  { return __builtin_isnanl(__x); }
126 
127 #endif
128 
129  _GLIBCXX_END_NAMESPACE_VERSION
130  } // namespace __detail
131 }
132 }
133 
134 #endif // _GLIBCXX_TR1_SPECIAL_FUNCTION_UTIL_H
135 
namespace std _GLIBCXX_VISIBILITY(default)
Definition: special_function_util.h:39