libstdc++
tr1/cmath
Go to the documentation of this file.
1// TR1 cmath -*- C++ -*-
2
3// Copyright (C) 2006-2025 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 tr1/cmath
26 * This is a TR1 C++ Library header.
27 */
28
29#ifndef _GLIBCXX_TR1_CMATH
30#define _GLIBCXX_TR1_CMATH 1
31
32#ifdef _GLIBCXX_SYSHDR
33#pragma GCC system_header
34#endif
35
36#include <bits/requires_hosted.h> // TR1
38
39#include <cmath>
40
41#ifdef _GLIBCXX_USE_C99_MATH_TR1
42
43#undef acosh
44#undef acoshf
45#undef acoshl
46#undef asinh
47#undef asinhf
48#undef asinhl
49#undef atanh
50#undef atanhf
51#undef atanhl
52#undef cbrt
53#undef cbrtf
54#undef cbrtl
55#undef copysign
56#undef copysignf
57#undef copysignl
58#undef erf
59#undef erff
60#undef erfl
61#undef erfc
62#undef erfcf
63#undef erfcl
64#undef exp2
65#undef exp2f
66#undef exp2l
67#undef expm1
68#undef expm1f
69#undef expm1l
70#undef fdim
71#undef fdimf
72#undef fdiml
73#undef fma
74#undef fmaf
75#undef fmal
76#undef fmax
77#undef fmaxf
78#undef fmaxl
79#undef fmin
80#undef fminf
81#undef fminl
82#undef hypot
83#undef hypotf
84#undef hypotl
85#undef ilogb
86#undef ilogbf
87#undef ilogbl
88#undef lgamma
89#undef lgammaf
90#undef lgammal
91#undef llrint
92#undef llrintf
93#undef llrintl
94#undef llround
95#undef llroundf
96#undef llroundl
97#undef log1p
98#undef log1pf
99#undef log1pl
100#undef log2
101#undef log2f
102#undef log2l
103#undef logb
104#undef logbf
105#undef logbl
106#undef lrint
107#undef lrintf
108#undef lrintl
109#undef lround
110#undef lroundf
111#undef lroundl
112#undef nan
113#undef nanf
114#undef nanl
115#undef nearbyint
116#undef nearbyintf
117#undef nearbyintl
118#undef nextafter
119#undef nextafterf
120#undef nextafterl
121#undef nexttoward
122#undef nexttowardf
123#undef nexttowardl
124#undef remainder
125#undef remainderf
126#undef remainderl
127#undef remquo
128#undef remquof
129#undef remquol
130#undef rint
131#undef rintf
132#undef rintl
133#undef round
134#undef roundf
135#undef roundl
136#undef scalbln
137#undef scalblnf
138#undef scalblnl
139#undef scalbn
140#undef scalbnf
141#undef scalbnl
142#undef tgamma
143#undef tgammaf
144#undef tgammal
145#undef trunc
146#undef truncf
147#undef truncl
148
149#endif
150
151namespace std _GLIBCXX_VISIBILITY(default)
152{
153_GLIBCXX_BEGIN_NAMESPACE_VERSION
154
155namespace tr1
156{
157#if _GLIBCXX_USE_C99_MATH_TR1
158
159 // Using declarations to bring names from libc's <math.h> into std::tr1.
160
161 // types
162 using ::double_t;
163 using ::float_t;
164
165 // functions
166 using ::acosh;
167 using ::acoshf;
168 using ::acoshl;
169
170 using ::asinh;
171 using ::asinhf;
172 using ::asinhl;
173
174 using ::atanh;
175 using ::atanhf;
176 using ::atanhl;
177
178 using ::cbrt;
179 using ::cbrtf;
180 using ::cbrtl;
181
182 using ::copysign;
183 using ::copysignf;
184 using ::copysignl;
185
186 using ::erf;
187 using ::erff;
188 using ::erfl;
189
190 using ::erfc;
191 using ::erfcf;
192 using ::erfcl;
193
194 using ::exp2;
195 using ::exp2f;
196 using ::exp2l;
197
198 using ::expm1;
199 using ::expm1f;
200 using ::expm1l;
201
202 using ::fdim;
203 using ::fdimf;
204 using ::fdiml;
205
206 using ::fma;
207 using ::fmaf;
208 using ::fmal;
209
210 using ::fmax;
211 using ::fmaxf;
212 using ::fmaxl;
213
214 using ::fmin;
215 using ::fminf;
216 using ::fminl;
217
218 using ::hypot;
219 using ::hypotf;
220 using ::hypotl;
221
222 using ::ilogb;
223 using ::ilogbf;
224 using ::ilogbl;
225
226 using ::lgamma;
227 using ::lgammaf;
228 using ::lgammal;
229
230 using ::llrint;
231 using ::llrintf;
232 using ::llrintl;
233
234 using ::llround;
235 using ::llroundf;
236 using ::llroundl;
237
238 using ::log1p;
239 using ::log1pf;
240 using ::log1pl;
241
242 using ::log2;
243 using ::log2f;
244 using ::log2l;
245
246 using ::logb;
247 using ::logbf;
248 using ::logbl;
249
250 using ::lrint;
251 using ::lrintf;
252 using ::lrintl;
253
254 using ::lround;
255 using ::lroundf;
256 using ::lroundl;
257
258 using ::nan;
259 using ::nanf;
260 using ::nanl;
261
262 using ::nearbyint;
263 using ::nearbyintf;
264 using ::nearbyintl;
265
266 using ::nextafter;
267 using ::nextafterf;
268 using ::nextafterl;
269
270 using ::nexttoward;
271 using ::nexttowardf;
272 using ::nexttowardl;
273
274 using ::remainder;
275 using ::remainderf;
276 using ::remainderl;
277
278 using ::remquo;
279 using ::remquof;
280 using ::remquol;
281
282 using ::rint;
283 using ::rintf;
284 using ::rintl;
285
286 using ::round;
287 using ::roundf;
288 using ::roundl;
289
290 using ::scalbln;
291 using ::scalblnf;
292 using ::scalblnl;
293
294 using ::scalbn;
295 using ::scalbnf;
296 using ::scalbnl;
297
298 using ::tgamma;
299 using ::tgammaf;
300 using ::tgammal;
301
302 using ::trunc;
303 using ::truncf;
304 using ::truncl;
305
306#endif
307
308#if _GLIBCXX_USE_C99_MATH
309#if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
310
311 /// Function template definitions [8.16.3].
312 template<typename _Tp>
313 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
314 int>::__type
315 fpclassify(_Tp __f)
316 {
317 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
318 return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
319 FP_SUBNORMAL, FP_ZERO, __type(__f));
320 }
321
322 template<typename _Tp>
323 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
324 int>::__type
325 isfinite(_Tp __f)
326 {
327 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
328 return __builtin_isfinite(__type(__f));
329 }
330
331 template<typename _Tp>
332 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
333 int>::__type
334 isinf(_Tp __f)
335 {
336 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
337 return __builtin_isinf(__type(__f));
338 }
339
340 template<typename _Tp>
341 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
342 int>::__type
343 isnan(_Tp __f)
344 {
345 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
346 return __builtin_isnan(__type(__f));
347 }
348
349 template<typename _Tp>
350 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
351 int>::__type
352 isnormal(_Tp __f)
353 {
354 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
355 return __builtin_isnormal(__type(__f));
356 }
357
358 template<typename _Tp>
359 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
360 int>::__type
361 signbit(_Tp __f)
362 {
363 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
364 return __builtin_signbit(__type(__f));
365 }
366
367 template<typename _Tp>
368 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
369 int>::__type
370 isgreater(_Tp __f1, _Tp __f2)
371 {
372 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
373 return __builtin_isgreater(__type(__f1), __type(__f2));
374 }
375
376 template<typename _Tp>
377 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
378 int>::__type
379 isgreaterequal(_Tp __f1, _Tp __f2)
380 {
381 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
382 return __builtin_isgreaterequal(__type(__f1), __type(__f2));
383 }
384
385 template<typename _Tp>
386 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
387 int>::__type
388 isless(_Tp __f1, _Tp __f2)
389 {
390 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
391 return __builtin_isless(__type(__f1), __type(__f2));
392 }
393
394 template<typename _Tp>
395 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
396 int>::__type
397 islessequal(_Tp __f1, _Tp __f2)
398 {
399 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
400 return __builtin_islessequal(__type(__f1), __type(__f2));
401 }
402
403 template<typename _Tp>
404 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
405 int>::__type
406 islessgreater(_Tp __f1, _Tp __f2)
407 {
408 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
409 return __builtin_islessgreater(__type(__f1), __type(__f2));
410 }
411
412 template<typename _Tp>
413 inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
414 int>::__type
415 isunordered(_Tp __f1, _Tp __f2)
416 {
417 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
418 return __builtin_isunordered(__type(__f1), __type(__f2));
419 }
420
421#endif
422#endif
423
424#if _GLIBCXX_USE_C99_MATH_TR1
425
426 /** Additional overloads [8.16.4].
427 * @{
428 */
429
430 // For functions defined in C++03 the additional overloads are already
431 // declared in <cmath> so we can just re-declare them in std::tr1.
432
433 using std::acos;
434 using std::asin;
435 using std::atan;
436 using std::atan2;
437 using std::ceil;
438 using std::cos;
439 using std::cosh;
440 using std::exp;
441 using std::floor;
442 using std::fmod;
443 using std::frexp;
444 using std::ldexp;
445 using std::log;
446 using std::log10;
447 using std::sin;
448 using std::sinh;
449 using std::sqrt;
450 using std::tan;
451 using std::tanh;
452
453#if __cplusplus >= 201103L
454
455 // Since C++11, <cmath> defines additional overloads for these functions
456 // in namespace std.
457
458 using std::acosh;
459 using std::asinh;
460 using std::atanh;
461 using std::cbrt;
462 using std::copysign;
463 using std::erf;
464 using std::erfc;
465 using std::exp2;
466 using std::expm1;
467 using std::fdim;
468 using std::fma;
469 using std::fmax;
470 using std::fmin;
471 using std::hypot;
472 using std::ilogb;
473 using std::lgamma;
474 using std::llrint;
475 using std::llround;
476 using std::log1p;
477 using std::log2;
478 using std::logb;
479 using std::lrint;
480 using std::lround;
481 using std::nan;
482 using std::nearbyint;
483 using std::nextafter;
484 using std::nexttoward;
485 using std::remainder;
486 using std::remquo;
487 using std::rint;
488 using std::round;
489 using std::scalbln;
490 using std::scalbn;
491 using std::tgamma;
492 using std::trunc;
493
494#else // __cplusplus < 201103L
495
496 // In C++03 we need to provide the additional overloads.
497
498#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
499 inline float
500 acosh(float __x)
501 { return __builtin_acoshf(__x); }
502
503 inline long double
504 acosh(long double __x)
505 { return __builtin_acoshl(__x); }
506#endif
507
508 template<typename _Tp>
509 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
510 double>::__type
511 acosh(_Tp __x)
512 { return __builtin_acosh(__x); }
513
514#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
515 inline float
516 asinh(float __x)
517 { return __builtin_asinhf(__x); }
518
519 inline long double
520 asinh(long double __x)
521 { return __builtin_asinhl(__x); }
522#endif
523
524 template<typename _Tp>
525 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
526 double>::__type
527 asinh(_Tp __x)
528 { return __builtin_asinh(__x); }
529
530#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
531 inline float
532 atanh(float __x)
533 { return __builtin_atanhf(__x); }
534
535 inline long double
536 atanh(long double __x)
537 { return __builtin_atanhl(__x); }
538#endif
539
540 template<typename _Tp>
541 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
542 double>::__type
543 atanh(_Tp __x)
544 { return __builtin_atanh(__x); }
545
546#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
547 inline float
548 cbrt(float __x)
549 { return __builtin_cbrtf(__x); }
550
551 inline long double
552 cbrt(long double __x)
553 { return __builtin_cbrtl(__x); }
554#endif
555
556 template<typename _Tp>
557 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
558 double>::__type
559 cbrt(_Tp __x)
560 { return __builtin_cbrt(__x); }
561
562#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
563 inline float
564 copysign(float __x, float __y)
565 { return __builtin_copysignf(__x, __y); }
566
567 inline long double
568 copysign(long double __x, long double __y)
569 { return __builtin_copysignl(__x, __y); }
570#endif
571
572 template<typename _Tp, typename _Up>
573 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
574 copysign(_Tp __x, _Up __y)
575 {
576 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
577 return copysign(__type(__x), __type(__y));
578 }
579
580#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
581 inline float
582 erf(float __x)
583 { return __builtin_erff(__x); }
584
585 inline long double
586 erf(long double __x)
587 { return __builtin_erfl(__x); }
588#endif
589
590 template<typename _Tp>
591 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
592 double>::__type
593 erf(_Tp __x)
594 { return __builtin_erf(__x); }
595
596#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
597 inline float
598 erfc(float __x)
599 { return __builtin_erfcf(__x); }
600
601 inline long double
602 erfc(long double __x)
603 { return __builtin_erfcl(__x); }
604#endif
605
606 template<typename _Tp>
607 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
608 double>::__type
609 erfc(_Tp __x)
610 { return __builtin_erfc(__x); }
611
612#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
613 inline float
614 exp2(float __x)
615 { return __builtin_exp2f(__x); }
616
617 inline long double
618 exp2(long double __x)
619 { return __builtin_exp2l(__x); }
620#endif
621
622 template<typename _Tp>
623 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
624 double>::__type
625 exp2(_Tp __x)
626 { return __builtin_exp2(__x); }
627
628#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
629 inline float
630 expm1(float __x)
631 { return __builtin_expm1f(__x); }
632
633 inline long double
634 expm1(long double __x)
635 { return __builtin_expm1l(__x); }
636#endif
637
638 template<typename _Tp>
639 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
640 double>::__type
641 expm1(_Tp __x)
642 { return __builtin_expm1(__x); }
643
644#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
645 inline float
646 fdim(float __x, float __y)
647 { return __builtin_fdimf(__x, __y); }
648
649 inline long double
650 fdim(long double __x, long double __y)
651 { return __builtin_fdiml(__x, __y); }
652#endif
653
654 template<typename _Tp, typename _Up>
655 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
656 fdim(_Tp __x, _Up __y)
657 {
658 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
659 return fdim(__type(__x), __type(__y));
660 }
661
662#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
663 inline float
664 fma(float __x, float __y, float __z)
665 { return __builtin_fmaf(__x, __y, __z); }
666
667 inline long double
668 fma(long double __x, long double __y, long double __z)
669 { return __builtin_fmal(__x, __y, __z); }
670#endif
671
672 template<typename _Tp, typename _Up, typename _Vp>
673 inline typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
674 fma(_Tp __x, _Up __y, _Vp __z)
675 {
676 typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
677 return fma(__type(__x), __type(__y), __type(__z));
678 }
679
680#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
681 inline float
682 fmax(float __x, float __y)
683 { return __builtin_fmaxf(__x, __y); }
684
685 inline long double
686 fmax(long double __x, long double __y)
687 { return __builtin_fmaxl(__x, __y); }
688#endif
689
690 template<typename _Tp, typename _Up>
691 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
692 fmax(_Tp __x, _Up __y)
693 {
694 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
695 return fmax(__type(__x), __type(__y));
696 }
697
698#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
699 inline float
700 fmin(float __x, float __y)
701 { return __builtin_fminf(__x, __y); }
702
703 inline long double
704 fmin(long double __x, long double __y)
705 { return __builtin_fminl(__x, __y); }
706#endif
707
708 template<typename _Tp, typename _Up>
709 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
710 fmin(_Tp __x, _Up __y)
711 {
712 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
713 return fmin(__type(__x), __type(__y));
714 }
715
716#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
717 inline float
718 hypot(float __x, float __y)
719 { return __builtin_hypotf(__x, __y); }
720
721 inline long double
722 hypot(long double __x, long double __y)
723 { return __builtin_hypotl(__x, __y); }
724#endif
725
726 template<typename _Tp, typename _Up>
727 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
728 hypot(_Tp __y, _Up __x)
729 {
730 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
731 return hypot(__type(__y), __type(__x));
732 }
733
734#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
735 inline int
736 ilogb(float __x)
737 { return __builtin_ilogbf(__x); }
738
739 inline int
740 ilogb(long double __x)
741 { return __builtin_ilogbl(__x); }
742#endif
743
744 template<typename _Tp>
745 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
746 int>::__type
747 ilogb(_Tp __x)
748 { return __builtin_ilogb(__x); }
749
750#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
751 inline float
752 lgamma(float __x)
753 { return __builtin_lgammaf(__x); }
754
755 inline long double
756 lgamma(long double __x)
757 { return __builtin_lgammal(__x); }
758#endif
759
760 template<typename _Tp>
761 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
762 double>::__type
763 lgamma(_Tp __x)
764 { return __builtin_lgamma(__x); }
765
766#pragma GCC diagnostic push
767#pragma GCC diagnostic ignored "-Wlong-long"
768
769#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
770 inline long long
771 llrint(float __x)
772 { return __builtin_llrintf(__x); }
773
774 inline long long
775 llrint(long double __x)
776 { return __builtin_llrintl(__x); }
777#endif
778
779 template<typename _Tp>
780 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
781 long long>::__type
782 llrint(_Tp __x)
783 { return __builtin_llrint(__x); }
784
785#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
786 inline long long
787 llround(float __x)
788 { return __builtin_llroundf(__x); }
789
790 inline long long
791 llround(long double __x)
792 { return __builtin_llroundl(__x); }
793#endif
794
795 template<typename _Tp>
796 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
797 long long>::__type
798 llround(_Tp __x)
799 { return __builtin_llround(__x); }
800#pragma GCC diagnostic pop
801
802#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
803 inline float
804 log1p(float __x)
805 { return __builtin_log1pf(__x); }
806
807 inline long double
808 log1p(long double __x)
809 { return __builtin_log1pl(__x); }
810#endif
811
812 template<typename _Tp>
813 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
814 double>::__type
815 log1p(_Tp __x)
816 { return __builtin_log1p(__x); }
817
818 // DR 568.
819#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
820 inline float
821 log2(float __x)
822 { return __builtin_log2f(__x); }
823
824 inline long double
825 log2(long double __x)
826 { return __builtin_log2l(__x); }
827#endif
828
829 template<typename _Tp>
830 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
831 double>::__type
832 log2(_Tp __x)
833 { return __builtin_log2(__x); }
834
835#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
836 inline float
837 logb(float __x)
838 { return __builtin_logbf(__x); }
839
840 inline long double
841 logb(long double __x)
842 { return __builtin_logbl(__x); }
843#endif
844
845 template<typename _Tp>
846 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
847 double>::__type
848 logb(_Tp __x)
849 {
850 return __builtin_logb(__x);
851 }
852
853#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
854 inline long
855 lrint(float __x)
856 { return __builtin_lrintf(__x); }
857
858 inline long
859 lrint(long double __x)
860 { return __builtin_lrintl(__x); }
861#endif
862
863 template<typename _Tp>
864 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
865 long>::__type
866 lrint(_Tp __x)
867 { return __builtin_lrint(__x); }
868
869#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
870 inline long
871 lround(float __x)
872 { return __builtin_lroundf(__x); }
873
874 inline long
875 lround(long double __x)
876 { return __builtin_lroundl(__x); }
877#endif
878
879 template<typename _Tp>
880 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
881 long>::__type
882 lround(_Tp __x)
883 { return __builtin_lround(__x); }
884
885#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
886 inline float
887 nearbyint(float __x)
888 { return __builtin_nearbyintf(__x); }
889
890 inline long double
891 nearbyint(long double __x)
892 { return __builtin_nearbyintl(__x); }
893#endif
894
895 template<typename _Tp>
896 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
897 double>::__type
898 nearbyint(_Tp __x)
899 { return __builtin_nearbyint(__x); }
900
901#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
902 inline float
903 nextafter(float __x, float __y)
904 { return __builtin_nextafterf(__x, __y); }
905
906 inline long double
907 nextafter(long double __x, long double __y)
908 { return __builtin_nextafterl(__x, __y); }
909#endif
910
911 template<typename _Tp, typename _Up>
912 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
913 nextafter(_Tp __x, _Up __y)
914 {
915 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
916 return nextafter(__type(__x), __type(__y));
917 }
918
919#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
920 inline float
921 nexttoward(float __x, long double __y)
922 { return __builtin_nexttowardf(__x, __y); }
923
924 inline long double
925 nexttoward(long double __x, long double __y)
926 { return __builtin_nexttowardl(__x, __y); }
927#endif
928
929 template<typename _Tp>
930 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
931 double>::__type
932 nexttoward(_Tp __x, long double __y)
933 { return __builtin_nexttoward(__x, __y); }
934
935#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
936 inline float
937 remainder(float __x, float __y)
938 { return __builtin_remainderf(__x, __y); }
939
940 inline long double
941 remainder(long double __x, long double __y)
942 { return __builtin_remainderl(__x, __y); }
943#endif
944
945 template<typename _Tp, typename _Up>
946 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
947 remainder(_Tp __x, _Up __y)
948 {
949 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
950 return remainder(__type(__x), __type(__y));
951 }
952
953#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
954 inline float
955 remquo(float __x, float __y, int* __pquo)
956 { return __builtin_remquof(__x, __y, __pquo); }
957
958 inline long double
959 remquo(long double __x, long double __y, int* __pquo)
960 { return __builtin_remquol(__x, __y, __pquo); }
961#endif
962
963 template<typename _Tp, typename _Up>
964 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
965 remquo(_Tp __x, _Up __y, int* __pquo)
966 {
967 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
968 return remquo(__type(__x), __type(__y), __pquo);
969 }
970
971#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
972 inline float
973 rint(float __x)
974 { return __builtin_rintf(__x); }
975
976 inline long double
977 rint(long double __x)
978 { return __builtin_rintl(__x); }
979#endif
980
981 template<typename _Tp>
982 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
983 double>::__type
984 rint(_Tp __x)
985 { return __builtin_rint(__x); }
986
987#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
988 inline float
989 round(float __x)
990 { return __builtin_roundf(__x); }
991
992 inline long double
993 round(long double __x)
994 { return __builtin_roundl(__x); }
995#endif
996
997 template<typename _Tp>
998 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
999 double>::__type
1000 round(_Tp __x)
1001 { return __builtin_round(__x); }
1002
1003#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1004 inline float
1005 scalbln(float __x, long __ex)
1006 { return __builtin_scalblnf(__x, __ex); }
1007
1008 inline long double
1009 scalbln(long double __x, long __ex)
1010 { return __builtin_scalblnl(__x, __ex); }
1011#endif
1012
1013 template<typename _Tp>
1014 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1015 double>::__type
1016 scalbln(_Tp __x, long __ex)
1017 { return __builtin_scalbln(__x, __ex); }
1018
1019#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1020 inline float
1021 scalbn(float __x, int __ex)
1022 { return __builtin_scalbnf(__x, __ex); }
1023
1024 inline long double
1025 scalbn(long double __x, int __ex)
1026 { return __builtin_scalbnl(__x, __ex); }
1027#endif
1028
1029 template<typename _Tp>
1030 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1031 double>::__type
1032 scalbn(_Tp __x, int __ex)
1033 { return __builtin_scalbn(__x, __ex); }
1034
1035#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1036 inline float
1037 tgamma(float __x)
1038 { return __builtin_tgammaf(__x); }
1039
1040 inline long double
1041 tgamma(long double __x)
1042 { return __builtin_tgammal(__x); }
1043#endif
1044
1045 template<typename _Tp>
1046 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1047 double>::__type
1048 tgamma(_Tp __x)
1049 { return __builtin_tgamma(__x); }
1050
1051#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1052 inline float
1053 trunc(float __x)
1054 { return __builtin_truncf(__x); }
1055
1056 inline long double
1057 trunc(long double __x)
1058 { return __builtin_truncl(__x); }
1059#endif
1060
1061 template<typename _Tp>
1062 inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
1063 double>::__type
1064 trunc(_Tp __x)
1065 { return __builtin_trunc(__x); }
1066
1067#endif // __cplusplus < 201103L
1068
1069 /// @}
1070
1071#endif /* _GLIBCXX_USE_C99_MATH_TR1 */
1072
1073 // DR 550. What should the return type of pow(float,int) be?
1074 // NB: C++11 and TR1 != C++03.
1075
1076 // We cannot do "using std::pow;" because that would bring in unwanted
1077 // pow(*, int) overloads in C++03, with the wrong return type. Instead we
1078 // define all the necessary overloads, but the std::tr1::pow(double, double)
1079 // overload cannot be provided here, because <tr1/math.h> would add it to
1080 // the global namespace where it would clash with ::pow(double,double) from
1081 // libc (revealed by the fix of PR c++/54537).
1082 // The solution is to forward std::tr1::pow(double,double) to
1083 // std::pow(double,double) via the function template below. See
1084 // the discussion about this issue here:
1085 // http://gcc.gnu.org/ml/gcc-patches/2012-09/msg01278.html
1086
1087#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1088 inline float
1089 pow(float __x, float __y)
1090 { return std::pow(__x, __y); }
1091
1092 inline long double
1093 pow(long double __x, long double __y)
1094 { return std::pow(__x, __y); }
1095#endif
1096
1097 template<typename _Tp, typename _Up>
1098 inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
1099 pow(_Tp __x, _Up __y)
1100 {
1101 typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
1102 return std::pow(__type(__x), __type(__y));
1103 }
1104
1105#if __cplusplus >= 201103L
1106 // We also deal with fabs in a special way, because "using std::fabs;"
1107 // could bring in C++11's std::fabs<T>(const std::complex<T>&) with a
1108 // different return type from std::tr1::fabs<T>(const std::complex<T>&).
1109 // We define the necessary overloads, except std::tr1::fabs(double) which
1110 // could clash with ::fabs(double) from libc.
1111 // The function template handles double as well as integers, forwarding
1112 // to std::fabs.
1113
1114#ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
1115#ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
1116 inline float
1117 fabs(float __x)
1118 { return __builtin_fabsf(__x); }
1119
1120 inline long double
1121 fabs(long double __x)
1122 { return __builtin_fabsl(__x); }
1123#endif
1124#endif
1125
1126 template<typename _Tp>
1127 inline typename __gnu_cxx::__promote<_Tp>::__type
1128 fabs(_Tp __x)
1129 { return std::fabs(__x); }
1130
1131#else // ! C++11
1132
1133 // For C++03 just use std::fabs as there is no overload for std::complex<>.
1134 using std::fabs;
1135
1136#endif // C++11
1137
1138} // namespace tr1
1139_GLIBCXX_END_NAMESPACE_VERSION
1140} // namespace std
1141
1142/**
1143 * @defgroup tr1_math_spec_func TR1 Mathematical Special Functions
1144 * @ingroup numerics
1145 *
1146 * A collection of advanced mathematical special functions.
1147 */
1148
1149#if _GLIBCXX_USE_STD_SPEC_FUNCS
1150
1151namespace std _GLIBCXX_VISIBILITY(default)
1152{
1153_GLIBCXX_BEGIN_NAMESPACE_VERSION
1154
1155namespace tr1
1156{
1159 using std::assoc_laguerre;
1160
1163 using std::assoc_legendre;
1164
1165 using std::betaf;
1166 using std::betal;
1167 using std::beta;
1168
1169 using std::comp_ellint_1f;
1170 using std::comp_ellint_1l;
1171 using std::comp_ellint_1;
1172
1173 using std::comp_ellint_2f;
1174 using std::comp_ellint_2l;
1175 using std::comp_ellint_2;
1176
1177 using std::comp_ellint_3f;
1178 using std::comp_ellint_3l;
1179 using std::comp_ellint_3;
1180
1181 using std::cyl_bessel_if;
1182 using std::cyl_bessel_il;
1183 using std::cyl_bessel_i;
1184
1185 using std::cyl_bessel_jf;
1186 using std::cyl_bessel_jl;
1187 using std::cyl_bessel_j;
1188
1189 using std::cyl_bessel_kf;
1190 using std::cyl_bessel_kl;
1191 using std::cyl_bessel_k;
1192
1193 using std::cyl_neumannf;
1194 using std::cyl_neumannl;
1195 using std::cyl_neumann;
1196
1197 using std::ellint_1f;
1198 using std::ellint_1l;
1199 using std::ellint_1;
1200
1201 using std::ellint_2f;
1202 using std::ellint_2l;
1203 using std::ellint_2;
1204
1205 using std::ellint_3f;
1206 using std::ellint_3l;
1207 using std::ellint_3;
1208
1209 using std::expintf;
1210 using std::expintl;
1211 using std::expint;
1212
1213 using std::hermitef;
1214 using std::hermitel;
1215 using std::hermite;
1216
1217 using std::laguerref;
1218 using std::laguerrel;
1219 using std::laguerre;
1220
1221 using std::legendref;
1222 using std::legendrel;
1223 using std::legendre;
1224
1225 using std::riemann_zetaf;
1226 using std::riemann_zetal;
1227 using std::riemann_zeta;
1228
1229 using std::sph_besself;
1230 using std::sph_bessell;
1231 using std::sph_bessel;
1232
1233 using std::sph_legendref;
1234 using std::sph_legendrel;
1235 using std::sph_legendre;
1236
1237 using std::sph_neumannf;
1238 using std::sph_neumannl;
1239 using std::sph_neumann;
1240
1241} // namespace tr1
1242_GLIBCXX_END_NAMESPACE_VERSION
1243} // namespace std
1244
1245#else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
1246
1247#include <bits/stl_algobase.h>
1248#include <limits>
1249#include <tr1/type_traits>
1250
1251#include <tr1/gamma.tcc>
1252#include <tr1/bessel_function.tcc>
1253#include <tr1/beta_function.tcc>
1254#include <tr1/ell_integral.tcc>
1255#include <tr1/exp_integral.tcc>
1256#include <tr1/legendre_function.tcc>
1257#include <tr1/modified_bessel_func.tcc>
1258#include <tr1/poly_hermite.tcc>
1259#include <tr1/poly_laguerre.tcc>
1260#include <tr1/riemann_zeta.tcc>
1261
1262namespace std _GLIBCXX_VISIBILITY(default)
1263{
1264_GLIBCXX_BEGIN_NAMESPACE_VERSION
1265namespace tr1
1266 {
1267 /** @addtogroup tr1_math_spec_func
1268 * @{
1269 */
1270
1271 inline float
1272 assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
1273 { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
1274
1275 inline long double
1276 assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
1277 {
1278 return __detail::__assoc_laguerre<long double>(__n, __m, __x);
1279 }
1280
1281 /// 5.2.1.1 Associated Laguerre polynomials.
1282 template<typename _Tp>
1283 inline typename __gnu_cxx::__promote<_Tp>::__type
1284 assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
1285 {
1286 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1287 return __detail::__assoc_laguerre<__type>(__n, __m, __x);
1288 }
1289
1290 inline float
1291 assoc_legendref(unsigned int __l, unsigned int __m, float __x)
1292 { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
1293
1294 inline long double
1295 assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
1296 { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
1297
1298 /// 5.2.1.2 Associated Legendre functions.
1299 template<typename _Tp>
1300 inline typename __gnu_cxx::__promote<_Tp>::__type
1301 assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
1302 {
1303 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1304 return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
1305 }
1306
1307 inline float
1308 betaf(float __x, float __y)
1309 { return __detail::__beta<float>(__x, __y); }
1310
1311 inline long double
1312 betal(long double __x, long double __y)
1313 { return __detail::__beta<long double>(__x, __y); }
1314
1315 /// 5.2.1.3 Beta functions.
1316 template<typename _Tpx, typename _Tpy>
1317 inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
1318 beta(_Tpx __x, _Tpy __y)
1319 {
1320 typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
1321 return __detail::__beta<__type>(__x, __y);
1322 }
1323
1324 inline float
1325 comp_ellint_1f(float __k)
1326 { return __detail::__comp_ellint_1<float>(__k); }
1327
1328 inline long double
1329 comp_ellint_1l(long double __k)
1330 { return __detail::__comp_ellint_1<long double>(__k); }
1331
1332 /// 5.2.1.4 Complete elliptic integrals of the first kind.
1333 template<typename _Tp>
1334 inline typename __gnu_cxx::__promote<_Tp>::__type
1336 {
1337 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1338 return __detail::__comp_ellint_1<__type>(__k);
1339 }
1340
1341 inline float
1342 comp_ellint_2f(float __k)
1343 { return __detail::__comp_ellint_2<float>(__k); }
1344
1345 inline long double
1346 comp_ellint_2l(long double __k)
1347 { return __detail::__comp_ellint_2<long double>(__k); }
1348
1349 /// 5.2.1.5 Complete elliptic integrals of the second kind.
1350 template<typename _Tp>
1351 inline typename __gnu_cxx::__promote<_Tp>::__type
1353 {
1354 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1355 return __detail::__comp_ellint_2<__type>(__k);
1356 }
1357
1358 inline float
1359 comp_ellint_3f(float __k, float __nu)
1360 { return __detail::__comp_ellint_3<float>(__k, __nu); }
1361
1362 inline long double
1363 comp_ellint_3l(long double __k, long double __nu)
1364 { return __detail::__comp_ellint_3<long double>(__k, __nu); }
1365
1366 /// 5.2.1.6 Complete elliptic integrals of the third kind.
1367 template<typename _Tp, typename _Tpn>
1368 inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
1369 comp_ellint_3(_Tp __k, _Tpn __nu)
1370 {
1371 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
1372 return __detail::__comp_ellint_3<__type>(__k, __nu);
1373 }
1374
1375 inline float
1376 cyl_bessel_if(float __nu, float __x)
1377 { return __detail::__cyl_bessel_i<float>(__nu, __x); }
1378
1379 inline long double
1380 cyl_bessel_il(long double __nu, long double __x)
1381 { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
1382
1383 /// 5.2.1.8 Regular modified cylindrical Bessel functions.
1384 template<typename _Tpnu, typename _Tp>
1385 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1386 cyl_bessel_i(_Tpnu __nu, _Tp __x)
1387 {
1388 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1389 return __detail::__cyl_bessel_i<__type>(__nu, __x);
1390 }
1391
1392 inline float
1393 cyl_bessel_jf(float __nu, float __x)
1394 { return __detail::__cyl_bessel_j<float>(__nu, __x); }
1395
1396 inline long double
1397 cyl_bessel_jl(long double __nu, long double __x)
1398 { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
1399
1400 /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
1401 template<typename _Tpnu, typename _Tp>
1402 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1403 cyl_bessel_j(_Tpnu __nu, _Tp __x)
1404 {
1405 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1406 return __detail::__cyl_bessel_j<__type>(__nu, __x);
1407 }
1408
1409 inline float
1410 cyl_bessel_kf(float __nu, float __x)
1411 { return __detail::__cyl_bessel_k<float>(__nu, __x); }
1412
1413 inline long double
1414 cyl_bessel_kl(long double __nu, long double __x)
1415 { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
1416
1417 /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
1418 template<typename _Tpnu, typename _Tp>
1419 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1420 cyl_bessel_k(_Tpnu __nu, _Tp __x)
1421 {
1422 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1423 return __detail::__cyl_bessel_k<__type>(__nu, __x);
1424 }
1425
1426 inline float
1427 cyl_neumannf(float __nu, float __x)
1428 { return __detail::__cyl_neumann_n<float>(__nu, __x); }
1429
1430 inline long double
1431 cyl_neumannl(long double __nu, long double __x)
1432 { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
1433
1434 /// 5.2.1.11 Cylindrical Neumann functions.
1435 template<typename _Tpnu, typename _Tp>
1436 inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
1437 cyl_neumann(_Tpnu __nu, _Tp __x)
1438 {
1439 typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
1440 return __detail::__cyl_neumann_n<__type>(__nu, __x);
1441 }
1442
1443 inline float
1444 ellint_1f(float __k, float __phi)
1445 { return __detail::__ellint_1<float>(__k, __phi); }
1446
1447 inline long double
1448 ellint_1l(long double __k, long double __phi)
1449 { return __detail::__ellint_1<long double>(__k, __phi); }
1450
1451 /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
1452 template<typename _Tp, typename _Tpp>
1453 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1454 ellint_1(_Tp __k, _Tpp __phi)
1455 {
1456 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1457 return __detail::__ellint_1<__type>(__k, __phi);
1458 }
1459
1460 inline float
1461 ellint_2f(float __k, float __phi)
1462 { return __detail::__ellint_2<float>(__k, __phi); }
1463
1464 inline long double
1465 ellint_2l(long double __k, long double __phi)
1466 { return __detail::__ellint_2<long double>(__k, __phi); }
1467
1468 /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
1469 template<typename _Tp, typename _Tpp>
1470 inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
1471 ellint_2(_Tp __k, _Tpp __phi)
1472 {
1473 typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
1474 return __detail::__ellint_2<__type>(__k, __phi);
1475 }
1476
1477 inline float
1478 ellint_3f(float __k, float __nu, float __phi)
1479 { return __detail::__ellint_3<float>(__k, __nu, __phi); }
1480
1481 inline long double
1482 ellint_3l(long double __k, long double __nu, long double __phi)
1483 { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
1484
1485 /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
1486 template<typename _Tp, typename _Tpn, typename _Tpp>
1487 inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
1488 ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
1489 {
1490 typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
1491 return __detail::__ellint_3<__type>(__k, __nu, __phi);
1492 }
1493
1494 inline float
1495 expintf(float __x)
1496 { return __detail::__expint<float>(__x); }
1497
1498 inline long double
1499 expintl(long double __x)
1500 { return __detail::__expint<long double>(__x); }
1501
1502 /// 5.2.1.15 Exponential integrals.
1503 template<typename _Tp>
1504 inline typename __gnu_cxx::__promote<_Tp>::__type
1505 expint(_Tp __x)
1506 {
1507 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1508 return __detail::__expint<__type>(__x);
1509 }
1510
1511 inline float
1512 hermitef(unsigned int __n, float __x)
1513 { return __detail::__poly_hermite<float>(__n, __x); }
1514
1515 inline long double
1516 hermitel(unsigned int __n, long double __x)
1517 { return __detail::__poly_hermite<long double>(__n, __x); }
1518
1519 /// 5.2.1.16 Hermite polynomials.
1520 template<typename _Tp>
1521 inline typename __gnu_cxx::__promote<_Tp>::__type
1522 hermite(unsigned int __n, _Tp __x)
1523 {
1524 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1525 return __detail::__poly_hermite<__type>(__n, __x);
1526 }
1527
1528 inline float
1529 laguerref(unsigned int __n, float __x)
1530 { return __detail::__laguerre<float>(__n, __x); }
1531
1532 inline long double
1533 laguerrel(unsigned int __n, long double __x)
1534 { return __detail::__laguerre<long double>(__n, __x); }
1535
1536 /// 5.2.1.18 Laguerre polynomials.
1537 template<typename _Tp>
1538 inline typename __gnu_cxx::__promote<_Tp>::__type
1539 laguerre(unsigned int __n, _Tp __x)
1540 {
1541 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1542 return __detail::__laguerre<__type>(__n, __x);
1543 }
1544
1545 inline float
1546 legendref(unsigned int __n, float __x)
1547 { return __detail::__poly_legendre_p<float>(__n, __x); }
1548
1549 inline long double
1550 legendrel(unsigned int __n, long double __x)
1551 { return __detail::__poly_legendre_p<long double>(__n, __x); }
1552
1553 /// 5.2.1.19 Legendre polynomials.
1554 template<typename _Tp>
1555 inline typename __gnu_cxx::__promote<_Tp>::__type
1556 legendre(unsigned int __n, _Tp __x)
1557 {
1558 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1559 return __detail::__poly_legendre_p<__type>(__n, __x);
1560 }
1561
1562 inline float
1563 riemann_zetaf(float __x)
1564 { return __detail::__riemann_zeta<float>(__x); }
1565
1566 inline long double
1567 riemann_zetal(long double __x)
1568 { return __detail::__riemann_zeta<long double>(__x); }
1569
1570 /// 5.2.1.20 Riemann zeta function.
1571 template<typename _Tp>
1572 inline typename __gnu_cxx::__promote<_Tp>::__type
1574 {
1575 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1576 return __detail::__riemann_zeta<__type>(__x);
1577 }
1578
1579 inline float
1580 sph_besself(unsigned int __n, float __x)
1581 { return __detail::__sph_bessel<float>(__n, __x); }
1582
1583 inline long double
1584 sph_bessell(unsigned int __n, long double __x)
1585 { return __detail::__sph_bessel<long double>(__n, __x); }
1586
1587 /// 5.2.1.21 Spherical Bessel functions.
1588 template<typename _Tp>
1589 inline typename __gnu_cxx::__promote<_Tp>::__type
1590 sph_bessel(unsigned int __n, _Tp __x)
1591 {
1592 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1593 return __detail::__sph_bessel<__type>(__n, __x);
1594 }
1595
1596 inline float
1597 sph_legendref(unsigned int __l, unsigned int __m, float __theta)
1598 { return __detail::__sph_legendre<float>(__l, __m, __theta); }
1599
1600 inline long double
1601 sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
1602 { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
1603
1604 /// 5.2.1.22 Spherical associated Legendre functions.
1605 template<typename _Tp>
1606 inline typename __gnu_cxx::__promote<_Tp>::__type
1607 sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
1608 {
1609 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1610 return __detail::__sph_legendre<__type>(__l, __m, __theta);
1611 }
1612
1613 inline float
1614 sph_neumannf(unsigned int __n, float __x)
1615 { return __detail::__sph_neumann<float>(__n, __x); }
1616
1617 inline long double
1618 sph_neumannl(unsigned int __n, long double __x)
1619 { return __detail::__sph_neumann<long double>(__n, __x); }
1620
1621 /// 5.2.1.23 Spherical Neumann functions.
1622 template<typename _Tp>
1623 inline typename __gnu_cxx::__promote<_Tp>::__type
1624 sph_neumann(unsigned int __n, _Tp __x)
1625 {
1626 typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
1627 return __detail::__sph_neumann<__type>(__n, __x);
1628 }
1629
1630 /// @} tr1_math_spec_func
1631
1632} // namespace tr1
1633
1634_GLIBCXX_END_NAMESPACE_VERSION
1635} // namespace std
1636
1637#endif // _GLIBCXX_USE_STD_SPEC_FUNCS
1638
1639#if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1640namespace std _GLIBCXX_VISIBILITY(default)
1641{
1642_GLIBCXX_BEGIN_NAMESPACE_VERSION
1643
1644namespace tr1
1645{
1649
1650 using __gnu_cxx::hypergf;
1651 using __gnu_cxx::hypergl;
1652 using __gnu_cxx::hyperg;
1653} // namespace tr1
1654
1655_GLIBCXX_END_NAMESPACE_VERSION
1656} // namespace std
1657
1658#else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
1659
1660#include <bits/stl_algobase.h>
1661#include <limits>
1662#include <tr1/type_traits>
1663
1664#include <tr1/hypergeometric.tcc>
1665
1666namespace std _GLIBCXX_VISIBILITY(default)
1667{
1668_GLIBCXX_BEGIN_NAMESPACE_VERSION
1669
1670namespace tr1
1671{
1672 /** @addtogroup tr1_math_spec_func
1673 * @{
1674 */
1675
1676 inline float
1677 conf_hypergf(float __a, float __c, float __x)
1678 { return __detail::__conf_hyperg<float>(__a, __c, __x); }
1679
1680 inline long double
1681 conf_hypergl(long double __a, long double __c, long double __x)
1682 { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
1683
1684 /// 5.2.1.7 Confluent hypergeometric functions.
1685 template<typename _Tpa, typename _Tpc, typename _Tp>
1686 inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
1687 conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
1688 {
1689 typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
1690 return __detail::__conf_hyperg<__type>(__a, __c, __x);
1691 }
1692
1693 inline float
1694 hypergf(float __a, float __b, float __c, float __x)
1695 { return __detail::__hyperg<float>(__a, __b, __c, __x); }
1696
1697 inline long double
1698 hypergl(long double __a, long double __b, long double __c, long double __x)
1699 { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
1700
1701 /// 5.2.1.17 Hypergeometric functions.
1702 template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
1703 inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
1704 hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
1705 {
1706 typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
1707 return __detail::__hyperg<__type>(__a, __b, __c, __x);
1708 }
1709
1710 /// @} tr1_math_spec_func
1711
1712} // namespace tr1
1713
1714_GLIBCXX_END_NAMESPACE_VERSION
1715} // namespace std
1716#endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
1717
1718#endif // _GLIBCXX_TR1_CMATH
complex< _Tp > log10(const complex< _Tp > &)
Return complex base 10 logarithm of z.
Definition complex:1167
complex< _Tp > sin(const complex< _Tp > &)
Return complex sine of z.
Definition complex:1197
complex< _Tp > log(const complex< _Tp > &)
Return complex natural logarithm of z.
Definition complex:1162
complex< _Tp > tan(const complex< _Tp > &)
Return complex tangent of z.
Definition complex:1298
complex< _Tp > exp(const complex< _Tp > &)
Return complex base e exponential of z.
Definition complex:1135
complex< _Tp > cosh(const complex< _Tp > &)
Return complex hyperbolic cosine of z.
Definition complex:1109
complex< _Tp > tanh(const complex< _Tp > &)
Return complex hyperbolic tangent of z.
Definition complex:1326
complex< _Tp > pow(const complex< _Tp > &, int)
Return x to the y'th power.
Definition complex:1357
complex< _Tp > sinh(const complex< _Tp > &)
Return complex hyperbolic sine of z.
Definition complex:1227
complex< _Tp > cos(const complex< _Tp > &)
Return complex cosine of z.
Definition complex:1079
complex< _Tp > sqrt(const complex< _Tp > &)
Return complex square root of z.
Definition complex:1271
__gnu_cxx::__promote< _Tp >::__type sph_bessel(unsigned int __n, _Tp __x)
Definition specfun.h:1101
long double conf_hypergl(long double __a, long double __c, long double __x)
Definition specfun.h:1305
long double sph_bessell(unsigned int __n, long double __x)
Definition specfun.h:1082
float betaf(float __a, float __b)
Definition specfun.h:311
long double expintl(long double __x)
Definition specfun.h:853
float cyl_bessel_jf(float __nu, float __x)
Definition specfun.h:549
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_k(_Tpnu __nu, _Tp __x)
Definition specfun.h:632
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
long double legendrel(unsigned int __l, long double __x)
Definition specfun.h:986
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
long double riemann_zetal(long double __s)
Definition specfun.h:1031
float cyl_bessel_kf(float __nu, float __x)
Definition specfun.h:595
float comp_ellint_2f(float __k)
Definition specfun.h:405
long double hermitel(unsigned int __n, long double __x)
Definition specfun.h:894
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_1(_Tp __k, _Tpp __phi)
Definition specfun.h:728
long double sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
Definition specfun.h:1127
float ellint_1f(float __k, float __phi)
Definition specfun.h:695
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_neumann(_Tpnu __nu, _Tp __x)
Definition specfun.h:680
float assoc_legendref(unsigned int __l, unsigned int __m, float __x)
Definition specfun.h:266
long double sph_neumannl(unsigned int __n, long double __x)
Definition specfun.h:1173
__gnu_cxx::__promote_4< _Tpa, _Tpb, _Tpc, _Tp >::__type hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
Definition specfun.h:1375
long double comp_ellint_2l(long double __k)
Definition specfun.h:415
__gnu_cxx::__promote< _Tp >::__type comp_ellint_2(_Tp __k)
Definition specfun.h:437
float sph_besself(unsigned int __n, float __x)
Definition specfun.h:1072
long double assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
Definition specfun.h:275
__gnu_cxx::__promote< _Tp >::__type legendre(unsigned int __l, _Tp __x)
Definition specfun.h:1006
float expintf(float __x)
Definition specfun.h:843
float ellint_2f(float __k, float __phi)
Return the incomplete elliptic integral of the second kind for float argument.
Definition specfun.h:743
__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
long double ellint_2l(long double __k, long double __phi)
Return the incomplete elliptic integral of the second kind .
Definition specfun.h:753
float cyl_neumannf(float __nu, float __x)
Definition specfun.h:647
__gnu_cxx::__promote_2< _Tpa, _Tpb >::__type beta(_Tpa __a, _Tpb __b)
Definition specfun.h:342
long double comp_ellint_1l(long double __k)
Definition specfun.h:367
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
float sph_neumannf(unsigned int __n, float __x)
Definition specfun.h:1163
__gnu_cxx::__promote< _Tp >::__type expint(_Tp __x)
Definition specfun.h:869
long double ellint_1l(long double __k, long double __phi)
Definition specfun.h:705
float comp_ellint_1f(float __k)
Definition specfun.h:357
long double betal(long double __a, long double __b)
Definition specfun.h:321
__gnu_cxx::__promote_3< _Tpa, _Tpc, _Tp >::__type conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
Definition specfun.h:1326
float hermitef(unsigned int __n, float __x)
Definition specfun.h:884
__gnu_cxx::__promote< _Tp >::__type riemann_zeta(_Tp __s)
Definition specfun.h:1057
long double hypergl(long double __a, long double __b, long double __c, long double __x)
Definition specfun.h:1353
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
float sph_legendref(unsigned int __l, unsigned int __m, float __theta)
Definition specfun.h:1116
__gnu_cxx::__promote< _Tp >::__type sph_neumann(unsigned int __n, _Tp __x)
Definition specfun.h:1192
float cyl_bessel_if(float __nu, float __x)
Definition specfun.h:503
long double laguerrel(unsigned int __n, long double __x)
Definition specfun.h:942
long double cyl_bessel_il(long double __nu, long double __x)
Definition specfun.h:513
__gnu_cxx::__promote< _Tp >::__type assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
Definition specfun.h:251
float conf_hypergf(float __a, float __c, float __x)
Definition specfun.h:1294
__gnu_cxx::__promote_2< _Tp, _Tpn >::__type comp_ellint_3(_Tp __k, _Tpn __nu)
Definition specfun.h:488
__gnu_cxx::__promote< _Tp >::__type sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
Definition specfun.h:1148
long double cyl_bessel_kl(long double __nu, long double __x)
Definition specfun.h:605
float hypergf(float __a, float __b, float __c, float __x)
Definition specfun.h:1342
long double assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
Definition specfun.h:215
__gnu_cxx::__promote< _Tp >::__type hermite(unsigned int __n, _Tp __x)
Definition specfun.h:917
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_j(_Tpnu __nu, _Tp __x)
Definition specfun.h:580
float laguerref(unsigned int __n, float __x)
Definition specfun.h:932
long double cyl_bessel_jl(long double __nu, long double __x)
Definition specfun.h:559
__gnu_cxx::__promote< _Tp >::__type comp_ellint_1(_Tp __k)
Definition specfun.h:390
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_2(_Tp __k, _Tpp __phi)
Definition specfun.h:776
__gnu_cxx::__promote< _Tp >::__type laguerre(unsigned int __n, _Tp __x)
Definition specfun.h:961
float legendref(unsigned int __l, float __x)
Definition specfun.h:976
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_i(_Tpnu __nu, _Tp __x)
Definition specfun.h:534
__gnu_cxx::__promote< _Tp >::__type assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
Definition specfun.h:297
float assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
Definition specfun.h:205
long double cyl_neumannl(long double __nu, long double __x)
Definition specfun.h:657
float riemann_zetaf(float __s)
Definition specfun.h:1021
__gnu_cxx::__promote_2< _Tp, _Tpn >::__type comp_ellint_3(_Tp __k, _Tpn __nu)
5.2.1.6 Complete elliptic integrals of the third kind.
Definition tr1/cmath:1369
__gnu_cxx::__promote< _Tp >::__type expint(_Tp __x)
5.2.1.15 Exponential integrals.
Definition tr1/cmath:1505
__gnu_cxx::__promote< _Tp >::__type assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
5.2.1.2 Associated Legendre functions.
Definition tr1/cmath:1301
__gnu_cxx::__promote< _Tp >::__type comp_ellint_1(_Tp __k)
5.2.1.4 Complete elliptic integrals of the first kind.
Definition tr1/cmath:1335
__gnu_cxx::__promote< _Tp >::__type sph_bessel(unsigned int __n, _Tp __x)
5.2.1.21 Spherical Bessel functions.
Definition tr1/cmath:1590
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_neumann(_Tpnu __nu, _Tp __x)
5.2.1.11 Cylindrical Neumann functions.
Definition tr1/cmath:1437
__gnu_cxx::__promote< _Tp >::__type assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
5.2.1.1 Associated Laguerre polynomials.
Definition tr1/cmath:1284
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_2(_Tp __k, _Tpp __phi)
5.2.1.13 Incomplete elliptic integrals of the second kind.
Definition tr1/cmath:1471
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_j(_Tpnu __nu, _Tp __x)
5.2.1.9 Cylindrical Bessel functions (of the first kind).
Definition tr1/cmath:1403
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_i(_Tpnu __nu, _Tp __x)
5.2.1.8 Regular modified cylindrical Bessel functions.
Definition tr1/cmath:1386
__gnu_cxx::__promote< _Tp >::__type riemann_zeta(_Tp __x)
5.2.1.20 Riemann zeta function.
Definition tr1/cmath:1573
__gnu_cxx::__promote_3< _Tp, _Tpn, _Tpp >::__type ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
5.2.1.14 Incomplete elliptic integrals of the third kind.
Definition tr1/cmath:1488
__gnu_cxx::__promote_2< _Tpx, _Tpy >::__type beta(_Tpx __x, _Tpy __y)
5.2.1.3 Beta functions.
Definition tr1/cmath:1318
__gnu_cxx::__promote_2< _Tpnu, _Tp >::__type cyl_bessel_k(_Tpnu __nu, _Tp __x)
5.2.1.10 Irregular modified cylindrical Bessel functions.
Definition tr1/cmath:1420
__gnu_cxx::__promote_2< _Tp, _Tpp >::__type ellint_1(_Tp __k, _Tpp __phi)
5.2.1.12 Incomplete elliptic integrals of the first kind.
Definition tr1/cmath:1454
__gnu_cxx::__promote< _Tp >::__type comp_ellint_2(_Tp __k)
5.2.1.5 Complete elliptic integrals of the second kind.
Definition tr1/cmath:1352
__gnu_cxx::__promote< _Tp >::__type legendre(unsigned int __n, _Tp __x)
5.2.1.19 Legendre polynomials.
Definition tr1/cmath:1556
__gnu_cxx::__promote< _Tp >::__type hermite(unsigned int __n, _Tp __x)
5.2.1.16 Hermite polynomials.
Definition tr1/cmath:1522
__gnu_cxx::__promote< _Tp >::__type sph_neumann(unsigned int __n, _Tp __x)
5.2.1.23 Spherical Neumann functions.
Definition tr1/cmath:1624
__gnu_cxx::__promote< _Tp >::__type sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
5.2.1.22 Spherical associated Legendre functions.
Definition tr1/cmath:1607
__gnu_cxx::__promote< _Tp >::__type laguerre(unsigned int __n, _Tp __x)
5.2.1.18 Laguerre polynomials.
Definition tr1/cmath:1539
ISO C++ entities toplevel namespace is std.
_Tp fabs(const std::complex< _Tp > &__z)
fabs(__z) TR1 8.1.8 [tr.c99.cmplx.fabs]
Definition complex:2525
ISO C++ TR1 entities toplevel namespace is std::tr1.
long double conf_hypergl(long double __a, long double __c, long double __x)
Definition specfun.h:1305
__gnu_cxx::__promote_4< _Tpa, _Tpb, _Tpc, _Tp >::__type hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
Definition specfun.h:1375
__gnu_cxx::__promote_3< _Tpa, _Tpc, _Tp >::__type conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
Definition specfun.h:1326
long double hypergl(long double __a, long double __b, long double __c, long double __x)
Definition specfun.h:1353
float conf_hypergf(float __a, float __c, float __x)
Definition specfun.h:1294
float hypergf(float __a, float __b, float __c, float __x)
Definition specfun.h:1342