cmath 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779
  1. // -*- C++ -*- C forwarding header.
  2. // Copyright (C) 1997-2015 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 include/cmath
  21. * This is a Standard C++ Library file. You should @c \#include this file
  22. * in your programs, rather than any of the @a *.h implementation files.
  23. *
  24. * This is the C++ version of the Standard C Library header @c math.h,
  25. * and its contents are (mostly) the same as that header, but are all
  26. * contained in the namespace @c std (except for names which are defined
  27. * as macros in C).
  28. */
  29. //
  30. // ISO C++ 14882: 26.5 C library
  31. //
  32. #pragma GCC system_header
  33. #include <bits/c++config.h>
  34. #include <bits/cpp_type_traits.h>
  35. #include <ext/type_traits.h>
  36. #include <math.h>
  37. #ifndef _GLIBCXX_CMATH
  38. #define _GLIBCXX_CMATH 1
  39. // Get rid of those macros defined in <math.h> in lieu of real functions.
  40. #undef abs
  41. #undef div
  42. #undef acos
  43. #undef asin
  44. #undef atan
  45. #undef atan2
  46. #undef ceil
  47. #undef cos
  48. #undef cosh
  49. #undef exp
  50. #undef fabs
  51. #undef floor
  52. #undef fmod
  53. #undef frexp
  54. #undef ldexp
  55. #undef log
  56. #undef log10
  57. #undef modf
  58. #undef pow
  59. #undef sin
  60. #undef sinh
  61. #undef sqrt
  62. #undef tan
  63. #undef tanh
  64. namespace std _GLIBCXX_VISIBILITY(default)
  65. {
  66. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  67. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  68. inline _GLIBCXX_CONSTEXPR double
  69. abs(double __x)
  70. { return __builtin_fabs(__x); }
  71. #endif
  72. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  73. inline _GLIBCXX_CONSTEXPR float
  74. abs(float __x)
  75. { return __builtin_fabsf(__x); }
  76. inline _GLIBCXX_CONSTEXPR long double
  77. abs(long double __x)
  78. { return __builtin_fabsl(__x); }
  79. #endif
  80. template<typename _Tp>
  81. inline _GLIBCXX_CONSTEXPR
  82. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  83. double>::__type
  84. abs(_Tp __x)
  85. { return __builtin_fabs(__x); }
  86. using ::acos;
  87. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  88. inline _GLIBCXX_CONSTEXPR float
  89. acos(float __x)
  90. { return __builtin_acosf(__x); }
  91. inline _GLIBCXX_CONSTEXPR long double
  92. acos(long double __x)
  93. { return __builtin_acosl(__x); }
  94. #endif
  95. template<typename _Tp>
  96. inline _GLIBCXX_CONSTEXPR
  97. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  98. double>::__type
  99. acos(_Tp __x)
  100. { return __builtin_acos(__x); }
  101. using ::asin;
  102. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  103. inline _GLIBCXX_CONSTEXPR float
  104. asin(float __x)
  105. { return __builtin_asinf(__x); }
  106. inline _GLIBCXX_CONSTEXPR long double
  107. asin(long double __x)
  108. { return __builtin_asinl(__x); }
  109. #endif
  110. template<typename _Tp>
  111. inline _GLIBCXX_CONSTEXPR
  112. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  113. double>::__type
  114. asin(_Tp __x)
  115. { return __builtin_asin(__x); }
  116. using ::atan;
  117. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  118. inline _GLIBCXX_CONSTEXPR float
  119. atan(float __x)
  120. { return __builtin_atanf(__x); }
  121. inline _GLIBCXX_CONSTEXPR long double
  122. atan(long double __x)
  123. { return __builtin_atanl(__x); }
  124. #endif
  125. template<typename _Tp>
  126. inline _GLIBCXX_CONSTEXPR
  127. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  128. double>::__type
  129. atan(_Tp __x)
  130. { return __builtin_atan(__x); }
  131. using ::atan2;
  132. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  133. inline _GLIBCXX_CONSTEXPR float
  134. atan2(float __y, float __x)
  135. { return __builtin_atan2f(__y, __x); }
  136. inline _GLIBCXX_CONSTEXPR long double
  137. atan2(long double __y, long double __x)
  138. { return __builtin_atan2l(__y, __x); }
  139. #endif
  140. template<typename _Tp, typename _Up>
  141. inline _GLIBCXX_CONSTEXPR
  142. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  143. atan2(_Tp __y, _Up __x)
  144. {
  145. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  146. return atan2(__type(__y), __type(__x));
  147. }
  148. using ::ceil;
  149. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  150. inline _GLIBCXX_CONSTEXPR float
  151. ceil(float __x)
  152. { return __builtin_ceilf(__x); }
  153. inline _GLIBCXX_CONSTEXPR long double
  154. ceil(long double __x)
  155. { return __builtin_ceill(__x); }
  156. #endif
  157. template<typename _Tp>
  158. inline _GLIBCXX_CONSTEXPR
  159. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  160. double>::__type
  161. ceil(_Tp __x)
  162. { return __builtin_ceil(__x); }
  163. using ::cos;
  164. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  165. inline _GLIBCXX_CONSTEXPR float
  166. cos(float __x)
  167. { return __builtin_cosf(__x); }
  168. inline _GLIBCXX_CONSTEXPR long double
  169. cos(long double __x)
  170. { return __builtin_cosl(__x); }
  171. #endif
  172. template<typename _Tp>
  173. inline _GLIBCXX_CONSTEXPR
  174. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  175. double>::__type
  176. cos(_Tp __x)
  177. { return __builtin_cos(__x); }
  178. using ::cosh;
  179. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  180. inline _GLIBCXX_CONSTEXPR float
  181. cosh(float __x)
  182. { return __builtin_coshf(__x); }
  183. inline _GLIBCXX_CONSTEXPR long double
  184. cosh(long double __x)
  185. { return __builtin_coshl(__x); }
  186. #endif
  187. template<typename _Tp>
  188. inline _GLIBCXX_CONSTEXPR
  189. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  190. double>::__type
  191. cosh(_Tp __x)
  192. { return __builtin_cosh(__x); }
  193. using ::exp;
  194. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  195. inline _GLIBCXX_CONSTEXPR float
  196. exp(float __x)
  197. { return __builtin_expf(__x); }
  198. inline _GLIBCXX_CONSTEXPR long double
  199. exp(long double __x)
  200. { return __builtin_expl(__x); }
  201. #endif
  202. template<typename _Tp>
  203. inline _GLIBCXX_CONSTEXPR
  204. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  205. double>::__type
  206. exp(_Tp __x)
  207. { return __builtin_exp(__x); }
  208. using ::fabs;
  209. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  210. inline _GLIBCXX_CONSTEXPR float
  211. fabs(float __x)
  212. { return __builtin_fabsf(__x); }
  213. inline _GLIBCXX_CONSTEXPR long double
  214. fabs(long double __x)
  215. { return __builtin_fabsl(__x); }
  216. #endif
  217. template<typename _Tp>
  218. inline _GLIBCXX_CONSTEXPR
  219. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  220. double>::__type
  221. fabs(_Tp __x)
  222. { return __builtin_fabs(__x); }
  223. using ::floor;
  224. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  225. inline _GLIBCXX_CONSTEXPR float
  226. floor(float __x)
  227. { return __builtin_floorf(__x); }
  228. inline _GLIBCXX_CONSTEXPR long double
  229. floor(long double __x)
  230. { return __builtin_floorl(__x); }
  231. #endif
  232. template<typename _Tp>
  233. inline _GLIBCXX_CONSTEXPR
  234. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  235. double>::__type
  236. floor(_Tp __x)
  237. { return __builtin_floor(__x); }
  238. using ::fmod;
  239. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  240. inline _GLIBCXX_CONSTEXPR float
  241. fmod(float __x, float __y)
  242. { return __builtin_fmodf(__x, __y); }
  243. inline _GLIBCXX_CONSTEXPR long double
  244. fmod(long double __x, long double __y)
  245. { return __builtin_fmodl(__x, __y); }
  246. #endif
  247. template<typename _Tp, typename _Up>
  248. inline _GLIBCXX_CONSTEXPR
  249. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  250. fmod(_Tp __x, _Up __y)
  251. {
  252. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  253. return fmod(__type(__x), __type(__y));
  254. }
  255. using ::frexp;
  256. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  257. inline float
  258. frexp(float __x, int* __exp)
  259. { return __builtin_frexpf(__x, __exp); }
  260. inline long double
  261. frexp(long double __x, int* __exp)
  262. { return __builtin_frexpl(__x, __exp); }
  263. #endif
  264. template<typename _Tp>
  265. inline _GLIBCXX_CONSTEXPR
  266. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  267. double>::__type
  268. frexp(_Tp __x, int* __exp)
  269. { return __builtin_frexp(__x, __exp); }
  270. using ::ldexp;
  271. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  272. inline _GLIBCXX_CONSTEXPR float
  273. ldexp(float __x, int __exp)
  274. { return __builtin_ldexpf(__x, __exp); }
  275. inline _GLIBCXX_CONSTEXPR long double
  276. ldexp(long double __x, int __exp)
  277. { return __builtin_ldexpl(__x, __exp); }
  278. #endif
  279. template<typename _Tp>
  280. inline _GLIBCXX_CONSTEXPR
  281. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  282. double>::__type
  283. ldexp(_Tp __x, int __exp)
  284. { return __builtin_ldexp(__x, __exp); }
  285. using ::log;
  286. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  287. inline _GLIBCXX_CONSTEXPR float
  288. log(float __x)
  289. { return __builtin_logf(__x); }
  290. inline _GLIBCXX_CONSTEXPR long double
  291. log(long double __x)
  292. { return __builtin_logl(__x); }
  293. #endif
  294. template<typename _Tp>
  295. inline _GLIBCXX_CONSTEXPR
  296. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  297. double>::__type
  298. log(_Tp __x)
  299. { return __builtin_log(__x); }
  300. using ::log10;
  301. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  302. inline _GLIBCXX_CONSTEXPR float
  303. log10(float __x)
  304. { return __builtin_log10f(__x); }
  305. inline _GLIBCXX_CONSTEXPR long double
  306. log10(long double __x)
  307. { return __builtin_log10l(__x); }
  308. #endif
  309. template<typename _Tp>
  310. inline _GLIBCXX_CONSTEXPR
  311. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  312. double>::__type
  313. log10(_Tp __x)
  314. { return __builtin_log10(__x); }
  315. using ::modf;
  316. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  317. inline float
  318. modf(float __x, float* __iptr)
  319. { return __builtin_modff(__x, __iptr); }
  320. inline long double
  321. modf(long double __x, long double* __iptr)
  322. { return __builtin_modfl(__x, __iptr); }
  323. #endif
  324. using ::pow;
  325. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  326. inline _GLIBCXX_CONSTEXPR float
  327. pow(float __x, float __y)
  328. { return __builtin_powf(__x, __y); }
  329. inline _GLIBCXX_CONSTEXPR long double
  330. pow(long double __x, long double __y)
  331. { return __builtin_powl(__x, __y); }
  332. #if __cplusplus < 201103L
  333. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  334. // DR 550. What should the return type of pow(float,int) be?
  335. inline double
  336. pow(double __x, int __i)
  337. { return __builtin_powi(__x, __i); }
  338. inline float
  339. pow(float __x, int __n)
  340. { return __builtin_powif(__x, __n); }
  341. inline long double
  342. pow(long double __x, int __n)
  343. { return __builtin_powil(__x, __n); }
  344. #endif
  345. #endif
  346. template<typename _Tp, typename _Up>
  347. inline _GLIBCXX_CONSTEXPR
  348. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  349. pow(_Tp __x, _Up __y)
  350. {
  351. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  352. return pow(__type(__x), __type(__y));
  353. }
  354. using ::sin;
  355. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  356. inline _GLIBCXX_CONSTEXPR float
  357. sin(float __x)
  358. { return __builtin_sinf(__x); }
  359. inline _GLIBCXX_CONSTEXPR long double
  360. sin(long double __x)
  361. { return __builtin_sinl(__x); }
  362. #endif
  363. template<typename _Tp>
  364. inline _GLIBCXX_CONSTEXPR
  365. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  366. double>::__type
  367. sin(_Tp __x)
  368. { return __builtin_sin(__x); }
  369. using ::sinh;
  370. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  371. inline _GLIBCXX_CONSTEXPR float
  372. sinh(float __x)
  373. { return __builtin_sinhf(__x); }
  374. inline _GLIBCXX_CONSTEXPR long double
  375. sinh(long double __x)
  376. { return __builtin_sinhl(__x); }
  377. #endif
  378. template<typename _Tp>
  379. inline _GLIBCXX_CONSTEXPR
  380. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  381. double>::__type
  382. sinh(_Tp __x)
  383. { return __builtin_sinh(__x); }
  384. using ::sqrt;
  385. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  386. inline _GLIBCXX_CONSTEXPR float
  387. sqrt(float __x)
  388. { return __builtin_sqrtf(__x); }
  389. inline _GLIBCXX_CONSTEXPR long double
  390. sqrt(long double __x)
  391. { return __builtin_sqrtl(__x); }
  392. #endif
  393. template<typename _Tp>
  394. inline _GLIBCXX_CONSTEXPR
  395. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  396. double>::__type
  397. sqrt(_Tp __x)
  398. { return __builtin_sqrt(__x); }
  399. using ::tan;
  400. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  401. inline _GLIBCXX_CONSTEXPR float
  402. tan(float __x)
  403. { return __builtin_tanf(__x); }
  404. inline _GLIBCXX_CONSTEXPR long double
  405. tan(long double __x)
  406. { return __builtin_tanl(__x); }
  407. #endif
  408. template<typename _Tp>
  409. inline _GLIBCXX_CONSTEXPR
  410. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  411. double>::__type
  412. tan(_Tp __x)
  413. { return __builtin_tan(__x); }
  414. using ::tanh;
  415. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  416. inline _GLIBCXX_CONSTEXPR float
  417. tanh(float __x)
  418. { return __builtin_tanhf(__x); }
  419. inline _GLIBCXX_CONSTEXPR long double
  420. tanh(long double __x)
  421. { return __builtin_tanhl(__x); }
  422. #endif
  423. template<typename _Tp>
  424. inline _GLIBCXX_CONSTEXPR
  425. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  426. double>::__type
  427. tanh(_Tp __x)
  428. { return __builtin_tanh(__x); }
  429. _GLIBCXX_END_NAMESPACE_VERSION
  430. } // namespace
  431. #if _GLIBCXX_USE_C99_MATH
  432. #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  433. // These are possible macros imported from C99-land.
  434. #undef fpclassify
  435. #undef isfinite
  436. #undef isinf
  437. #undef isnan
  438. #undef isnormal
  439. #undef signbit
  440. #undef isgreater
  441. #undef isgreaterequal
  442. #undef isless
  443. #undef islessequal
  444. #undef islessgreater
  445. #undef isunordered
  446. namespace std _GLIBCXX_VISIBILITY(default)
  447. {
  448. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  449. #if __cplusplus >= 201103L
  450. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  451. constexpr int
  452. fpclassify(float __x)
  453. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  454. FP_SUBNORMAL, FP_ZERO, __x); }
  455. constexpr int
  456. fpclassify(double __x)
  457. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  458. FP_SUBNORMAL, FP_ZERO, __x); }
  459. constexpr int
  460. fpclassify(long double __x)
  461. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  462. FP_SUBNORMAL, FP_ZERO, __x); }
  463. #endif
  464. template<typename _Tp>
  465. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  466. int>::__type
  467. fpclassify(_Tp __x)
  468. { return __x != 0 ? FP_NORMAL : FP_ZERO; }
  469. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  470. constexpr bool
  471. isfinite(float __x)
  472. { return __builtin_isfinite(__x); }
  473. constexpr bool
  474. isfinite(double __x)
  475. { return __builtin_isfinite(__x); }
  476. constexpr bool
  477. isfinite(long double __x)
  478. { return __builtin_isfinite(__x); }
  479. #endif
  480. template<typename _Tp>
  481. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  482. bool>::__type
  483. isfinite(_Tp __x)
  484. { return true; }
  485. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  486. constexpr bool
  487. isinf(float __x)
  488. { return __builtin_isinf(__x); }
  489. constexpr bool
  490. isinf(double __x)
  491. { return __builtin_isinf(__x); }
  492. constexpr bool
  493. isinf(long double __x)
  494. { return __builtin_isinf(__x); }
  495. #endif
  496. template<typename _Tp>
  497. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  498. bool>::__type
  499. isinf(_Tp __x)
  500. { return false; }
  501. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  502. constexpr bool
  503. isnan(float __x)
  504. { return __builtin_isnan(__x); }
  505. constexpr bool
  506. isnan(double __x)
  507. { return __builtin_isnan(__x); }
  508. constexpr bool
  509. isnan(long double __x)
  510. { return __builtin_isnan(__x); }
  511. #endif
  512. template<typename _Tp>
  513. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  514. bool>::__type
  515. isnan(_Tp __x)
  516. { return false; }
  517. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  518. constexpr bool
  519. isnormal(float __x)
  520. { return __builtin_isnormal(__x); }
  521. constexpr bool
  522. isnormal(double __x)
  523. { return __builtin_isnormal(__x); }
  524. constexpr bool
  525. isnormal(long double __x)
  526. { return __builtin_isnormal(__x); }
  527. #endif
  528. template<typename _Tp>
  529. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  530. bool>::__type
  531. isnormal(_Tp __x)
  532. { return __x != 0 ? true : false; }
  533. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  534. // The front-end doesn't provide a type generic builtin (libstdc++/58625).
  535. constexpr bool
  536. signbit(float __x)
  537. { return __builtin_signbitf(__x); }
  538. constexpr bool
  539. signbit(double __x)
  540. { return __builtin_signbit(__x); }
  541. constexpr bool
  542. signbit(long double __x)
  543. { return __builtin_signbitl(__x); }
  544. #endif
  545. template<typename _Tp>
  546. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  547. bool>::__type
  548. signbit(_Tp __x)
  549. { return __x < 0 ? true : false; }
  550. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  551. constexpr bool
  552. isgreater(float __x, float __y)
  553. { return __builtin_isgreater(__x, __y); }
  554. constexpr bool
  555. isgreater(double __x, double __y)
  556. { return __builtin_isgreater(__x, __y); }
  557. constexpr bool
  558. isgreater(long double __x, long double __y)
  559. { return __builtin_isgreater(__x, __y); }
  560. #endif
  561. template<typename _Tp, typename _Up>
  562. constexpr typename
  563. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  564. && __is_arithmetic<_Up>::__value), bool>::__type
  565. isgreater(_Tp __x, _Up __y)
  566. {
  567. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  568. return __builtin_isgreater(__type(__x), __type(__y));
  569. }
  570. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  571. constexpr bool
  572. isgreaterequal(float __x, float __y)
  573. { return __builtin_isgreaterequal(__x, __y); }
  574. constexpr bool
  575. isgreaterequal(double __x, double __y)
  576. { return __builtin_isgreaterequal(__x, __y); }
  577. constexpr bool
  578. isgreaterequal(long double __x, long double __y)
  579. { return __builtin_isgreaterequal(__x, __y); }
  580. #endif
  581. template<typename _Tp, typename _Up>
  582. constexpr typename
  583. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  584. && __is_arithmetic<_Up>::__value), bool>::__type
  585. isgreaterequal(_Tp __x, _Up __y)
  586. {
  587. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  588. return __builtin_isgreaterequal(__type(__x), __type(__y));
  589. }
  590. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  591. constexpr bool
  592. isless(float __x, float __y)
  593. { return __builtin_isless(__x, __y); }
  594. constexpr bool
  595. isless(double __x, double __y)
  596. { return __builtin_isless(__x, __y); }
  597. constexpr bool
  598. isless(long double __x, long double __y)
  599. { return __builtin_isless(__x, __y); }
  600. #endif
  601. template<typename _Tp, typename _Up>
  602. constexpr typename
  603. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  604. && __is_arithmetic<_Up>::__value), bool>::__type
  605. isless(_Tp __x, _Up __y)
  606. {
  607. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  608. return __builtin_isless(__type(__x), __type(__y));
  609. }
  610. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  611. constexpr bool
  612. islessequal(float __x, float __y)
  613. { return __builtin_islessequal(__x, __y); }
  614. constexpr bool
  615. islessequal(double __x, double __y)
  616. { return __builtin_islessequal(__x, __y); }
  617. constexpr bool
  618. islessequal(long double __x, long double __y)
  619. { return __builtin_islessequal(__x, __y); }
  620. #endif
  621. template<typename _Tp, typename _Up>
  622. constexpr typename
  623. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  624. && __is_arithmetic<_Up>::__value), bool>::__type
  625. islessequal(_Tp __x, _Up __y)
  626. {
  627. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  628. return __builtin_islessequal(__type(__x), __type(__y));
  629. }
  630. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  631. constexpr bool
  632. islessgreater(float __x, float __y)
  633. { return __builtin_islessgreater(__x, __y); }
  634. constexpr bool
  635. islessgreater(double __x, double __y)
  636. { return __builtin_islessgreater(__x, __y); }
  637. constexpr bool
  638. islessgreater(long double __x, long double __y)
  639. { return __builtin_islessgreater(__x, __y); }
  640. #endif
  641. template<typename _Tp, typename _Up>
  642. constexpr typename
  643. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  644. && __is_arithmetic<_Up>::__value), bool>::__type
  645. islessgreater(_Tp __x, _Up __y)
  646. {
  647. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  648. return __builtin_islessgreater(__type(__x), __type(__y));
  649. }
  650. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  651. constexpr bool
  652. isunordered(float __x, float __y)
  653. { return __builtin_isunordered(__x, __y); }
  654. constexpr bool
  655. isunordered(double __x, double __y)
  656. { return __builtin_isunordered(__x, __y); }
  657. constexpr bool
  658. isunordered(long double __x, long double __y)
  659. { return __builtin_isunordered(__x, __y); }
  660. #endif
  661. template<typename _Tp, typename _Up>
  662. constexpr typename
  663. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  664. && __is_arithmetic<_Up>::__value), bool>::__type
  665. isunordered(_Tp __x, _Up __y)
  666. {
  667. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  668. return __builtin_isunordered(__type(__x), __type(__y));
  669. }
  670. #else
  671. template<typename _Tp>
  672. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  673. int>::__type
  674. fpclassify(_Tp __f)
  675. {
  676. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  677. return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  678. FP_SUBNORMAL, FP_ZERO, __type(__f));
  679. }
  680. template<typename _Tp>
  681. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  682. int>::__type
  683. isfinite(_Tp __f)
  684. {
  685. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  686. return __builtin_isfinite(__type(__f));
  687. }
  688. template<typename _Tp>
  689. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  690. int>::__type
  691. isinf(_Tp __f)
  692. {
  693. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  694. return __builtin_isinf(__type(__f));
  695. }
  696. template<typename _Tp>
  697. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  698. int>::__type
  699. isnan(_Tp __f)
  700. {
  701. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  702. return __builtin_isnan(__type(__f));
  703. }
  704. template<typename _Tp>
  705. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  706. int>::__type
  707. isnormal(_Tp __f)
  708. {
  709. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  710. return __builtin_isnormal(__type(__f));
  711. }
  712. template<typename _Tp>
  713. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  714. int>::__type
  715. signbit(_Tp __f)
  716. {
  717. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  718. return __builtin_signbit(__type(__f));
  719. }
  720. template<typename _Tp>
  721. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  722. int>::__type
  723. isgreater(_Tp __f1, _Tp __f2)
  724. {
  725. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  726. return __builtin_isgreater(__type(__f1), __type(__f2));
  727. }
  728. template<typename _Tp>
  729. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  730. int>::__type
  731. isgreaterequal(_Tp __f1, _Tp __f2)
  732. {
  733. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  734. return __builtin_isgreaterequal(__type(__f1), __type(__f2));
  735. }
  736. template<typename _Tp>
  737. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  738. int>::__type
  739. isless(_Tp __f1, _Tp __f2)
  740. {
  741. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  742. return __builtin_isless(__type(__f1), __type(__f2));
  743. }
  744. template<typename _Tp>
  745. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  746. int>::__type
  747. islessequal(_Tp __f1, _Tp __f2)
  748. {
  749. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  750. return __builtin_islessequal(__type(__f1), __type(__f2));
  751. }
  752. template<typename _Tp>
  753. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  754. int>::__type
  755. islessgreater(_Tp __f1, _Tp __f2)
  756. {
  757. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  758. return __builtin_islessgreater(__type(__f1), __type(__f2));
  759. }
  760. template<typename _Tp>
  761. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  762. int>::__type
  763. isunordered(_Tp __f1, _Tp __f2)
  764. {
  765. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  766. return __builtin_isunordered(__type(__f1), __type(__f2));
  767. }
  768. #endif
  769. _GLIBCXX_END_NAMESPACE_VERSION
  770. } // namespace
  771. #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
  772. #endif
  773. #if __cplusplus >= 201103L
  774. #ifdef _GLIBCXX_USE_C99_MATH_TR1
  775. #undef acosh
  776. #undef acoshf
  777. #undef acoshl
  778. #undef asinh
  779. #undef asinhf
  780. #undef asinhl
  781. #undef atanh
  782. #undef atanhf
  783. #undef atanhl
  784. #undef cbrt
  785. #undef cbrtf
  786. #undef cbrtl
  787. #undef copysign
  788. #undef copysignf
  789. #undef copysignl
  790. #undef erf
  791. #undef erff
  792. #undef erfl
  793. #undef erfc
  794. #undef erfcf
  795. #undef erfcl
  796. #undef exp2
  797. #undef exp2f
  798. #undef exp2l
  799. #undef expm1
  800. #undef expm1f
  801. #undef expm1l
  802. #undef fdim
  803. #undef fdimf
  804. #undef fdiml
  805. #undef fma
  806. #undef fmaf
  807. #undef fmal
  808. #undef fmax
  809. #undef fmaxf
  810. #undef fmaxl
  811. #undef fmin
  812. #undef fminf
  813. #undef fminl
  814. #undef hypot
  815. #undef hypotf
  816. #undef hypotl
  817. #undef ilogb
  818. #undef ilogbf
  819. #undef ilogbl
  820. #undef lgamma
  821. #undef lgammaf
  822. #undef lgammal
  823. #undef llrint
  824. #undef llrintf
  825. #undef llrintl
  826. #undef llround
  827. #undef llroundf
  828. #undef llroundl
  829. #undef log1p
  830. #undef log1pf
  831. #undef log1pl
  832. #undef log2
  833. #undef log2f
  834. #undef log2l
  835. #undef logb
  836. #undef logbf
  837. #undef logbl
  838. #undef lrint
  839. #undef lrintf
  840. #undef lrintl
  841. #undef lround
  842. #undef lroundf
  843. #undef lroundl
  844. #undef nan
  845. #undef nanf
  846. #undef nanl
  847. #undef nearbyint
  848. #undef nearbyintf
  849. #undef nearbyintl
  850. #undef nextafter
  851. #undef nextafterf
  852. #undef nextafterl
  853. #undef nexttoward
  854. #undef nexttowardf
  855. #undef nexttowardl
  856. #undef remainder
  857. #undef remainderf
  858. #undef remainderl
  859. #undef remquo
  860. #undef remquof
  861. #undef remquol
  862. #undef rint
  863. #undef rintf
  864. #undef rintl
  865. #undef round
  866. #undef roundf
  867. #undef roundl
  868. #undef scalbln
  869. #undef scalblnf
  870. #undef scalblnl
  871. #undef scalbn
  872. #undef scalbnf
  873. #undef scalbnl
  874. #undef tgamma
  875. #undef tgammaf
  876. #undef tgammal
  877. #undef trunc
  878. #undef truncf
  879. #undef truncl
  880. namespace std _GLIBCXX_VISIBILITY(default)
  881. {
  882. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  883. // types
  884. using ::double_t;
  885. using ::float_t;
  886. // functions
  887. using ::acosh;
  888. using ::acoshf;
  889. using ::acoshl;
  890. using ::asinh;
  891. using ::asinhf;
  892. using ::asinhl;
  893. using ::atanh;
  894. using ::atanhf;
  895. using ::atanhl;
  896. using ::cbrt;
  897. using ::cbrtf;
  898. using ::cbrtl;
  899. using ::copysign;
  900. using ::copysignf;
  901. using ::copysignl;
  902. using ::erf;
  903. using ::erff;
  904. using ::erfl;
  905. using ::erfc;
  906. using ::erfcf;
  907. using ::erfcl;
  908. using ::exp2;
  909. using ::exp2f;
  910. using ::exp2l;
  911. using ::expm1;
  912. using ::expm1f;
  913. using ::expm1l;
  914. using ::fdim;
  915. using ::fdimf;
  916. using ::fdiml;
  917. using ::fma;
  918. using ::fmaf;
  919. using ::fmal;
  920. using ::fmax;
  921. using ::fmaxf;
  922. using ::fmaxl;
  923. using ::fmin;
  924. using ::fminf;
  925. using ::fminl;
  926. using ::hypot;
  927. using ::hypotf;
  928. using ::hypotl;
  929. using ::ilogb;
  930. using ::ilogbf;
  931. using ::ilogbl;
  932. using ::lgamma;
  933. using ::lgammaf;
  934. using ::lgammal;
  935. using ::llrint;
  936. using ::llrintf;
  937. using ::llrintl;
  938. using ::llround;
  939. using ::llroundf;
  940. using ::llroundl;
  941. using ::log1p;
  942. using ::log1pf;
  943. using ::log1pl;
  944. using ::log2;
  945. using ::log2f;
  946. using ::log2l;
  947. using ::logb;
  948. using ::logbf;
  949. using ::logbl;
  950. using ::lrint;
  951. using ::lrintf;
  952. using ::lrintl;
  953. using ::lround;
  954. using ::lroundf;
  955. using ::lroundl;
  956. using ::nan;
  957. using ::nanf;
  958. using ::nanl;
  959. using ::nearbyint;
  960. using ::nearbyintf;
  961. using ::nearbyintl;
  962. using ::nextafter;
  963. using ::nextafterf;
  964. using ::nextafterl;
  965. using ::nexttoward;
  966. using ::nexttowardf;
  967. using ::nexttowardl;
  968. using ::remainder;
  969. using ::remainderf;
  970. using ::remainderl;
  971. using ::remquo;
  972. using ::remquof;
  973. using ::remquol;
  974. using ::rint;
  975. using ::rintf;
  976. using ::rintl;
  977. using ::round;
  978. using ::roundf;
  979. using ::roundl;
  980. using ::scalbln;
  981. using ::scalblnf;
  982. using ::scalblnl;
  983. using ::scalbn;
  984. using ::scalbnf;
  985. using ::scalbnl;
  986. using ::tgamma;
  987. using ::tgammaf;
  988. using ::tgammal;
  989. using ::trunc;
  990. using ::truncf;
  991. using ::truncl;
  992. /// Additional overloads.
  993. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  994. constexpr float
  995. acosh(float __x)
  996. { return __builtin_acoshf(__x); }
  997. constexpr long double
  998. acosh(long double __x)
  999. { return __builtin_acoshl(__x); }
  1000. #endif
  1001. template<typename _Tp>
  1002. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1003. double>::__type
  1004. acosh(_Tp __x)
  1005. { return __builtin_acosh(__x); }
  1006. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1007. constexpr float
  1008. asinh(float __x)
  1009. { return __builtin_asinhf(__x); }
  1010. constexpr long double
  1011. asinh(long double __x)
  1012. { return __builtin_asinhl(__x); }
  1013. #endif
  1014. template<typename _Tp>
  1015. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1016. double>::__type
  1017. asinh(_Tp __x)
  1018. { return __builtin_asinh(__x); }
  1019. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1020. constexpr float
  1021. atanh(float __x)
  1022. { return __builtin_atanhf(__x); }
  1023. constexpr long double
  1024. atanh(long double __x)
  1025. { return __builtin_atanhl(__x); }
  1026. #endif
  1027. template<typename _Tp>
  1028. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1029. double>::__type
  1030. atanh(_Tp __x)
  1031. { return __builtin_atanh(__x); }
  1032. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1033. constexpr float
  1034. cbrt(float __x)
  1035. { return __builtin_cbrtf(__x); }
  1036. constexpr long double
  1037. cbrt(long double __x)
  1038. { return __builtin_cbrtl(__x); }
  1039. #endif
  1040. template<typename _Tp>
  1041. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1042. double>::__type
  1043. cbrt(_Tp __x)
  1044. { return __builtin_cbrt(__x); }
  1045. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1046. constexpr float
  1047. copysign(float __x, float __y)
  1048. { return __builtin_copysignf(__x, __y); }
  1049. constexpr long double
  1050. copysign(long double __x, long double __y)
  1051. { return __builtin_copysignl(__x, __y); }
  1052. #endif
  1053. template<typename _Tp, typename _Up>
  1054. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1055. copysign(_Tp __x, _Up __y)
  1056. {
  1057. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1058. return copysign(__type(__x), __type(__y));
  1059. }
  1060. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1061. constexpr float
  1062. erf(float __x)
  1063. { return __builtin_erff(__x); }
  1064. constexpr long double
  1065. erf(long double __x)
  1066. { return __builtin_erfl(__x); }
  1067. #endif
  1068. template<typename _Tp>
  1069. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1070. double>::__type
  1071. erf(_Tp __x)
  1072. { return __builtin_erf(__x); }
  1073. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1074. constexpr float
  1075. erfc(float __x)
  1076. { return __builtin_erfcf(__x); }
  1077. constexpr long double
  1078. erfc(long double __x)
  1079. { return __builtin_erfcl(__x); }
  1080. #endif
  1081. template<typename _Tp>
  1082. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1083. double>::__type
  1084. erfc(_Tp __x)
  1085. { return __builtin_erfc(__x); }
  1086. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1087. constexpr float
  1088. exp2(float __x)
  1089. { return __builtin_exp2f(__x); }
  1090. constexpr long double
  1091. exp2(long double __x)
  1092. { return __builtin_exp2l(__x); }
  1093. #endif
  1094. template<typename _Tp>
  1095. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1096. double>::__type
  1097. exp2(_Tp __x)
  1098. { return __builtin_exp2(__x); }
  1099. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1100. constexpr float
  1101. expm1(float __x)
  1102. { return __builtin_expm1f(__x); }
  1103. constexpr long double
  1104. expm1(long double __x)
  1105. { return __builtin_expm1l(__x); }
  1106. #endif
  1107. template<typename _Tp>
  1108. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1109. double>::__type
  1110. expm1(_Tp __x)
  1111. { return __builtin_expm1(__x); }
  1112. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1113. constexpr float
  1114. fdim(float __x, float __y)
  1115. { return __builtin_fdimf(__x, __y); }
  1116. constexpr long double
  1117. fdim(long double __x, long double __y)
  1118. { return __builtin_fdiml(__x, __y); }
  1119. #endif
  1120. template<typename _Tp, typename _Up>
  1121. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1122. fdim(_Tp __x, _Up __y)
  1123. {
  1124. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1125. return fdim(__type(__x), __type(__y));
  1126. }
  1127. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1128. constexpr float
  1129. fma(float __x, float __y, float __z)
  1130. { return __builtin_fmaf(__x, __y, __z); }
  1131. constexpr long double
  1132. fma(long double __x, long double __y, long double __z)
  1133. { return __builtin_fmal(__x, __y, __z); }
  1134. #endif
  1135. template<typename _Tp, typename _Up, typename _Vp>
  1136. constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
  1137. fma(_Tp __x, _Up __y, _Vp __z)
  1138. {
  1139. typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
  1140. return fma(__type(__x), __type(__y), __type(__z));
  1141. }
  1142. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1143. constexpr float
  1144. fmax(float __x, float __y)
  1145. { return __builtin_fmaxf(__x, __y); }
  1146. constexpr long double
  1147. fmax(long double __x, long double __y)
  1148. { return __builtin_fmaxl(__x, __y); }
  1149. #endif
  1150. template<typename _Tp, typename _Up>
  1151. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1152. fmax(_Tp __x, _Up __y)
  1153. {
  1154. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1155. return fmax(__type(__x), __type(__y));
  1156. }
  1157. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1158. constexpr float
  1159. fmin(float __x, float __y)
  1160. { return __builtin_fminf(__x, __y); }
  1161. constexpr long double
  1162. fmin(long double __x, long double __y)
  1163. { return __builtin_fminl(__x, __y); }
  1164. #endif
  1165. template<typename _Tp, typename _Up>
  1166. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1167. fmin(_Tp __x, _Up __y)
  1168. {
  1169. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1170. return fmin(__type(__x), __type(__y));
  1171. }
  1172. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1173. constexpr float
  1174. hypot(float __x, float __y)
  1175. { return __builtin_hypotf(__x, __y); }
  1176. constexpr long double
  1177. hypot(long double __x, long double __y)
  1178. { return __builtin_hypotl(__x, __y); }
  1179. #endif
  1180. template<typename _Tp, typename _Up>
  1181. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1182. hypot(_Tp __x, _Up __y)
  1183. {
  1184. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1185. return hypot(__type(__x), __type(__y));
  1186. }
  1187. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1188. constexpr int
  1189. ilogb(float __x)
  1190. { return __builtin_ilogbf(__x); }
  1191. constexpr int
  1192. ilogb(long double __x)
  1193. { return __builtin_ilogbl(__x); }
  1194. #endif
  1195. template<typename _Tp>
  1196. constexpr
  1197. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1198. int>::__type
  1199. ilogb(_Tp __x)
  1200. { return __builtin_ilogb(__x); }
  1201. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1202. constexpr float
  1203. lgamma(float __x)
  1204. { return __builtin_lgammaf(__x); }
  1205. constexpr long double
  1206. lgamma(long double __x)
  1207. { return __builtin_lgammal(__x); }
  1208. #endif
  1209. template<typename _Tp>
  1210. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1211. double>::__type
  1212. lgamma(_Tp __x)
  1213. { return __builtin_lgamma(__x); }
  1214. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1215. constexpr long long
  1216. llrint(float __x)
  1217. { return __builtin_llrintf(__x); }
  1218. constexpr long long
  1219. llrint(long double __x)
  1220. { return __builtin_llrintl(__x); }
  1221. #endif
  1222. template<typename _Tp>
  1223. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1224. long long>::__type
  1225. llrint(_Tp __x)
  1226. { return __builtin_llrint(__x); }
  1227. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1228. constexpr long long
  1229. llround(float __x)
  1230. { return __builtin_llroundf(__x); }
  1231. constexpr long long
  1232. llround(long double __x)
  1233. { return __builtin_llroundl(__x); }
  1234. #endif
  1235. template<typename _Tp>
  1236. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1237. long long>::__type
  1238. llround(_Tp __x)
  1239. { return __builtin_llround(__x); }
  1240. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1241. constexpr float
  1242. log1p(float __x)
  1243. { return __builtin_log1pf(__x); }
  1244. constexpr long double
  1245. log1p(long double __x)
  1246. { return __builtin_log1pl(__x); }
  1247. #endif
  1248. template<typename _Tp>
  1249. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1250. double>::__type
  1251. log1p(_Tp __x)
  1252. { return __builtin_log1p(__x); }
  1253. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1254. // DR 568.
  1255. constexpr float
  1256. log2(float __x)
  1257. { return __builtin_log2f(__x); }
  1258. constexpr long double
  1259. log2(long double __x)
  1260. { return __builtin_log2l(__x); }
  1261. #endif
  1262. template<typename _Tp>
  1263. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1264. double>::__type
  1265. log2(_Tp __x)
  1266. { return __builtin_log2(__x); }
  1267. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1268. constexpr float
  1269. logb(float __x)
  1270. { return __builtin_logbf(__x); }
  1271. constexpr long double
  1272. logb(long double __x)
  1273. { return __builtin_logbl(__x); }
  1274. #endif
  1275. template<typename _Tp>
  1276. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1277. double>::__type
  1278. logb(_Tp __x)
  1279. { return __builtin_logb(__x); }
  1280. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1281. constexpr long
  1282. lrint(float __x)
  1283. { return __builtin_lrintf(__x); }
  1284. constexpr long
  1285. lrint(long double __x)
  1286. { return __builtin_lrintl(__x); }
  1287. #endif
  1288. template<typename _Tp>
  1289. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1290. long>::__type
  1291. lrint(_Tp __x)
  1292. { return __builtin_lrint(__x); }
  1293. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1294. constexpr long
  1295. lround(float __x)
  1296. { return __builtin_lroundf(__x); }
  1297. constexpr long
  1298. lround(long double __x)
  1299. { return __builtin_lroundl(__x); }
  1300. #endif
  1301. template<typename _Tp>
  1302. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1303. long>::__type
  1304. lround(_Tp __x)
  1305. { return __builtin_lround(__x); }
  1306. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1307. constexpr float
  1308. nearbyint(float __x)
  1309. { return __builtin_nearbyintf(__x); }
  1310. constexpr long double
  1311. nearbyint(long double __x)
  1312. { return __builtin_nearbyintl(__x); }
  1313. #endif
  1314. template<typename _Tp>
  1315. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1316. double>::__type
  1317. nearbyint(_Tp __x)
  1318. { return __builtin_nearbyint(__x); }
  1319. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1320. constexpr float
  1321. nextafter(float __x, float __y)
  1322. { return __builtin_nextafterf(__x, __y); }
  1323. constexpr long double
  1324. nextafter(long double __x, long double __y)
  1325. { return __builtin_nextafterl(__x, __y); }
  1326. #endif
  1327. template<typename _Tp, typename _Up>
  1328. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1329. nextafter(_Tp __x, _Up __y)
  1330. {
  1331. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1332. return nextafter(__type(__x), __type(__y));
  1333. }
  1334. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1335. constexpr float
  1336. nexttoward(float __x, long double __y)
  1337. { return __builtin_nexttowardf(__x, __y); }
  1338. constexpr long double
  1339. nexttoward(long double __x, long double __y)
  1340. { return __builtin_nexttowardl(__x, __y); }
  1341. #endif
  1342. template<typename _Tp>
  1343. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1344. double>::__type
  1345. nexttoward(_Tp __x, long double __y)
  1346. { return __builtin_nexttoward(__x, __y); }
  1347. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1348. constexpr float
  1349. remainder(float __x, float __y)
  1350. { return __builtin_remainderf(__x, __y); }
  1351. constexpr long double
  1352. remainder(long double __x, long double __y)
  1353. { return __builtin_remainderl(__x, __y); }
  1354. #endif
  1355. template<typename _Tp, typename _Up>
  1356. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1357. remainder(_Tp __x, _Up __y)
  1358. {
  1359. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1360. return remainder(__type(__x), __type(__y));
  1361. }
  1362. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1363. inline float
  1364. remquo(float __x, float __y, int* __pquo)
  1365. { return __builtin_remquof(__x, __y, __pquo); }
  1366. inline long double
  1367. remquo(long double __x, long double __y, int* __pquo)
  1368. { return __builtin_remquol(__x, __y, __pquo); }
  1369. #endif
  1370. template<typename _Tp, typename _Up>
  1371. inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1372. remquo(_Tp __x, _Up __y, int* __pquo)
  1373. {
  1374. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1375. return remquo(__type(__x), __type(__y), __pquo);
  1376. }
  1377. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1378. constexpr float
  1379. rint(float __x)
  1380. { return __builtin_rintf(__x); }
  1381. constexpr long double
  1382. rint(long double __x)
  1383. { return __builtin_rintl(__x); }
  1384. #endif
  1385. template<typename _Tp>
  1386. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1387. double>::__type
  1388. rint(_Tp __x)
  1389. { return __builtin_rint(__x); }
  1390. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1391. constexpr float
  1392. round(float __x)
  1393. { return __builtin_roundf(__x); }
  1394. constexpr long double
  1395. round(long double __x)
  1396. { return __builtin_roundl(__x); }
  1397. #endif
  1398. template<typename _Tp>
  1399. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1400. double>::__type
  1401. round(_Tp __x)
  1402. { return __builtin_round(__x); }
  1403. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1404. constexpr float
  1405. scalbln(float __x, long __ex)
  1406. { return __builtin_scalblnf(__x, __ex); }
  1407. constexpr long double
  1408. scalbln(long double __x, long __ex)
  1409. { return __builtin_scalblnl(__x, __ex); }
  1410. #endif
  1411. template<typename _Tp>
  1412. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1413. double>::__type
  1414. scalbln(_Tp __x, long __ex)
  1415. { return __builtin_scalbln(__x, __ex); }
  1416. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1417. constexpr float
  1418. scalbn(float __x, int __ex)
  1419. { return __builtin_scalbnf(__x, __ex); }
  1420. constexpr long double
  1421. scalbn(long double __x, int __ex)
  1422. { return __builtin_scalbnl(__x, __ex); }
  1423. #endif
  1424. template<typename _Tp>
  1425. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1426. double>::__type
  1427. scalbn(_Tp __x, int __ex)
  1428. { return __builtin_scalbn(__x, __ex); }
  1429. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1430. constexpr float
  1431. tgamma(float __x)
  1432. { return __builtin_tgammaf(__x); }
  1433. constexpr long double
  1434. tgamma(long double __x)
  1435. { return __builtin_tgammal(__x); }
  1436. #endif
  1437. template<typename _Tp>
  1438. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1439. double>::__type
  1440. tgamma(_Tp __x)
  1441. { return __builtin_tgamma(__x); }
  1442. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO
  1443. constexpr float
  1444. trunc(float __x)
  1445. { return __builtin_truncf(__x); }
  1446. constexpr long double
  1447. trunc(long double __x)
  1448. { return __builtin_truncl(__x); }
  1449. #endif
  1450. template<typename _Tp>
  1451. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1452. double>::__type
  1453. trunc(_Tp __x)
  1454. { return __builtin_trunc(__x); }
  1455. _GLIBCXX_END_NAMESPACE_VERSION
  1456. } // namespace
  1457. #endif // _GLIBCXX_USE_C99_MATH_TR1
  1458. #endif // C++11
  1459. #endif