1// -*- C++ -*- C forwarding header.
2
3// Copyright (C) 1997-2017 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 include/cmath
26 * This is a Standard C++ Library file. You should @c \#include this file
27 * in your programs, rather than any of the @a *.h implementation files.
28 *
29 * This is the C++ version of the Standard C Library header @c math.h,
30 * and its contents are (mostly) the same as that header, but are all
31 * contained in the namespace @c std (except for names which are defined
32 * as macros in C).
33 */
34
35//
36// ISO C++ 14882: 26.5 C library
37//
38
39#pragma GCC system_header
40
41#include <bits/c++config.h>
42#include <bits/cpp_type_traits.h>
43#include <ext/type_traits.h>
44#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
45#include_next <math.h>
46#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
47#include <bits/std_abs.h>
48
49#ifndef _GLIBCXX_CMATH
50#define _GLIBCXX_CMATH 1
51
52// Get rid of those macros defined in <math.h> in lieu of real functions.
53#undef div
54#undef acos
55#undef asin
56#undef atan
57#undef atan2
58#undef ceil
59#undef cos
60#undef cosh
61#undef exp
62#undef fabs
63#undef floor
64#undef fmod
65#undef frexp
66#undef ldexp
67#undef log
68#undef log10
69#undef modf
70#undef pow
71#undef sin
72#undef sinh
73#undef sqrt
74#undef tan
75#undef tanh
76
77extern "C++"
78{
79namespace std _GLIBCXX_VISIBILITY(default)
80{
81_GLIBCXX_BEGIN_NAMESPACE_VERSION
82
83 using ::acos;
84
85#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
86 inline _GLIBCXX_CONSTEXPR float
87 acos(float __x)
88 { return __builtin_acosf(__x); }
89
90 inline _GLIBCXX_CONSTEXPR long double
91 acos(long double __x)
92 { return __builtin_acosl(__x); }
93#endif
94
95 template<typename _Tp>
96 inline _GLIBCXX_CONSTEXPR
97 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
98 double>::__type
99 acos(_Tp __x)
100 { return __builtin_acos(__x); }
101
102 using ::asin;
103
104#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
105 inline _GLIBCXX_CONSTEXPR float
106 asin(float __x)
107 { return __builtin_asinf(__x); }
108
109 inline _GLIBCXX_CONSTEXPR long double
110 asin(long double __x)
111 { return __builtin_asinl(__x); }
112#endif
113
114 template<typename _Tp>
115 inline _GLIBCXX_CONSTEXPR
116 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
117 double>::__type
118 asin(_Tp __x)
119 { return __builtin_asin(__x); }
120
121 using ::atan;
122
123#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
124 inline _GLIBCXX_CONSTEXPR float
125 atan(float __x)
126 { return __builtin_atanf(__x); }
127
128 inline _GLIBCXX_CONSTEXPR long double
129 atan(long double __x)
130 { return __builtin_atanl(__x); }
131#endif
132
133 template<typename _Tp>
134 inline _GLIBCXX_CONSTEXPR
135 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
136 double>::__type
137 atan(_Tp __x)
138 { return __builtin_atan(__x); }
139
140 using ::atan2;
141
142#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
143 inline _GLIBCXX_CONSTEXPR float
144 atan2(float __y, float __x)
145 { return __builtin_atan2f(__y, __x); }
146
147 inline _GLIBCXX_CONSTEXPR long double
148 atan2(long double __y, long double __x)
149 { return __builtin_atan2l(__y, __x); }
150#endif
151
152 template<typename _Tp, typename _Up>
153 inline _GLIBCXX_CONSTEXPR
154 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
155 atan2(_Tp __y, _Up __x)
156 {
157 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
158 return atan2(__type(__y), __type(__x));
159 }
160
161 using ::ceil;
162
163#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
164 inline _GLIBCXX_CONSTEXPR float
165 ceil(float __x)
166 { return __builtin_ceilf(__x); }
167
168 inline _GLIBCXX_CONSTEXPR long double
169 ceil(long double __x)
170 { return __builtin_ceill(__x); }
171#endif
172
173 template<typename _Tp>
174 inline _GLIBCXX_CONSTEXPR
175 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
176 double>::__type
177 ceil(_Tp __x)
178 { return __builtin_ceil(__x); }
179
180 using ::cos;
181
182#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
183 inline _GLIBCXX_CONSTEXPR float
184 cos(float __x)
185 { return __builtin_cosf(__x); }
186
187 inline _GLIBCXX_CONSTEXPR long double
188 cos(long double __x)
189 { return __builtin_cosl(__x); }
190#endif
191
192 template<typename _Tp>
193 inline _GLIBCXX_CONSTEXPR
194 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
195 double>::__type
196 cos(_Tp __x)
197 { return __builtin_cos(__x); }
198
199 using ::cosh;
200
201#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
202 inline _GLIBCXX_CONSTEXPR float
203 cosh(float __x)
204 { return __builtin_coshf(__x); }
205
206 inline _GLIBCXX_CONSTEXPR long double
207 cosh(long double __x)
208 { return __builtin_coshl(__x); }
209#endif
210
211 template<typename _Tp>
212 inline _GLIBCXX_CONSTEXPR
213 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
214 double>::__type
215 cosh(_Tp __x)
216 { return __builtin_cosh(__x); }
217
218 using ::exp;
219
220#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
221 inline _GLIBCXX_CONSTEXPR float
222 exp(float __x)
223 { return __builtin_expf(__x); }
224
225 inline _GLIBCXX_CONSTEXPR long double
226 exp(long double __x)
227 { return __builtin_expl(__x); }
228#endif
229
230 template<typename _Tp>
231 inline _GLIBCXX_CONSTEXPR
232 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
233 double>::__type
234 exp(_Tp __x)
235 { return __builtin_exp(__x); }
236
237 using ::fabs;
238
239#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
240 inline _GLIBCXX_CONSTEXPR float
241 fabs(float __x)
242 { return __builtin_fabsf(__x); }
243
244 inline _GLIBCXX_CONSTEXPR long double
245 fabs(long double __x)
246 { return __builtin_fabsl(__x); }
247#endif
248
249 template<typename _Tp>
250 inline _GLIBCXX_CONSTEXPR
251 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
252 double>::__type
253 fabs(_Tp __x)
254 { return __builtin_fabs(__x); }
255
256 using ::floor;
257
258#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
259 inline _GLIBCXX_CONSTEXPR float
260 floor(float __x)
261 { return __builtin_floorf(__x); }
262
263 inline _GLIBCXX_CONSTEXPR long double
264 floor(long double __x)
265 { return __builtin_floorl(__x); }
266#endif
267
268 template<typename _Tp>
269 inline _GLIBCXX_CONSTEXPR
270 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
271 double>::__type
272 floor(_Tp __x)
273 { return __builtin_floor(__x); }
274
275 using ::fmod;
276
277#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
278 inline _GLIBCXX_CONSTEXPR float
279 fmod(float __x, float __y)
280 { return __builtin_fmodf(__x, __y); }
281
282 inline _GLIBCXX_CONSTEXPR long double
283 fmod(long double __x, long double __y)
284 { return __builtin_fmodl(__x, __y); }
285#endif
286
287 template<typename _Tp, typename _Up>
288 inline _GLIBCXX_CONSTEXPR
289 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
290 fmod(_Tp __x, _Up __y)
291 {
292 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
293 return fmod(__type(__x), __type(__y));
294 }
295
296 using ::frexp;
297
298#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
299 inline float
300 frexp(float __x, int* __exp)
301 { return __builtin_frexpf(__x, __exp); }
302
303 inline long double
304 frexp(long double __x, int* __exp)
305 { return __builtin_frexpl(__x, __exp); }
306#endif
307
308 template<typename _Tp>
309 inline _GLIBCXX_CONSTEXPR
310 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
311 double>::__type
312 frexp(_Tp __x, int* __exp)
313 { return __builtin_frexp(__x, __exp); }
314
315 using ::ldexp;
316
317#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
318 inline _GLIBCXX_CONSTEXPR float
319 ldexp(float __x, int __exp)
320 { return __builtin_ldexpf(__x, __exp); }
321
322 inline _GLIBCXX_CONSTEXPR long double
323 ldexp(long double __x, int __exp)
324 { return __builtin_ldexpl(__x, __exp); }
325#endif
326
327 template<typename _Tp>
328 inline _GLIBCXX_CONSTEXPR
329 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
330 double>::__type
331 ldexp(_Tp __x, int __exp)
332 { return __builtin_ldexp(__x, __exp); }
333
334 using ::log;
335
336#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
337 inline _GLIBCXX_CONSTEXPR float
338 log(float __x)
339 { return __builtin_logf(__x); }
340
341 inline _GLIBCXX_CONSTEXPR long double
342 log(long double __x)
343 { return __builtin_logl(__x); }
344#endif
345
346 template<typename _Tp>
347 inline _GLIBCXX_CONSTEXPR
348 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
349 double>::__type
350 log(_Tp __x)
351 { return __builtin_log(__x); }
352
353 using ::log10;
354
355#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
356 inline _GLIBCXX_CONSTEXPR float
357 log10(float __x)
358 { return __builtin_log10f(__x); }
359
360 inline _GLIBCXX_CONSTEXPR long double
361 log10(long double __x)
362 { return __builtin_log10l(__x); }
363#endif
364
365 template<typename _Tp>
366 inline _GLIBCXX_CONSTEXPR
367 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
368 double>::__type
369 log10(_Tp __x)
370 { return __builtin_log10(__x); }
371
372 using ::modf;
373
374#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
375 inline float
376 modf(float __x, float* __iptr)
377 { return __builtin_modff(__x, __iptr); }
378
379 inline long double
380 modf(long double __x, long double* __iptr)
381 { return __builtin_modfl(__x, __iptr); }
382#endif
383
384 using ::pow;
385
386#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
387 inline _GLIBCXX_CONSTEXPR float
388 pow(float __x, float __y)
389 { return __builtin_powf(__x, __y); }
390
391 inline _GLIBCXX_CONSTEXPR long double
392 pow(long double __x, long double __y)
393 { return __builtin_powl(__x, __y); }
394
395#if __cplusplus < 201103L
396 // _GLIBCXX_RESOLVE_LIB_DEFECTS
397 // DR 550. What should the return type of pow(float,int) be?
398 inline double
399 pow(double __x, int __i)
400 { return __builtin_powi(__x, __i); }
401
402 inline float
403 pow(float __x, int __n)
404 { return __builtin_powif(__x, __n); }
405
406 inline long double
407 pow(long double __x, int __n)
408 { return __builtin_powil(__x, __n); }
409#endif
410#endif
411
412 template<typename _Tp, typename _Up>
413 inline _GLIBCXX_CONSTEXPR
414 typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
415 pow(_Tp __x, _Up __y)
416 {
417 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
418 return pow(__type(__x), __type(__y));
419 }
420
421 using ::sin;
422
423#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
424 inline _GLIBCXX_CONSTEXPR float
425 sin(float __x)
426 { return __builtin_sinf(__x); }
427
428 inline _GLIBCXX_CONSTEXPR long double
429 sin(long double __x)
430 { return __builtin_sinl(__x); }
431#endif
432
433 template<typename _Tp>
434 inline _GLIBCXX_CONSTEXPR
435 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
436 double>::__type
437 sin(_Tp __x)
438 { return __builtin_sin(__x); }
439
440 using ::sinh;
441
442#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
443 inline _GLIBCXX_CONSTEXPR float
444 sinh(float __x)
445 { return __builtin_sinhf(__x); }
446
447 inline _GLIBCXX_CONSTEXPR long double
448 sinh(long double __x)
449 { return __builtin_sinhl(__x); }
450#endif
451
452 template<typename _Tp>
453 inline _GLIBCXX_CONSTEXPR
454 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
455 double>::__type
456 sinh(_Tp __x)
457 { return __builtin_sinh(__x); }
458
459 using ::sqrt;
460
461#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
462 inline _GLIBCXX_CONSTEXPR float
463 sqrt(float __x)
464 { return __builtin_sqrtf(__x); }
465
466 inline _GLIBCXX_CONSTEXPR long double
467 sqrt(long double __x)
468 { return __builtin_sqrtl(__x); }
469#endif
470
471 template<typename _Tp>
472 inline _GLIBCXX_CONSTEXPR
473 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
474 double>::__type
475 sqrt(_Tp __x)
476 { return __builtin_sqrt(__x); }
477
478 using ::tan;
479
480#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
481 inline _GLIBCXX_CONSTEXPR float
482 tan(float __x)
483 { return __builtin_tanf(__x); }
484
485 inline _GLIBCXX_CONSTEXPR long double
486 tan(long double __x)
487 { return __builtin_tanl(__x); }
488#endif
489
490 template<typename _Tp>
491 inline _GLIBCXX_CONSTEXPR
492 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
493 double>::__type
494 tan(_Tp __x)
495 { return __builtin_tan(__x); }
496
497 using ::tanh;
498
499#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
500 inline _GLIBCXX_CONSTEXPR float
501 tanh(float __x)
502 { return __builtin_tanhf(__x); }
503
504 inline _GLIBCXX_CONSTEXPR long double
505 tanh(long double __x)
506 { return __builtin_tanhl(__x); }
507#endif
508
509 template<typename _Tp>
510 inline _GLIBCXX_CONSTEXPR
511 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
512 double>::__type
513 tanh(_Tp __x)
514 { return __builtin_tanh(__x); }
515
516_GLIBCXX_END_NAMESPACE_VERSION
517} // namespace
518
519#if _GLIBCXX_USE_C99_MATH
520#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
521
522// These are possible macros imported from C99-land.
523#undef fpclassify
524#undef isfinite
525#undef isinf
526#undef isnan
527#undef isnormal
528#undef signbit
529#undef isgreater
530#undef isgreaterequal
531#undef isless
532#undef islessequal
533#undef islessgreater
534#undef isunordered
535
536namespace std _GLIBCXX_VISIBILITY(default)
537{
538_GLIBCXX_BEGIN_NAMESPACE_VERSION
539
540#if __cplusplus >= 201103L
541
542#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
543 constexpr int
544 fpclassify(float __x)
545 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
546 FP_SUBNORMAL, FP_ZERO, __x); }
547
548 constexpr int
549 fpclassify(double __x)
550 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
551 FP_SUBNORMAL, FP_ZERO, __x); }
552
553 constexpr int
554 fpclassify(long double __x)
555 { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
556 FP_SUBNORMAL, FP_ZERO, __x); }
557#endif
558
559#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
560 template<typename _Tp>
561 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
562 int>::__type
563 fpclassify(_Tp __x)
564 { return __x != 0 ? FP_NORMAL : FP_ZERO; }
565#endif
566
567#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
568 constexpr bool
569 isfinite(float __x)
570 { return __builtin_isfinite(__x); }
571
572 constexpr bool
573 isfinite(double __x)
574 { return __builtin_isfinite(__x); }
575
576 constexpr bool
577 isfinite(long double __x)
578 { return __builtin_isfinite(__x); }
579#endif
580
581#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
582 template<typename _Tp>
583 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
584 bool>::__type
585 isfinite(_Tp __x)
586 { return true; }
587#endif
588
589#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
590 constexpr bool
591 isinf(float __x)
592 { return __builtin_isinf(__x); }
593
594#if _GLIBCXX_HAVE_OBSOLETE_ISINF \
595 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
596 using ::isinf;
597#else
598 constexpr bool
599 isinf(double __x)
600 { return __builtin_isinf(__x); }
601#endif
602
603 constexpr bool
604 isinf(long double __x)
605 { return __builtin_isinf(__x); }
606#endif
607
608#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
609 template<typename _Tp>
610 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
611 bool>::__type
612 isinf(_Tp __x)
613 { return false; }
614#endif
615
616#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
617 constexpr bool
618 isnan(float __x)
619 { return __builtin_isnan(__x); }
620
621#if _GLIBCXX_HAVE_OBSOLETE_ISNAN \
622 && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
623 using ::isnan;
624#else
625 constexpr bool
626 isnan(double __x)
627 { return __builtin_isnan(__x); }
628#endif
629
630 constexpr bool
631 isnan(long double __x)
632 { return __builtin_isnan(__x); }
633#endif
634
635#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
636 template<typename _Tp>
637 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
638 bool>::__type
639 isnan(_Tp __x)
640 { return false; }
641#endif
642
643#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
644 constexpr bool
645 isnormal(float __x)
646 { return __builtin_isnormal(__x); }
647
648 constexpr bool
649 isnormal(double __x)
650 { return __builtin_isnormal(__x); }
651
652 constexpr bool
653 isnormal(long double __x)
654 { return __builtin_isnormal(__x); }
655#endif
656
657#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
658 template<typename _Tp>
659 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
660 bool>::__type
661 isnormal(_Tp __x)
662 { return __x != 0 ? true : false; }
663#endif
664
665#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
666 // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic.
667 constexpr bool
668 signbit(float __x)
669 { return __builtin_signbit(__x); }
670
671 constexpr bool
672 signbit(double __x)
673 { return __builtin_signbit(__x); }
674
675 constexpr bool
676 signbit(long double __x)
677 { return __builtin_signbit(__x); }
678#endif
679
680#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
681 template<typename _Tp>
682 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
683 bool>::__type
684 signbit(_Tp __x)
685 { return __x < 0 ? true : false; }
686#endif
687
688#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
689 constexpr bool
690 isgreater(float __x, float __y)
691 { return __builtin_isgreater(__x, __y); }
692
693 constexpr bool
694 isgreater(double __x, double __y)
695 { return __builtin_isgreater(__x, __y); }
696
697 constexpr bool
698 isgreater(long double __x, long double __y)
699 { return __builtin_isgreater(__x, __y); }
700#endif
701
702#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
703 template<typename _Tp, typename _Up>
704 constexpr typename
705 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
706 && __is_arithmetic<_Up>::__value), bool>::__type
707 isgreater(_Tp __x, _Up __y)
708 {
709 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
710 return __builtin_isgreater(__type(__x), __type(__y));
711 }
712#endif
713
714#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
715 constexpr bool
716 isgreaterequal(float __x, float __y)
717 { return __builtin_isgreaterequal(__x, __y); }
718
719 constexpr bool
720 isgreaterequal(double __x, double __y)
721 { return __builtin_isgreaterequal(__x, __y); }
722
723 constexpr bool
724 isgreaterequal(long double __x, long double __y)
725 { return __builtin_isgreaterequal(__x, __y); }
726#endif
727
728#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
729 template<typename _Tp, typename _Up>
730 constexpr typename
731 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
732 && __is_arithmetic<_Up>::__value), bool>::__type
733 isgreaterequal(_Tp __x, _Up __y)
734 {
735 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
736 return __builtin_isgreaterequal(__type(__x), __type(__y));
737 }
738#endif
739
740#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
741 constexpr bool
742 isless(float __x, float __y)
743 { return __builtin_isless(__x, __y); }
744
745 constexpr bool
746 isless(double __x, double __y)
747 { return __builtin_isless(__x, __y); }
748
749 constexpr bool
750 isless(long double __x, long double __y)
751 { return __builtin_isless(__x, __y); }
752#endif
753
754#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
755 template<typename _Tp, typename _Up>
756 constexpr typename
757 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
758 && __is_arithmetic<_Up>::__value), bool>::__type
759 isless(_Tp __x, _Up __y)
760 {
761 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
762 return __builtin_isless(__type(__x), __type(__y));
763 }
764#endif
765
766#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
767 constexpr bool
768 islessequal(float __x, float __y)
769 { return __builtin_islessequal(__x, __y); }
770
771 constexpr bool
772 islessequal(double __x, double __y)
773 { return __builtin_islessequal(__x, __y); }
774
775 constexpr bool
776 islessequal(long double __x, long double __y)
777 { return __builtin_islessequal(__x, __y); }
778#endif
779
780#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
781 template<typename _Tp, typename _Up>
782 constexpr typename
783 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
784 && __is_arithmetic<_Up>::__value), bool>::__type
785 islessequal(_Tp __x, _Up __y)
786 {
787 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
788 return __builtin_islessequal(__type(__x), __type(__y));
789 }
790#endif
791
792#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
793 constexpr bool
794 islessgreater(float __x, float __y)
795 { return __builtin_islessgreater(__x, __y); }
796
797 constexpr bool
798 islessgreater(double __x, double __y)
799 { return __builtin_islessgreater(__x, __y); }
800
801 constexpr bool
802 islessgreater(long double __x, long double __y)
803 { return __builtin_islessgreater(__x, __y); }
804#endif
805
806#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
807 template<typename _Tp, typename _Up>
808 constexpr typename
809 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
810 && __is_arithmetic<_Up>::__value), bool>::__type
811 islessgreater(_Tp __x, _Up __y)
812 {
813 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
814 return __builtin_islessgreater(__type(__x), __type(__y));
815 }
816#endif
817
818#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
819 constexpr bool
820 isunordered(float __x, float __y)
821 { return __builtin_isunordered(__x, __y); }
822
823 constexpr bool
824 isunordered(double __x, double __y)
825 { return __builtin_isunordered(__x, __y); }
826
827 constexpr bool
828 isunordered(long double __x, long double __y)
829 { return __builtin_isunordered(__x, __y); }
830#endif
831
832#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
833 template<typename _Tp, typename _Up>
834 constexpr typename
835 __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
836 && __is_arithmetic<_Up>::__value), bool>::__type
837 isunordered(_Tp __x, _Up __y)
838 {
839 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
840 return __builtin_isunordered(__type(__x), __type(__y));
841 }
842#endif
843
844#else
845
846 template<typename _Tp>
847 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
848 int>::__type
849 fpclassify(_Tp __f)
850 {
851 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
852 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
853 FP_SUBNORMAL, FP_ZERO, __type(__f));
854 }
855
856 template<typename _Tp>
857 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
858 int>::__type
859 isfinite(_Tp __f)
860 {
861 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
862 return __builtin_isfinite(__type(__f));
863 }
864
865 template<typename _Tp>
866 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
867 int>::__type
868 isinf(_Tp __f)
869 {
870 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
871 return __builtin_isinf(__type(__f));
872 }
873
874 template<typename _Tp>
875 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
876 int>::__type
877 isnan(_Tp __f)
878 {
879 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
880 return __builtin_isnan(__type(__f));
881 }
882
883 template<typename _Tp>
884 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
885 int>::__type
886 isnormal(_Tp __f)
887 {
888 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
889 return __builtin_isnormal(__type(__f));
890 }
891
892 template<typename _Tp>
893 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
894 int>::__type
895 signbit(_Tp __f)
896 {
897 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
898 return __builtin_signbit(__type(__f));
899 }
900
901 template<typename _Tp>
902 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
903 int>::__type
904 isgreater(_Tp __f1, _Tp __f2)
905 {
906 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
907 return __builtin_isgreater(__type(__f1), __type(__f2));
908 }
909
910 template<typename _Tp>
911 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
912 int>::__type
913 isgreaterequal(_Tp __f1, _Tp __f2)
914 {
915 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
916 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
917 }
918
919 template<typename _Tp>
920 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
921 int>::__type
922 isless(_Tp __f1, _Tp __f2)
923 {
924 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
925 return __builtin_isless(__type(__f1), __type(__f2));
926 }
927
928 template<typename _Tp>
929 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
930 int>::__type
931 islessequal(_Tp __f1, _Tp __f2)
932 {
933 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
934 return __builtin_islessequal(__type(__f1), __type(__f2));
935 }
936
937 template<typename _Tp>
938 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
939 int>::__type
940 islessgreater(_Tp __f1, _Tp __f2)
941 {
942 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
943 return __builtin_islessgreater(__type(__f1), __type(__f2));
944 }
945
946 template<typename _Tp>
947 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
948 int>::__type
949 isunordered(_Tp __f1, _Tp __f2)
950 {
951 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
952 return __builtin_isunordered(__type(__f1), __type(__f2));
953 }
954
955#endif
956
957_GLIBCXX_END_NAMESPACE_VERSION
958} // namespace
959
960#endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
961#endif
962
963#if __cplusplus >= 201103L
964
965#ifdef _GLIBCXX_USE_C99_MATH_TR1
966
967#undef acosh
968#undef acoshf
969#undef acoshl
970#undef asinh
971#undef asinhf
972#undef asinhl
973#undef atanh
974#undef atanhf
975#undef atanhl
976#undef cbrt
977#undef cbrtf
978#undef cbrtl
979#undef copysign
980#undef copysignf
981#undef copysignl
982#undef erf
983#undef erff
984#undef erfl
985#undef erfc
986#undef erfcf
987#undef erfcl
988#undef exp2
989#undef exp2f
990#undef exp2l
991#undef expm1
992#undef expm1f
993#undef expm1l
994#undef fdim
995#undef fdimf
996#undef fdiml
997#undef fma
998#undef fmaf
999#undef fmal
1000#undef fmax
1001#undef fmaxf
1002#undef fmaxl
1003#undef fmin
1004#undef fminf
1005#undef fminl
1006#undef hypot
1007#undef hypotf
1008#undef hypotl
1009#undef ilogb
1010#undef ilogbf
1011#undef ilogbl
1012#undef lgamma
1013#undef lgammaf
1014#undef lgammal
1015#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
1016#undef llrint
1017#undef llrintf
1018#undef llrintl
1019#undef llround
1020#undef llroundf
1021#undef llroundl
1022#endif
1023#undef log1p
1024#undef log1pf
1025#undef log1pl
1026#undef log2
1027#undef log2f
1028#undef log2l
1029#undef logb
1030#undef logbf
1031#undef logbl
1032#undef lrint
1033#undef lrintf
1034#undef lrintl
1035#undef lround
1036#undef lroundf
1037#undef lroundl
1038#undef nan
1039#undef nanf
1040#undef nanl
1041#undef nearbyint
1042#undef nearbyintf
1043#undef nearbyintl
1044#undef nextafter
1045#undef nextafterf
1046#undef nextafterl
1047#undef nexttoward
1048#undef nexttowardf
1049#undef nexttowardl
1050#undef remainder
1051#undef remainderf
1052#undef remainderl
1053#undef remquo
1054#undef remquof
1055#undef remquol
1056#undef rint
1057#undef rintf
1058#undef rintl
1059#undef round
1060#undef roundf
1061#undef roundl
1062#undef scalbln
1063#undef scalblnf
1064#undef scalblnl
1065#undef scalbn
1066#undef scalbnf
1067#undef scalbnl
1068#undef tgamma
1069#undef tgammaf
1070#undef tgammal
1071#undef trunc
1072#undef truncf
1073#undef truncl
1074
1075namespace std _GLIBCXX_VISIBILITY(default)
1076{
1077_GLIBCXX_BEGIN_NAMESPACE_VERSION
1078
1079 // types
1080 using ::double_t;
1081 using ::float_t;
1082
1083 // functions
1084 using ::acosh;
1085 using ::acoshf;
1086 using ::acoshl;
1087
1088 using ::asinh;
1089 using ::asinhf;
1090 using ::asinhl;
1091
1092 using ::atanh;
1093 using ::atanhf;
1094 using ::atanhl;
1095
1096 using ::cbrt;
1097 using ::cbrtf;
1098 using ::cbrtl;
1099
1100 using ::copysign;
1101 using ::copysignf;
1102 using ::copysignl;
1103
1104 using ::erf;
1105 using ::erff;
1106 using ::erfl;
1107
1108 using ::erfc;
1109 using ::erfcf;
1110 using ::erfcl;
1111
1112 using ::exp2;
1113 using ::exp2f;
1114 using ::exp2l;
1115
1116 using ::expm1;
1117 using ::expm1f;
1118 using ::expm1l;
1119
1120 using ::fdim;
1121 using ::fdimf;
1122 using ::fdiml;
1123
1124 using ::fma;
1125 using ::fmaf;
1126 using ::fmal;
1127
1128 using ::fmax;
1129 using ::fmaxf;
1130 using ::fmaxl;
1131
1132 using ::fmin;
1133 using ::fminf;
1134 using ::fminl;
1135
1136 using ::hypot;
1137 using ::hypotf;
1138 using ::hypotl;
1139
1140 using ::ilogb;
1141 using ::ilogbf;
1142 using ::ilogbl;
1143
1144 using ::lgamma;
1145 using ::lgammaf;
1146 using ::lgammal;
1147
1148#ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
1149 using ::llrint;
1150 using ::llrintf;
1151 using ::llrintl;
1152
1153 using ::llround;
1154 using ::llroundf;
1155 using ::llroundl;
1156#endif
1157
1158 using ::log1p;
1159 using ::log1pf;
1160 using ::log1pl;
1161
1162 using ::log2;
1163 using ::log2f;
1164 using ::log2l;
1165
1166 using ::logb;
1167 using ::logbf;
1168 using ::logbl;
1169
1170 using ::lrint;
1171 using ::lrintf;
1172 using ::lrintl;
1173
1174 using ::lround;
1175 using ::lroundf;
1176 using ::lroundl;
1177
1178 using ::nan;
1179 using ::nanf;
1180 using ::nanl;
1181
1182 using ::nearbyint;
1183 using ::nearbyintf;
1184 using ::nearbyintl;
1185
1186 using ::nextafter;
1187 using ::nextafterf;
1188 using ::nextafterl;
1189
1190 using ::nexttoward;
1191 using ::nexttowardf;
1192 using ::nexttowardl;
1193
1194 using ::remainder;
1195 using ::remainderf;
1196 using ::remainderl;
1197
1198 using ::remquo;
1199 using ::remquof;
1200 using ::remquol;
1201
1202 using ::rint;
1203 using ::rintf;
1204 using ::rintl;
1205
1206 using ::round;
1207 using ::roundf;
1208 using ::roundl;
1209
1210 using ::scalbln;
1211 using ::scalblnf;
1212 using ::scalblnl;
1213
1214 using ::scalbn;
1215 using ::scalbnf;
1216 using ::scalbnl;
1217
1218 using ::tgamma;
1219 using ::tgammaf;
1220 using ::tgammal;
1221
1222 using ::trunc;
1223 using ::truncf;
1224 using ::truncl;
1225
1226 /// Additional overloads.
1227#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1228 constexpr float
1229 acosh(float __x)
1230 { return __builtin_acoshf(__x); }
1231
1232 constexpr long double
1233 acosh(long double __x)
1234 { return __builtin_acoshl(__x); }
1235#endif
1236
1237#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1238 template<typename _Tp>
1239 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1240 double>::__type
1241 acosh(_Tp __x)
1242 { return __builtin_acosh(__x); }
1243#endif
1244
1245#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1246 constexpr float
1247 asinh(float __x)
1248 { return __builtin_asinhf(__x); }
1249
1250 constexpr long double
1251 asinh(long double __x)
1252 { return __builtin_asinhl(__x); }
1253#endif
1254
1255#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1256 template<typename _Tp>
1257 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1258 double>::__type
1259 asinh(_Tp __x)
1260 { return __builtin_asinh(__x); }
1261#endif
1262
1263#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1264 constexpr float
1265 atanh(float __x)
1266 { return __builtin_atanhf(__x); }
1267
1268 constexpr long double
1269 atanh(long double __x)
1270 { return __builtin_atanhl(__x); }
1271#endif
1272
1273#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1274 template<typename _Tp>
1275 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1276 double>::__type
1277 atanh(_Tp __x)
1278 { return __builtin_atanh(__x); }
1279#endif
1280
1281#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1282 constexpr float
1283 cbrt(float __x)
1284 { return __builtin_cbrtf(__x); }
1285
1286 constexpr long double
1287 cbrt(long double __x)
1288 { return __builtin_cbrtl(__x); }
1289#endif
1290
1291#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1292 template<typename _Tp>
1293 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1294 double>::__type
1295 cbrt(_Tp __x)
1296 { return __builtin_cbrt(__x); }
1297#endif
1298
1299#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1300 constexpr float
1301 copysign(float __x, float __y)
1302 { return __builtin_copysignf(__x, __y); }
1303
1304 constexpr long double
1305 copysign(long double __x, long double __y)
1306 { return __builtin_copysignl(__x, __y); }
1307#endif
1308
1309#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1310 template<typename _Tp, typename _Up>
1311 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1312 copysign(_Tp __x, _Up __y)
1313 {
1314 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1315 return copysign(__type(__x), __type(__y));
1316 }
1317#endif
1318
1319#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1320 constexpr float
1321 erf(float __x)
1322 { return __builtin_erff(__x); }
1323
1324 constexpr long double
1325 erf(long double __x)
1326 { return __builtin_erfl(__x); }
1327#endif
1328
1329#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1330 template<typename _Tp>
1331 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1332 double>::__type
1333 erf(_Tp __x)
1334 { return __builtin_erf(__x); }
1335#endif
1336
1337#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1338 constexpr float
1339 erfc(float __x)
1340 { return __builtin_erfcf(__x); }
1341
1342 constexpr long double
1343 erfc(long double __x)
1344 { return __builtin_erfcl(__x); }
1345#endif
1346
1347#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1348 template<typename _Tp>
1349 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1350 double>::__type
1351 erfc(_Tp __x)
1352 { return __builtin_erfc(__x); }
1353#endif
1354
1355#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1356 constexpr float
1357 exp2(float __x)
1358 { return __builtin_exp2f(__x); }
1359
1360 constexpr long double
1361 exp2(long double __x)
1362 { return __builtin_exp2l(__x); }
1363#endif
1364
1365#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1366 template<typename _Tp>
1367 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1368 double>::__type
1369 exp2(_Tp __x)
1370 { return __builtin_exp2(__x); }
1371#endif
1372
1373#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1374 constexpr float
1375 expm1(float __x)
1376 { return __builtin_expm1f(__x); }
1377
1378 constexpr long double
1379 expm1(long double __x)
1380 { return __builtin_expm1l(__x); }
1381#endif
1382
1383#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1384 template<typename _Tp>
1385 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1386 double>::__type
1387 expm1(_Tp __x)
1388 { return __builtin_expm1(__x); }
1389#endif
1390
1391#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1392 constexpr float
1393 fdim(float __x, float __y)
1394 { return __builtin_fdimf(__x, __y); }
1395
1396 constexpr long double
1397 fdim(long double __x, long double __y)
1398 { return __builtin_fdiml(__x, __y); }
1399#endif
1400
1401#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1402 template<typename _Tp, typename _Up>
1403 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1404 fdim(_Tp __x, _Up __y)
1405 {
1406 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1407 return fdim(__type(__x), __type(__y));
1408 }
1409#endif
1410
1411#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1412 constexpr float
1413 fma(float __x, float __y, float __z)
1414 { return __builtin_fmaf(__x, __y, __z); }
1415
1416 constexpr long double
1417 fma(long double __x, long double __y, long double __z)
1418 { return __builtin_fmal(__x, __y, __z); }
1419#endif
1420
1421#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1422 template<typename _Tp, typename _Up, typename _Vp>
1423 constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
1424 fma(_Tp __x, _Up __y, _Vp __z)
1425 {
1426 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
1427 return fma(__type(__x), __type(__y), __type(__z));
1428 }
1429#endif
1430
1431#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1432 constexpr float
1433 fmax(float __x, float __y)
1434 { return __builtin_fmaxf(__x, __y); }
1435
1436 constexpr long double
1437 fmax(long double __x, long double __y)
1438 { return __builtin_fmaxl(__x, __y); }
1439#endif
1440
1441#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1442 template<typename _Tp, typename _Up>
1443 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1444 fmax(_Tp __x, _Up __y)
1445 {
1446 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1447 return fmax(__type(__x), __type(__y));
1448 }
1449#endif
1450
1451#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1452 constexpr float
1453 fmin(float __x, float __y)
1454 { return __builtin_fminf(__x, __y); }
1455
1456 constexpr long double
1457 fmin(long double __x, long double __y)
1458 { return __builtin_fminl(__x, __y); }
1459#endif
1460
1461#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1462 template<typename _Tp, typename _Up>
1463 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1464 fmin(_Tp __x, _Up __y)
1465 {
1466 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1467 return fmin(__type(__x), __type(__y));
1468 }
1469#endif
1470
1471#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1472 constexpr float
1473 hypot(float __x, float __y)
1474 { return __builtin_hypotf(__x, __y); }
1475
1476 constexpr long double
1477 hypot(long double __x, long double __y)
1478 { return __builtin_hypotl(__x, __y); }
1479#endif
1480
1481#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1482 template<typename _Tp, typename _Up>
1483 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1484 hypot(_Tp __x, _Up __y)
1485 {
1486 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1487 return hypot(__type(__x), __type(__y));
1488 }
1489#endif
1490
1491#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1492 constexpr int
1493 ilogb(float __x)
1494 { return __builtin_ilogbf(__x); }
1495
1496 constexpr int
1497 ilogb(long double __x)
1498 { return __builtin_ilogbl(__x); }
1499#endif
1500
1501#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1502 template<typename _Tp>
1503 constexpr
1504 typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1505 int>::__type
1506 ilogb(_Tp __x)
1507 { return __builtin_ilogb(__x); }
1508#endif
1509
1510#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1511 constexpr float
1512 lgamma(float __x)
1513 { return __builtin_lgammaf(__x); }
1514
1515 constexpr long double
1516 lgamma(long double __x)
1517 { return __builtin_lgammal(__x); }
1518#endif
1519
1520#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1521 template<typename _Tp>
1522 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1523 double>::__type
1524 lgamma(_Tp __x)
1525 { return __builtin_lgamma(__x); }
1526#endif
1527
1528#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1529 constexpr long long
1530 llrint(float __x)
1531 { return __builtin_llrintf(__x); }
1532
1533 constexpr long long
1534 llrint(long double __x)
1535 { return __builtin_llrintl(__x); }
1536#endif
1537
1538#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1539 template<typename _Tp>
1540 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1541 long long>::__type
1542 llrint(_Tp __x)
1543 { return __builtin_llrint(__x); }
1544#endif
1545
1546#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1547 constexpr long long
1548 llround(float __x)
1549 { return __builtin_llroundf(__x); }
1550
1551 constexpr long long
1552 llround(long double __x)
1553 { return __builtin_llroundl(__x); }
1554#endif
1555
1556#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1557 template<typename _Tp>
1558 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1559 long long>::__type
1560 llround(_Tp __x)
1561 { return __builtin_llround(__x); }
1562#endif
1563
1564#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1565 constexpr float
1566 log1p(float __x)
1567 { return __builtin_log1pf(__x); }
1568
1569 constexpr long double
1570 log1p(long double __x)
1571 { return __builtin_log1pl(__x); }
1572#endif
1573
1574#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1575 template<typename _Tp>
1576 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1577 double>::__type
1578 log1p(_Tp __x)
1579 { return __builtin_log1p(__x); }
1580#endif
1581
1582#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1583 // DR 568.
1584 constexpr float
1585 log2(float __x)
1586 { return __builtin_log2f(__x); }
1587
1588 constexpr long double
1589 log2(long double __x)
1590 { return __builtin_log2l(__x); }
1591#endif
1592
1593#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1594 template<typename _Tp>
1595 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1596 double>::__type
1597 log2(_Tp __x)
1598 { return __builtin_log2(__x); }
1599#endif
1600
1601#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1602 constexpr float
1603 logb(float __x)
1604 { return __builtin_logbf(__x); }
1605
1606 constexpr long double
1607 logb(long double __x)
1608 { return __builtin_logbl(__x); }
1609#endif
1610
1611#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1612 template<typename _Tp>
1613 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1614 double>::__type
1615 logb(_Tp __x)
1616 { return __builtin_logb(__x); }
1617#endif
1618
1619#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1620 constexpr long
1621 lrint(float __x)
1622 { return __builtin_lrintf(__x); }
1623
1624 constexpr long
1625 lrint(long double __x)
1626 { return __builtin_lrintl(__x); }
1627#endif
1628
1629#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1630 template<typename _Tp>
1631 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1632 long>::__type
1633 lrint(_Tp __x)
1634 { return __builtin_lrint(__x); }
1635#endif
1636
1637#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1638 constexpr long
1639 lround(float __x)
1640 { return __builtin_lroundf(__x); }
1641
1642 constexpr long
1643 lround(long double __x)
1644 { return __builtin_lroundl(__x); }
1645#endif
1646
1647#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1648 template<typename _Tp>
1649 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1650 long>::__type
1651 lround(_Tp __x)
1652 { return __builtin_lround(__x); }
1653#endif
1654
1655#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1656 constexpr float
1657 nearbyint(float __x)
1658 { return __builtin_nearbyintf(__x); }
1659
1660 constexpr long double
1661 nearbyint(long double __x)
1662 { return __builtin_nearbyintl(__x); }
1663#endif
1664
1665#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1666 template<typename _Tp>
1667 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1668 double>::__type
1669 nearbyint(_Tp __x)
1670 { return __builtin_nearbyint(__x); }
1671#endif
1672
1673#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1674 constexpr float
1675 nextafter(float __x, float __y)
1676 { return __builtin_nextafterf(__x, __y); }
1677
1678 constexpr long double
1679 nextafter(long double __x, long double __y)
1680 { return __builtin_nextafterl(__x, __y); }
1681#endif
1682
1683#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1684 template<typename _Tp, typename _Up>
1685 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1686 nextafter(_Tp __x, _Up __y)
1687 {
1688 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1689 return nextafter(__type(__x), __type(__y));
1690 }
1691#endif
1692
1693#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1694 constexpr float
1695 nexttoward(float __x, long double __y)
1696 { return __builtin_nexttowardf(__x, __y); }
1697
1698 constexpr long double
1699 nexttoward(long double __x, long double __y)
1700 { return __builtin_nexttowardl(__x, __y); }
1701#endif
1702
1703#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1704 template<typename _Tp>
1705 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1706 double>::__type
1707 nexttoward(_Tp __x, long double __y)
1708 { return __builtin_nexttoward(__x, __y); }
1709#endif
1710
1711#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1712 constexpr float
1713 remainder(float __x, float __y)
1714 { return __builtin_remainderf(__x, __y); }
1715
1716 constexpr long double
1717 remainder(long double __x, long double __y)
1718 { return __builtin_remainderl(__x, __y); }
1719#endif
1720
1721#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1722 template<typename _Tp, typename _Up>
1723 constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1724 remainder(_Tp __x, _Up __y)
1725 {
1726 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1727 return remainder(__type(__x), __type(__y));
1728 }
1729#endif
1730
1731#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1732 inline float
1733 remquo(float __x, float __y, int* __pquo)
1734 { return __builtin_remquof(__x, __y, __pquo); }
1735
1736 inline long double
1737 remquo(long double __x, long double __y, int* __pquo)
1738 { return __builtin_remquol(__x, __y, __pquo); }
1739#endif
1740
1741#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1742 template<typename _Tp, typename _Up>
1743 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1744 remquo(_Tp __x, _Up __y, int* __pquo)
1745 {
1746 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1747 return remquo(__type(__x), __type(__y), __pquo);
1748 }
1749#endif
1750
1751#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1752 constexpr float
1753 rint(float __x)
1754 { return __builtin_rintf(__x); }
1755
1756 constexpr long double
1757 rint(long double __x)
1758 { return __builtin_rintl(__x); }
1759#endif
1760
1761#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1762 template<typename _Tp>
1763 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1764 double>::__type
1765 rint(_Tp __x)
1766 { return __builtin_rint(__x); }
1767#endif
1768
1769#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1770 constexpr float
1771 round(float __x)
1772 { return __builtin_roundf(__x); }
1773
1774 constexpr long double
1775 round(long double __x)
1776 { return __builtin_roundl(__x); }
1777#endif
1778
1779#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1780 template<typename _Tp>
1781 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1782 double>::__type
1783 round(_Tp __x)
1784 { return __builtin_round(__x); }
1785#endif
1786
1787#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1788 constexpr float
1789 scalbln(float __x, long __ex)
1790 { return __builtin_scalblnf(__x, __ex); }
1791
1792 constexpr long double
1793 scalbln(long double __x, long __ex)
1794 { return __builtin_scalblnl(__x, __ex); }
1795#endif
1796
1797#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1798 template<typename _Tp>
1799 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1800 double>::__type
1801 scalbln(_Tp __x, long __ex)
1802 { return __builtin_scalbln(__x, __ex); }
1803#endif
1804
1805#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1806 constexpr float
1807 scalbn(float __x, int __ex)
1808 { return __builtin_scalbnf(__x, __ex); }
1809
1810 constexpr long double
1811 scalbn(long double __x, int __ex)
1812 { return __builtin_scalbnl(__x, __ex); }
1813#endif
1814
1815#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1816 template<typename _Tp>
1817 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1818 double>::__type
1819 scalbn(_Tp __x, int __ex)
1820 { return __builtin_scalbn(__x, __ex); }
1821#endif
1822
1823#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1824 constexpr float
1825 tgamma(float __x)
1826 { return __builtin_tgammaf(__x); }
1827
1828 constexpr long double
1829 tgamma(long double __x)
1830 { return __builtin_tgammal(__x); }
1831#endif
1832
1833#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1834 template<typename _Tp>
1835 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1836 double>::__type
1837 tgamma(_Tp __x)
1838 { return __builtin_tgamma(__x); }
1839#endif
1840
1841#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1842 constexpr float
1843 trunc(float __x)
1844 { return __builtin_truncf(__x); }
1845
1846 constexpr long double
1847 trunc(long double __x)
1848 { return __builtin_truncl(__x); }
1849#endif
1850
1851#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
1852 template<typename _Tp>
1853 constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1854 double>::__type
1855 trunc(_Tp __x)
1856 { return __builtin_trunc(__x); }
1857#endif
1858
1859_GLIBCXX_END_NAMESPACE_VERSION
1860} // namespace
1861
1862#endif // _GLIBCXX_USE_C99_MATH_TR1
1863
1864#endif // C++11
1865
1866#if __cplusplus > 201402L
1867namespace std _GLIBCXX_VISIBILITY(default)
1868{
1869_GLIBCXX_BEGIN_NAMESPACE_VERSION
1870
1871 // [c.math.hypot3], three-dimensional hypotenuse
1872#define __cpp_lib_hypot 201603
1873
1874 template<typename _Tp>
1875 inline _Tp
1876 __hypot3(_Tp __x, _Tp __y, _Tp __z)
1877 {
1878 __x = std::abs(__x);
1879 __y = std::abs(__y);
1880 __z = std::abs(__z);
1881 if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x)
1882 return __a * std::sqrt((__x / __a) * (__x / __a)
1883 + (__y / __a) * (__y / __a)
1884 + (__z / __a) * (__z / __a));
1885 else
1886 return {};
1887 }
1888
1889 inline float
1890 hypot(float __x, float __y, float __z)
1891 { return std::__hypot3<float>(__x, __y, __z); }
1892
1893 inline double
1894 hypot(double __x, double __y, double __z)
1895 { return std::__hypot3<double>(__x, __y, __z); }
1896
1897 inline long double
1898 hypot(long double __x, long double __y, long double __z)
1899 { return std::__hypot3<long double>(__x, __y, __z); }
1900
1901 template<typename _Tp, typename _Up, typename _Vp>
1902 typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
1903 hypot(_Tp __x, _Up __y, _Vp __z)
1904 {
1905 using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type;
1906 return std::__hypot3<__type>(__x, __y, __z);
1907 }
1908_GLIBCXX_END_NAMESPACE_VERSION
1909} // namespace
1910#endif // C++17
1911
1912
1913#if _GLIBCXX_USE_STD_SPEC_FUNCS
1914# include <bits/specfun.h>
1915#endif
1916
1917} // extern "C++"
1918
1919#endif
1920