cmath 44 KB

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