You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1710 lines
43KB

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