annotate libstdc++-v3/include/ext/cmath @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // Math extensions -*- C++ -*-
kono
parents:
diff changeset
2
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
3 // Copyright (C) 2013-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
4 //
kono
parents:
diff changeset
5 // This file is part of the GNU ISO C++ Library. This library is free
kono
parents:
diff changeset
6 // software; you can redistribute it and/or modify it under the
kono
parents:
diff changeset
7 // terms of the GNU General Public License as published by the
kono
parents:
diff changeset
8 // Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
9 // any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 // This library is distributed in the hope that it will be useful,
kono
parents:
diff changeset
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
14 // GNU General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 // Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
17 // permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
18 // 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 // You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
21 // a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
23 // <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 /** @file ext/cmath
kono
parents:
diff changeset
26 * This file is a GNU extension to the Standard C++ Library.
kono
parents:
diff changeset
27 */
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 #ifndef _EXT_CMATH
kono
parents:
diff changeset
30 #define _EXT_CMATH 1
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 #pragma GCC system_header
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 #if __cplusplus < 201103L
kono
parents:
diff changeset
35 # include <bits/c++0x_warning.h>
kono
parents:
diff changeset
36 #else
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 #include <cmath>
kono
parents:
diff changeset
39 #include <type_traits>
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
kono
parents:
diff changeset
42 {
kono
parents:
diff changeset
43 _GLIBCXX_BEGIN_NAMESPACE_VERSION
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 // A class for math constants.
kono
parents:
diff changeset
46 template<typename _RealType>
kono
parents:
diff changeset
47 struct __math_constants
kono
parents:
diff changeset
48 {
kono
parents:
diff changeset
49 static_assert(std::is_floating_point<_RealType>::value,
kono
parents:
diff changeset
50 "template argument not a floating point type");
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 // Constant @f$ \pi @f$.
kono
parents:
diff changeset
53 static constexpr _RealType __pi = 3.1415926535897932384626433832795029L;
kono
parents:
diff changeset
54 // Constant @f$ \pi / 2 @f$.
kono
parents:
diff changeset
55 static constexpr _RealType __pi_half = 1.5707963267948966192313216916397514L;
kono
parents:
diff changeset
56 // Constant @f$ \pi / 3 @f$.
kono
parents:
diff changeset
57 static constexpr _RealType __pi_third = 1.0471975511965977461542144610931676L;
kono
parents:
diff changeset
58 // Constant @f$ \pi / 4 @f$.
kono
parents:
diff changeset
59 static constexpr _RealType __pi_quarter = 0.7853981633974483096156608458198757L;
kono
parents:
diff changeset
60 // Constant @f$ \sqrt(\pi / 2) @f$.
kono
parents:
diff changeset
61 static constexpr _RealType __root_pi_div_2 = 1.2533141373155002512078826424055226L;
kono
parents:
diff changeset
62 // Constant @f$ 1 / \pi @f$.
kono
parents:
diff changeset
63 static constexpr _RealType __one_div_pi = 0.3183098861837906715377675267450287L;
kono
parents:
diff changeset
64 // Constant @f$ 2 / \pi @f$.
kono
parents:
diff changeset
65 static constexpr _RealType __two_div_pi = 0.6366197723675813430755350534900574L;
kono
parents:
diff changeset
66 // Constant @f$ 2 / \sqrt(\pi) @f$.
kono
parents:
diff changeset
67 static constexpr _RealType __two_div_root_pi = 1.1283791670955125738961589031215452L;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 // Constant Euler's number @f$ e @f$.
kono
parents:
diff changeset
70 static constexpr _RealType __e = 2.7182818284590452353602874713526625L;
kono
parents:
diff changeset
71 // Constant @f$ 1 / e @f$.
kono
parents:
diff changeset
72 static constexpr _RealType __one_div_e = 0.36787944117144232159552377016146087L;
kono
parents:
diff changeset
73 // Constant @f$ \log_2(e) @f$.
kono
parents:
diff changeset
74 static constexpr _RealType __log2_e = 1.4426950408889634073599246810018921L;
kono
parents:
diff changeset
75 // Constant @f$ \log_10(e) @f$.
kono
parents:
diff changeset
76 static constexpr _RealType __log10_e = 0.4342944819032518276511289189166051L;
kono
parents:
diff changeset
77 // Constant @f$ \ln(2) @f$.
kono
parents:
diff changeset
78 static constexpr _RealType __ln_2 = 0.6931471805599453094172321214581766L;
kono
parents:
diff changeset
79 // Constant @f$ \ln(3) @f$.
kono
parents:
diff changeset
80 static constexpr _RealType __ln_3 = 1.0986122886681096913952452369225257L;
kono
parents:
diff changeset
81 // Constant @f$ \ln(10) @f$.
kono
parents:
diff changeset
82 static constexpr _RealType __ln_10 = 2.3025850929940456840179914546843642L;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 // Constant Euler-Mascheroni @f$ \gamma_E @f$.
kono
parents:
diff changeset
85 static constexpr _RealType __gamma_e = 0.5772156649015328606065120900824024L;
kono
parents:
diff changeset
86 // Constant Golden Ratio @f$ \phi @f$.
kono
parents:
diff changeset
87 static constexpr _RealType __phi = 1.6180339887498948482045868343656381L;
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 // Constant @f$ \sqrt(2) @f$.
kono
parents:
diff changeset
90 static constexpr _RealType __root_2 = 1.4142135623730950488016887242096981L;
kono
parents:
diff changeset
91 // Constant @f$ \sqrt(3) @f$.
kono
parents:
diff changeset
92 static constexpr _RealType __root_3 = 1.7320508075688772935274463415058724L;
kono
parents:
diff changeset
93 // Constant @f$ \sqrt(5) @f$.
kono
parents:
diff changeset
94 static constexpr _RealType __root_5 = 2.2360679774997896964091736687312762L;
kono
parents:
diff changeset
95 // Constant @f$ \sqrt(7) @f$.
kono
parents:
diff changeset
96 static constexpr _RealType __root_7 = 2.6457513110645905905016157536392604L;
kono
parents:
diff changeset
97 // Constant @f$ 1 / \sqrt(2) @f$.
kono
parents:
diff changeset
98 static constexpr _RealType __one_div_root_2 = 0.7071067811865475244008443621048490L;
kono
parents:
diff changeset
99 };
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 // And the template definitions for the constants.
kono
parents:
diff changeset
102 template<typename _RealType>
kono
parents:
diff changeset
103 constexpr _RealType __math_constants<_RealType>::__pi;
kono
parents:
diff changeset
104 template<typename _RealType>
kono
parents:
diff changeset
105 constexpr _RealType __math_constants<_RealType>::__pi_half;
kono
parents:
diff changeset
106 template<typename _RealType>
kono
parents:
diff changeset
107 constexpr _RealType __math_constants<_RealType>::__pi_third;
kono
parents:
diff changeset
108 template<typename _RealType>
kono
parents:
diff changeset
109 constexpr _RealType __math_constants<_RealType>::__pi_quarter;
kono
parents:
diff changeset
110 template<typename _RealType>
kono
parents:
diff changeset
111 constexpr _RealType __math_constants<_RealType>::__root_pi_div_2;
kono
parents:
diff changeset
112 template<typename _RealType>
kono
parents:
diff changeset
113 constexpr _RealType __math_constants<_RealType>::__one_div_pi;
kono
parents:
diff changeset
114 template<typename _RealType>
kono
parents:
diff changeset
115 constexpr _RealType __math_constants<_RealType>::__two_div_pi;
kono
parents:
diff changeset
116 template<typename _RealType>
kono
parents:
diff changeset
117 constexpr _RealType __math_constants<_RealType>::__two_div_root_pi;
kono
parents:
diff changeset
118 template<typename _RealType>
kono
parents:
diff changeset
119 constexpr _RealType __math_constants<_RealType>::__e;
kono
parents:
diff changeset
120 template<typename _RealType>
kono
parents:
diff changeset
121 constexpr _RealType __math_constants<_RealType>::__one_div_e;
kono
parents:
diff changeset
122 template<typename _RealType>
kono
parents:
diff changeset
123 constexpr _RealType __math_constants<_RealType>::__log2_e;
kono
parents:
diff changeset
124 template<typename _RealType>
kono
parents:
diff changeset
125 constexpr _RealType __math_constants<_RealType>::__log10_e;
kono
parents:
diff changeset
126 template<typename _RealType>
kono
parents:
diff changeset
127 constexpr _RealType __math_constants<_RealType>::__ln_2;
kono
parents:
diff changeset
128 template<typename _RealType>
kono
parents:
diff changeset
129 constexpr _RealType __math_constants<_RealType>::__ln_3;
kono
parents:
diff changeset
130 template<typename _RealType>
kono
parents:
diff changeset
131 constexpr _RealType __math_constants<_RealType>::__ln_10;
kono
parents:
diff changeset
132 template<typename _RealType>
kono
parents:
diff changeset
133 constexpr _RealType __math_constants<_RealType>::__gamma_e;
kono
parents:
diff changeset
134 template<typename _RealType>
kono
parents:
diff changeset
135 constexpr _RealType __math_constants<_RealType>::__phi;
kono
parents:
diff changeset
136 template<typename _RealType>
kono
parents:
diff changeset
137 constexpr _RealType __math_constants<_RealType>::__root_2;
kono
parents:
diff changeset
138 template<typename _RealType>
kono
parents:
diff changeset
139 constexpr _RealType __math_constants<_RealType>::__root_3;
kono
parents:
diff changeset
140 template<typename _RealType>
kono
parents:
diff changeset
141 constexpr _RealType __math_constants<_RealType>::__root_5;
kono
parents:
diff changeset
142 template<typename _RealType>
kono
parents:
diff changeset
143 constexpr _RealType __math_constants<_RealType>::__root_7;
kono
parents:
diff changeset
144 template<typename _RealType>
kono
parents:
diff changeset
145 constexpr _RealType __math_constants<_RealType>::__one_div_root_2;
kono
parents:
diff changeset
146
kono
parents:
diff changeset
147 _GLIBCXX_END_NAMESPACE_VERSION
kono
parents:
diff changeset
148 } // namespace __gnu_cxx
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 #endif // C++11
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 #endif // _EXT_CMATH