xref: /netbsd-src/external/apache2/llvm/dist/libcxx/include/cmath (revision 4d6fc14bc9b0c5bf3e30be318c143ee82cadd108)
1*4d6fc14bSjoerg// -*- C++ -*-
2*4d6fc14bSjoerg//===---------------------------- cmath -----------------------------------===//
3*4d6fc14bSjoerg//
4*4d6fc14bSjoerg// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5*4d6fc14bSjoerg// See https://llvm.org/LICENSE.txt for license information.
6*4d6fc14bSjoerg// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7*4d6fc14bSjoerg//
8*4d6fc14bSjoerg//===----------------------------------------------------------------------===//
9*4d6fc14bSjoerg
10*4d6fc14bSjoerg#ifndef _LIBCPP_CMATH
11*4d6fc14bSjoerg#define _LIBCPP_CMATH
12*4d6fc14bSjoerg
13*4d6fc14bSjoerg/*
14*4d6fc14bSjoerg    cmath synopsis
15*4d6fc14bSjoerg
16*4d6fc14bSjoergMacros:
17*4d6fc14bSjoerg
18*4d6fc14bSjoerg    HUGE_VAL
19*4d6fc14bSjoerg    HUGE_VALF               // C99
20*4d6fc14bSjoerg    HUGE_VALL               // C99
21*4d6fc14bSjoerg    INFINITY                // C99
22*4d6fc14bSjoerg    NAN                     // C99
23*4d6fc14bSjoerg    FP_INFINITE             // C99
24*4d6fc14bSjoerg    FP_NAN                  // C99
25*4d6fc14bSjoerg    FP_NORMAL               // C99
26*4d6fc14bSjoerg    FP_SUBNORMAL            // C99
27*4d6fc14bSjoerg    FP_ZERO                 // C99
28*4d6fc14bSjoerg    FP_FAST_FMA             // C99
29*4d6fc14bSjoerg    FP_FAST_FMAF            // C99
30*4d6fc14bSjoerg    FP_FAST_FMAL            // C99
31*4d6fc14bSjoerg    FP_ILOGB0               // C99
32*4d6fc14bSjoerg    FP_ILOGBNAN             // C99
33*4d6fc14bSjoerg    MATH_ERRNO              // C99
34*4d6fc14bSjoerg    MATH_ERREXCEPT          // C99
35*4d6fc14bSjoerg    math_errhandling        // C99
36*4d6fc14bSjoerg
37*4d6fc14bSjoergnamespace std
38*4d6fc14bSjoerg{
39*4d6fc14bSjoerg
40*4d6fc14bSjoergTypes:
41*4d6fc14bSjoerg
42*4d6fc14bSjoerg    float_t                 // C99
43*4d6fc14bSjoerg    double_t                // C99
44*4d6fc14bSjoerg
45*4d6fc14bSjoerg// C90
46*4d6fc14bSjoerg
47*4d6fc14bSjoergfloating_point abs(floating_point x);
48*4d6fc14bSjoerg
49*4d6fc14bSjoergfloating_point acos (arithmetic x);
50*4d6fc14bSjoergfloat          acosf(float x);
51*4d6fc14bSjoerglong double    acosl(long double x);
52*4d6fc14bSjoerg
53*4d6fc14bSjoergfloating_point asin (arithmetic x);
54*4d6fc14bSjoergfloat          asinf(float x);
55*4d6fc14bSjoerglong double    asinl(long double x);
56*4d6fc14bSjoerg
57*4d6fc14bSjoergfloating_point atan (arithmetic x);
58*4d6fc14bSjoergfloat          atanf(float x);
59*4d6fc14bSjoerglong double    atanl(long double x);
60*4d6fc14bSjoerg
61*4d6fc14bSjoergfloating_point atan2 (arithmetic y, arithmetic x);
62*4d6fc14bSjoergfloat          atan2f(float y, float x);
63*4d6fc14bSjoerglong double    atan2l(long double y, long double x);
64*4d6fc14bSjoerg
65*4d6fc14bSjoergfloating_point ceil (arithmetic x);
66*4d6fc14bSjoergfloat          ceilf(float x);
67*4d6fc14bSjoerglong double    ceill(long double x);
68*4d6fc14bSjoerg
69*4d6fc14bSjoergfloating_point cos (arithmetic x);
70*4d6fc14bSjoergfloat          cosf(float x);
71*4d6fc14bSjoerglong double    cosl(long double x);
72*4d6fc14bSjoerg
73*4d6fc14bSjoergfloating_point cosh (arithmetic x);
74*4d6fc14bSjoergfloat          coshf(float x);
75*4d6fc14bSjoerglong double    coshl(long double x);
76*4d6fc14bSjoerg
77*4d6fc14bSjoergfloating_point exp (arithmetic x);
78*4d6fc14bSjoergfloat          expf(float x);
79*4d6fc14bSjoerglong double    expl(long double x);
80*4d6fc14bSjoerg
81*4d6fc14bSjoergfloating_point fabs (arithmetic x);
82*4d6fc14bSjoergfloat          fabsf(float x);
83*4d6fc14bSjoerglong double    fabsl(long double x);
84*4d6fc14bSjoerg
85*4d6fc14bSjoergfloating_point floor (arithmetic x);
86*4d6fc14bSjoergfloat          floorf(float x);
87*4d6fc14bSjoerglong double    floorl(long double x);
88*4d6fc14bSjoerg
89*4d6fc14bSjoergfloating_point fmod (arithmetic x, arithmetic y);
90*4d6fc14bSjoergfloat          fmodf(float x, float y);
91*4d6fc14bSjoerglong double    fmodl(long double x, long double y);
92*4d6fc14bSjoerg
93*4d6fc14bSjoergfloating_point frexp (arithmetic value, int* exp);
94*4d6fc14bSjoergfloat          frexpf(float value, int* exp);
95*4d6fc14bSjoerglong double    frexpl(long double value, int* exp);
96*4d6fc14bSjoerg
97*4d6fc14bSjoergfloating_point ldexp (arithmetic value, int exp);
98*4d6fc14bSjoergfloat          ldexpf(float value, int exp);
99*4d6fc14bSjoerglong double    ldexpl(long double value, int exp);
100*4d6fc14bSjoerg
101*4d6fc14bSjoergfloating_point log (arithmetic x);
102*4d6fc14bSjoergfloat          logf(float x);
103*4d6fc14bSjoerglong double    logl(long double x);
104*4d6fc14bSjoerg
105*4d6fc14bSjoergfloating_point log10 (arithmetic x);
106*4d6fc14bSjoergfloat          log10f(float x);
107*4d6fc14bSjoerglong double    log10l(long double x);
108*4d6fc14bSjoerg
109*4d6fc14bSjoergfloating_point modf (floating_point value, floating_point* iptr);
110*4d6fc14bSjoergfloat          modff(float value, float* iptr);
111*4d6fc14bSjoerglong double    modfl(long double value, long double* iptr);
112*4d6fc14bSjoerg
113*4d6fc14bSjoergfloating_point pow (arithmetic x, arithmetic y);
114*4d6fc14bSjoergfloat          powf(float x, float y);
115*4d6fc14bSjoerglong double    powl(long double x, long double y);
116*4d6fc14bSjoerg
117*4d6fc14bSjoergfloating_point sin (arithmetic x);
118*4d6fc14bSjoergfloat          sinf(float x);
119*4d6fc14bSjoerglong double    sinl(long double x);
120*4d6fc14bSjoerg
121*4d6fc14bSjoergfloating_point sinh (arithmetic x);
122*4d6fc14bSjoergfloat          sinhf(float x);
123*4d6fc14bSjoerglong double    sinhl(long double x);
124*4d6fc14bSjoerg
125*4d6fc14bSjoergfloating_point sqrt (arithmetic x);
126*4d6fc14bSjoergfloat          sqrtf(float x);
127*4d6fc14bSjoerglong double    sqrtl(long double x);
128*4d6fc14bSjoerg
129*4d6fc14bSjoergfloating_point tan (arithmetic x);
130*4d6fc14bSjoergfloat          tanf(float x);
131*4d6fc14bSjoerglong double    tanl(long double x);
132*4d6fc14bSjoerg
133*4d6fc14bSjoergfloating_point tanh (arithmetic x);
134*4d6fc14bSjoergfloat          tanhf(float x);
135*4d6fc14bSjoerglong double    tanhl(long double x);
136*4d6fc14bSjoerg
137*4d6fc14bSjoerg//  C99
138*4d6fc14bSjoerg
139*4d6fc14bSjoergbool signbit(arithmetic x);
140*4d6fc14bSjoerg
141*4d6fc14bSjoergint fpclassify(arithmetic x);
142*4d6fc14bSjoerg
143*4d6fc14bSjoergbool isfinite(arithmetic x);
144*4d6fc14bSjoergbool isinf(arithmetic x);
145*4d6fc14bSjoergbool isnan(arithmetic x);
146*4d6fc14bSjoergbool isnormal(arithmetic x);
147*4d6fc14bSjoerg
148*4d6fc14bSjoergbool isgreater(arithmetic x, arithmetic y);
149*4d6fc14bSjoergbool isgreaterequal(arithmetic x, arithmetic y);
150*4d6fc14bSjoergbool isless(arithmetic x, arithmetic y);
151*4d6fc14bSjoergbool islessequal(arithmetic x, arithmetic y);
152*4d6fc14bSjoergbool islessgreater(arithmetic x, arithmetic y);
153*4d6fc14bSjoergbool isunordered(arithmetic x, arithmetic y);
154*4d6fc14bSjoerg
155*4d6fc14bSjoergfloating_point acosh (arithmetic x);
156*4d6fc14bSjoergfloat          acoshf(float x);
157*4d6fc14bSjoerglong double    acoshl(long double x);
158*4d6fc14bSjoerg
159*4d6fc14bSjoergfloating_point asinh (arithmetic x);
160*4d6fc14bSjoergfloat          asinhf(float x);
161*4d6fc14bSjoerglong double    asinhl(long double x);
162*4d6fc14bSjoerg
163*4d6fc14bSjoergfloating_point atanh (arithmetic x);
164*4d6fc14bSjoergfloat          atanhf(float x);
165*4d6fc14bSjoerglong double    atanhl(long double x);
166*4d6fc14bSjoerg
167*4d6fc14bSjoergfloating_point cbrt (arithmetic x);
168*4d6fc14bSjoergfloat          cbrtf(float x);
169*4d6fc14bSjoerglong double    cbrtl(long double x);
170*4d6fc14bSjoerg
171*4d6fc14bSjoergfloating_point copysign (arithmetic x, arithmetic y);
172*4d6fc14bSjoergfloat          copysignf(float x, float y);
173*4d6fc14bSjoerglong double    copysignl(long double x, long double y);
174*4d6fc14bSjoerg
175*4d6fc14bSjoergfloating_point erf (arithmetic x);
176*4d6fc14bSjoergfloat          erff(float x);
177*4d6fc14bSjoerglong double    erfl(long double x);
178*4d6fc14bSjoerg
179*4d6fc14bSjoergfloating_point erfc (arithmetic x);
180*4d6fc14bSjoergfloat          erfcf(float x);
181*4d6fc14bSjoerglong double    erfcl(long double x);
182*4d6fc14bSjoerg
183*4d6fc14bSjoergfloating_point exp2 (arithmetic x);
184*4d6fc14bSjoergfloat          exp2f(float x);
185*4d6fc14bSjoerglong double    exp2l(long double x);
186*4d6fc14bSjoerg
187*4d6fc14bSjoergfloating_point expm1 (arithmetic x);
188*4d6fc14bSjoergfloat          expm1f(float x);
189*4d6fc14bSjoerglong double    expm1l(long double x);
190*4d6fc14bSjoerg
191*4d6fc14bSjoergfloating_point fdim (arithmetic x, arithmetic y);
192*4d6fc14bSjoergfloat          fdimf(float x, float y);
193*4d6fc14bSjoerglong double    fdiml(long double x, long double y);
194*4d6fc14bSjoerg
195*4d6fc14bSjoergfloating_point fma (arithmetic x, arithmetic y, arithmetic z);
196*4d6fc14bSjoergfloat          fmaf(float x, float y, float z);
197*4d6fc14bSjoerglong double    fmal(long double x, long double y, long double z);
198*4d6fc14bSjoerg
199*4d6fc14bSjoergfloating_point fmax (arithmetic x, arithmetic y);
200*4d6fc14bSjoergfloat          fmaxf(float x, float y);
201*4d6fc14bSjoerglong double    fmaxl(long double x, long double y);
202*4d6fc14bSjoerg
203*4d6fc14bSjoergfloating_point fmin (arithmetic x, arithmetic y);
204*4d6fc14bSjoergfloat          fminf(float x, float y);
205*4d6fc14bSjoerglong double    fminl(long double x, long double y);
206*4d6fc14bSjoerg
207*4d6fc14bSjoergfloating_point hypot (arithmetic x, arithmetic y);
208*4d6fc14bSjoergfloat          hypotf(float x, float y);
209*4d6fc14bSjoerglong double    hypotl(long double x, long double y);
210*4d6fc14bSjoerg
211*4d6fc14bSjoergdouble       hypot(double x, double y, double z);                // C++17
212*4d6fc14bSjoergfloat        hypot(float x, float y, float z);                   // C++17
213*4d6fc14bSjoerglong double  hypot(long double x, long double y, long double z); // C++17
214*4d6fc14bSjoerg
215*4d6fc14bSjoergint ilogb (arithmetic x);
216*4d6fc14bSjoergint ilogbf(float x);
217*4d6fc14bSjoergint ilogbl(long double x);
218*4d6fc14bSjoerg
219*4d6fc14bSjoergfloating_point lgamma (arithmetic x);
220*4d6fc14bSjoergfloat          lgammaf(float x);
221*4d6fc14bSjoerglong double    lgammal(long double x);
222*4d6fc14bSjoerg
223*4d6fc14bSjoerglong long llrint (arithmetic x);
224*4d6fc14bSjoerglong long llrintf(float x);
225*4d6fc14bSjoerglong long llrintl(long double x);
226*4d6fc14bSjoerg
227*4d6fc14bSjoerglong long llround (arithmetic x);
228*4d6fc14bSjoerglong long llroundf(float x);
229*4d6fc14bSjoerglong long llroundl(long double x);
230*4d6fc14bSjoerg
231*4d6fc14bSjoergfloating_point log1p (arithmetic x);
232*4d6fc14bSjoergfloat          log1pf(float x);
233*4d6fc14bSjoerglong double    log1pl(long double x);
234*4d6fc14bSjoerg
235*4d6fc14bSjoergfloating_point log2 (arithmetic x);
236*4d6fc14bSjoergfloat          log2f(float x);
237*4d6fc14bSjoerglong double    log2l(long double x);
238*4d6fc14bSjoerg
239*4d6fc14bSjoergfloating_point logb (arithmetic x);
240*4d6fc14bSjoergfloat          logbf(float x);
241*4d6fc14bSjoerglong double    logbl(long double x);
242*4d6fc14bSjoerg
243*4d6fc14bSjoerglong lrint (arithmetic x);
244*4d6fc14bSjoerglong lrintf(float x);
245*4d6fc14bSjoerglong lrintl(long double x);
246*4d6fc14bSjoerg
247*4d6fc14bSjoerglong lround (arithmetic x);
248*4d6fc14bSjoerglong lroundf(float x);
249*4d6fc14bSjoerglong lroundl(long double x);
250*4d6fc14bSjoerg
251*4d6fc14bSjoergdouble      nan (const char* str);
252*4d6fc14bSjoergfloat       nanf(const char* str);
253*4d6fc14bSjoerglong double nanl(const char* str);
254*4d6fc14bSjoerg
255*4d6fc14bSjoergfloating_point nearbyint (arithmetic x);
256*4d6fc14bSjoergfloat          nearbyintf(float x);
257*4d6fc14bSjoerglong double    nearbyintl(long double x);
258*4d6fc14bSjoerg
259*4d6fc14bSjoergfloating_point nextafter (arithmetic x, arithmetic y);
260*4d6fc14bSjoergfloat          nextafterf(float x, float y);
261*4d6fc14bSjoerglong double    nextafterl(long double x, long double y);
262*4d6fc14bSjoerg
263*4d6fc14bSjoergfloating_point nexttoward (arithmetic x, long double y);
264*4d6fc14bSjoergfloat          nexttowardf(float x, long double y);
265*4d6fc14bSjoerglong double    nexttowardl(long double x, long double y);
266*4d6fc14bSjoerg
267*4d6fc14bSjoergfloating_point remainder (arithmetic x, arithmetic y);
268*4d6fc14bSjoergfloat          remainderf(float x, float y);
269*4d6fc14bSjoerglong double    remainderl(long double x, long double y);
270*4d6fc14bSjoerg
271*4d6fc14bSjoergfloating_point remquo (arithmetic x, arithmetic y, int* pquo);
272*4d6fc14bSjoergfloat          remquof(float x, float y, int* pquo);
273*4d6fc14bSjoerglong double    remquol(long double x, long double y, int* pquo);
274*4d6fc14bSjoerg
275*4d6fc14bSjoergfloating_point rint (arithmetic x);
276*4d6fc14bSjoergfloat          rintf(float x);
277*4d6fc14bSjoerglong double    rintl(long double x);
278*4d6fc14bSjoerg
279*4d6fc14bSjoergfloating_point round (arithmetic x);
280*4d6fc14bSjoergfloat          roundf(float x);
281*4d6fc14bSjoerglong double    roundl(long double x);
282*4d6fc14bSjoerg
283*4d6fc14bSjoergfloating_point scalbln (arithmetic x, long ex);
284*4d6fc14bSjoergfloat          scalblnf(float x, long ex);
285*4d6fc14bSjoerglong double    scalblnl(long double x, long ex);
286*4d6fc14bSjoerg
287*4d6fc14bSjoergfloating_point scalbn (arithmetic x, int ex);
288*4d6fc14bSjoergfloat          scalbnf(float x, int ex);
289*4d6fc14bSjoerglong double    scalbnl(long double x, int ex);
290*4d6fc14bSjoerg
291*4d6fc14bSjoergfloating_point tgamma (arithmetic x);
292*4d6fc14bSjoergfloat          tgammaf(float x);
293*4d6fc14bSjoerglong double    tgammal(long double x);
294*4d6fc14bSjoerg
295*4d6fc14bSjoergfloating_point trunc (arithmetic x);
296*4d6fc14bSjoergfloat          truncf(float x);
297*4d6fc14bSjoerglong double    truncl(long double x);
298*4d6fc14bSjoerg
299*4d6fc14bSjoergconstexpr float       lerp(float a, float b, float t) noexcept;                   // C++20
300*4d6fc14bSjoergconstexpr double      lerp(double a, double b, double t) noexcept;                // C++20
301*4d6fc14bSjoergconstexpr long double lerp(long double a, long double b, long double t) noexcept; // C++20
302*4d6fc14bSjoerg
303*4d6fc14bSjoerg}  // std
304*4d6fc14bSjoerg
305*4d6fc14bSjoerg*/
306*4d6fc14bSjoerg
307*4d6fc14bSjoerg#include <__config>
308*4d6fc14bSjoerg#include <math.h>
309*4d6fc14bSjoerg#include <version>
310*4d6fc14bSjoerg#include <type_traits>
311*4d6fc14bSjoerg
312*4d6fc14bSjoerg#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
313*4d6fc14bSjoerg#pragma GCC system_header
314*4d6fc14bSjoerg#endif
315*4d6fc14bSjoerg
316*4d6fc14bSjoerg_LIBCPP_PUSH_MACROS
317*4d6fc14bSjoerg#include <__undef_macros>
318*4d6fc14bSjoerg
319*4d6fc14bSjoerg_LIBCPP_BEGIN_NAMESPACE_STD
320*4d6fc14bSjoerg
321*4d6fc14bSjoergusing ::signbit;
322*4d6fc14bSjoergusing ::fpclassify;
323*4d6fc14bSjoergusing ::isfinite;
324*4d6fc14bSjoergusing ::isinf;
325*4d6fc14bSjoergusing ::isnan;
326*4d6fc14bSjoergusing ::isnormal;
327*4d6fc14bSjoergusing ::isgreater;
328*4d6fc14bSjoergusing ::isgreaterequal;
329*4d6fc14bSjoergusing ::isless;
330*4d6fc14bSjoergusing ::islessequal;
331*4d6fc14bSjoergusing ::islessgreater;
332*4d6fc14bSjoergusing ::isunordered;
333*4d6fc14bSjoergusing ::isunordered;
334*4d6fc14bSjoerg
335*4d6fc14bSjoergusing ::float_t;
336*4d6fc14bSjoergusing ::double_t;
337*4d6fc14bSjoerg
338*4d6fc14bSjoergusing ::abs;
339*4d6fc14bSjoerg
340*4d6fc14bSjoergusing ::acos;
341*4d6fc14bSjoergusing ::acosf;
342*4d6fc14bSjoergusing ::asin;
343*4d6fc14bSjoergusing ::asinf;
344*4d6fc14bSjoergusing ::atan;
345*4d6fc14bSjoergusing ::atanf;
346*4d6fc14bSjoergusing ::atan2;
347*4d6fc14bSjoergusing ::atan2f;
348*4d6fc14bSjoergusing ::ceil;
349*4d6fc14bSjoergusing ::ceilf;
350*4d6fc14bSjoergusing ::cos;
351*4d6fc14bSjoergusing ::cosf;
352*4d6fc14bSjoergusing ::cosh;
353*4d6fc14bSjoergusing ::coshf;
354*4d6fc14bSjoerg
355*4d6fc14bSjoergusing ::exp;
356*4d6fc14bSjoergusing ::expf;
357*4d6fc14bSjoerg
358*4d6fc14bSjoergusing ::fabs;
359*4d6fc14bSjoergusing ::fabsf;
360*4d6fc14bSjoergusing ::floor;
361*4d6fc14bSjoergusing ::floorf;
362*4d6fc14bSjoerg
363*4d6fc14bSjoergusing ::fmod;
364*4d6fc14bSjoergusing ::fmodf;
365*4d6fc14bSjoerg
366*4d6fc14bSjoergusing ::frexp;
367*4d6fc14bSjoergusing ::frexpf;
368*4d6fc14bSjoergusing ::ldexp;
369*4d6fc14bSjoergusing ::ldexpf;
370*4d6fc14bSjoerg
371*4d6fc14bSjoergusing ::log;
372*4d6fc14bSjoergusing ::logf;
373*4d6fc14bSjoerg
374*4d6fc14bSjoergusing ::log10;
375*4d6fc14bSjoergusing ::log10f;
376*4d6fc14bSjoergusing ::modf;
377*4d6fc14bSjoergusing ::modff;
378*4d6fc14bSjoerg
379*4d6fc14bSjoergusing ::pow;
380*4d6fc14bSjoergusing ::powf;
381*4d6fc14bSjoerg
382*4d6fc14bSjoergusing ::sin;
383*4d6fc14bSjoergusing ::sinf;
384*4d6fc14bSjoergusing ::sinh;
385*4d6fc14bSjoergusing ::sinhf;
386*4d6fc14bSjoerg
387*4d6fc14bSjoergusing ::sqrt;
388*4d6fc14bSjoergusing ::sqrtf;
389*4d6fc14bSjoergusing ::tan;
390*4d6fc14bSjoergusing ::tanf;
391*4d6fc14bSjoerg
392*4d6fc14bSjoergusing ::tanh;
393*4d6fc14bSjoergusing ::tanhf;
394*4d6fc14bSjoerg
395*4d6fc14bSjoergusing ::acosh;
396*4d6fc14bSjoergusing ::acoshf;
397*4d6fc14bSjoergusing ::asinh;
398*4d6fc14bSjoergusing ::asinhf;
399*4d6fc14bSjoergusing ::atanh;
400*4d6fc14bSjoergusing ::atanhf;
401*4d6fc14bSjoergusing ::cbrt;
402*4d6fc14bSjoergusing ::cbrtf;
403*4d6fc14bSjoerg
404*4d6fc14bSjoergusing ::copysign;
405*4d6fc14bSjoergusing ::copysignf;
406*4d6fc14bSjoerg
407*4d6fc14bSjoergusing ::erf;
408*4d6fc14bSjoergusing ::erff;
409*4d6fc14bSjoergusing ::erfc;
410*4d6fc14bSjoergusing ::erfcf;
411*4d6fc14bSjoergusing ::exp2;
412*4d6fc14bSjoergusing ::exp2f;
413*4d6fc14bSjoergusing ::expm1;
414*4d6fc14bSjoergusing ::expm1f;
415*4d6fc14bSjoergusing ::fdim;
416*4d6fc14bSjoergusing ::fdimf;
417*4d6fc14bSjoergusing ::fmaf;
418*4d6fc14bSjoergusing ::fma;
419*4d6fc14bSjoergusing ::fmax;
420*4d6fc14bSjoergusing ::fmaxf;
421*4d6fc14bSjoergusing ::fmin;
422*4d6fc14bSjoergusing ::fminf;
423*4d6fc14bSjoergusing ::hypot;
424*4d6fc14bSjoergusing ::hypotf;
425*4d6fc14bSjoergusing ::ilogb;
426*4d6fc14bSjoergusing ::ilogbf;
427*4d6fc14bSjoergusing ::lgamma;
428*4d6fc14bSjoergusing ::lgammaf;
429*4d6fc14bSjoergusing ::llrint;
430*4d6fc14bSjoergusing ::llrintf;
431*4d6fc14bSjoergusing ::llround;
432*4d6fc14bSjoergusing ::llroundf;
433*4d6fc14bSjoergusing ::log1p;
434*4d6fc14bSjoergusing ::log1pf;
435*4d6fc14bSjoergusing ::log2;
436*4d6fc14bSjoergusing ::log2f;
437*4d6fc14bSjoergusing ::logb;
438*4d6fc14bSjoergusing ::logbf;
439*4d6fc14bSjoergusing ::lrint;
440*4d6fc14bSjoergusing ::lrintf;
441*4d6fc14bSjoergusing ::lround;
442*4d6fc14bSjoergusing ::lroundf;
443*4d6fc14bSjoerg
444*4d6fc14bSjoergusing ::nan;
445*4d6fc14bSjoergusing ::nanf;
446*4d6fc14bSjoerg
447*4d6fc14bSjoergusing ::nearbyint;
448*4d6fc14bSjoergusing ::nearbyintf;
449*4d6fc14bSjoergusing ::nextafter;
450*4d6fc14bSjoergusing ::nextafterf;
451*4d6fc14bSjoergusing ::nexttoward;
452*4d6fc14bSjoergusing ::nexttowardf;
453*4d6fc14bSjoergusing ::remainder;
454*4d6fc14bSjoergusing ::remainderf;
455*4d6fc14bSjoergusing ::remquo;
456*4d6fc14bSjoergusing ::remquof;
457*4d6fc14bSjoergusing ::rint;
458*4d6fc14bSjoergusing ::rintf;
459*4d6fc14bSjoergusing ::round;
460*4d6fc14bSjoergusing ::roundf;
461*4d6fc14bSjoergusing ::scalbln;
462*4d6fc14bSjoergusing ::scalblnf;
463*4d6fc14bSjoergusing ::scalbn;
464*4d6fc14bSjoergusing ::scalbnf;
465*4d6fc14bSjoergusing ::tgamma;
466*4d6fc14bSjoergusing ::tgammaf;
467*4d6fc14bSjoergusing ::trunc;
468*4d6fc14bSjoergusing ::truncf;
469*4d6fc14bSjoerg
470*4d6fc14bSjoergusing ::acosl;
471*4d6fc14bSjoergusing ::asinl;
472*4d6fc14bSjoergusing ::atanl;
473*4d6fc14bSjoergusing ::atan2l;
474*4d6fc14bSjoergusing ::ceill;
475*4d6fc14bSjoergusing ::cosl;
476*4d6fc14bSjoergusing ::coshl;
477*4d6fc14bSjoergusing ::expl;
478*4d6fc14bSjoergusing ::fabsl;
479*4d6fc14bSjoergusing ::floorl;
480*4d6fc14bSjoergusing ::fmodl;
481*4d6fc14bSjoergusing ::frexpl;
482*4d6fc14bSjoergusing ::ldexpl;
483*4d6fc14bSjoergusing ::logl;
484*4d6fc14bSjoergusing ::log10l;
485*4d6fc14bSjoergusing ::modfl;
486*4d6fc14bSjoergusing ::powl;
487*4d6fc14bSjoergusing ::sinl;
488*4d6fc14bSjoergusing ::sinhl;
489*4d6fc14bSjoergusing ::sqrtl;
490*4d6fc14bSjoergusing ::tanl;
491*4d6fc14bSjoerg
492*4d6fc14bSjoergusing ::tanhl;
493*4d6fc14bSjoergusing ::acoshl;
494*4d6fc14bSjoergusing ::asinhl;
495*4d6fc14bSjoergusing ::atanhl;
496*4d6fc14bSjoergusing ::cbrtl;
497*4d6fc14bSjoerg
498*4d6fc14bSjoergusing ::copysignl;
499*4d6fc14bSjoerg
500*4d6fc14bSjoergusing ::erfl;
501*4d6fc14bSjoergusing ::erfcl;
502*4d6fc14bSjoergusing ::exp2l;
503*4d6fc14bSjoergusing ::expm1l;
504*4d6fc14bSjoergusing ::fdiml;
505*4d6fc14bSjoergusing ::fmal;
506*4d6fc14bSjoergusing ::fmaxl;
507*4d6fc14bSjoergusing ::fminl;
508*4d6fc14bSjoergusing ::hypotl;
509*4d6fc14bSjoergusing ::ilogbl;
510*4d6fc14bSjoergusing ::lgammal;
511*4d6fc14bSjoergusing ::llrintl;
512*4d6fc14bSjoergusing ::llroundl;
513*4d6fc14bSjoergusing ::log1pl;
514*4d6fc14bSjoergusing ::log2l;
515*4d6fc14bSjoergusing ::logbl;
516*4d6fc14bSjoergusing ::lrintl;
517*4d6fc14bSjoergusing ::lroundl;
518*4d6fc14bSjoergusing ::nanl;
519*4d6fc14bSjoergusing ::nearbyintl;
520*4d6fc14bSjoergusing ::nextafterl;
521*4d6fc14bSjoergusing ::nexttowardl;
522*4d6fc14bSjoergusing ::remainderl;
523*4d6fc14bSjoergusing ::remquol;
524*4d6fc14bSjoergusing ::rintl;
525*4d6fc14bSjoergusing ::roundl;
526*4d6fc14bSjoergusing ::scalblnl;
527*4d6fc14bSjoergusing ::scalbnl;
528*4d6fc14bSjoergusing ::tgammal;
529*4d6fc14bSjoergusing ::truncl;
530*4d6fc14bSjoerg
531*4d6fc14bSjoerg#if _LIBCPP_STD_VER > 14
532*4d6fc14bSjoerginline _LIBCPP_INLINE_VISIBILITY float       hypot(       float x,       float y,       float z ) { return sqrt(x*x + y*y + z*z); }
533*4d6fc14bSjoerginline _LIBCPP_INLINE_VISIBILITY double      hypot(      double x,      double y,      double z ) { return sqrt(x*x + y*y + z*z); }
534*4d6fc14bSjoerginline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y, long double z ) { return sqrt(x*x + y*y + z*z); }
535*4d6fc14bSjoerg
536*4d6fc14bSjoergtemplate <class _A1, class _A2, class _A3>
537*4d6fc14bSjoerginline _LIBCPP_INLINE_VISIBILITY
538*4d6fc14bSjoergtypename _EnableIf
539*4d6fc14bSjoerg<
540*4d6fc14bSjoerg    is_arithmetic<_A1>::value &&
541*4d6fc14bSjoerg    is_arithmetic<_A2>::value &&
542*4d6fc14bSjoerg    is_arithmetic<_A3>::value,
543*4d6fc14bSjoerg    __promote<_A1, _A2, _A3>
544*4d6fc14bSjoerg>::type
545*4d6fc14bSjoerghypot(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
546*4d6fc14bSjoerg{
547*4d6fc14bSjoerg    typedef typename __promote<_A1, _A2, _A3>::type __result_type;
548*4d6fc14bSjoerg    static_assert((!(is_same<_A1, __result_type>::value &&
549*4d6fc14bSjoerg                     is_same<_A2, __result_type>::value &&
550*4d6fc14bSjoerg                     is_same<_A3, __result_type>::value)), "");
551*4d6fc14bSjoerg    return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
552*4d6fc14bSjoerg}
553*4d6fc14bSjoerg#endif
554*4d6fc14bSjoerg
555*4d6fc14bSjoergtemplate <class _A1>
556*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
557*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
558*4d6fc14bSjoerg__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
559*4d6fc14bSjoerg{
560*4d6fc14bSjoerg#if __has_builtin(__builtin_isnan)
561*4d6fc14bSjoerg    return __builtin_isnan(__lcpp_x);
562*4d6fc14bSjoerg#else
563*4d6fc14bSjoerg    return isnan(__lcpp_x);
564*4d6fc14bSjoerg#endif
565*4d6fc14bSjoerg}
566*4d6fc14bSjoerg
567*4d6fc14bSjoergtemplate <class _A1>
568*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
569*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
570*4d6fc14bSjoerg__libcpp_isnan_or_builtin(_A1 __lcpp_x) _NOEXCEPT
571*4d6fc14bSjoerg{
572*4d6fc14bSjoerg    return isnan(__lcpp_x);
573*4d6fc14bSjoerg}
574*4d6fc14bSjoerg
575*4d6fc14bSjoergtemplate <class _A1>
576*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
577*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
578*4d6fc14bSjoerg__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
579*4d6fc14bSjoerg{
580*4d6fc14bSjoerg#if __has_builtin(__builtin_isinf)
581*4d6fc14bSjoerg    return __builtin_isinf(__lcpp_x);
582*4d6fc14bSjoerg#else
583*4d6fc14bSjoerg    return isinf(__lcpp_x);
584*4d6fc14bSjoerg#endif
585*4d6fc14bSjoerg}
586*4d6fc14bSjoerg
587*4d6fc14bSjoergtemplate <class _A1>
588*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
589*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
590*4d6fc14bSjoerg__libcpp_isinf_or_builtin(_A1 __lcpp_x) _NOEXCEPT
591*4d6fc14bSjoerg{
592*4d6fc14bSjoerg    return isinf(__lcpp_x);
593*4d6fc14bSjoerg}
594*4d6fc14bSjoerg
595*4d6fc14bSjoergtemplate <class _A1>
596*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
597*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<is_floating_point<_A1>::value, bool>::type
598*4d6fc14bSjoerg__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
599*4d6fc14bSjoerg{
600*4d6fc14bSjoerg#if __has_builtin(__builtin_isfinite)
601*4d6fc14bSjoerg    return __builtin_isfinite(__lcpp_x);
602*4d6fc14bSjoerg#else
603*4d6fc14bSjoerg    return isfinite(__lcpp_x);
604*4d6fc14bSjoerg#endif
605*4d6fc14bSjoerg}
606*4d6fc14bSjoerg
607*4d6fc14bSjoergtemplate <class _A1>
608*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
609*4d6fc14bSjoerg_LIBCPP_CONSTEXPR typename enable_if<!is_floating_point<_A1>::value, bool>::type
610*4d6fc14bSjoerg__libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
611*4d6fc14bSjoerg{
612*4d6fc14bSjoerg    return isfinite(__lcpp_x);
613*4d6fc14bSjoerg}
614*4d6fc14bSjoerg
615*4d6fc14bSjoerg#if _LIBCPP_STD_VER > 17
616*4d6fc14bSjoergtemplate <typename _Fp>
617*4d6fc14bSjoergconstexpr
618*4d6fc14bSjoerg_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
619*4d6fc14bSjoerg    if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
620*4d6fc14bSjoerg        return __t * __b + (1 - __t) * __a;
621*4d6fc14bSjoerg
622*4d6fc14bSjoerg    if (__t == 1) return __b;
623*4d6fc14bSjoerg    const _Fp __x = __a + __t * (__b - __a);
624*4d6fc14bSjoerg    if (__t > 1 == __b > __a)
625*4d6fc14bSjoerg        return __b < __x ? __x : __b;
626*4d6fc14bSjoerg    else
627*4d6fc14bSjoerg        return __x < __b ? __x : __b;
628*4d6fc14bSjoerg}
629*4d6fc14bSjoerg
630*4d6fc14bSjoergconstexpr float
631*4d6fc14bSjoerglerp(float __a, float __b, float __t)                   _NOEXCEPT { return __lerp(__a, __b, __t); }
632*4d6fc14bSjoerg
633*4d6fc14bSjoergconstexpr double
634*4d6fc14bSjoerglerp(double __a, double __b, double __t)                _NOEXCEPT { return __lerp(__a, __b, __t); }
635*4d6fc14bSjoerg
636*4d6fc14bSjoergconstexpr long double
637*4d6fc14bSjoerglerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
638*4d6fc14bSjoerg
639*4d6fc14bSjoerg#endif // _LIBCPP_STD_VER > 17
640*4d6fc14bSjoerg
641*4d6fc14bSjoergtemplate <class _IntT, class _FloatT,
642*4d6fc14bSjoerg    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
643*4d6fc14bSjoerg    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
644*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
645*4d6fc14bSjoerg_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT {
646*4d6fc14bSjoerg  static_assert(is_floating_point<_FloatT>::value, "must be a floating point type");
647*4d6fc14bSjoerg  static_assert(is_integral<_IntT>::value, "must be an integral type");
648*4d6fc14bSjoerg  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
649*4d6fc14bSjoerg  static_assert((_IsSame<_FloatT, float>::value || _IsSame<_FloatT, double>::value
650*4d6fc14bSjoerg                 || _IsSame<_FloatT,long double>::value), "unsupported floating point type");
651*4d6fc14bSjoerg  return _FloatBigger ? numeric_limits<_IntT>::max() :  (numeric_limits<_IntT>::max() >> _Bits << _Bits);
652*4d6fc14bSjoerg}
653*4d6fc14bSjoerg
654*4d6fc14bSjoerg// Convert a floating point number to the specified integral type after
655*4d6fc14bSjoerg// clamping to the integral types representable range.
656*4d6fc14bSjoerg//
657*4d6fc14bSjoerg// The behavior is undefined if `__r` is NaN.
658*4d6fc14bSjoergtemplate <class _IntT, class _RealT>
659*4d6fc14bSjoerg_LIBCPP_INLINE_VISIBILITY
660*4d6fc14bSjoerg_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT {
661*4d6fc14bSjoerg  using _Lim = numeric_limits<_IntT>;
662*4d6fc14bSjoerg  const _IntT _MaxVal = __max_representable_int_for_float<_IntT, _RealT>();
663*4d6fc14bSjoerg  if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) {
664*4d6fc14bSjoerg    return _Lim::max();
665*4d6fc14bSjoerg  } else if (__r <= _Lim::lowest()) {
666*4d6fc14bSjoerg    return _Lim::min();
667*4d6fc14bSjoerg  }
668*4d6fc14bSjoerg  return static_cast<_IntT>(__r);
669*4d6fc14bSjoerg}
670*4d6fc14bSjoerg
671*4d6fc14bSjoerg_LIBCPP_END_NAMESPACE_STD
672*4d6fc14bSjoerg
673*4d6fc14bSjoerg_LIBCPP_POP_MACROS
674*4d6fc14bSjoerg
675*4d6fc14bSjoerg#endif // _LIBCPP_CMATH
676