libstdc++: math.h Source File

libstdc++

math.h
Go to the documentation of this file.
1// -*- C++ -*- compatibility header.
2
3// Copyright (C) 2002-2026 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
25/** @file math.h
26 * This is a Standard C++ Library header.
27 */
28
29#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
30# include_next <math.h>
31#else
32
33#ifndef _GLIBCXX_MATH_H
34#define _GLIBCXX_MATH_H 1
35
36# include <cmath>
37
38using std::abs;
39using std::acos;
40using std::asin;
41using std::atan;
42using std::atan2;
43using std::cos;
44using std::sin;
45using std::tan;
46using std::cosh;
47using std::sinh;
48using std::tanh;
49using std::exp;
50using std::frexp;
51using std::ldexp;
52using std::log;
53using std::log10;
54using std::modf;
55using std::pow;
56using std::sqrt;
57using std::ceil;
58using std::fabs;
59using std::floor;
60using std::fmod;
61
62#if _GLIBCXX_USE_C99_MATH
63using std::fpclassify;
64using std::isfinite;
65using std::isinf;
66using std::isnan;
67using std::isnormal;
68using std::signbit;
69using std::isgreater;
70using std::isgreaterequal;
71using std::isless;
72using std::islessequal;
73using std::islessgreater;
74using std::isunordered;
75#endif
76
77#if __cplusplus >= 201103L && defined(_GLIBCXX_USE_C99_MATH_FUNCS)
78using std::acosh;
79using std::asinh;
80using std::atanh;
81using std::cbrt;
82using std::copysign;
83using std::erf;
84using std::erfc;
85using std::exp2;
86using std::expm1;
87using std::fdim;
88using std::fma;
89using std::fmax;
90using std::fmin;
91using std::hypot;
92using std::ilogb;
93using std::lgamma;
94using std::llrint;
95using std::llround;
96using std::log1p;
97using std::log2;
98using std::logb;
99using std::lrint;
100using std::lround;
101using std::nearbyint;
102using std::nextafter;
103using std::nexttoward;
104using std::remainder;
105using std::remquo;
106using std::rint;
107using std::round;
108using std::scalbln;
109using std::scalbn;
110using std::tgamma;
111using std::trunc;
112#endif // C++11 && _GLIBCXX_USE_C99_MATH_FUNCS
113
114// The mathematical special functions are only added to the global namespace
115// by IS 29124, but not by C++17.
116#if __cplusplus >= 201103L && __STDCPP_WANT_MATH_SPEC_FUNCS__ != 0
117using std::assoc_laguerref;
118using std::assoc_laguerrel;
119using std::assoc_laguerre;
120using std::assoc_legendref;
121using std::assoc_legendrel;
122using std::assoc_legendre;
123using std::betaf;
124using std::betal;
125using std::beta;
126using std::comp_ellint_1f;
127using std::comp_ellint_1l;
128using std::comp_ellint_1;
129using std::comp_ellint_2f;
130using std::comp_ellint_2l;
131using std::comp_ellint_2;
132using std::comp_ellint_3f;
133using std::comp_ellint_3l;
134using std::comp_ellint_3;
135using std::cyl_bessel_if;
136using std::cyl_bessel_il;
137using std::cyl_bessel_i;
138using std::cyl_bessel_jf;
139using std::cyl_bessel_jl;
140using std::cyl_bessel_j;
141using std::cyl_bessel_kf;
142using std::cyl_bessel_kl;
143using std::cyl_bessel_k;
144using std::cyl_neumannf;
145using std::cyl_neumannl;
146using std::cyl_neumann;
147using std::ellint_1f;
148using std::ellint_1l;
149using std::ellint_1;
150using std::ellint_2f;
151using std::ellint_2l;
152using std::ellint_2;
153using std::ellint_3f;
154using std::ellint_3l;
155using std::ellint_3;
156using std::expintf;
157using std::expintl;
158using std::expint;
159using std::hermitef;
160using std::hermitel;
161using std::hermite;
162using std::laguerref;
163using std::laguerrel;
164using std::laguerre;
165using std::legendref;
166using std::legendrel;
167using std::legendre;
168using std::riemann_zetaf;
169using std::riemann_zetal;
170using std::riemann_zeta;
171using std::sph_besself;
172using std::sph_bessell;
173using std::sph_bessel;
174using std::sph_legendref;
175using std::sph_legendrel;
176using std::sph_legendre;
177using std::sph_neumannf;
178using std::sph_neumannl;
179using std::sph_neumann;
180#endif // _GLIBCXX_USE_STD_SPEC_FUNCS
181
182#if __cplusplus > 201703L
183using std::lerp;
184#endif // C++20
185
186#endif // _GLIBCXX_MATH_H
187#endif // __cplusplus
cmath
std::log10
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
Definition complex:1167
std::sin
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
Definition complex:1197
std::log
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
Definition complex:1162
std::tan
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
Definition complex:1298
std::abs
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
Definition complex:968
std::exp
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
Definition complex:1135
std::cosh
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
Definition complex:1109
std::tanh
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
Definition complex:1326
std::pow
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
Definition complex:1357
std::sinh
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
Definition complex:1227
std::cos
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
Definition complex:1079
std::sqrt
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
Definition complex:1271
std::sph_bessel
__gnu_cxx::__promote< _Tp >::__type sph_bessel(unsigned int __n, _Tp __x)
Definition specfun.h:1101
std::sph_bessell
long double sph_bessell(unsigned int __n, long double __x)
Definition specfun.h:1082
std::betaf
float betaf(float __a, float __b)
Definition specfun.h:311
std::expintl
long double expintl(long double __x)
Definition specfun.h:853
std::cyl_bessel_jf
float cyl_bessel_jf(float __nu, float __x)
Definition specfun.h:549
std::cyl_bessel_k
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_k(_Tpnu __nu, _Tp __x)
Definition specfun.h:632
std::ellint_3f
float ellint_3f(float __k, float __nu, float __phi)
Return the incomplete elliptic integral of the third kind for float argument.
Definition specfun.h:791
std::legendrel
long double legendrel(unsigned int __l, long double __x)
Definition specfun.h:986
std::comp_ellint_3l
long double comp_ellint_3l(long double __k, long double __nu)
Return the complete elliptic integral of the third kind for long double modulus k.
Definition specfun.h:462
std::riemann_zetal
long double riemann_zetal(long double __s)
Definition specfun.h:1031
std::cyl_bessel_kf
float cyl_bessel_kf(float __nu, float __x)
Definition specfun.h:595
std::comp_ellint_2f
float comp_ellint_2f(float __k)
Definition specfun.h:405
std::hermitel
long double hermitel(unsigned int __n, long double __x)
Definition specfun.h:894
std::ellint_1
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_1(_Tp __k, _Tpp __phi)
Definition specfun.h:728
std::sph_legendrel
long double sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
Definition specfun.h:1127
std::ellint_1f
float ellint_1f(float __k, float __phi)
Definition specfun.h:695
std::cyl_neumann
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_neumann(_Tpnu __nu, _Tp __x)
Definition specfun.h:680
std::assoc_legendref
float assoc_legendref(unsigned int __l, unsigned int __m, float __x)
Definition specfun.h:266
std::sph_neumannl
long double sph_neumannl(unsigned int __n, long double __x)
Definition specfun.h:1173
std::comp_ellint_2l
long double comp_ellint_2l(long double __k)
Definition specfun.h:415
std::comp_ellint_2
__gnu_cxx::__promote< _Tp >::__type comp_ellint_2(_Tp __k)
Definition specfun.h:437
std::sph_besself
float sph_besself(unsigned int __n, float __x)
Definition specfun.h:1072
std::assoc_legendrel
long double assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
Definition specfun.h:275
std::legendre
__gnu_cxx::__promote< _Tp >::__type legendre(unsigned int __l, _Tp __x)
Definition specfun.h:1006
std::expintf
float expintf(float __x)
Definition specfun.h:843
std::ellint_2f
float ellint_2f(float __k, float __phi)
Return the incomplete elliptic integral of the second kind for float argument.
Definition specfun.h:743
std::ellint_3
__gnu_cxx::__promote_3< _Tp, _Tpn, _Tpp >::__type ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
Return the incomplete elliptic integral of the third kind .
Definition specfun.h:829
std::ellint_2l
long double ellint_2l(long double __k, long double __phi)
Return the incomplete elliptic integral of the second kind .
Definition specfun.h:753
std::cyl_neumannf
float cyl_neumannf(float __nu, float __x)
Definition specfun.h:647
std::beta
__gnu_cxx::__promote_2< _Tpa, _Tpb >::__type beta(_Tpa __a, _Tpb __b)
Definition specfun.h:342
std::comp_ellint_1l
long double comp_ellint_1l(long double __k)
Definition specfun.h:367
std::comp_ellint_3f
float comp_ellint_3f(float __k, float __nu)
Return the complete elliptic integral of the third kind for float modulus k.
Definition specfun.h:452
std::sph_neumannf
float sph_neumannf(unsigned int __n, float __x)
Definition specfun.h:1163
std::expint
__gnu_cxx::__promote< _Tp >::__type expint(_Tp __x)
Definition specfun.h:869
std::ellint_1l
long double ellint_1l(long double __k, long double __phi)
Definition specfun.h:705
std::comp_ellint_1f
float comp_ellint_1f(float __k)
Definition specfun.h:357
std::betal
long double betal(long double __a, long double __b)
Definition specfun.h:321
std::hermitef
float hermitef(unsigned int __n, float __x)
Definition specfun.h:884
std::riemann_zeta
__gnu_cxx::__promote< _Tp >::__type riemann_zeta(_Tp __s)
Definition specfun.h:1057
std::ellint_3l
long double ellint_3l(long double __k, long double __nu, long double __phi)
Return the incomplete elliptic integral of the third kind .
Definition specfun.h:801
std::sph_legendref
float sph_legendref(unsigned int __l, unsigned int __m, float __theta)
Definition specfun.h:1116
std::sph_neumann
__gnu_cxx::__promote< _Tp >::__type sph_neumann(unsigned int __n, _Tp __x)
Definition specfun.h:1192
std::cyl_bessel_if
float cyl_bessel_if(float __nu, float __x)
Definition specfun.h:503
std::laguerrel
long double laguerrel(unsigned int __n, long double __x)
Definition specfun.h:942
std::cyl_bessel_il
long double cyl_bessel_il(long double __nu, long double __x)
Definition specfun.h:513
std::assoc_laguerre
__gnu_cxx::__promote< _Tp >::__type assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
Definition specfun.h:251
std::comp_ellint_3
__gnu_cxx::__promote_2< _Tp, _Tpn >::__type comp_ellint_3(_Tp __k, _Tpn __nu)
Definition specfun.h:488
std::sph_legendre
__gnu_cxx::__promote< _Tp >::__type sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
Definition specfun.h:1148
std::cyl_bessel_kl
long double cyl_bessel_kl(long double __nu, long double __x)
Definition specfun.h:605
std::assoc_laguerrel
long double assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
Definition specfun.h:215
std::hermite
__gnu_cxx::__promote< _Tp >::__type hermite(unsigned int __n, _Tp __x)
Definition specfun.h:917
std::cyl_bessel_j
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_j(_Tpnu __nu, _Tp __x)
Definition specfun.h:580
std::laguerref
float laguerref(unsigned int __n, float __x)
Definition specfun.h:932
std::cyl_bessel_jl
long double cyl_bessel_jl(long double __nu, long double __x)
Definition specfun.h:559
std::comp_ellint_1
__gnu_cxx::__promote< _Tp >::__type comp_ellint_1(_Tp __k)
Definition specfun.h:390
std::ellint_2
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_2(_Tp __k, _Tpp __phi)
Definition specfun.h:776
std::laguerre
__gnu_cxx::__promote< _Tp >::__type laguerre(unsigned int __n, _Tp __x)
Definition specfun.h:961
std::legendref
float legendref(unsigned int __l, float __x)
Definition specfun.h:976
std::cyl_bessel_i
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_i(_Tpnu __nu, _Tp __x)
Definition specfun.h:534
std::assoc_legendre
__gnu_cxx::__promote< _Tp >::__type assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
Definition specfun.h:297
std::assoc_laguerref
float assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
Definition specfun.h:205
std::cyl_neumannl
long double cyl_neumannl(long double __nu, long double __x)
Definition specfun.h:657
std::riemann_zetaf
float riemann_zetaf(float __s)
Definition specfun.h:1021
std::fabs
_Tp fabs(const std::complex< _Tp > &__z)
fabs(__z) TR1 8.1.8 [tr.c99.cmplx.fabs]
Definition complex:2525