Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

1933 lines
48KB

  1. // -*- C++ -*- C forwarding header.
  2. // Copyright (C) 1997-2020 Free Software Foundation, Inc.
  3. //
  4. // This file is part of the GNU ISO C++ Library. This library is free
  5. // software; you can redistribute it and/or modify it under the
  6. // terms of the GNU General Public License as published by the
  7. // Free Software Foundation; either version 3, or (at your option)
  8. // any later version.
  9. // This library is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. // Under Section 7 of GPL version 3, you are granted additional
  14. // permissions described in the GCC Runtime Library Exception, version
  15. // 3.1, as published by the Free Software Foundation.
  16. // You should have received a copy of the GNU General Public License and
  17. // a copy of the GCC Runtime Library Exception along with this program;
  18. // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  19. // <http://www.gnu.org/licenses/>.
  20. /** @file 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. #include <bits/std_abs.h>
  40. #ifndef _GLIBCXX_CMATH
  41. #define _GLIBCXX_CMATH 1
  42. // Get rid of those macros defined in <math.h> in lieu of real functions.
  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. using ::acos;
  72. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  73. inline _GLIBCXX_CONSTEXPR float
  74. acos(float __x)
  75. { return __builtin_acosf(__x); }
  76. inline _GLIBCXX_CONSTEXPR long double
  77. acos(long double __x)
  78. { return __builtin_acosl(__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. acos(_Tp __x)
  85. { return __builtin_acos(__x); }
  86. using ::asin;
  87. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  88. inline _GLIBCXX_CONSTEXPR float
  89. asin(float __x)
  90. { return __builtin_asinf(__x); }
  91. inline _GLIBCXX_CONSTEXPR long double
  92. asin(long double __x)
  93. { return __builtin_asinl(__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. asin(_Tp __x)
  100. { return __builtin_asin(__x); }
  101. using ::atan;
  102. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  103. inline _GLIBCXX_CONSTEXPR float
  104. atan(float __x)
  105. { return __builtin_atanf(__x); }
  106. inline _GLIBCXX_CONSTEXPR long double
  107. atan(long double __x)
  108. { return __builtin_atanl(__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. atan(_Tp __x)
  115. { return __builtin_atan(__x); }
  116. using ::atan2;
  117. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  118. inline _GLIBCXX_CONSTEXPR float
  119. atan2(float __y, float __x)
  120. { return __builtin_atan2f(__y, __x); }
  121. inline _GLIBCXX_CONSTEXPR long double
  122. atan2(long double __y, long double __x)
  123. { return __builtin_atan2l(__y, __x); }
  124. #endif
  125. template<typename _Tp, typename _Up>
  126. inline _GLIBCXX_CONSTEXPR
  127. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  128. atan2(_Tp __y, _Up __x)
  129. {
  130. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  131. return atan2(__type(__y), __type(__x));
  132. }
  133. using ::ceil;
  134. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  135. inline _GLIBCXX_CONSTEXPR float
  136. ceil(float __x)
  137. { return __builtin_ceilf(__x); }
  138. inline _GLIBCXX_CONSTEXPR long double
  139. ceil(long double __x)
  140. { return __builtin_ceill(__x); }
  141. #endif
  142. template<typename _Tp>
  143. inline _GLIBCXX_CONSTEXPR
  144. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  145. double>::__type
  146. ceil(_Tp __x)
  147. { return __builtin_ceil(__x); }
  148. using ::cos;
  149. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  150. inline _GLIBCXX_CONSTEXPR float
  151. cos(float __x)
  152. { return __builtin_cosf(__x); }
  153. inline _GLIBCXX_CONSTEXPR long double
  154. cos(long double __x)
  155. { return __builtin_cosl(__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. cos(_Tp __x)
  162. { return __builtin_cos(__x); }
  163. using ::cosh;
  164. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  165. inline _GLIBCXX_CONSTEXPR float
  166. cosh(float __x)
  167. { return __builtin_coshf(__x); }
  168. inline _GLIBCXX_CONSTEXPR long double
  169. cosh(long double __x)
  170. { return __builtin_coshl(__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. cosh(_Tp __x)
  177. { return __builtin_cosh(__x); }
  178. using ::exp;
  179. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  180. inline _GLIBCXX_CONSTEXPR float
  181. exp(float __x)
  182. { return __builtin_expf(__x); }
  183. inline _GLIBCXX_CONSTEXPR long double
  184. exp(long double __x)
  185. { return __builtin_expl(__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. exp(_Tp __x)
  192. { return __builtin_exp(__x); }
  193. using ::fabs;
  194. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  195. inline _GLIBCXX_CONSTEXPR float
  196. fabs(float __x)
  197. { return __builtin_fabsf(__x); }
  198. inline _GLIBCXX_CONSTEXPR long double
  199. fabs(long double __x)
  200. { return __builtin_fabsl(__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. fabs(_Tp __x)
  207. { return __builtin_fabs(__x); }
  208. using ::floor;
  209. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  210. inline _GLIBCXX_CONSTEXPR float
  211. floor(float __x)
  212. { return __builtin_floorf(__x); }
  213. inline _GLIBCXX_CONSTEXPR long double
  214. floor(long double __x)
  215. { return __builtin_floorl(__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. floor(_Tp __x)
  222. { return __builtin_floor(__x); }
  223. using ::fmod;
  224. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  225. inline _GLIBCXX_CONSTEXPR float
  226. fmod(float __x, float __y)
  227. { return __builtin_fmodf(__x, __y); }
  228. inline _GLIBCXX_CONSTEXPR long double
  229. fmod(long double __x, long double __y)
  230. { return __builtin_fmodl(__x, __y); }
  231. #endif
  232. template<typename _Tp, typename _Up>
  233. inline _GLIBCXX_CONSTEXPR
  234. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  235. fmod(_Tp __x, _Up __y)
  236. {
  237. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  238. return fmod(__type(__x), __type(__y));
  239. }
  240. using ::frexp;
  241. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  242. inline float
  243. frexp(float __x, int* __exp)
  244. { return __builtin_frexpf(__x, __exp); }
  245. inline long double
  246. frexp(long double __x, int* __exp)
  247. { return __builtin_frexpl(__x, __exp); }
  248. #endif
  249. template<typename _Tp>
  250. inline _GLIBCXX_CONSTEXPR
  251. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  252. double>::__type
  253. frexp(_Tp __x, int* __exp)
  254. { return __builtin_frexp(__x, __exp); }
  255. using ::ldexp;
  256. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  257. inline _GLIBCXX_CONSTEXPR float
  258. ldexp(float __x, int __exp)
  259. { return __builtin_ldexpf(__x, __exp); }
  260. inline _GLIBCXX_CONSTEXPR long double
  261. ldexp(long double __x, int __exp)
  262. { return __builtin_ldexpl(__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. ldexp(_Tp __x, int __exp)
  269. { return __builtin_ldexp(__x, __exp); }
  270. using ::log;
  271. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  272. inline _GLIBCXX_CONSTEXPR float
  273. log(float __x)
  274. { return __builtin_logf(__x); }
  275. inline _GLIBCXX_CONSTEXPR long double
  276. log(long double __x)
  277. { return __builtin_logl(__x); }
  278. #endif
  279. template<typename _Tp>
  280. inline _GLIBCXX_CONSTEXPR
  281. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  282. double>::__type
  283. log(_Tp __x)
  284. { return __builtin_log(__x); }
  285. using ::log10;
  286. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  287. inline _GLIBCXX_CONSTEXPR float
  288. log10(float __x)
  289. { return __builtin_log10f(__x); }
  290. inline _GLIBCXX_CONSTEXPR long double
  291. log10(long double __x)
  292. { return __builtin_log10l(__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. log10(_Tp __x)
  299. { return __builtin_log10(__x); }
  300. using ::modf;
  301. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  302. inline float
  303. modf(float __x, float* __iptr)
  304. { return __builtin_modff(__x, __iptr); }
  305. inline long double
  306. modf(long double __x, long double* __iptr)
  307. { return __builtin_modfl(__x, __iptr); }
  308. #endif
  309. using ::pow;
  310. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  311. inline _GLIBCXX_CONSTEXPR float
  312. pow(float __x, float __y)
  313. { return __builtin_powf(__x, __y); }
  314. inline _GLIBCXX_CONSTEXPR long double
  315. pow(long double __x, long double __y)
  316. { return __builtin_powl(__x, __y); }
  317. #if __cplusplus < 201103L
  318. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  319. // DR 550. What should the return type of pow(float,int) be?
  320. inline double
  321. pow(double __x, int __i)
  322. { return __builtin_powi(__x, __i); }
  323. inline float
  324. pow(float __x, int __n)
  325. { return __builtin_powif(__x, __n); }
  326. inline long double
  327. pow(long double __x, int __n)
  328. { return __builtin_powil(__x, __n); }
  329. #endif
  330. #endif
  331. template<typename _Tp, typename _Up>
  332. inline _GLIBCXX_CONSTEXPR
  333. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  334. pow(_Tp __x, _Up __y)
  335. {
  336. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  337. return pow(__type(__x), __type(__y));
  338. }
  339. using ::sin;
  340. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  341. inline _GLIBCXX_CONSTEXPR float
  342. sin(float __x)
  343. { return __builtin_sinf(__x); }
  344. inline _GLIBCXX_CONSTEXPR long double
  345. sin(long double __x)
  346. { return __builtin_sinl(__x); }
  347. #endif
  348. template<typename _Tp>
  349. inline _GLIBCXX_CONSTEXPR
  350. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  351. double>::__type
  352. sin(_Tp __x)
  353. { return __builtin_sin(__x); }
  354. using ::sinh;
  355. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  356. inline _GLIBCXX_CONSTEXPR float
  357. sinh(float __x)
  358. { return __builtin_sinhf(__x); }
  359. inline _GLIBCXX_CONSTEXPR long double
  360. sinh(long double __x)
  361. { return __builtin_sinhl(__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. sinh(_Tp __x)
  368. { return __builtin_sinh(__x); }
  369. using ::sqrt;
  370. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  371. inline _GLIBCXX_CONSTEXPR float
  372. sqrt(float __x)
  373. { return __builtin_sqrtf(__x); }
  374. inline _GLIBCXX_CONSTEXPR long double
  375. sqrt(long double __x)
  376. { return __builtin_sqrtl(__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. sqrt(_Tp __x)
  383. { return __builtin_sqrt(__x); }
  384. using ::tan;
  385. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  386. inline _GLIBCXX_CONSTEXPR float
  387. tan(float __x)
  388. { return __builtin_tanf(__x); }
  389. inline _GLIBCXX_CONSTEXPR long double
  390. tan(long double __x)
  391. { return __builtin_tanl(__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. tan(_Tp __x)
  398. { return __builtin_tan(__x); }
  399. using ::tanh;
  400. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  401. inline _GLIBCXX_CONSTEXPR float
  402. tanh(float __x)
  403. { return __builtin_tanhf(__x); }
  404. inline _GLIBCXX_CONSTEXPR long double
  405. tanh(long double __x)
  406. { return __builtin_tanhl(__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. tanh(_Tp __x)
  413. { return __builtin_tanh(__x); }
  414. #if _GLIBCXX_USE_C99_MATH
  415. #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  416. // These are possible macros imported from C99-land.
  417. #undef fpclassify
  418. #undef isfinite
  419. #undef isinf
  420. #undef isnan
  421. #undef isnormal
  422. #undef signbit
  423. #undef isgreater
  424. #undef isgreaterequal
  425. #undef isless
  426. #undef islessequal
  427. #undef islessgreater
  428. #undef isunordered
  429. #if __cplusplus >= 201103L
  430. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  431. constexpr int
  432. fpclassify(float __x)
  433. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  434. FP_SUBNORMAL, FP_ZERO, __x); }
  435. constexpr int
  436. fpclassify(double __x)
  437. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  438. FP_SUBNORMAL, FP_ZERO, __x); }
  439. constexpr int
  440. fpclassify(long double __x)
  441. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  442. FP_SUBNORMAL, FP_ZERO, __x); }
  443. #endif
  444. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  445. template<typename _Tp>
  446. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  447. int>::__type
  448. fpclassify(_Tp __x)
  449. { return __x != 0 ? FP_NORMAL : FP_ZERO; }
  450. #endif
  451. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  452. constexpr bool
  453. isfinite(float __x)
  454. { return __builtin_isfinite(__x); }
  455. constexpr bool
  456. isfinite(double __x)
  457. { return __builtin_isfinite(__x); }
  458. constexpr bool
  459. isfinite(long double __x)
  460. { return __builtin_isfinite(__x); }
  461. #endif
  462. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  463. template<typename _Tp>
  464. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  465. bool>::__type
  466. isfinite(_Tp __x)
  467. { return true; }
  468. #endif
  469. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  470. constexpr bool
  471. isinf(float __x)
  472. { return __builtin_isinf(__x); }
  473. #if _GLIBCXX_HAVE_OBSOLETE_ISINF \
  474. && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
  475. using ::isinf;
  476. #else
  477. constexpr bool
  478. isinf(double __x)
  479. { return __builtin_isinf(__x); }
  480. #endif
  481. constexpr bool
  482. isinf(long double __x)
  483. { return __builtin_isinf(__x); }
  484. #endif
  485. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  486. template<typename _Tp>
  487. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  488. bool>::__type
  489. isinf(_Tp __x)
  490. { return false; }
  491. #endif
  492. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  493. constexpr bool
  494. isnan(float __x)
  495. { return __builtin_isnan(__x); }
  496. #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \
  497. && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
  498. using ::isnan;
  499. #else
  500. constexpr bool
  501. isnan(double __x)
  502. { return __builtin_isnan(__x); }
  503. #endif
  504. constexpr bool
  505. isnan(long double __x)
  506. { return __builtin_isnan(__x); }
  507. #endif
  508. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  509. template<typename _Tp>
  510. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  511. bool>::__type
  512. isnan(_Tp __x)
  513. { return false; }
  514. #endif
  515. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  516. constexpr bool
  517. isnormal(float __x)
  518. { return __builtin_isnormal(__x); }
  519. constexpr bool
  520. isnormal(double __x)
  521. { return __builtin_isnormal(__x); }
  522. constexpr bool
  523. isnormal(long double __x)
  524. { return __builtin_isnormal(__x); }
  525. #endif
  526. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  527. template<typename _Tp>
  528. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  529. bool>::__type
  530. isnormal(_Tp __x)
  531. { return __x != 0 ? true : false; }
  532. #endif
  533. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  534. // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic.
  535. constexpr bool
  536. signbit(float __x)
  537. { return __builtin_signbit(__x); }
  538. constexpr bool
  539. signbit(double __x)
  540. { return __builtin_signbit(__x); }
  541. constexpr bool
  542. signbit(long double __x)
  543. { return __builtin_signbit(__x); }
  544. #endif
  545. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  546. template<typename _Tp>
  547. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  548. bool>::__type
  549. signbit(_Tp __x)
  550. { return __x < 0 ? true : false; }
  551. #endif
  552. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  553. constexpr bool
  554. isgreater(float __x, float __y)
  555. { return __builtin_isgreater(__x, __y); }
  556. constexpr bool
  557. isgreater(double __x, double __y)
  558. { return __builtin_isgreater(__x, __y); }
  559. constexpr bool
  560. isgreater(long double __x, long double __y)
  561. { return __builtin_isgreater(__x, __y); }
  562. #endif
  563. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  564. template<typename _Tp, typename _Up>
  565. constexpr typename
  566. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  567. && __is_arithmetic<_Up>::__value), bool>::__type
  568. isgreater(_Tp __x, _Up __y)
  569. {
  570. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  571. return __builtin_isgreater(__type(__x), __type(__y));
  572. }
  573. #endif
  574. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  575. constexpr bool
  576. isgreaterequal(float __x, float __y)
  577. { return __builtin_isgreaterequal(__x, __y); }
  578. constexpr bool
  579. isgreaterequal(double __x, double __y)
  580. { return __builtin_isgreaterequal(__x, __y); }
  581. constexpr bool
  582. isgreaterequal(long double __x, long double __y)
  583. { return __builtin_isgreaterequal(__x, __y); }
  584. #endif
  585. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  586. template<typename _Tp, typename _Up>
  587. constexpr typename
  588. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  589. && __is_arithmetic<_Up>::__value), bool>::__type
  590. isgreaterequal(_Tp __x, _Up __y)
  591. {
  592. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  593. return __builtin_isgreaterequal(__type(__x), __type(__y));
  594. }
  595. #endif
  596. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  597. constexpr bool
  598. isless(float __x, float __y)
  599. { return __builtin_isless(__x, __y); }
  600. constexpr bool
  601. isless(double __x, double __y)
  602. { return __builtin_isless(__x, __y); }
  603. constexpr bool
  604. isless(long double __x, long double __y)
  605. { return __builtin_isless(__x, __y); }
  606. #endif
  607. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  608. template<typename _Tp, typename _Up>
  609. constexpr typename
  610. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  611. && __is_arithmetic<_Up>::__value), bool>::__type
  612. isless(_Tp __x, _Up __y)
  613. {
  614. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  615. return __builtin_isless(__type(__x), __type(__y));
  616. }
  617. #endif
  618. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  619. constexpr bool
  620. islessequal(float __x, float __y)
  621. { return __builtin_islessequal(__x, __y); }
  622. constexpr bool
  623. islessequal(double __x, double __y)
  624. { return __builtin_islessequal(__x, __y); }
  625. constexpr bool
  626. islessequal(long double __x, long double __y)
  627. { return __builtin_islessequal(__x, __y); }
  628. #endif
  629. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  630. template<typename _Tp, typename _Up>
  631. constexpr typename
  632. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  633. && __is_arithmetic<_Up>::__value), bool>::__type
  634. islessequal(_Tp __x, _Up __y)
  635. {
  636. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  637. return __builtin_islessequal(__type(__x), __type(__y));
  638. }
  639. #endif
  640. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  641. constexpr bool
  642. islessgreater(float __x, float __y)
  643. { return __builtin_islessgreater(__x, __y); }
  644. constexpr bool
  645. islessgreater(double __x, double __y)
  646. { return __builtin_islessgreater(__x, __y); }
  647. constexpr bool
  648. islessgreater(long double __x, long double __y)
  649. { return __builtin_islessgreater(__x, __y); }
  650. #endif
  651. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  652. template<typename _Tp, typename _Up>
  653. constexpr typename
  654. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  655. && __is_arithmetic<_Up>::__value), bool>::__type
  656. islessgreater(_Tp __x, _Up __y)
  657. {
  658. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  659. return __builtin_islessgreater(__type(__x), __type(__y));
  660. }
  661. #endif
  662. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  663. constexpr bool
  664. isunordered(float __x, float __y)
  665. { return __builtin_isunordered(__x, __y); }
  666. constexpr bool
  667. isunordered(double __x, double __y)
  668. { return __builtin_isunordered(__x, __y); }
  669. constexpr bool
  670. isunordered(long double __x, long double __y)
  671. { return __builtin_isunordered(__x, __y); }
  672. #endif
  673. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  674. template<typename _Tp, typename _Up>
  675. constexpr typename
  676. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  677. && __is_arithmetic<_Up>::__value), bool>::__type
  678. isunordered(_Tp __x, _Up __y)
  679. {
  680. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  681. return __builtin_isunordered(__type(__x), __type(__y));
  682. }
  683. #endif
  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 // C++11
  783. #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
  784. #endif /* _GLIBCXX_USE_C99_MATH */
  785. #if __cplusplus >= 201103L
  786. #ifdef _GLIBCXX_USE_C99_MATH_TR1
  787. #undef acosh
  788. #undef acoshf
  789. #undef acoshl
  790. #undef asinh
  791. #undef asinhf
  792. #undef asinhl
  793. #undef atanh
  794. #undef atanhf
  795. #undef atanhl
  796. #undef cbrt
  797. #undef cbrtf
  798. #undef cbrtl
  799. #undef copysign
  800. #undef copysignf
  801. #undef copysignl
  802. #undef erf
  803. #undef erff
  804. #undef erfl
  805. #undef erfc
  806. #undef erfcf
  807. #undef erfcl
  808. #undef exp2
  809. #undef exp2f
  810. #undef exp2l
  811. #undef expm1
  812. #undef expm1f
  813. #undef expm1l
  814. #undef fdim
  815. #undef fdimf
  816. #undef fdiml
  817. #undef fma
  818. #undef fmaf
  819. #undef fmal
  820. #undef fmax
  821. #undef fmaxf
  822. #undef fmaxl
  823. #undef fmin
  824. #undef fminf
  825. #undef fminl
  826. #undef hypot
  827. #undef hypotf
  828. #undef hypotl
  829. #undef ilogb
  830. #undef ilogbf
  831. #undef ilogbl
  832. #undef lgamma
  833. #undef lgammaf
  834. #undef lgammal
  835. #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
  836. #undef llrint
  837. #undef llrintf
  838. #undef llrintl
  839. #undef llround
  840. #undef llroundf
  841. #undef llroundl
  842. #endif
  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. // types
  895. using ::double_t;
  896. using ::float_t;
  897. // functions
  898. using ::acosh;
  899. using ::acoshf;
  900. using ::acoshl;
  901. using ::asinh;
  902. using ::asinhf;
  903. using ::asinhl;
  904. using ::atanh;
  905. using ::atanhf;
  906. using ::atanhl;
  907. using ::cbrt;
  908. using ::cbrtf;
  909. using ::cbrtl;
  910. using ::copysign;
  911. using ::copysignf;
  912. using ::copysignl;
  913. using ::erf;
  914. using ::erff;
  915. using ::erfl;
  916. using ::erfc;
  917. using ::erfcf;
  918. using ::erfcl;
  919. using ::exp2;
  920. using ::exp2f;
  921. using ::exp2l;
  922. using ::expm1;
  923. using ::expm1f;
  924. using ::expm1l;
  925. using ::fdim;
  926. using ::fdimf;
  927. using ::fdiml;
  928. using ::fma;
  929. using ::fmaf;
  930. using ::fmal;
  931. using ::fmax;
  932. using ::fmaxf;
  933. using ::fmaxl;
  934. using ::fmin;
  935. using ::fminf;
  936. using ::fminl;
  937. using ::hypot;
  938. using ::hypotf;
  939. using ::hypotl;
  940. using ::ilogb;
  941. using ::ilogbf;
  942. using ::ilogbl;
  943. using ::lgamma;
  944. using ::lgammaf;
  945. using ::lgammal;
  946. #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
  947. using ::llrint;
  948. using ::llrintf;
  949. using ::llrintl;
  950. using ::llround;
  951. using ::llroundf;
  952. using ::llroundl;
  953. #endif
  954. using ::log1p;
  955. using ::log1pf;
  956. using ::log1pl;
  957. using ::log2;
  958. using ::log2f;
  959. using ::log2l;
  960. using ::logb;
  961. using ::logbf;
  962. using ::logbl;
  963. using ::lrint;
  964. using ::lrintf;
  965. using ::lrintl;
  966. using ::lround;
  967. using ::lroundf;
  968. using ::lroundl;
  969. using ::nan;
  970. using ::nanf;
  971. using ::nanl;
  972. using ::nearbyint;
  973. using ::nearbyintf;
  974. using ::nearbyintl;
  975. using ::nextafter;
  976. using ::nextafterf;
  977. using ::nextafterl;
  978. using ::nexttoward;
  979. using ::nexttowardf;
  980. using ::nexttowardl;
  981. using ::remainder;
  982. using ::remainderf;
  983. using ::remainderl;
  984. using ::remquo;
  985. using ::remquof;
  986. using ::remquol;
  987. using ::rint;
  988. using ::rintf;
  989. using ::rintl;
  990. using ::round;
  991. using ::roundf;
  992. using ::roundl;
  993. using ::scalbln;
  994. using ::scalblnf;
  995. using ::scalblnl;
  996. using ::scalbn;
  997. using ::scalbnf;
  998. using ::scalbnl;
  999. using ::tgamma;
  1000. using ::tgammaf;
  1001. using ::tgammal;
  1002. using ::trunc;
  1003. using ::truncf;
  1004. using ::truncl;
  1005. /// Additional overloads.
  1006. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1007. constexpr float
  1008. acosh(float __x)
  1009. { return __builtin_acoshf(__x); }
  1010. constexpr long double
  1011. acosh(long double __x)
  1012. { return __builtin_acoshl(__x); }
  1013. #endif
  1014. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  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. #endif
  1021. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1022. constexpr float
  1023. asinh(float __x)
  1024. { return __builtin_asinhf(__x); }
  1025. constexpr long double
  1026. asinh(long double __x)
  1027. { return __builtin_asinhl(__x); }
  1028. #endif
  1029. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1030. template<typename _Tp>
  1031. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1032. double>::__type
  1033. asinh(_Tp __x)
  1034. { return __builtin_asinh(__x); }
  1035. #endif
  1036. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1037. constexpr float
  1038. atanh(float __x)
  1039. { return __builtin_atanhf(__x); }
  1040. constexpr long double
  1041. atanh(long double __x)
  1042. { return __builtin_atanhl(__x); }
  1043. #endif
  1044. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1045. template<typename _Tp>
  1046. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1047. double>::__type
  1048. atanh(_Tp __x)
  1049. { return __builtin_atanh(__x); }
  1050. #endif
  1051. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1052. constexpr float
  1053. cbrt(float __x)
  1054. { return __builtin_cbrtf(__x); }
  1055. constexpr long double
  1056. cbrt(long double __x)
  1057. { return __builtin_cbrtl(__x); }
  1058. #endif
  1059. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1060. template<typename _Tp>
  1061. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1062. double>::__type
  1063. cbrt(_Tp __x)
  1064. { return __builtin_cbrt(__x); }
  1065. #endif
  1066. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1067. constexpr float
  1068. copysign(float __x, float __y)
  1069. { return __builtin_copysignf(__x, __y); }
  1070. constexpr long double
  1071. copysign(long double __x, long double __y)
  1072. { return __builtin_copysignl(__x, __y); }
  1073. #endif
  1074. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1075. template<typename _Tp, typename _Up>
  1076. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1077. copysign(_Tp __x, _Up __y)
  1078. {
  1079. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1080. return copysign(__type(__x), __type(__y));
  1081. }
  1082. #endif
  1083. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1084. constexpr float
  1085. erf(float __x)
  1086. { return __builtin_erff(__x); }
  1087. constexpr long double
  1088. erf(long double __x)
  1089. { return __builtin_erfl(__x); }
  1090. #endif
  1091. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1092. template<typename _Tp>
  1093. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1094. double>::__type
  1095. erf(_Tp __x)
  1096. { return __builtin_erf(__x); }
  1097. #endif
  1098. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1099. constexpr float
  1100. erfc(float __x)
  1101. { return __builtin_erfcf(__x); }
  1102. constexpr long double
  1103. erfc(long double __x)
  1104. { return __builtin_erfcl(__x); }
  1105. #endif
  1106. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1107. template<typename _Tp>
  1108. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1109. double>::__type
  1110. erfc(_Tp __x)
  1111. { return __builtin_erfc(__x); }
  1112. #endif
  1113. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1114. constexpr float
  1115. exp2(float __x)
  1116. { return __builtin_exp2f(__x); }
  1117. constexpr long double
  1118. exp2(long double __x)
  1119. { return __builtin_exp2l(__x); }
  1120. #endif
  1121. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1122. template<typename _Tp>
  1123. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1124. double>::__type
  1125. exp2(_Tp __x)
  1126. { return __builtin_exp2(__x); }
  1127. #endif
  1128. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1129. constexpr float
  1130. expm1(float __x)
  1131. { return __builtin_expm1f(__x); }
  1132. constexpr long double
  1133. expm1(long double __x)
  1134. { return __builtin_expm1l(__x); }
  1135. #endif
  1136. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1137. template<typename _Tp>
  1138. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1139. double>::__type
  1140. expm1(_Tp __x)
  1141. { return __builtin_expm1(__x); }
  1142. #endif
  1143. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1144. constexpr float
  1145. fdim(float __x, float __y)
  1146. { return __builtin_fdimf(__x, __y); }
  1147. constexpr long double
  1148. fdim(long double __x, long double __y)
  1149. { return __builtin_fdiml(__x, __y); }
  1150. #endif
  1151. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1152. template<typename _Tp, typename _Up>
  1153. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1154. fdim(_Tp __x, _Up __y)
  1155. {
  1156. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1157. return fdim(__type(__x), __type(__y));
  1158. }
  1159. #endif
  1160. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1161. constexpr float
  1162. fma(float __x, float __y, float __z)
  1163. { return __builtin_fmaf(__x, __y, __z); }
  1164. constexpr long double
  1165. fma(long double __x, long double __y, long double __z)
  1166. { return __builtin_fmal(__x, __y, __z); }
  1167. #endif
  1168. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1169. template<typename _Tp, typename _Up, typename _Vp>
  1170. constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
  1171. fma(_Tp __x, _Up __y, _Vp __z)
  1172. {
  1173. typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
  1174. return fma(__type(__x), __type(__y), __type(__z));
  1175. }
  1176. #endif
  1177. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1178. constexpr float
  1179. fmax(float __x, float __y)
  1180. { return __builtin_fmaxf(__x, __y); }
  1181. constexpr long double
  1182. fmax(long double __x, long double __y)
  1183. { return __builtin_fmaxl(__x, __y); }
  1184. #endif
  1185. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1186. template<typename _Tp, typename _Up>
  1187. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1188. fmax(_Tp __x, _Up __y)
  1189. {
  1190. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1191. return fmax(__type(__x), __type(__y));
  1192. }
  1193. #endif
  1194. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1195. constexpr float
  1196. fmin(float __x, float __y)
  1197. { return __builtin_fminf(__x, __y); }
  1198. constexpr long double
  1199. fmin(long double __x, long double __y)
  1200. { return __builtin_fminl(__x, __y); }
  1201. #endif
  1202. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1203. template<typename _Tp, typename _Up>
  1204. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1205. fmin(_Tp __x, _Up __y)
  1206. {
  1207. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1208. return fmin(__type(__x), __type(__y));
  1209. }
  1210. #endif
  1211. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1212. constexpr float
  1213. hypot(float __x, float __y)
  1214. { return __builtin_hypotf(__x, __y); }
  1215. constexpr long double
  1216. hypot(long double __x, long double __y)
  1217. { return __builtin_hypotl(__x, __y); }
  1218. #endif
  1219. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1220. template<typename _Tp, typename _Up>
  1221. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1222. hypot(_Tp __x, _Up __y)
  1223. {
  1224. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1225. return hypot(__type(__x), __type(__y));
  1226. }
  1227. #endif
  1228. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1229. constexpr int
  1230. ilogb(float __x)
  1231. { return __builtin_ilogbf(__x); }
  1232. constexpr int
  1233. ilogb(long double __x)
  1234. { return __builtin_ilogbl(__x); }
  1235. #endif
  1236. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1237. template<typename _Tp>
  1238. constexpr
  1239. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1240. int>::__type
  1241. ilogb(_Tp __x)
  1242. { return __builtin_ilogb(__x); }
  1243. #endif
  1244. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1245. constexpr float
  1246. lgamma(float __x)
  1247. { return __builtin_lgammaf(__x); }
  1248. constexpr long double
  1249. lgamma(long double __x)
  1250. { return __builtin_lgammal(__x); }
  1251. #endif
  1252. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1253. template<typename _Tp>
  1254. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1255. double>::__type
  1256. lgamma(_Tp __x)
  1257. { return __builtin_lgamma(__x); }
  1258. #endif
  1259. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1260. constexpr long long
  1261. llrint(float __x)
  1262. { return __builtin_llrintf(__x); }
  1263. constexpr long long
  1264. llrint(long double __x)
  1265. { return __builtin_llrintl(__x); }
  1266. #endif
  1267. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1268. template<typename _Tp>
  1269. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1270. long long>::__type
  1271. llrint(_Tp __x)
  1272. { return __builtin_llrint(__x); }
  1273. #endif
  1274. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1275. constexpr long long
  1276. llround(float __x)
  1277. { return __builtin_llroundf(__x); }
  1278. constexpr long long
  1279. llround(long double __x)
  1280. { return __builtin_llroundl(__x); }
  1281. #endif
  1282. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1283. template<typename _Tp>
  1284. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1285. long long>::__type
  1286. llround(_Tp __x)
  1287. { return __builtin_llround(__x); }
  1288. #endif
  1289. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1290. constexpr float
  1291. log1p(float __x)
  1292. { return __builtin_log1pf(__x); }
  1293. constexpr long double
  1294. log1p(long double __x)
  1295. { return __builtin_log1pl(__x); }
  1296. #endif
  1297. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1298. template<typename _Tp>
  1299. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1300. double>::__type
  1301. log1p(_Tp __x)
  1302. { return __builtin_log1p(__x); }
  1303. #endif
  1304. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1305. // DR 568.
  1306. constexpr float
  1307. log2(float __x)
  1308. { return __builtin_log2f(__x); }
  1309. constexpr long double
  1310. log2(long double __x)
  1311. { return __builtin_log2l(__x); }
  1312. #endif
  1313. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1314. template<typename _Tp>
  1315. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1316. double>::__type
  1317. log2(_Tp __x)
  1318. { return __builtin_log2(__x); }
  1319. #endif
  1320. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1321. constexpr float
  1322. logb(float __x)
  1323. { return __builtin_logbf(__x); }
  1324. constexpr long double
  1325. logb(long double __x)
  1326. { return __builtin_logbl(__x); }
  1327. #endif
  1328. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1329. template<typename _Tp>
  1330. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1331. double>::__type
  1332. logb(_Tp __x)
  1333. { return __builtin_logb(__x); }
  1334. #endif
  1335. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1336. constexpr long
  1337. lrint(float __x)
  1338. { return __builtin_lrintf(__x); }
  1339. constexpr long
  1340. lrint(long double __x)
  1341. { return __builtin_lrintl(__x); }
  1342. #endif
  1343. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1344. template<typename _Tp>
  1345. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1346. long>::__type
  1347. lrint(_Tp __x)
  1348. { return __builtin_lrint(__x); }
  1349. #endif
  1350. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1351. constexpr long
  1352. lround(float __x)
  1353. { return __builtin_lroundf(__x); }
  1354. constexpr long
  1355. lround(long double __x)
  1356. { return __builtin_lroundl(__x); }
  1357. #endif
  1358. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1359. template<typename _Tp>
  1360. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1361. long>::__type
  1362. lround(_Tp __x)
  1363. { return __builtin_lround(__x); }
  1364. #endif
  1365. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1366. constexpr float
  1367. nearbyint(float __x)
  1368. { return __builtin_nearbyintf(__x); }
  1369. constexpr long double
  1370. nearbyint(long double __x)
  1371. { return __builtin_nearbyintl(__x); }
  1372. #endif
  1373. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1374. template<typename _Tp>
  1375. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1376. double>::__type
  1377. nearbyint(_Tp __x)
  1378. { return __builtin_nearbyint(__x); }
  1379. #endif
  1380. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1381. constexpr float
  1382. nextafter(float __x, float __y)
  1383. { return __builtin_nextafterf(__x, __y); }
  1384. constexpr long double
  1385. nextafter(long double __x, long double __y)
  1386. { return __builtin_nextafterl(__x, __y); }
  1387. #endif
  1388. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1389. template<typename _Tp, typename _Up>
  1390. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1391. nextafter(_Tp __x, _Up __y)
  1392. {
  1393. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1394. return nextafter(__type(__x), __type(__y));
  1395. }
  1396. #endif
  1397. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1398. constexpr float
  1399. nexttoward(float __x, long double __y)
  1400. { return __builtin_nexttowardf(__x, __y); }
  1401. constexpr long double
  1402. nexttoward(long double __x, long double __y)
  1403. { return __builtin_nexttowardl(__x, __y); }
  1404. #endif
  1405. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1406. template<typename _Tp>
  1407. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1408. double>::__type
  1409. nexttoward(_Tp __x, long double __y)
  1410. { return __builtin_nexttoward(__x, __y); }
  1411. #endif
  1412. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1413. constexpr float
  1414. remainder(float __x, float __y)
  1415. { return __builtin_remainderf(__x, __y); }
  1416. constexpr long double
  1417. remainder(long double __x, long double __y)
  1418. { return __builtin_remainderl(__x, __y); }
  1419. #endif
  1420. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1421. template<typename _Tp, typename _Up>
  1422. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1423. remainder(_Tp __x, _Up __y)
  1424. {
  1425. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1426. return remainder(__type(__x), __type(__y));
  1427. }
  1428. #endif
  1429. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1430. inline float
  1431. remquo(float __x, float __y, int* __pquo)
  1432. { return __builtin_remquof(__x, __y, __pquo); }
  1433. inline long double
  1434. remquo(long double __x, long double __y, int* __pquo)
  1435. { return __builtin_remquol(__x, __y, __pquo); }
  1436. #endif
  1437. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1438. template<typename _Tp, typename _Up>
  1439. inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  1440. remquo(_Tp __x, _Up __y, int* __pquo)
  1441. {
  1442. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1443. return remquo(__type(__x), __type(__y), __pquo);
  1444. }
  1445. #endif
  1446. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1447. constexpr float
  1448. rint(float __x)
  1449. { return __builtin_rintf(__x); }
  1450. constexpr long double
  1451. rint(long double __x)
  1452. { return __builtin_rintl(__x); }
  1453. #endif
  1454. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1455. template<typename _Tp>
  1456. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1457. double>::__type
  1458. rint(_Tp __x)
  1459. { return __builtin_rint(__x); }
  1460. #endif
  1461. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1462. constexpr float
  1463. round(float __x)
  1464. { return __builtin_roundf(__x); }
  1465. constexpr long double
  1466. round(long double __x)
  1467. { return __builtin_roundl(__x); }
  1468. #endif
  1469. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1470. template<typename _Tp>
  1471. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1472. double>::__type
  1473. round(_Tp __x)
  1474. { return __builtin_round(__x); }
  1475. #endif
  1476. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1477. constexpr float
  1478. scalbln(float __x, long __ex)
  1479. { return __builtin_scalblnf(__x, __ex); }
  1480. constexpr long double
  1481. scalbln(long double __x, long __ex)
  1482. { return __builtin_scalblnl(__x, __ex); }
  1483. #endif
  1484. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1485. template<typename _Tp>
  1486. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1487. double>::__type
  1488. scalbln(_Tp __x, long __ex)
  1489. { return __builtin_scalbln(__x, __ex); }
  1490. #endif
  1491. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1492. constexpr float
  1493. scalbn(float __x, int __ex)
  1494. { return __builtin_scalbnf(__x, __ex); }
  1495. constexpr long double
  1496. scalbn(long double __x, int __ex)
  1497. { return __builtin_scalbnl(__x, __ex); }
  1498. #endif
  1499. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1500. template<typename _Tp>
  1501. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1502. double>::__type
  1503. scalbn(_Tp __x, int __ex)
  1504. { return __builtin_scalbn(__x, __ex); }
  1505. #endif
  1506. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1507. constexpr float
  1508. tgamma(float __x)
  1509. { return __builtin_tgammaf(__x); }
  1510. constexpr long double
  1511. tgamma(long double __x)
  1512. { return __builtin_tgammal(__x); }
  1513. #endif
  1514. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1515. template<typename _Tp>
  1516. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1517. double>::__type
  1518. tgamma(_Tp __x)
  1519. { return __builtin_tgamma(__x); }
  1520. #endif
  1521. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1522. constexpr float
  1523. trunc(float __x)
  1524. { return __builtin_truncf(__x); }
  1525. constexpr long double
  1526. trunc(long double __x)
  1527. { return __builtin_truncl(__x); }
  1528. #endif
  1529. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1530. template<typename _Tp>
  1531. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1532. double>::__type
  1533. trunc(_Tp __x)
  1534. { return __builtin_trunc(__x); }
  1535. #endif
  1536. #endif // _GLIBCXX_USE_C99_MATH_TR1
  1537. #endif // C++11
  1538. #if __cplusplus > 201402L
  1539. // [c.math.hypot3], three-dimensional hypotenuse
  1540. #define __cpp_lib_hypot 201603
  1541. template<typename _Tp>
  1542. inline _Tp
  1543. __hypot3(_Tp __x, _Tp __y, _Tp __z)
  1544. {
  1545. __x = std::abs(__x);
  1546. __y = std::abs(__y);
  1547. __z = std::abs(__z);
  1548. if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x)
  1549. return __a * std::sqrt((__x / __a) * (__x / __a)
  1550. + (__y / __a) * (__y / __a)
  1551. + (__z / __a) * (__z / __a));
  1552. else
  1553. return {};
  1554. }
  1555. inline float
  1556. hypot(float __x, float __y, float __z)
  1557. { return std::__hypot3<float>(__x, __y, __z); }
  1558. inline double
  1559. hypot(double __x, double __y, double __z)
  1560. { return std::__hypot3<double>(__x, __y, __z); }
  1561. inline long double
  1562. hypot(long double __x, long double __y, long double __z)
  1563. { return std::__hypot3<long double>(__x, __y, __z); }
  1564. template<typename _Tp, typename _Up, typename _Vp>
  1565. typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
  1566. hypot(_Tp __x, _Up __y, _Vp __z)
  1567. {
  1568. using __type = typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type;
  1569. return std::__hypot3<__type>(__x, __y, __z);
  1570. }
  1571. #endif // C++17
  1572. #if __cplusplus > 201703L
  1573. // linear interpolation
  1574. # define __cpp_lib_interpolate 201902L
  1575. template<typename _Fp>
  1576. constexpr _Fp
  1577. __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
  1578. {
  1579. if (__a <= 0 && __b >= 0 || __a >= 0 && __b <= 0)
  1580. return __t * __b + (1 - __t) * __a;
  1581. if (__t == 1)
  1582. return __b; // exact
  1583. // Exact at __t=0, monotonic except near __t=1,
  1584. // bounded, determinate, and consistent:
  1585. const _Fp __x = __a + __t * (__b - __a);
  1586. return __t > 1 == __b > __a
  1587. ? (__b < __x ? __x : __b)
  1588. : (__b > __x ? __x : __b); // monotonic near __t=1
  1589. }
  1590. constexpr float
  1591. lerp(float __a, float __b, float __t) noexcept
  1592. { return std::__lerp(__a, __b, __t); }
  1593. constexpr double
  1594. lerp(double __a, double __b, double __t) noexcept
  1595. { return std::__lerp(__a, __b, __t); }
  1596. constexpr long double
  1597. lerp(long double __a, long double __b, long double __t) noexcept
  1598. { return std::__lerp(__a, __b, __t); }
  1599. #endif // C++20
  1600. _GLIBCXX_END_NAMESPACE_VERSION
  1601. } // namespace
  1602. #if _GLIBCXX_USE_STD_SPEC_FUNCS
  1603. # include <bits/specfun.h>
  1604. #endif
  1605. } // extern "C++"
  1606. #endif