cmath 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701
  1. // TR1 cmath -*- C++ -*-
  2. // Copyright (C) 2006-2018 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. #if _GLIBCXX_USE_STD_SPEC_FUNCS
  938. /**
  939. * @defgroup tr1_math_spec_func Mathematical Special Functions
  940. * @ingroup numerics
  941. *
  942. * A collection of advanced mathematical special functions.
  943. * @{
  944. */
  945. using std::assoc_laguerref;
  946. using std::assoc_laguerrel;
  947. using std::assoc_laguerre;
  948. using std::assoc_legendref;
  949. using std::assoc_legendrel;
  950. using std::assoc_legendre;
  951. using std::betaf;
  952. using std::betal;
  953. using std::beta;
  954. using std::comp_ellint_1f;
  955. using std::comp_ellint_1l;
  956. using std::comp_ellint_1;
  957. using std::comp_ellint_2f;
  958. using std::comp_ellint_2l;
  959. using std::comp_ellint_2;
  960. using std::comp_ellint_3f;
  961. using std::comp_ellint_3l;
  962. using std::comp_ellint_3;
  963. using std::cyl_bessel_if;
  964. using std::cyl_bessel_il;
  965. using std::cyl_bessel_i;
  966. using std::cyl_bessel_jf;
  967. using std::cyl_bessel_jl;
  968. using std::cyl_bessel_j;
  969. using std::cyl_bessel_kf;
  970. using std::cyl_bessel_kl;
  971. using std::cyl_bessel_k;
  972. using std::cyl_neumannf;
  973. using std::cyl_neumannl;
  974. using std::cyl_neumann;
  975. using std::ellint_1f;
  976. using std::ellint_1l;
  977. using std::ellint_1;
  978. using std::ellint_2f;
  979. using std::ellint_2l;
  980. using std::ellint_2;
  981. using std::ellint_3f;
  982. using std::ellint_3l;
  983. using std::ellint_3;
  984. using std::expintf;
  985. using std::expintl;
  986. using std::expint;
  987. using std::hermitef;
  988. using std::hermitel;
  989. using std::hermite;
  990. using std::laguerref;
  991. using std::laguerrel;
  992. using std::laguerre;
  993. using std::legendref;
  994. using std::legendrel;
  995. using std::legendre;
  996. using std::riemann_zetaf;
  997. using std::riemann_zetal;
  998. using std::riemann_zeta;
  999. using std::sph_besself;
  1000. using std::sph_bessell;
  1001. using std::sph_bessel;
  1002. using std::sph_legendref;
  1003. using std::sph_legendrel;
  1004. using std::sph_legendre;
  1005. using std::sph_neumannf;
  1006. using std::sph_neumannl;
  1007. using std::sph_neumann;
  1008. /* @} */ // tr1_math_spec_func
  1009. #else // ! _GLIBCXX_USE_STD_SPEC_FUNCS
  1010. } // namespace tr1
  1011. _GLIBCXX_END_NAMESPACE_VERSION
  1012. } // namespace std
  1013. #include <bits/stl_algobase.h>
  1014. #include <limits>
  1015. #include <tr1/type_traits>
  1016. #include <tr1/gamma.tcc>
  1017. #include <tr1/bessel_function.tcc>
  1018. #include <tr1/beta_function.tcc>
  1019. #include <tr1/ell_integral.tcc>
  1020. #include <tr1/exp_integral.tcc>
  1021. #include <tr1/legendre_function.tcc>
  1022. #include <tr1/modified_bessel_func.tcc>
  1023. #include <tr1/poly_hermite.tcc>
  1024. #include <tr1/poly_laguerre.tcc>
  1025. #include <tr1/riemann_zeta.tcc>
  1026. namespace std _GLIBCXX_VISIBILITY(default)
  1027. {
  1028. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  1029. namespace tr1
  1030. {
  1031. /**
  1032. * @defgroup tr1_math_spec_func Mathematical Special Functions
  1033. * @ingroup numerics
  1034. *
  1035. * A collection of advanced mathematical special functions.
  1036. * @{
  1037. */
  1038. inline float
  1039. assoc_laguerref(unsigned int __n, unsigned int __m, float __x)
  1040. { return __detail::__assoc_laguerre<float>(__n, __m, __x); }
  1041. inline long double
  1042. assoc_laguerrel(unsigned int __n, unsigned int __m, long double __x)
  1043. {
  1044. return __detail::__assoc_laguerre<long double>(__n, __m, __x);
  1045. }
  1046. /// 5.2.1.1 Associated Laguerre polynomials.
  1047. template<typename _Tp>
  1048. inline typename __gnu_cxx::__promote<_Tp>::__type
  1049. assoc_laguerre(unsigned int __n, unsigned int __m, _Tp __x)
  1050. {
  1051. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1052. return __detail::__assoc_laguerre<__type>(__n, __m, __x);
  1053. }
  1054. inline float
  1055. assoc_legendref(unsigned int __l, unsigned int __m, float __x)
  1056. { return __detail::__assoc_legendre_p<float>(__l, __m, __x); }
  1057. inline long double
  1058. assoc_legendrel(unsigned int __l, unsigned int __m, long double __x)
  1059. { return __detail::__assoc_legendre_p<long double>(__l, __m, __x); }
  1060. /// 5.2.1.2 Associated Legendre functions.
  1061. template<typename _Tp>
  1062. inline typename __gnu_cxx::__promote<_Tp>::__type
  1063. assoc_legendre(unsigned int __l, unsigned int __m, _Tp __x)
  1064. {
  1065. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1066. return __detail::__assoc_legendre_p<__type>(__l, __m, __x);
  1067. }
  1068. inline float
  1069. betaf(float __x, float __y)
  1070. { return __detail::__beta<float>(__x, __y); }
  1071. inline long double
  1072. betal(long double __x, long double __y)
  1073. { return __detail::__beta<long double>(__x, __y); }
  1074. /// 5.2.1.3 Beta functions.
  1075. template<typename _Tpx, typename _Tpy>
  1076. inline typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type
  1077. beta(_Tpx __x, _Tpy __y)
  1078. {
  1079. typedef typename __gnu_cxx::__promote_2<_Tpx, _Tpy>::__type __type;
  1080. return __detail::__beta<__type>(__x, __y);
  1081. }
  1082. inline float
  1083. comp_ellint_1f(float __k)
  1084. { return __detail::__comp_ellint_1<float>(__k); }
  1085. inline long double
  1086. comp_ellint_1l(long double __k)
  1087. { return __detail::__comp_ellint_1<long double>(__k); }
  1088. /// 5.2.1.4 Complete elliptic integrals of the first kind.
  1089. template<typename _Tp>
  1090. inline typename __gnu_cxx::__promote<_Tp>::__type
  1091. comp_ellint_1(_Tp __k)
  1092. {
  1093. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1094. return __detail::__comp_ellint_1<__type>(__k);
  1095. }
  1096. inline float
  1097. comp_ellint_2f(float __k)
  1098. { return __detail::__comp_ellint_2<float>(__k); }
  1099. inline long double
  1100. comp_ellint_2l(long double __k)
  1101. { return __detail::__comp_ellint_2<long double>(__k); }
  1102. /// 5.2.1.5 Complete elliptic integrals of the second kind.
  1103. template<typename _Tp>
  1104. inline typename __gnu_cxx::__promote<_Tp>::__type
  1105. comp_ellint_2(_Tp __k)
  1106. {
  1107. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1108. return __detail::__comp_ellint_2<__type>(__k);
  1109. }
  1110. inline float
  1111. comp_ellint_3f(float __k, float __nu)
  1112. { return __detail::__comp_ellint_3<float>(__k, __nu); }
  1113. inline long double
  1114. comp_ellint_3l(long double __k, long double __nu)
  1115. { return __detail::__comp_ellint_3<long double>(__k, __nu); }
  1116. /// 5.2.1.6 Complete elliptic integrals of the third kind.
  1117. template<typename _Tp, typename _Tpn>
  1118. inline typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type
  1119. comp_ellint_3(_Tp __k, _Tpn __nu)
  1120. {
  1121. typedef typename __gnu_cxx::__promote_2<_Tp, _Tpn>::__type __type;
  1122. return __detail::__comp_ellint_3<__type>(__k, __nu);
  1123. }
  1124. inline float
  1125. cyl_bessel_if(float __nu, float __x)
  1126. { return __detail::__cyl_bessel_i<float>(__nu, __x); }
  1127. inline long double
  1128. cyl_bessel_il(long double __nu, long double __x)
  1129. { return __detail::__cyl_bessel_i<long double>(__nu, __x); }
  1130. /// 5.2.1.8 Regular modified cylindrical Bessel functions.
  1131. template<typename _Tpnu, typename _Tp>
  1132. inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
  1133. cyl_bessel_i(_Tpnu __nu, _Tp __x)
  1134. {
  1135. typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
  1136. return __detail::__cyl_bessel_i<__type>(__nu, __x);
  1137. }
  1138. inline float
  1139. cyl_bessel_jf(float __nu, float __x)
  1140. { return __detail::__cyl_bessel_j<float>(__nu, __x); }
  1141. inline long double
  1142. cyl_bessel_jl(long double __nu, long double __x)
  1143. { return __detail::__cyl_bessel_j<long double>(__nu, __x); }
  1144. /// 5.2.1.9 Cylindrical Bessel functions (of the first kind).
  1145. template<typename _Tpnu, typename _Tp>
  1146. inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
  1147. cyl_bessel_j(_Tpnu __nu, _Tp __x)
  1148. {
  1149. typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
  1150. return __detail::__cyl_bessel_j<__type>(__nu, __x);
  1151. }
  1152. inline float
  1153. cyl_bessel_kf(float __nu, float __x)
  1154. { return __detail::__cyl_bessel_k<float>(__nu, __x); }
  1155. inline long double
  1156. cyl_bessel_kl(long double __nu, long double __x)
  1157. { return __detail::__cyl_bessel_k<long double>(__nu, __x); }
  1158. /// 5.2.1.10 Irregular modified cylindrical Bessel functions.
  1159. template<typename _Tpnu, typename _Tp>
  1160. inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
  1161. cyl_bessel_k(_Tpnu __nu, _Tp __x)
  1162. {
  1163. typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
  1164. return __detail::__cyl_bessel_k<__type>(__nu, __x);
  1165. }
  1166. inline float
  1167. cyl_neumannf(float __nu, float __x)
  1168. { return __detail::__cyl_neumann_n<float>(__nu, __x); }
  1169. inline long double
  1170. cyl_neumannl(long double __nu, long double __x)
  1171. { return __detail::__cyl_neumann_n<long double>(__nu, __x); }
  1172. /// 5.2.1.11 Cylindrical Neumann functions.
  1173. template<typename _Tpnu, typename _Tp>
  1174. inline typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type
  1175. cyl_neumann(_Tpnu __nu, _Tp __x)
  1176. {
  1177. typedef typename __gnu_cxx::__promote_2<_Tpnu, _Tp>::__type __type;
  1178. return __detail::__cyl_neumann_n<__type>(__nu, __x);
  1179. }
  1180. inline float
  1181. ellint_1f(float __k, float __phi)
  1182. { return __detail::__ellint_1<float>(__k, __phi); }
  1183. inline long double
  1184. ellint_1l(long double __k, long double __phi)
  1185. { return __detail::__ellint_1<long double>(__k, __phi); }
  1186. /// 5.2.1.12 Incomplete elliptic integrals of the first kind.
  1187. template<typename _Tp, typename _Tpp>
  1188. inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
  1189. ellint_1(_Tp __k, _Tpp __phi)
  1190. {
  1191. typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
  1192. return __detail::__ellint_1<__type>(__k, __phi);
  1193. }
  1194. inline float
  1195. ellint_2f(float __k, float __phi)
  1196. { return __detail::__ellint_2<float>(__k, __phi); }
  1197. inline long double
  1198. ellint_2l(long double __k, long double __phi)
  1199. { return __detail::__ellint_2<long double>(__k, __phi); }
  1200. /// 5.2.1.13 Incomplete elliptic integrals of the second kind.
  1201. template<typename _Tp, typename _Tpp>
  1202. inline typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type
  1203. ellint_2(_Tp __k, _Tpp __phi)
  1204. {
  1205. typedef typename __gnu_cxx::__promote_2<_Tp, _Tpp>::__type __type;
  1206. return __detail::__ellint_2<__type>(__k, __phi);
  1207. }
  1208. inline float
  1209. ellint_3f(float __k, float __nu, float __phi)
  1210. { return __detail::__ellint_3<float>(__k, __nu, __phi); }
  1211. inline long double
  1212. ellint_3l(long double __k, long double __nu, long double __phi)
  1213. { return __detail::__ellint_3<long double>(__k, __nu, __phi); }
  1214. /// 5.2.1.14 Incomplete elliptic integrals of the third kind.
  1215. template<typename _Tp, typename _Tpn, typename _Tpp>
  1216. inline typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type
  1217. ellint_3(_Tp __k, _Tpn __nu, _Tpp __phi)
  1218. {
  1219. typedef typename __gnu_cxx::__promote_3<_Tp, _Tpn, _Tpp>::__type __type;
  1220. return __detail::__ellint_3<__type>(__k, __nu, __phi);
  1221. }
  1222. inline float
  1223. expintf(float __x)
  1224. { return __detail::__expint<float>(__x); }
  1225. inline long double
  1226. expintl(long double __x)
  1227. { return __detail::__expint<long double>(__x); }
  1228. /// 5.2.1.15 Exponential integrals.
  1229. template<typename _Tp>
  1230. inline typename __gnu_cxx::__promote<_Tp>::__type
  1231. expint(_Tp __x)
  1232. {
  1233. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1234. return __detail::__expint<__type>(__x);
  1235. }
  1236. inline float
  1237. hermitef(unsigned int __n, float __x)
  1238. { return __detail::__poly_hermite<float>(__n, __x); }
  1239. inline long double
  1240. hermitel(unsigned int __n, long double __x)
  1241. { return __detail::__poly_hermite<long double>(__n, __x); }
  1242. /// 5.2.1.16 Hermite polynomials.
  1243. template<typename _Tp>
  1244. inline typename __gnu_cxx::__promote<_Tp>::__type
  1245. hermite(unsigned int __n, _Tp __x)
  1246. {
  1247. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1248. return __detail::__poly_hermite<__type>(__n, __x);
  1249. }
  1250. inline float
  1251. laguerref(unsigned int __n, float __x)
  1252. { return __detail::__laguerre<float>(__n, __x); }
  1253. inline long double
  1254. laguerrel(unsigned int __n, long double __x)
  1255. { return __detail::__laguerre<long double>(__n, __x); }
  1256. /// 5.2.1.18 Laguerre polynomials.
  1257. template<typename _Tp>
  1258. inline typename __gnu_cxx::__promote<_Tp>::__type
  1259. laguerre(unsigned int __n, _Tp __x)
  1260. {
  1261. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1262. return __detail::__laguerre<__type>(__n, __x);
  1263. }
  1264. inline float
  1265. legendref(unsigned int __n, float __x)
  1266. { return __detail::__poly_legendre_p<float>(__n, __x); }
  1267. inline long double
  1268. legendrel(unsigned int __n, long double __x)
  1269. { return __detail::__poly_legendre_p<long double>(__n, __x); }
  1270. /// 5.2.1.19 Legendre polynomials.
  1271. template<typename _Tp>
  1272. inline typename __gnu_cxx::__promote<_Tp>::__type
  1273. legendre(unsigned int __n, _Tp __x)
  1274. {
  1275. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1276. return __detail::__poly_legendre_p<__type>(__n, __x);
  1277. }
  1278. inline float
  1279. riemann_zetaf(float __x)
  1280. { return __detail::__riemann_zeta<float>(__x); }
  1281. inline long double
  1282. riemann_zetal(long double __x)
  1283. { return __detail::__riemann_zeta<long double>(__x); }
  1284. /// 5.2.1.20 Riemann zeta function.
  1285. template<typename _Tp>
  1286. inline typename __gnu_cxx::__promote<_Tp>::__type
  1287. riemann_zeta(_Tp __x)
  1288. {
  1289. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1290. return __detail::__riemann_zeta<__type>(__x);
  1291. }
  1292. inline float
  1293. sph_besself(unsigned int __n, float __x)
  1294. { return __detail::__sph_bessel<float>(__n, __x); }
  1295. inline long double
  1296. sph_bessell(unsigned int __n, long double __x)
  1297. { return __detail::__sph_bessel<long double>(__n, __x); }
  1298. /// 5.2.1.21 Spherical Bessel functions.
  1299. template<typename _Tp>
  1300. inline typename __gnu_cxx::__promote<_Tp>::__type
  1301. sph_bessel(unsigned int __n, _Tp __x)
  1302. {
  1303. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1304. return __detail::__sph_bessel<__type>(__n, __x);
  1305. }
  1306. inline float
  1307. sph_legendref(unsigned int __l, unsigned int __m, float __theta)
  1308. { return __detail::__sph_legendre<float>(__l, __m, __theta); }
  1309. inline long double
  1310. sph_legendrel(unsigned int __l, unsigned int __m, long double __theta)
  1311. { return __detail::__sph_legendre<long double>(__l, __m, __theta); }
  1312. /// 5.2.1.22 Spherical associated Legendre functions.
  1313. template<typename _Tp>
  1314. inline typename __gnu_cxx::__promote<_Tp>::__type
  1315. sph_legendre(unsigned int __l, unsigned int __m, _Tp __theta)
  1316. {
  1317. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1318. return __detail::__sph_legendre<__type>(__l, __m, __theta);
  1319. }
  1320. inline float
  1321. sph_neumannf(unsigned int __n, float __x)
  1322. { return __detail::__sph_neumann<float>(__n, __x); }
  1323. inline long double
  1324. sph_neumannl(unsigned int __n, long double __x)
  1325. { return __detail::__sph_neumann<long double>(__n, __x); }
  1326. /// 5.2.1.23 Spherical Neumann functions.
  1327. template<typename _Tp>
  1328. inline typename __gnu_cxx::__promote<_Tp>::__type
  1329. sph_neumann(unsigned int __n, _Tp __x)
  1330. {
  1331. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1332. return __detail::__sph_neumann<__type>(__n, __x);
  1333. }
  1334. /* @} */ // tr1_math_spec_func
  1335. #endif // _GLIBCXX_USE_STD_SPEC_FUNCS
  1336. } // namespace tr1
  1337. _GLIBCXX_END_NAMESPACE_VERSION
  1338. } // namespace std
  1339. #if _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
  1340. namespace std _GLIBCXX_VISIBILITY(default)
  1341. {
  1342. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  1343. namespace tr1
  1344. {
  1345. using __gnu_cxx::conf_hypergf;
  1346. using __gnu_cxx::conf_hypergl;
  1347. using __gnu_cxx::conf_hyperg;
  1348. using __gnu_cxx::hypergf;
  1349. using __gnu_cxx::hypergl;
  1350. using __gnu_cxx::hyperg;
  1351. } // namespace tr1
  1352. _GLIBCXX_END_NAMESPACE_VERSION
  1353. } // namespace std
  1354. #else // ! (_GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__))
  1355. #include <bits/stl_algobase.h>
  1356. #include <limits>
  1357. #include <tr1/type_traits>
  1358. #include <tr1/hypergeometric.tcc>
  1359. namespace std _GLIBCXX_VISIBILITY(default)
  1360. {
  1361. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  1362. namespace tr1
  1363. {
  1364. inline float
  1365. conf_hypergf(float __a, float __c, float __x)
  1366. { return __detail::__conf_hyperg<float>(__a, __c, __x); }
  1367. inline long double
  1368. conf_hypergl(long double __a, long double __c, long double __x)
  1369. { return __detail::__conf_hyperg<long double>(__a, __c, __x); }
  1370. /// 5.2.1.7 Confluent hypergeometric functions.
  1371. template<typename _Tpa, typename _Tpc, typename _Tp>
  1372. inline typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type
  1373. conf_hyperg(_Tpa __a, _Tpc __c, _Tp __x)
  1374. {
  1375. typedef typename __gnu_cxx::__promote_3<_Tpa, _Tpc, _Tp>::__type __type;
  1376. return __detail::__conf_hyperg<__type>(__a, __c, __x);
  1377. }
  1378. inline float
  1379. hypergf(float __a, float __b, float __c, float __x)
  1380. { return __detail::__hyperg<float>(__a, __b, __c, __x); }
  1381. inline long double
  1382. hypergl(long double __a, long double __b, long double __c, long double __x)
  1383. { return __detail::__hyperg<long double>(__a, __b, __c, __x); }
  1384. /// 5.2.1.17 Hypergeometric functions.
  1385. template<typename _Tpa, typename _Tpb, typename _Tpc, typename _Tp>
  1386. inline typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type
  1387. hyperg(_Tpa __a, _Tpb __b, _Tpc __c, _Tp __x)
  1388. {
  1389. typedef typename __gnu_cxx::__promote_4<_Tpa, _Tpb, _Tpc, _Tp>::__type __type;
  1390. return __detail::__hyperg<__type>(__a, __b, __c, __x);
  1391. }
  1392. } // namespace tr1
  1393. _GLIBCXX_END_NAMESPACE_VERSION
  1394. } // namespace std
  1395. #endif // _GLIBCXX_USE_STD_SPEC_FUNCS && !defined(__STRICT_ANSI__)
  1396. #endif // _GLIBCXX_TR1_CMATH