cmath 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704
  1. // -*- C++ -*- C forwarding header.
  2. // Copyright (C) 1997-2023 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/requires_hosted.h>
  34. #include <bits/c++config.h>
  35. #include <bits/cpp_type_traits.h>
  36. #include <ext/type_traits.h>
  37. #define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
  38. #include_next <math.h>
  39. #undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
  40. #include <bits/std_abs.h>
  41. #ifndef _GLIBCXX_CMATH
  42. #define _GLIBCXX_CMATH 1
  43. // Get rid of those macros defined in <math.h> in lieu of real functions.
  44. #undef div
  45. #undef acos
  46. #undef asin
  47. #undef atan
  48. #undef atan2
  49. #undef ceil
  50. #undef cos
  51. #undef cosh
  52. #undef exp
  53. #undef fabs
  54. #undef floor
  55. #undef fmod
  56. #undef frexp
  57. #undef ldexp
  58. #undef log
  59. #undef log10
  60. #undef modf
  61. #undef pow
  62. #undef sin
  63. #undef sinh
  64. #undef sqrt
  65. #undef tan
  66. #undef tanh
  67. extern "C++"
  68. {
  69. namespace std _GLIBCXX_VISIBILITY(default)
  70. {
  71. _GLIBCXX_BEGIN_NAMESPACE_VERSION
  72. using ::acos;
  73. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  74. inline _GLIBCXX_CONSTEXPR float
  75. acos(float __x)
  76. { return __builtin_acosf(__x); }
  77. inline _GLIBCXX_CONSTEXPR long double
  78. acos(long double __x)
  79. { return __builtin_acosl(__x); }
  80. #endif
  81. template<typename _Tp>
  82. inline _GLIBCXX_CONSTEXPR
  83. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  84. double>::__type
  85. acos(_Tp __x)
  86. { return __builtin_acos(__x); }
  87. using ::asin;
  88. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  89. inline _GLIBCXX_CONSTEXPR float
  90. asin(float __x)
  91. { return __builtin_asinf(__x); }
  92. inline _GLIBCXX_CONSTEXPR long double
  93. asin(long double __x)
  94. { return __builtin_asinl(__x); }
  95. #endif
  96. template<typename _Tp>
  97. inline _GLIBCXX_CONSTEXPR
  98. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  99. double>::__type
  100. asin(_Tp __x)
  101. { return __builtin_asin(__x); }
  102. using ::atan;
  103. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  104. inline _GLIBCXX_CONSTEXPR float
  105. atan(float __x)
  106. { return __builtin_atanf(__x); }
  107. inline _GLIBCXX_CONSTEXPR long double
  108. atan(long double __x)
  109. { return __builtin_atanl(__x); }
  110. #endif
  111. template<typename _Tp>
  112. inline _GLIBCXX_CONSTEXPR
  113. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  114. double>::__type
  115. atan(_Tp __x)
  116. { return __builtin_atan(__x); }
  117. using ::atan2;
  118. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  119. inline _GLIBCXX_CONSTEXPR float
  120. atan2(float __y, float __x)
  121. { return __builtin_atan2f(__y, __x); }
  122. inline _GLIBCXX_CONSTEXPR long double
  123. atan2(long double __y, long double __x)
  124. { return __builtin_atan2l(__y, __x); }
  125. #endif
  126. using ::ceil;
  127. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  128. inline _GLIBCXX_CONSTEXPR float
  129. ceil(float __x)
  130. { return __builtin_ceilf(__x); }
  131. inline _GLIBCXX_CONSTEXPR long double
  132. ceil(long double __x)
  133. { return __builtin_ceill(__x); }
  134. #endif
  135. template<typename _Tp>
  136. inline _GLIBCXX_CONSTEXPR
  137. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  138. double>::__type
  139. ceil(_Tp __x)
  140. { return __builtin_ceil(__x); }
  141. using ::cos;
  142. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  143. inline _GLIBCXX_CONSTEXPR float
  144. cos(float __x)
  145. { return __builtin_cosf(__x); }
  146. inline _GLIBCXX_CONSTEXPR long double
  147. cos(long double __x)
  148. { return __builtin_cosl(__x); }
  149. #endif
  150. template<typename _Tp>
  151. inline _GLIBCXX_CONSTEXPR
  152. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  153. double>::__type
  154. cos(_Tp __x)
  155. { return __builtin_cos(__x); }
  156. using ::cosh;
  157. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  158. inline _GLIBCXX_CONSTEXPR float
  159. cosh(float __x)
  160. { return __builtin_coshf(__x); }
  161. inline _GLIBCXX_CONSTEXPR long double
  162. cosh(long double __x)
  163. { return __builtin_coshl(__x); }
  164. #endif
  165. template<typename _Tp>
  166. inline _GLIBCXX_CONSTEXPR
  167. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  168. double>::__type
  169. cosh(_Tp __x)
  170. { return __builtin_cosh(__x); }
  171. using ::exp;
  172. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  173. inline _GLIBCXX_CONSTEXPR float
  174. exp(float __x)
  175. { return __builtin_expf(__x); }
  176. inline _GLIBCXX_CONSTEXPR long double
  177. exp(long double __x)
  178. { return __builtin_expl(__x); }
  179. #endif
  180. template<typename _Tp>
  181. inline _GLIBCXX_CONSTEXPR
  182. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  183. double>::__type
  184. exp(_Tp __x)
  185. { return __builtin_exp(__x); }
  186. using ::fabs;
  187. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  188. inline _GLIBCXX_CONSTEXPR float
  189. fabs(float __x)
  190. { return __builtin_fabsf(__x); }
  191. inline _GLIBCXX_CONSTEXPR long double
  192. fabs(long double __x)
  193. { return __builtin_fabsl(__x); }
  194. #endif
  195. template<typename _Tp>
  196. inline _GLIBCXX_CONSTEXPR
  197. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  198. double>::__type
  199. fabs(_Tp __x)
  200. { return __builtin_fabs(__x); }
  201. using ::floor;
  202. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  203. inline _GLIBCXX_CONSTEXPR float
  204. floor(float __x)
  205. { return __builtin_floorf(__x); }
  206. inline _GLIBCXX_CONSTEXPR long double
  207. floor(long double __x)
  208. { return __builtin_floorl(__x); }
  209. #endif
  210. template<typename _Tp>
  211. inline _GLIBCXX_CONSTEXPR
  212. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  213. double>::__type
  214. floor(_Tp __x)
  215. { return __builtin_floor(__x); }
  216. using ::fmod;
  217. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  218. inline _GLIBCXX_CONSTEXPR float
  219. fmod(float __x, float __y)
  220. { return __builtin_fmodf(__x, __y); }
  221. inline _GLIBCXX_CONSTEXPR long double
  222. fmod(long double __x, long double __y)
  223. { return __builtin_fmodl(__x, __y); }
  224. #endif
  225. using ::frexp;
  226. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  227. inline float
  228. frexp(float __x, int* __exp)
  229. { return __builtin_frexpf(__x, __exp); }
  230. inline long double
  231. frexp(long double __x, int* __exp)
  232. { return __builtin_frexpl(__x, __exp); }
  233. #endif
  234. template<typename _Tp>
  235. inline _GLIBCXX_CONSTEXPR
  236. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  237. double>::__type
  238. frexp(_Tp __x, int* __exp)
  239. { return __builtin_frexp(__x, __exp); }
  240. using ::ldexp;
  241. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  242. inline _GLIBCXX_CONSTEXPR float
  243. ldexp(float __x, int __exp)
  244. { return __builtin_ldexpf(__x, __exp); }
  245. inline _GLIBCXX_CONSTEXPR long double
  246. ldexp(long double __x, int __exp)
  247. { return __builtin_ldexpl(__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. ldexp(_Tp __x, int __exp)
  254. { return __builtin_ldexp(__x, __exp); }
  255. using ::log;
  256. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  257. inline _GLIBCXX_CONSTEXPR float
  258. log(float __x)
  259. { return __builtin_logf(__x); }
  260. inline _GLIBCXX_CONSTEXPR long double
  261. log(long double __x)
  262. { return __builtin_logl(__x); }
  263. #endif
  264. template<typename _Tp>
  265. inline _GLIBCXX_CONSTEXPR
  266. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  267. double>::__type
  268. log(_Tp __x)
  269. { return __builtin_log(__x); }
  270. using ::log10;
  271. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  272. inline _GLIBCXX_CONSTEXPR float
  273. log10(float __x)
  274. { return __builtin_log10f(__x); }
  275. inline _GLIBCXX_CONSTEXPR long double
  276. log10(long double __x)
  277. { return __builtin_log10l(__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. log10(_Tp __x)
  284. { return __builtin_log10(__x); }
  285. using ::modf;
  286. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  287. inline float
  288. modf(float __x, float* __iptr)
  289. { return __builtin_modff(__x, __iptr); }
  290. inline long double
  291. modf(long double __x, long double* __iptr)
  292. { return __builtin_modfl(__x, __iptr); }
  293. #endif
  294. using ::pow;
  295. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  296. inline _GLIBCXX_CONSTEXPR float
  297. pow(float __x, float __y)
  298. { return __builtin_powf(__x, __y); }
  299. inline _GLIBCXX_CONSTEXPR long double
  300. pow(long double __x, long double __y)
  301. { return __builtin_powl(__x, __y); }
  302. #if __cplusplus < 201103L
  303. // _GLIBCXX_RESOLVE_LIB_DEFECTS
  304. // DR 550. What should the return type of pow(float,int) be?
  305. inline double
  306. pow(double __x, int __i)
  307. { return __builtin_powi(__x, __i); }
  308. inline float
  309. pow(float __x, int __n)
  310. { return __builtin_powif(__x, __n); }
  311. inline long double
  312. pow(long double __x, int __n)
  313. { return __builtin_powil(__x, __n); }
  314. #endif
  315. #endif
  316. using ::sin;
  317. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  318. inline _GLIBCXX_CONSTEXPR float
  319. sin(float __x)
  320. { return __builtin_sinf(__x); }
  321. inline _GLIBCXX_CONSTEXPR long double
  322. sin(long double __x)
  323. { return __builtin_sinl(__x); }
  324. #endif
  325. template<typename _Tp>
  326. inline _GLIBCXX_CONSTEXPR
  327. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  328. double>::__type
  329. sin(_Tp __x)
  330. { return __builtin_sin(__x); }
  331. using ::sinh;
  332. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  333. inline _GLIBCXX_CONSTEXPR float
  334. sinh(float __x)
  335. { return __builtin_sinhf(__x); }
  336. inline _GLIBCXX_CONSTEXPR long double
  337. sinh(long double __x)
  338. { return __builtin_sinhl(__x); }
  339. #endif
  340. template<typename _Tp>
  341. inline _GLIBCXX_CONSTEXPR
  342. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  343. double>::__type
  344. sinh(_Tp __x)
  345. { return __builtin_sinh(__x); }
  346. using ::sqrt;
  347. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  348. inline _GLIBCXX_CONSTEXPR float
  349. sqrt(float __x)
  350. { return __builtin_sqrtf(__x); }
  351. inline _GLIBCXX_CONSTEXPR long double
  352. sqrt(long double __x)
  353. { return __builtin_sqrtl(__x); }
  354. #endif
  355. template<typename _Tp>
  356. inline _GLIBCXX_CONSTEXPR
  357. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  358. double>::__type
  359. sqrt(_Tp __x)
  360. { return __builtin_sqrt(__x); }
  361. using ::tan;
  362. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  363. inline _GLIBCXX_CONSTEXPR float
  364. tan(float __x)
  365. { return __builtin_tanf(__x); }
  366. inline _GLIBCXX_CONSTEXPR long double
  367. tan(long double __x)
  368. { return __builtin_tanl(__x); }
  369. #endif
  370. template<typename _Tp>
  371. inline _GLIBCXX_CONSTEXPR
  372. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  373. double>::__type
  374. tan(_Tp __x)
  375. { return __builtin_tan(__x); }
  376. using ::tanh;
  377. #ifndef __CORRECT_ISO_CPP_MATH_H_PROTO
  378. inline _GLIBCXX_CONSTEXPR float
  379. tanh(float __x)
  380. { return __builtin_tanhf(__x); }
  381. inline _GLIBCXX_CONSTEXPR long double
  382. tanh(long double __x)
  383. { return __builtin_tanhl(__x); }
  384. #endif
  385. template<typename _Tp>
  386. inline _GLIBCXX_CONSTEXPR
  387. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  388. double>::__type
  389. tanh(_Tp __x)
  390. { return __builtin_tanh(__x); }
  391. #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  392. constexpr _Float16
  393. acos(_Float16 __x)
  394. { return _Float16(__builtin_acosf(__x)); }
  395. constexpr _Float16
  396. asin(_Float16 __x)
  397. { return _Float16(__builtin_asinf(__x)); }
  398. constexpr _Float16
  399. atan(_Float16 __x)
  400. { return _Float16(__builtin_atanf(__x)); }
  401. constexpr _Float16
  402. atan2(_Float16 __y, _Float16 __x)
  403. { return _Float16(__builtin_atan2f(__y, __x)); }
  404. constexpr _Float16
  405. ceil(_Float16 __x)
  406. { return _Float16(__builtin_ceilf(__x)); }
  407. constexpr _Float16
  408. cos(_Float16 __x)
  409. { return _Float16(__builtin_cosf(__x)); }
  410. constexpr _Float16
  411. cosh(_Float16 __x)
  412. { return _Float16(__builtin_coshf(__x)); }
  413. constexpr _Float16
  414. exp(_Float16 __x)
  415. { return _Float16(__builtin_expf(__x)); }
  416. constexpr _Float16
  417. fabs(_Float16 __x)
  418. { return _Float16(__builtin_fabsf(__x)); }
  419. constexpr _Float16
  420. floor(_Float16 __x)
  421. { return _Float16(__builtin_floorf(__x)); }
  422. constexpr _Float16
  423. fmod(_Float16 __x, _Float16 __y)
  424. { return _Float16(__builtin_fmodf(__x, __y)); }
  425. inline _Float16
  426. frexp(_Float16 __x, int* __exp)
  427. { return _Float16(__builtin_frexpf(__x, __exp)); }
  428. constexpr _Float16
  429. ldexp(_Float16 __x, int __exp)
  430. { return _Float16(__builtin_ldexpf(__x, __exp)); }
  431. constexpr _Float16
  432. log(_Float16 __x)
  433. { return _Float16(__builtin_logf(__x)); }
  434. constexpr _Float16
  435. log10(_Float16 __x)
  436. { return _Float16(__builtin_log10f(__x)); }
  437. inline _Float16
  438. modf(_Float16 __x, _Float16* __iptr)
  439. {
  440. float __i, __ret = __builtin_modff(__x, &__i);
  441. *__iptr = _Float16(__i);
  442. return _Float16(__ret);
  443. }
  444. constexpr _Float16
  445. pow(_Float16 __x, _Float16 __y)
  446. { return _Float16(__builtin_powf(__x, __y)); }
  447. constexpr _Float16
  448. sin(_Float16 __x)
  449. { return _Float16(__builtin_sinf(__x)); }
  450. constexpr _Float16
  451. sinh(_Float16 __x)
  452. { return _Float16(__builtin_sinhf(__x)); }
  453. constexpr _Float16
  454. sqrt(_Float16 __x)
  455. { return _Float16(__builtin_sqrtf(__x)); }
  456. constexpr _Float16
  457. tan(_Float16 __x)
  458. { return _Float16(__builtin_tanf(__x)); }
  459. constexpr _Float16
  460. tanh(_Float16 __x)
  461. { return _Float16(__builtin_tanhf(__x)); }
  462. #endif
  463. #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  464. constexpr _Float32
  465. acos(_Float32 __x)
  466. { return __builtin_acosf(__x); }
  467. constexpr _Float32
  468. asin(_Float32 __x)
  469. { return __builtin_asinf(__x); }
  470. constexpr _Float32
  471. atan(_Float32 __x)
  472. { return __builtin_atanf(__x); }
  473. constexpr _Float32
  474. atan2(_Float32 __y, _Float32 __x)
  475. { return __builtin_atan2f(__y, __x); }
  476. constexpr _Float32
  477. ceil(_Float32 __x)
  478. { return __builtin_ceilf(__x); }
  479. constexpr _Float32
  480. cos(_Float32 __x)
  481. { return __builtin_cosf(__x); }
  482. constexpr _Float32
  483. cosh(_Float32 __x)
  484. { return __builtin_coshf(__x); }
  485. constexpr _Float32
  486. exp(_Float32 __x)
  487. { return __builtin_expf(__x); }
  488. constexpr _Float32
  489. fabs(_Float32 __x)
  490. { return __builtin_fabsf(__x); }
  491. constexpr _Float32
  492. floor(_Float32 __x)
  493. { return __builtin_floorf(__x); }
  494. constexpr _Float32
  495. fmod(_Float32 __x, _Float32 __y)
  496. { return __builtin_fmodf(__x, __y); }
  497. inline _Float32
  498. frexp(_Float32 __x, int* __exp)
  499. { return __builtin_frexpf(__x, __exp); }
  500. constexpr _Float32
  501. ldexp(_Float32 __x, int __exp)
  502. { return __builtin_ldexpf(__x, __exp); }
  503. constexpr _Float32
  504. log(_Float32 __x)
  505. { return __builtin_logf(__x); }
  506. constexpr _Float32
  507. log10(_Float32 __x)
  508. { return __builtin_log10f(__x); }
  509. inline _Float32
  510. modf(_Float32 __x, _Float32* __iptr)
  511. {
  512. float __i, __ret = __builtin_modff(__x, &__i);
  513. *__iptr = __i;
  514. return __ret;
  515. }
  516. constexpr _Float32
  517. pow(_Float32 __x, _Float32 __y)
  518. { return __builtin_powf(__x, __y); }
  519. constexpr _Float32
  520. sin(_Float32 __x)
  521. { return __builtin_sinf(__x); }
  522. constexpr _Float32
  523. sinh(_Float32 __x)
  524. { return __builtin_sinhf(__x); }
  525. constexpr _Float32
  526. sqrt(_Float32 __x)
  527. { return __builtin_sqrtf(__x); }
  528. constexpr _Float32
  529. tan(_Float32 __x)
  530. { return __builtin_tanf(__x); }
  531. constexpr _Float32
  532. tanh(_Float32 __x)
  533. { return __builtin_tanhf(__x); }
  534. #endif
  535. #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
  536. constexpr _Float64
  537. acos(_Float64 __x)
  538. { return __builtin_acos(__x); }
  539. constexpr _Float64
  540. asin(_Float64 __x)
  541. { return __builtin_asin(__x); }
  542. constexpr _Float64
  543. atan(_Float64 __x)
  544. { return __builtin_atan(__x); }
  545. constexpr _Float64
  546. atan2(_Float64 __y, _Float64 __x)
  547. { return __builtin_atan2(__y, __x); }
  548. constexpr _Float64
  549. ceil(_Float64 __x)
  550. { return __builtin_ceil(__x); }
  551. constexpr _Float64
  552. cos(_Float64 __x)
  553. { return __builtin_cos(__x); }
  554. constexpr _Float64
  555. cosh(_Float64 __x)
  556. { return __builtin_cosh(__x); }
  557. constexpr _Float64
  558. exp(_Float64 __x)
  559. { return __builtin_exp(__x); }
  560. constexpr _Float64
  561. fabs(_Float64 __x)
  562. { return __builtin_fabs(__x); }
  563. constexpr _Float64
  564. floor(_Float64 __x)
  565. { return __builtin_floor(__x); }
  566. constexpr _Float64
  567. fmod(_Float64 __x, _Float64 __y)
  568. { return __builtin_fmod(__x, __y); }
  569. inline _Float64
  570. frexp(_Float64 __x, int* __exp)
  571. { return __builtin_frexp(__x, __exp); }
  572. constexpr _Float64
  573. ldexp(_Float64 __x, int __exp)
  574. { return __builtin_ldexp(__x, __exp); }
  575. constexpr _Float64
  576. log(_Float64 __x)
  577. { return __builtin_log(__x); }
  578. constexpr _Float64
  579. log10(_Float64 __x)
  580. { return __builtin_log10(__x); }
  581. inline _Float64
  582. modf(_Float64 __x, _Float64* __iptr)
  583. {
  584. double __i, __ret = __builtin_modf(__x, &__i);
  585. *__iptr = __i;
  586. return __ret;
  587. }
  588. constexpr _Float64
  589. pow(_Float64 __x, _Float64 __y)
  590. { return __builtin_pow(__x, __y); }
  591. constexpr _Float64
  592. sin(_Float64 __x)
  593. { return __builtin_sin(__x); }
  594. constexpr _Float64
  595. sinh(_Float64 __x)
  596. { return __builtin_sinh(__x); }
  597. constexpr _Float64
  598. sqrt(_Float64 __x)
  599. { return __builtin_sqrt(__x); }
  600. constexpr _Float64
  601. tan(_Float64 __x)
  602. { return __builtin_tan(__x); }
  603. constexpr _Float64
  604. tanh(_Float64 __x)
  605. { return __builtin_tanh(__x); }
  606. #endif
  607. #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
  608. constexpr _Float128
  609. acos(_Float128 __x)
  610. { return __builtin_acosl(__x); }
  611. constexpr _Float128
  612. asin(_Float128 __x)
  613. { return __builtin_asinl(__x); }
  614. constexpr _Float128
  615. atan(_Float128 __x)
  616. { return __builtin_atanl(__x); }
  617. constexpr _Float128
  618. atan2(_Float128 __y, _Float128 __x)
  619. { return __builtin_atan2l(__y, __x); }
  620. constexpr _Float128
  621. ceil(_Float128 __x)
  622. { return __builtin_ceill(__x); }
  623. constexpr _Float128
  624. cos(_Float128 __x)
  625. { return __builtin_cosl(__x); }
  626. constexpr _Float128
  627. cosh(_Float128 __x)
  628. { return __builtin_coshl(__x); }
  629. constexpr _Float128
  630. exp(_Float128 __x)
  631. { return __builtin_expl(__x); }
  632. constexpr _Float128
  633. fabs(_Float128 __x)
  634. { return __builtin_fabsl(__x); }
  635. constexpr _Float128
  636. floor(_Float128 __x)
  637. { return __builtin_floorl(__x); }
  638. constexpr _Float128
  639. fmod(_Float128 __x, _Float128 __y)
  640. { return __builtin_fmodl(__x, __y); }
  641. inline _Float128
  642. frexp(_Float128 __x, int* __exp)
  643. { return __builtin_frexpl(__x, __exp); }
  644. constexpr _Float128
  645. ldexp(_Float128 __x, int __exp)
  646. { return __builtin_ldexpl(__x, __exp); }
  647. constexpr _Float128
  648. log(_Float128 __x)
  649. { return __builtin_logl(__x); }
  650. constexpr _Float128
  651. log10(_Float128 __x)
  652. { return __builtin_log10l(__x); }
  653. inline _Float128
  654. modf(_Float128 __x, _Float128* __iptr)
  655. {
  656. long double __i, __ret = __builtin_modfl(__x, &__i);
  657. *__iptr = __i;
  658. return __ret;
  659. }
  660. constexpr _Float128
  661. pow(_Float128 __x, _Float128 __y)
  662. { return __builtin_powl(__x, __y); }
  663. constexpr _Float128
  664. sin(_Float128 __x)
  665. { return __builtin_sinl(__x); }
  666. constexpr _Float128
  667. sinh(_Float128 __x)
  668. { return __builtin_sinhl(__x); }
  669. constexpr _Float128
  670. sqrt(_Float128 __x)
  671. { return __builtin_sqrtl(__x); }
  672. constexpr _Float128
  673. tan(_Float128 __x)
  674. { return __builtin_tanl(__x); }
  675. constexpr _Float128
  676. tanh(_Float128 __x)
  677. { return __builtin_tanhl(__x); }
  678. #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
  679. constexpr _Float128
  680. acos(_Float128 __x)
  681. { return __builtin_acosf128(__x); }
  682. constexpr _Float128
  683. asin(_Float128 __x)
  684. { return __builtin_asinf128(__x); }
  685. constexpr _Float128
  686. atan(_Float128 __x)
  687. { return __builtin_atanf128(__x); }
  688. constexpr _Float128
  689. atan2(_Float128 __y, _Float128 __x)
  690. { return __builtin_atan2f128(__y, __x); }
  691. constexpr _Float128
  692. ceil(_Float128 __x)
  693. { return __builtin_ceilf128(__x); }
  694. constexpr _Float128
  695. cos(_Float128 __x)
  696. { return __builtin_cosf128(__x); }
  697. constexpr _Float128
  698. cosh(_Float128 __x)
  699. { return __builtin_coshf128(__x); }
  700. constexpr _Float128
  701. exp(_Float128 __x)
  702. { return __builtin_expf128(__x); }
  703. constexpr _Float128
  704. fabs(_Float128 __x)
  705. { return __builtin_fabsf128(__x); }
  706. constexpr _Float128
  707. floor(_Float128 __x)
  708. { return __builtin_floorf128(__x); }
  709. constexpr _Float128
  710. fmod(_Float128 __x, _Float128 __y)
  711. { return __builtin_fmodf128(__x, __y); }
  712. inline _Float128
  713. frexp(_Float128 __x, int* __exp)
  714. { return __builtin_frexpf128(__x, __exp); }
  715. constexpr _Float128
  716. ldexp(_Float128 __x, int __exp)
  717. { return __builtin_ldexpf128(__x, __exp); }
  718. constexpr _Float128
  719. log(_Float128 __x)
  720. { return __builtin_logf128(__x); }
  721. constexpr _Float128
  722. log10(_Float128 __x)
  723. { return __builtin_log10f128(__x); }
  724. inline _Float128
  725. modf(_Float128 __x, _Float128* __iptr)
  726. { return __builtin_modff128(__x, __iptr); }
  727. constexpr _Float128
  728. pow(_Float128 __x, _Float128 __y)
  729. { return __builtin_powf128(__x, __y); }
  730. constexpr _Float128
  731. sin(_Float128 __x)
  732. { return __builtin_sinf128(__x); }
  733. constexpr _Float128
  734. sinh(_Float128 __x)
  735. { return __builtin_sinhf128(__x); }
  736. constexpr _Float128
  737. sqrt(_Float128 __x)
  738. { return __builtin_sqrtf128(__x); }
  739. constexpr _Float128
  740. tan(_Float128 __x)
  741. { return __builtin_tanf128(__x); }
  742. constexpr _Float128
  743. tanh(_Float128 __x)
  744. { return __builtin_tanhf128(__x); }
  745. #endif
  746. #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  747. constexpr __gnu_cxx::__bfloat16_t
  748. acos(__gnu_cxx::__bfloat16_t __x)
  749. { return __gnu_cxx::__bfloat16_t(__builtin_acosf(__x)); }
  750. constexpr __gnu_cxx::__bfloat16_t
  751. asin(__gnu_cxx::__bfloat16_t __x)
  752. { return __gnu_cxx::__bfloat16_t(__builtin_asinf(__x)); }
  753. constexpr __gnu_cxx::__bfloat16_t
  754. atan(__gnu_cxx::__bfloat16_t __x)
  755. { return __gnu_cxx::__bfloat16_t(__builtin_atanf(__x)); }
  756. constexpr __gnu_cxx::__bfloat16_t
  757. atan2(__gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __x)
  758. { return __gnu_cxx::__bfloat16_t(__builtin_atan2f(__y, __x)); }
  759. constexpr __gnu_cxx::__bfloat16_t
  760. ceil(__gnu_cxx::__bfloat16_t __x)
  761. { return __gnu_cxx::__bfloat16_t(__builtin_ceilf(__x)); }
  762. constexpr __gnu_cxx::__bfloat16_t
  763. cos(__gnu_cxx::__bfloat16_t __x)
  764. { return __gnu_cxx::__bfloat16_t(__builtin_cosf(__x)); }
  765. constexpr __gnu_cxx::__bfloat16_t
  766. cosh(__gnu_cxx::__bfloat16_t __x)
  767. { return __gnu_cxx::__bfloat16_t(__builtin_coshf(__x)); }
  768. constexpr __gnu_cxx::__bfloat16_t
  769. exp(__gnu_cxx::__bfloat16_t __x)
  770. { return __gnu_cxx::__bfloat16_t(__builtin_expf(__x)); }
  771. constexpr __gnu_cxx::__bfloat16_t
  772. fabs(__gnu_cxx::__bfloat16_t __x)
  773. { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); }
  774. constexpr __gnu_cxx::__bfloat16_t
  775. floor(__gnu_cxx::__bfloat16_t __x)
  776. { return __gnu_cxx::__bfloat16_t(__builtin_floorf(__x)); }
  777. constexpr __gnu_cxx::__bfloat16_t
  778. fmod(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  779. { return __gnu_cxx::__bfloat16_t(__builtin_fmodf(__x, __y)); }
  780. inline __gnu_cxx::__bfloat16_t
  781. frexp(__gnu_cxx::__bfloat16_t __x, int* __exp)
  782. { return __gnu_cxx::__bfloat16_t(__builtin_frexpf(__x, __exp)); }
  783. constexpr __gnu_cxx::__bfloat16_t
  784. ldexp(__gnu_cxx::__bfloat16_t __x, int __exp)
  785. { return __gnu_cxx::__bfloat16_t(__builtin_ldexpf(__x, __exp)); }
  786. constexpr __gnu_cxx::__bfloat16_t
  787. log(__gnu_cxx::__bfloat16_t __x)
  788. { return __gnu_cxx::__bfloat16_t(__builtin_logf(__x)); }
  789. constexpr __gnu_cxx::__bfloat16_t
  790. log10(__gnu_cxx::__bfloat16_t __x)
  791. { return __gnu_cxx::__bfloat16_t(__builtin_log10f(__x)); }
  792. inline __gnu_cxx::__bfloat16_t
  793. modf(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t* __iptr)
  794. {
  795. float __i, __ret = __builtin_modff(__x, &__i);
  796. *__iptr = __gnu_cxx::__bfloat16_t(__i);
  797. return __gnu_cxx::__bfloat16_t(__ret);
  798. }
  799. constexpr __gnu_cxx::__bfloat16_t
  800. pow(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  801. { return __gnu_cxx::__bfloat16_t(__builtin_powf(__x, __y)); }
  802. constexpr __gnu_cxx::__bfloat16_t
  803. sin(__gnu_cxx::__bfloat16_t __x)
  804. { return __gnu_cxx::__bfloat16_t(__builtin_sinf(__x)); }
  805. constexpr __gnu_cxx::__bfloat16_t
  806. sinh(__gnu_cxx::__bfloat16_t __x)
  807. { return __gnu_cxx::__bfloat16_t(__builtin_sinhf(__x)); }
  808. constexpr __gnu_cxx::__bfloat16_t
  809. sqrt(__gnu_cxx::__bfloat16_t __x)
  810. { return __gnu_cxx::__bfloat16_t(__builtin_sqrtf(__x)); }
  811. constexpr __gnu_cxx::__bfloat16_t
  812. tan(__gnu_cxx::__bfloat16_t __x)
  813. { return __gnu_cxx::__bfloat16_t(__builtin_tanf(__x)); }
  814. constexpr __gnu_cxx::__bfloat16_t
  815. tanh(__gnu_cxx::__bfloat16_t __x)
  816. { return __gnu_cxx::__bfloat16_t(__builtin_tanhf(__x)); }
  817. #endif
  818. template<typename _Tp, typename _Up>
  819. inline _GLIBCXX_CONSTEXPR
  820. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  821. atan2(_Tp __y, _Up __x)
  822. {
  823. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  824. return atan2(__type(__y), __type(__x));
  825. }
  826. template<typename _Tp, typename _Up>
  827. inline _GLIBCXX_CONSTEXPR
  828. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  829. fmod(_Tp __x, _Up __y)
  830. {
  831. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  832. return fmod(__type(__x), __type(__y));
  833. }
  834. template<typename _Tp, typename _Up>
  835. inline _GLIBCXX_CONSTEXPR
  836. typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  837. pow(_Tp __x, _Up __y)
  838. {
  839. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  840. return pow(__type(__x), __type(__y));
  841. }
  842. #if _GLIBCXX_USE_C99_MATH
  843. #if !_GLIBCXX_USE_C99_FP_MACROS_DYNAMIC
  844. // These are possible macros imported from C99-land.
  845. #undef fpclassify
  846. #undef isfinite
  847. #undef isinf
  848. #undef isnan
  849. #undef isnormal
  850. #undef signbit
  851. #undef isgreater
  852. #undef isgreaterequal
  853. #undef isless
  854. #undef islessequal
  855. #undef islessgreater
  856. #undef isunordered
  857. #if __cplusplus >= 201103L
  858. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  859. constexpr int
  860. fpclassify(float __x)
  861. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  862. FP_SUBNORMAL, FP_ZERO, __x); }
  863. constexpr int
  864. fpclassify(double __x)
  865. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  866. FP_SUBNORMAL, FP_ZERO, __x); }
  867. constexpr int
  868. fpclassify(long double __x)
  869. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  870. FP_SUBNORMAL, FP_ZERO, __x); }
  871. #endif
  872. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  873. template<typename _Tp>
  874. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  875. int>::__type
  876. fpclassify(_Tp __x)
  877. { return __x != 0 ? FP_NORMAL : FP_ZERO; }
  878. #endif
  879. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  880. constexpr bool
  881. isfinite(float __x)
  882. { return __builtin_isfinite(__x); }
  883. constexpr bool
  884. isfinite(double __x)
  885. { return __builtin_isfinite(__x); }
  886. constexpr bool
  887. isfinite(long double __x)
  888. { return __builtin_isfinite(__x); }
  889. #endif
  890. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  891. template<typename _Tp>
  892. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  893. bool>::__type
  894. isfinite(_Tp)
  895. { return true; }
  896. #endif
  897. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  898. constexpr bool
  899. isinf(float __x)
  900. { return __builtin_isinf(__x); }
  901. #if _GLIBCXX_HAVE_OBSOLETE_ISINF \
  902. && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
  903. using ::isinf;
  904. #else
  905. constexpr bool
  906. isinf(double __x)
  907. { return __builtin_isinf(__x); }
  908. #endif
  909. constexpr bool
  910. isinf(long double __x)
  911. { return __builtin_isinf(__x); }
  912. #endif
  913. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  914. template<typename _Tp>
  915. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  916. bool>::__type
  917. isinf(_Tp)
  918. { return false; }
  919. #endif
  920. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  921. constexpr bool
  922. isnan(float __x)
  923. { return __builtin_isnan(__x); }
  924. #if _GLIBCXX_HAVE_OBSOLETE_ISNAN \
  925. && !_GLIBCXX_NO_OBSOLETE_ISINF_ISNAN_DYNAMIC
  926. using ::isnan;
  927. #else
  928. constexpr bool
  929. isnan(double __x)
  930. { return __builtin_isnan(__x); }
  931. #endif
  932. constexpr bool
  933. isnan(long double __x)
  934. { return __builtin_isnan(__x); }
  935. #endif
  936. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  937. template<typename _Tp>
  938. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  939. bool>::__type
  940. isnan(_Tp)
  941. { return false; }
  942. #endif
  943. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  944. constexpr bool
  945. isnormal(float __x)
  946. { return __builtin_isnormal(__x); }
  947. constexpr bool
  948. isnormal(double __x)
  949. { return __builtin_isnormal(__x); }
  950. constexpr bool
  951. isnormal(long double __x)
  952. { return __builtin_isnormal(__x); }
  953. #endif
  954. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  955. template<typename _Tp>
  956. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  957. bool>::__type
  958. isnormal(_Tp __x)
  959. { return __x != 0 ? true : false; }
  960. #endif
  961. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  962. // Note: middle-end/36757 is fixed, __builtin_signbit is type-generic.
  963. constexpr bool
  964. signbit(float __x)
  965. { return __builtin_signbit(__x); }
  966. constexpr bool
  967. signbit(double __x)
  968. { return __builtin_signbit(__x); }
  969. constexpr bool
  970. signbit(long double __x)
  971. { return __builtin_signbit(__x); }
  972. #endif
  973. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  974. template<typename _Tp>
  975. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  976. bool>::__type
  977. signbit(_Tp __x)
  978. { return __x < 0 ? true : false; }
  979. #endif
  980. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  981. constexpr bool
  982. isgreater(float __x, float __y)
  983. { return __builtin_isgreater(__x, __y); }
  984. constexpr bool
  985. isgreater(double __x, double __y)
  986. { return __builtin_isgreater(__x, __y); }
  987. constexpr bool
  988. isgreater(long double __x, long double __y)
  989. { return __builtin_isgreater(__x, __y); }
  990. #endif
  991. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  992. template<typename _Tp, typename _Up>
  993. constexpr typename
  994. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  995. && __is_arithmetic<_Up>::__value), bool>::__type
  996. isgreater(_Tp __x, _Up __y)
  997. {
  998. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  999. return __builtin_isgreater(__type(__x), __type(__y));
  1000. }
  1001. #endif
  1002. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1003. constexpr bool
  1004. isgreaterequal(float __x, float __y)
  1005. { return __builtin_isgreaterequal(__x, __y); }
  1006. constexpr bool
  1007. isgreaterequal(double __x, double __y)
  1008. { return __builtin_isgreaterequal(__x, __y); }
  1009. constexpr bool
  1010. isgreaterequal(long double __x, long double __y)
  1011. { return __builtin_isgreaterequal(__x, __y); }
  1012. #endif
  1013. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1014. template<typename _Tp, typename _Up>
  1015. constexpr typename
  1016. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  1017. && __is_arithmetic<_Up>::__value), bool>::__type
  1018. isgreaterequal(_Tp __x, _Up __y)
  1019. {
  1020. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1021. return __builtin_isgreaterequal(__type(__x), __type(__y));
  1022. }
  1023. #endif
  1024. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1025. constexpr bool
  1026. isless(float __x, float __y)
  1027. { return __builtin_isless(__x, __y); }
  1028. constexpr bool
  1029. isless(double __x, double __y)
  1030. { return __builtin_isless(__x, __y); }
  1031. constexpr bool
  1032. isless(long double __x, long double __y)
  1033. { return __builtin_isless(__x, __y); }
  1034. #endif
  1035. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1036. template<typename _Tp, typename _Up>
  1037. constexpr typename
  1038. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  1039. && __is_arithmetic<_Up>::__value), bool>::__type
  1040. isless(_Tp __x, _Up __y)
  1041. {
  1042. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1043. return __builtin_isless(__type(__x), __type(__y));
  1044. }
  1045. #endif
  1046. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1047. constexpr bool
  1048. islessequal(float __x, float __y)
  1049. { return __builtin_islessequal(__x, __y); }
  1050. constexpr bool
  1051. islessequal(double __x, double __y)
  1052. { return __builtin_islessequal(__x, __y); }
  1053. constexpr bool
  1054. islessequal(long double __x, long double __y)
  1055. { return __builtin_islessequal(__x, __y); }
  1056. #endif
  1057. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1058. template<typename _Tp, typename _Up>
  1059. constexpr typename
  1060. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  1061. && __is_arithmetic<_Up>::__value), bool>::__type
  1062. islessequal(_Tp __x, _Up __y)
  1063. {
  1064. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1065. return __builtin_islessequal(__type(__x), __type(__y));
  1066. }
  1067. #endif
  1068. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1069. constexpr bool
  1070. islessgreater(float __x, float __y)
  1071. { return __builtin_islessgreater(__x, __y); }
  1072. constexpr bool
  1073. islessgreater(double __x, double __y)
  1074. { return __builtin_islessgreater(__x, __y); }
  1075. constexpr bool
  1076. islessgreater(long double __x, long double __y)
  1077. { return __builtin_islessgreater(__x, __y); }
  1078. #endif
  1079. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1080. template<typename _Tp, typename _Up>
  1081. constexpr typename
  1082. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  1083. && __is_arithmetic<_Up>::__value), bool>::__type
  1084. islessgreater(_Tp __x, _Up __y)
  1085. {
  1086. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1087. return __builtin_islessgreater(__type(__x), __type(__y));
  1088. }
  1089. #endif
  1090. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1091. constexpr bool
  1092. isunordered(float __x, float __y)
  1093. { return __builtin_isunordered(__x, __y); }
  1094. constexpr bool
  1095. isunordered(double __x, double __y)
  1096. { return __builtin_isunordered(__x, __y); }
  1097. constexpr bool
  1098. isunordered(long double __x, long double __y)
  1099. { return __builtin_isunordered(__x, __y); }
  1100. #endif
  1101. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1102. template<typename _Tp, typename _Up>
  1103. constexpr typename
  1104. __gnu_cxx::__enable_if<(__is_arithmetic<_Tp>::__value
  1105. && __is_arithmetic<_Up>::__value), bool>::__type
  1106. isunordered(_Tp __x, _Up __y)
  1107. {
  1108. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  1109. return __builtin_isunordered(__type(__x), __type(__y));
  1110. }
  1111. #endif
  1112. #else
  1113. template<typename _Tp>
  1114. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1115. int>::__type
  1116. fpclassify(_Tp __f)
  1117. {
  1118. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1119. return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1120. FP_SUBNORMAL, FP_ZERO, __type(__f));
  1121. }
  1122. template<typename _Tp>
  1123. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1124. int>::__type
  1125. isfinite(_Tp __f)
  1126. {
  1127. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1128. return __builtin_isfinite(__type(__f));
  1129. }
  1130. template<typename _Tp>
  1131. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1132. int>::__type
  1133. isinf(_Tp __f)
  1134. {
  1135. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1136. return __builtin_isinf(__type(__f));
  1137. }
  1138. template<typename _Tp>
  1139. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1140. int>::__type
  1141. isnan(_Tp __f)
  1142. {
  1143. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1144. return __builtin_isnan(__type(__f));
  1145. }
  1146. template<typename _Tp>
  1147. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1148. int>::__type
  1149. isnormal(_Tp __f)
  1150. {
  1151. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1152. return __builtin_isnormal(__type(__f));
  1153. }
  1154. template<typename _Tp>
  1155. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1156. int>::__type
  1157. signbit(_Tp __f)
  1158. {
  1159. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1160. return __builtin_signbit(__type(__f));
  1161. }
  1162. template<typename _Tp>
  1163. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1164. int>::__type
  1165. isgreater(_Tp __f1, _Tp __f2)
  1166. {
  1167. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1168. return __builtin_isgreater(__type(__f1), __type(__f2));
  1169. }
  1170. template<typename _Tp>
  1171. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1172. int>::__type
  1173. isgreaterequal(_Tp __f1, _Tp __f2)
  1174. {
  1175. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1176. return __builtin_isgreaterequal(__type(__f1), __type(__f2));
  1177. }
  1178. template<typename _Tp>
  1179. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1180. int>::__type
  1181. isless(_Tp __f1, _Tp __f2)
  1182. {
  1183. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1184. return __builtin_isless(__type(__f1), __type(__f2));
  1185. }
  1186. template<typename _Tp>
  1187. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1188. int>::__type
  1189. islessequal(_Tp __f1, _Tp __f2)
  1190. {
  1191. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1192. return __builtin_islessequal(__type(__f1), __type(__f2));
  1193. }
  1194. template<typename _Tp>
  1195. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1196. int>::__type
  1197. islessgreater(_Tp __f1, _Tp __f2)
  1198. {
  1199. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1200. return __builtin_islessgreater(__type(__f1), __type(__f2));
  1201. }
  1202. template<typename _Tp>
  1203. inline typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value,
  1204. int>::__type
  1205. isunordered(_Tp __f1, _Tp __f2)
  1206. {
  1207. typedef typename __gnu_cxx::__promote<_Tp>::__type __type;
  1208. return __builtin_isunordered(__type(__f1), __type(__f2));
  1209. }
  1210. #endif // C++11
  1211. #ifdef __STDCPP_FLOAT16_T__
  1212. constexpr int
  1213. fpclassify(_Float16 __x)
  1214. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1215. FP_SUBNORMAL, FP_ZERO, __x); }
  1216. constexpr bool
  1217. isfinite(_Float16 __x)
  1218. { return __builtin_isfinite(__x); }
  1219. constexpr bool
  1220. isinf(_Float16 __x)
  1221. { return __builtin_isinf(__x); }
  1222. constexpr bool
  1223. isnan(_Float16 __x)
  1224. { return __builtin_isnan(__x); }
  1225. constexpr bool
  1226. isnormal(_Float16 __x)
  1227. { return __builtin_isnormal(__x); }
  1228. constexpr bool
  1229. signbit(_Float16 __x)
  1230. { return __builtin_signbit(__x); }
  1231. constexpr bool
  1232. isgreater(_Float16 __x, _Float16 __y)
  1233. { return __builtin_isgreater(__x, __y); }
  1234. constexpr bool
  1235. isgreaterequal(_Float16 __x, _Float16 __y)
  1236. { return __builtin_isgreaterequal(__x, __y); }
  1237. constexpr bool
  1238. isless(_Float16 __x, _Float16 __y)
  1239. { return __builtin_isless(__x, __y); }
  1240. constexpr bool
  1241. islessequal(_Float16 __x, _Float16 __y)
  1242. { return __builtin_islessequal(__x, __y); }
  1243. constexpr bool
  1244. islessgreater(_Float16 __x, _Float16 __y)
  1245. { return __builtin_islessgreater(__x, __y); }
  1246. constexpr bool
  1247. isunordered(_Float16 __x, _Float16 __y)
  1248. { return __builtin_isunordered(__x, __y); }
  1249. #endif
  1250. #ifdef __STDCPP_FLOAT32_T__
  1251. constexpr int
  1252. fpclassify(_Float32 __x)
  1253. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1254. FP_SUBNORMAL, FP_ZERO, __x); }
  1255. constexpr bool
  1256. isfinite(_Float32 __x)
  1257. { return __builtin_isfinite(__x); }
  1258. constexpr bool
  1259. isinf(_Float32 __x)
  1260. { return __builtin_isinf(__x); }
  1261. constexpr bool
  1262. isnan(_Float32 __x)
  1263. { return __builtin_isnan(__x); }
  1264. constexpr bool
  1265. isnormal(_Float32 __x)
  1266. { return __builtin_isnormal(__x); }
  1267. constexpr bool
  1268. signbit(_Float32 __x)
  1269. { return __builtin_signbit(__x); }
  1270. constexpr bool
  1271. isgreater(_Float32 __x, _Float32 __y)
  1272. { return __builtin_isgreater(__x, __y); }
  1273. constexpr bool
  1274. isgreaterequal(_Float32 __x, _Float32 __y)
  1275. { return __builtin_isgreaterequal(__x, __y); }
  1276. constexpr bool
  1277. isless(_Float32 __x, _Float32 __y)
  1278. { return __builtin_isless(__x, __y); }
  1279. constexpr bool
  1280. islessequal(_Float32 __x, _Float32 __y)
  1281. { return __builtin_islessequal(__x, __y); }
  1282. constexpr bool
  1283. islessgreater(_Float32 __x, _Float32 __y)
  1284. { return __builtin_islessgreater(__x, __y); }
  1285. constexpr bool
  1286. isunordered(_Float32 __x, _Float32 __y)
  1287. { return __builtin_isunordered(__x, __y); }
  1288. #endif
  1289. #ifdef __STDCPP_FLOAT64_T__
  1290. constexpr int
  1291. fpclassify(_Float64 __x)
  1292. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1293. FP_SUBNORMAL, FP_ZERO, __x); }
  1294. constexpr bool
  1295. isfinite(_Float64 __x)
  1296. { return __builtin_isfinite(__x); }
  1297. constexpr bool
  1298. isinf(_Float64 __x)
  1299. { return __builtin_isinf(__x); }
  1300. constexpr bool
  1301. isnan(_Float64 __x)
  1302. { return __builtin_isnan(__x); }
  1303. constexpr bool
  1304. isnormal(_Float64 __x)
  1305. { return __builtin_isnormal(__x); }
  1306. constexpr bool
  1307. signbit(_Float64 __x)
  1308. { return __builtin_signbit(__x); }
  1309. constexpr bool
  1310. isgreater(_Float64 __x, _Float64 __y)
  1311. { return __builtin_isgreater(__x, __y); }
  1312. constexpr bool
  1313. isgreaterequal(_Float64 __x, _Float64 __y)
  1314. { return __builtin_isgreaterequal(__x, __y); }
  1315. constexpr bool
  1316. isless(_Float64 __x, _Float64 __y)
  1317. { return __builtin_isless(__x, __y); }
  1318. constexpr bool
  1319. islessequal(_Float64 __x, _Float64 __y)
  1320. { return __builtin_islessequal(__x, __y); }
  1321. constexpr bool
  1322. islessgreater(_Float64 __x, _Float64 __y)
  1323. { return __builtin_islessgreater(__x, __y); }
  1324. constexpr bool
  1325. isunordered(_Float64 __x, _Float64 __y)
  1326. { return __builtin_isunordered(__x, __y); }
  1327. #endif
  1328. #ifdef __STDCPP_FLOAT128_T__
  1329. constexpr int
  1330. fpclassify(_Float128 __x)
  1331. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1332. FP_SUBNORMAL, FP_ZERO, __x); }
  1333. constexpr bool
  1334. isfinite(_Float128 __x)
  1335. { return __builtin_isfinite(__x); }
  1336. constexpr bool
  1337. isinf(_Float128 __x)
  1338. { return __builtin_isinf(__x); }
  1339. constexpr bool
  1340. isnan(_Float128 __x)
  1341. { return __builtin_isnan(__x); }
  1342. constexpr bool
  1343. isnormal(_Float128 __x)
  1344. { return __builtin_isnormal(__x); }
  1345. constexpr bool
  1346. signbit(_Float128 __x)
  1347. { return __builtin_signbit(__x); }
  1348. constexpr bool
  1349. isgreater(_Float128 __x, _Float128 __y)
  1350. { return __builtin_isgreater(__x, __y); }
  1351. constexpr bool
  1352. isgreaterequal(_Float128 __x, _Float128 __y)
  1353. { return __builtin_isgreaterequal(__x, __y); }
  1354. constexpr bool
  1355. isless(_Float128 __x, _Float128 __y)
  1356. { return __builtin_isless(__x, __y); }
  1357. constexpr bool
  1358. islessequal(_Float128 __x, _Float128 __y)
  1359. { return __builtin_islessequal(__x, __y); }
  1360. constexpr bool
  1361. islessgreater(_Float128 __x, _Float128 __y)
  1362. { return __builtin_islessgreater(__x, __y); }
  1363. constexpr bool
  1364. isunordered(_Float128 __x, _Float128 __y)
  1365. { return __builtin_isunordered(__x, __y); }
  1366. #endif
  1367. #ifdef __STDCPP_BFLOAT16_T__
  1368. constexpr int
  1369. fpclassify(__gnu_cxx::__bfloat16_t __x)
  1370. { return __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL,
  1371. FP_SUBNORMAL, FP_ZERO, __x); }
  1372. constexpr bool
  1373. isfinite(__gnu_cxx::__bfloat16_t __x)
  1374. { return __builtin_isfinite(__x); }
  1375. constexpr bool
  1376. isinf(__gnu_cxx::__bfloat16_t __x)
  1377. { return __builtin_isinf(__x); }
  1378. constexpr bool
  1379. isnan(__gnu_cxx::__bfloat16_t __x)
  1380. { return __builtin_isnan(__x); }
  1381. constexpr bool
  1382. isnormal(__gnu_cxx::__bfloat16_t __x)
  1383. { return __builtin_isnormal(__x); }
  1384. constexpr bool
  1385. signbit(__gnu_cxx::__bfloat16_t __x)
  1386. { return __builtin_signbit(__x); }
  1387. constexpr bool
  1388. isgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1389. { return __builtin_isgreater(__x, __y); }
  1390. constexpr bool
  1391. isgreaterequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1392. { return __builtin_isgreaterequal(__x, __y); }
  1393. constexpr bool
  1394. isless(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1395. { return __builtin_isless(__x, __y); }
  1396. constexpr bool
  1397. islessequal(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1398. { return __builtin_islessequal(__x, __y); }
  1399. constexpr bool
  1400. islessgreater(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1401. { return __builtin_islessgreater(__x, __y); }
  1402. constexpr bool
  1403. isunordered(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  1404. { return __builtin_isunordered(__x, __y); }
  1405. #endif
  1406. #endif /* _GLIBCXX_USE_C99_FP_MACROS_DYNAMIC */
  1407. #endif /* _GLIBCXX_USE_C99_MATH */
  1408. #if __cplusplus >= 201103L
  1409. #ifdef _GLIBCXX_USE_C99_MATH_TR1
  1410. #undef acosh
  1411. #undef acoshf
  1412. #undef acoshl
  1413. #undef asinh
  1414. #undef asinhf
  1415. #undef asinhl
  1416. #undef atanh
  1417. #undef atanhf
  1418. #undef atanhl
  1419. #undef cbrt
  1420. #undef cbrtf
  1421. #undef cbrtl
  1422. #undef copysign
  1423. #undef copysignf
  1424. #undef copysignl
  1425. #undef erf
  1426. #undef erff
  1427. #undef erfl
  1428. #undef erfc
  1429. #undef erfcf
  1430. #undef erfcl
  1431. #undef exp2
  1432. #undef exp2f
  1433. #undef exp2l
  1434. #undef expm1
  1435. #undef expm1f
  1436. #undef expm1l
  1437. #undef fdim
  1438. #undef fdimf
  1439. #undef fdiml
  1440. #undef fma
  1441. #undef fmaf
  1442. #undef fmal
  1443. #undef fmax
  1444. #undef fmaxf
  1445. #undef fmaxl
  1446. #undef fmin
  1447. #undef fminf
  1448. #undef fminl
  1449. #undef hypot
  1450. #undef hypotf
  1451. #undef hypotl
  1452. #undef ilogb
  1453. #undef ilogbf
  1454. #undef ilogbl
  1455. #undef lgamma
  1456. #undef lgammaf
  1457. #undef lgammal
  1458. #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
  1459. #undef llrint
  1460. #undef llrintf
  1461. #undef llrintl
  1462. #undef llround
  1463. #undef llroundf
  1464. #undef llroundl
  1465. #endif
  1466. #undef log1p
  1467. #undef log1pf
  1468. #undef log1pl
  1469. #undef log2
  1470. #undef log2f
  1471. #undef log2l
  1472. #undef logb
  1473. #undef logbf
  1474. #undef logbl
  1475. #undef lrint
  1476. #undef lrintf
  1477. #undef lrintl
  1478. #undef lround
  1479. #undef lroundf
  1480. #undef lroundl
  1481. #undef nan
  1482. #undef nanf
  1483. #undef nanl
  1484. #undef nearbyint
  1485. #undef nearbyintf
  1486. #undef nearbyintl
  1487. #undef nextafter
  1488. #undef nextafterf
  1489. #undef nextafterl
  1490. #undef nexttoward
  1491. #undef nexttowardf
  1492. #undef nexttowardl
  1493. #undef remainder
  1494. #undef remainderf
  1495. #undef remainderl
  1496. #undef remquo
  1497. #undef remquof
  1498. #undef remquol
  1499. #undef rint
  1500. #undef rintf
  1501. #undef rintl
  1502. #undef round
  1503. #undef roundf
  1504. #undef roundl
  1505. #undef scalbln
  1506. #undef scalblnf
  1507. #undef scalblnl
  1508. #undef scalbn
  1509. #undef scalbnf
  1510. #undef scalbnl
  1511. #undef tgamma
  1512. #undef tgammaf
  1513. #undef tgammal
  1514. #undef trunc
  1515. #undef truncf
  1516. #undef truncl
  1517. // types
  1518. using ::double_t;
  1519. using ::float_t;
  1520. // functions
  1521. using ::acosh;
  1522. using ::acoshf;
  1523. using ::acoshl;
  1524. using ::asinh;
  1525. using ::asinhf;
  1526. using ::asinhl;
  1527. using ::atanh;
  1528. using ::atanhf;
  1529. using ::atanhl;
  1530. using ::cbrt;
  1531. using ::cbrtf;
  1532. using ::cbrtl;
  1533. using ::copysign;
  1534. using ::copysignf;
  1535. using ::copysignl;
  1536. using ::erf;
  1537. using ::erff;
  1538. using ::erfl;
  1539. using ::erfc;
  1540. using ::erfcf;
  1541. using ::erfcl;
  1542. using ::exp2;
  1543. using ::exp2f;
  1544. using ::exp2l;
  1545. using ::expm1;
  1546. using ::expm1f;
  1547. using ::expm1l;
  1548. using ::fdim;
  1549. using ::fdimf;
  1550. using ::fdiml;
  1551. using ::fma;
  1552. using ::fmaf;
  1553. using ::fmal;
  1554. using ::fmax;
  1555. using ::fmaxf;
  1556. using ::fmaxl;
  1557. using ::fmin;
  1558. using ::fminf;
  1559. using ::fminl;
  1560. using ::hypot;
  1561. using ::hypotf;
  1562. using ::hypotl;
  1563. using ::ilogb;
  1564. using ::ilogbf;
  1565. using ::ilogbl;
  1566. using ::lgamma;
  1567. using ::lgammaf;
  1568. using ::lgammal;
  1569. #ifndef _GLIBCXX_NO_C99_ROUNDING_FUNCS
  1570. using ::llrint;
  1571. using ::llrintf;
  1572. using ::llrintl;
  1573. using ::llround;
  1574. using ::llroundf;
  1575. using ::llroundl;
  1576. #endif
  1577. using ::log1p;
  1578. using ::log1pf;
  1579. using ::log1pl;
  1580. using ::log2;
  1581. using ::log2f;
  1582. using ::log2l;
  1583. using ::logb;
  1584. using ::logbf;
  1585. using ::logbl;
  1586. using ::lrint;
  1587. using ::lrintf;
  1588. using ::lrintl;
  1589. using ::lround;
  1590. using ::lroundf;
  1591. using ::lroundl;
  1592. using ::nan;
  1593. using ::nanf;
  1594. using ::nanl;
  1595. using ::nearbyint;
  1596. using ::nearbyintf;
  1597. using ::nearbyintl;
  1598. using ::nextafter;
  1599. using ::nextafterf;
  1600. using ::nextafterl;
  1601. using ::nexttoward;
  1602. using ::nexttowardf;
  1603. using ::nexttowardl;
  1604. using ::remainder;
  1605. using ::remainderf;
  1606. using ::remainderl;
  1607. using ::remquo;
  1608. using ::remquof;
  1609. using ::remquol;
  1610. using ::rint;
  1611. using ::rintf;
  1612. using ::rintl;
  1613. using ::round;
  1614. using ::roundf;
  1615. using ::roundl;
  1616. using ::scalbln;
  1617. using ::scalblnf;
  1618. using ::scalblnl;
  1619. using ::scalbn;
  1620. using ::scalbnf;
  1621. using ::scalbnl;
  1622. using ::tgamma;
  1623. using ::tgammaf;
  1624. using ::tgammal;
  1625. using ::trunc;
  1626. using ::truncf;
  1627. using ::truncl;
  1628. /// Additional overloads.
  1629. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1630. constexpr float
  1631. acosh(float __x)
  1632. { return __builtin_acoshf(__x); }
  1633. constexpr long double
  1634. acosh(long double __x)
  1635. { return __builtin_acoshl(__x); }
  1636. #endif
  1637. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1638. template<typename _Tp>
  1639. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1640. double>::__type
  1641. acosh(_Tp __x)
  1642. { return __builtin_acosh(__x); }
  1643. #endif
  1644. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1645. constexpr float
  1646. asinh(float __x)
  1647. { return __builtin_asinhf(__x); }
  1648. constexpr long double
  1649. asinh(long double __x)
  1650. { return __builtin_asinhl(__x); }
  1651. #endif
  1652. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1653. template<typename _Tp>
  1654. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1655. double>::__type
  1656. asinh(_Tp __x)
  1657. { return __builtin_asinh(__x); }
  1658. #endif
  1659. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1660. constexpr float
  1661. atanh(float __x)
  1662. { return __builtin_atanhf(__x); }
  1663. constexpr long double
  1664. atanh(long double __x)
  1665. { return __builtin_atanhl(__x); }
  1666. #endif
  1667. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1668. template<typename _Tp>
  1669. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1670. double>::__type
  1671. atanh(_Tp __x)
  1672. { return __builtin_atanh(__x); }
  1673. #endif
  1674. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1675. constexpr float
  1676. cbrt(float __x)
  1677. { return __builtin_cbrtf(__x); }
  1678. constexpr long double
  1679. cbrt(long double __x)
  1680. { return __builtin_cbrtl(__x); }
  1681. #endif
  1682. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1683. template<typename _Tp>
  1684. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1685. double>::__type
  1686. cbrt(_Tp __x)
  1687. { return __builtin_cbrt(__x); }
  1688. #endif
  1689. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1690. constexpr float
  1691. copysign(float __x, float __y)
  1692. { return __builtin_copysignf(__x, __y); }
  1693. constexpr long double
  1694. copysign(long double __x, long double __y)
  1695. { return __builtin_copysignl(__x, __y); }
  1696. #endif
  1697. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1698. constexpr float
  1699. erf(float __x)
  1700. { return __builtin_erff(__x); }
  1701. constexpr long double
  1702. erf(long double __x)
  1703. { return __builtin_erfl(__x); }
  1704. #endif
  1705. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1706. template<typename _Tp>
  1707. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1708. double>::__type
  1709. erf(_Tp __x)
  1710. { return __builtin_erf(__x); }
  1711. #endif
  1712. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1713. constexpr float
  1714. erfc(float __x)
  1715. { return __builtin_erfcf(__x); }
  1716. constexpr long double
  1717. erfc(long double __x)
  1718. { return __builtin_erfcl(__x); }
  1719. #endif
  1720. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1721. template<typename _Tp>
  1722. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1723. double>::__type
  1724. erfc(_Tp __x)
  1725. { return __builtin_erfc(__x); }
  1726. #endif
  1727. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1728. constexpr float
  1729. exp2(float __x)
  1730. { return __builtin_exp2f(__x); }
  1731. constexpr long double
  1732. exp2(long double __x)
  1733. { return __builtin_exp2l(__x); }
  1734. #endif
  1735. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1736. template<typename _Tp>
  1737. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1738. double>::__type
  1739. exp2(_Tp __x)
  1740. { return __builtin_exp2(__x); }
  1741. #endif
  1742. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1743. constexpr float
  1744. expm1(float __x)
  1745. { return __builtin_expm1f(__x); }
  1746. constexpr long double
  1747. expm1(long double __x)
  1748. { return __builtin_expm1l(__x); }
  1749. #endif
  1750. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1751. template<typename _Tp>
  1752. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1753. double>::__type
  1754. expm1(_Tp __x)
  1755. { return __builtin_expm1(__x); }
  1756. #endif
  1757. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1758. constexpr float
  1759. fdim(float __x, float __y)
  1760. { return __builtin_fdimf(__x, __y); }
  1761. constexpr long double
  1762. fdim(long double __x, long double __y)
  1763. { return __builtin_fdiml(__x, __y); }
  1764. #endif
  1765. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1766. constexpr float
  1767. fma(float __x, float __y, float __z)
  1768. { return __builtin_fmaf(__x, __y, __z); }
  1769. constexpr long double
  1770. fma(long double __x, long double __y, long double __z)
  1771. { return __builtin_fmal(__x, __y, __z); }
  1772. #endif
  1773. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1774. constexpr float
  1775. fmax(float __x, float __y)
  1776. { return __builtin_fmaxf(__x, __y); }
  1777. constexpr long double
  1778. fmax(long double __x, long double __y)
  1779. { return __builtin_fmaxl(__x, __y); }
  1780. #endif
  1781. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1782. constexpr float
  1783. fmin(float __x, float __y)
  1784. { return __builtin_fminf(__x, __y); }
  1785. constexpr long double
  1786. fmin(long double __x, long double __y)
  1787. { return __builtin_fminl(__x, __y); }
  1788. #endif
  1789. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1790. constexpr float
  1791. hypot(float __x, float __y)
  1792. { return __builtin_hypotf(__x, __y); }
  1793. constexpr long double
  1794. hypot(long double __x, long double __y)
  1795. { return __builtin_hypotl(__x, __y); }
  1796. #endif
  1797. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1798. constexpr int
  1799. ilogb(float __x)
  1800. { return __builtin_ilogbf(__x); }
  1801. constexpr int
  1802. ilogb(long double __x)
  1803. { return __builtin_ilogbl(__x); }
  1804. #endif
  1805. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1806. template<typename _Tp>
  1807. constexpr
  1808. typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1809. int>::__type
  1810. ilogb(_Tp __x)
  1811. { return __builtin_ilogb(__x); }
  1812. #endif
  1813. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1814. constexpr float
  1815. lgamma(float __x)
  1816. { return __builtin_lgammaf(__x); }
  1817. constexpr long double
  1818. lgamma(long double __x)
  1819. { return __builtin_lgammal(__x); }
  1820. #endif
  1821. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1822. template<typename _Tp>
  1823. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1824. double>::__type
  1825. lgamma(_Tp __x)
  1826. { return __builtin_lgamma(__x); }
  1827. #endif
  1828. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1829. constexpr long long
  1830. llrint(float __x)
  1831. { return __builtin_llrintf(__x); }
  1832. constexpr long long
  1833. llrint(long double __x)
  1834. { return __builtin_llrintl(__x); }
  1835. #endif
  1836. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1837. template<typename _Tp>
  1838. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1839. long long>::__type
  1840. llrint(_Tp __x)
  1841. { return __builtin_llrint(__x); }
  1842. #endif
  1843. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1844. constexpr long long
  1845. llround(float __x)
  1846. { return __builtin_llroundf(__x); }
  1847. constexpr long long
  1848. llround(long double __x)
  1849. { return __builtin_llroundl(__x); }
  1850. #endif
  1851. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1852. template<typename _Tp>
  1853. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1854. long long>::__type
  1855. llround(_Tp __x)
  1856. { return __builtin_llround(__x); }
  1857. #endif
  1858. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1859. constexpr float
  1860. log1p(float __x)
  1861. { return __builtin_log1pf(__x); }
  1862. constexpr long double
  1863. log1p(long double __x)
  1864. { return __builtin_log1pl(__x); }
  1865. #endif
  1866. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1867. template<typename _Tp>
  1868. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1869. double>::__type
  1870. log1p(_Tp __x)
  1871. { return __builtin_log1p(__x); }
  1872. #endif
  1873. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1874. // DR 568.
  1875. constexpr float
  1876. log2(float __x)
  1877. { return __builtin_log2f(__x); }
  1878. constexpr long double
  1879. log2(long double __x)
  1880. { return __builtin_log2l(__x); }
  1881. #endif
  1882. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1883. template<typename _Tp>
  1884. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1885. double>::__type
  1886. log2(_Tp __x)
  1887. { return __builtin_log2(__x); }
  1888. #endif
  1889. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1890. constexpr float
  1891. logb(float __x)
  1892. { return __builtin_logbf(__x); }
  1893. constexpr long double
  1894. logb(long double __x)
  1895. { return __builtin_logbl(__x); }
  1896. #endif
  1897. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1898. template<typename _Tp>
  1899. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1900. double>::__type
  1901. logb(_Tp __x)
  1902. { return __builtin_logb(__x); }
  1903. #endif
  1904. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1905. constexpr long
  1906. lrint(float __x)
  1907. { return __builtin_lrintf(__x); }
  1908. constexpr long
  1909. lrint(long double __x)
  1910. { return __builtin_lrintl(__x); }
  1911. #endif
  1912. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1913. template<typename _Tp>
  1914. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1915. long>::__type
  1916. lrint(_Tp __x)
  1917. { return __builtin_lrint(__x); }
  1918. #endif
  1919. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1920. constexpr long
  1921. lround(float __x)
  1922. { return __builtin_lroundf(__x); }
  1923. constexpr long
  1924. lround(long double __x)
  1925. { return __builtin_lroundl(__x); }
  1926. #endif
  1927. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1928. template<typename _Tp>
  1929. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1930. long>::__type
  1931. lround(_Tp __x)
  1932. { return __builtin_lround(__x); }
  1933. #endif
  1934. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1935. constexpr float
  1936. nearbyint(float __x)
  1937. { return __builtin_nearbyintf(__x); }
  1938. constexpr long double
  1939. nearbyint(long double __x)
  1940. { return __builtin_nearbyintl(__x); }
  1941. #endif
  1942. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1943. template<typename _Tp>
  1944. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1945. double>::__type
  1946. nearbyint(_Tp __x)
  1947. { return __builtin_nearbyint(__x); }
  1948. #endif
  1949. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1950. constexpr float
  1951. nextafter(float __x, float __y)
  1952. { return __builtin_nextafterf(__x, __y); }
  1953. constexpr long double
  1954. nextafter(long double __x, long double __y)
  1955. { return __builtin_nextafterl(__x, __y); }
  1956. #endif
  1957. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1958. constexpr float
  1959. nexttoward(float __x, long double __y)
  1960. { return __builtin_nexttowardf(__x, __y); }
  1961. constexpr long double
  1962. nexttoward(long double __x, long double __y)
  1963. { return __builtin_nexttowardl(__x, __y); }
  1964. #endif
  1965. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1966. template<typename _Tp>
  1967. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1968. double>::__type
  1969. nexttoward(_Tp __x, long double __y)
  1970. { return __builtin_nexttoward(__x, __y); }
  1971. #endif
  1972. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1973. constexpr float
  1974. remainder(float __x, float __y)
  1975. { return __builtin_remainderf(__x, __y); }
  1976. constexpr long double
  1977. remainder(long double __x, long double __y)
  1978. { return __builtin_remainderl(__x, __y); }
  1979. #endif
  1980. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1981. inline float
  1982. remquo(float __x, float __y, int* __pquo)
  1983. { return __builtin_remquof(__x, __y, __pquo); }
  1984. inline long double
  1985. remquo(long double __x, long double __y, int* __pquo)
  1986. { return __builtin_remquol(__x, __y, __pquo); }
  1987. #endif
  1988. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  1989. constexpr float
  1990. rint(float __x)
  1991. { return __builtin_rintf(__x); }
  1992. constexpr long double
  1993. rint(long double __x)
  1994. { return __builtin_rintl(__x); }
  1995. #endif
  1996. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  1997. template<typename _Tp>
  1998. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  1999. double>::__type
  2000. rint(_Tp __x)
  2001. { return __builtin_rint(__x); }
  2002. #endif
  2003. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2004. constexpr float
  2005. round(float __x)
  2006. { return __builtin_roundf(__x); }
  2007. constexpr long double
  2008. round(long double __x)
  2009. { return __builtin_roundl(__x); }
  2010. #endif
  2011. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2012. template<typename _Tp>
  2013. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  2014. double>::__type
  2015. round(_Tp __x)
  2016. { return __builtin_round(__x); }
  2017. #endif
  2018. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2019. constexpr float
  2020. scalbln(float __x, long __ex)
  2021. { return __builtin_scalblnf(__x, __ex); }
  2022. constexpr long double
  2023. scalbln(long double __x, long __ex)
  2024. { return __builtin_scalblnl(__x, __ex); }
  2025. #endif
  2026. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2027. template<typename _Tp>
  2028. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  2029. double>::__type
  2030. scalbln(_Tp __x, long __ex)
  2031. { return __builtin_scalbln(__x, __ex); }
  2032. #endif
  2033. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2034. constexpr float
  2035. scalbn(float __x, int __ex)
  2036. { return __builtin_scalbnf(__x, __ex); }
  2037. constexpr long double
  2038. scalbn(long double __x, int __ex)
  2039. { return __builtin_scalbnl(__x, __ex); }
  2040. #endif
  2041. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2042. template<typename _Tp>
  2043. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  2044. double>::__type
  2045. scalbn(_Tp __x, int __ex)
  2046. { return __builtin_scalbn(__x, __ex); }
  2047. #endif
  2048. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2049. constexpr float
  2050. tgamma(float __x)
  2051. { return __builtin_tgammaf(__x); }
  2052. constexpr long double
  2053. tgamma(long double __x)
  2054. { return __builtin_tgammal(__x); }
  2055. #endif
  2056. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2057. template<typename _Tp>
  2058. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  2059. double>::__type
  2060. tgamma(_Tp __x)
  2061. { return __builtin_tgamma(__x); }
  2062. #endif
  2063. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_FP
  2064. constexpr float
  2065. trunc(float __x)
  2066. { return __builtin_truncf(__x); }
  2067. constexpr long double
  2068. trunc(long double __x)
  2069. { return __builtin_truncl(__x); }
  2070. #endif
  2071. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2072. template<typename _Tp>
  2073. constexpr typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value,
  2074. double>::__type
  2075. trunc(_Tp __x)
  2076. { return __builtin_trunc(__x); }
  2077. #endif
  2078. #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2079. constexpr _Float16
  2080. acosh(_Float16 __x)
  2081. { return _Float16(__builtin_acoshf(__x)); }
  2082. constexpr _Float16
  2083. asinh(_Float16 __x)
  2084. { return _Float16(__builtin_asinhf(__x)); }
  2085. constexpr _Float16
  2086. atanh(_Float16 __x)
  2087. { return _Float16(__builtin_atanhf(__x)); }
  2088. constexpr _Float16
  2089. cbrt(_Float16 __x)
  2090. { return _Float16(__builtin_cbrtf(__x)); }
  2091. constexpr _Float16
  2092. copysign(_Float16 __x, _Float16 __y)
  2093. { return __builtin_copysignf16(__x, __y); }
  2094. constexpr _Float16
  2095. erf(_Float16 __x)
  2096. { return _Float16(__builtin_erff(__x)); }
  2097. constexpr _Float16
  2098. erfc(_Float16 __x)
  2099. { return _Float16(__builtin_erfcf(__x)); }
  2100. constexpr _Float16
  2101. exp2(_Float16 __x)
  2102. { return _Float16(__builtin_exp2f(__x)); }
  2103. constexpr _Float16
  2104. expm1(_Float16 __x)
  2105. { return _Float16(__builtin_expm1f(__x)); }
  2106. constexpr _Float16
  2107. fdim(_Float16 __x, _Float16 __y)
  2108. { return _Float16(__builtin_fdimf(__x, __y)); }
  2109. constexpr _Float16
  2110. fma(_Float16 __x, _Float16 __y, _Float16 __z)
  2111. { return _Float16(__builtin_fmaf(__x, __y, __z)); }
  2112. constexpr _Float16
  2113. fmax(_Float16 __x, _Float16 __y)
  2114. { return _Float16(__builtin_fmaxf(__x, __y)); }
  2115. constexpr _Float16
  2116. fmin(_Float16 __x, _Float16 __y)
  2117. { return _Float16(__builtin_fminf(__x, __y)); }
  2118. constexpr _Float16
  2119. hypot(_Float16 __x, _Float16 __y)
  2120. { return _Float16(__builtin_hypotf(__x, __y)); }
  2121. constexpr int
  2122. ilogb(_Float16 __x)
  2123. { return _Float16(__builtin_ilogbf(__x)); }
  2124. constexpr _Float16
  2125. lgamma(_Float16 __x)
  2126. { return _Float16(__builtin_lgammaf(__x)); }
  2127. constexpr long long
  2128. llrint(_Float16 __x)
  2129. { return _Float16(__builtin_llrintf(__x)); }
  2130. constexpr long long
  2131. llround(_Float16 __x)
  2132. { return _Float16(__builtin_llroundf(__x)); }
  2133. constexpr _Float16
  2134. log1p(_Float16 __x)
  2135. { return _Float16(__builtin_log1pf(__x)); }
  2136. // DR 568.
  2137. constexpr _Float16
  2138. log2(_Float16 __x)
  2139. { return _Float16(__builtin_log2f(__x)); }
  2140. constexpr _Float16
  2141. logb(_Float16 __x)
  2142. { return _Float16(__builtin_logbf(__x)); }
  2143. constexpr long
  2144. lrint(_Float16 __x)
  2145. { return _Float16(__builtin_lrintf(__x)); }
  2146. constexpr long
  2147. lround(_Float16 __x)
  2148. { return _Float16(__builtin_lroundf(__x)); }
  2149. constexpr _Float16
  2150. nearbyint(_Float16 __x)
  2151. { return _Float16(__builtin_nearbyintf(__x)); }
  2152. constexpr _Float16
  2153. nextafter(_Float16 __x, _Float16 __y)
  2154. {
  2155. if (std::__is_constant_evaluated())
  2156. return __builtin_nextafterf16(__x, __y);
  2157. #ifdef __INT16_TYPE__
  2158. using __float16_int_type = __INT16_TYPE__;
  2159. #else
  2160. using __float16_int_type = short int;
  2161. #endif
  2162. __float16_int_type __hx, __hy, __ix, __iy;
  2163. __builtin_memcpy(&__hx, &__x, sizeof(__x));
  2164. __builtin_memcpy(&__hy, &__y, sizeof(__x));
  2165. __ix = __hx & 0x7fff; // |x|
  2166. __iy = __hy & 0x7fff; // |y|
  2167. if (__ix > 0x7c00 || __iy > 0x7c00) // x or y is NaN
  2168. return __x + __y;
  2169. if (__x == __y)
  2170. return __y; // x == y, return y
  2171. if (__ix == 0) // x == 0
  2172. {
  2173. __hy = (__hy & 0x8000) | 1; // return +-__FLT16_DENORM_MIN__
  2174. __builtin_memcpy(&__x, &__hy, sizeof(__x));
  2175. __builtin_nextafterf(0.0f, 1.0f); // raise underflow
  2176. return __x;
  2177. }
  2178. if (__hx >= 0) // x > 0
  2179. {
  2180. if (__hx > __hy) // x > y, x -= ulp
  2181. --__hx;
  2182. else // x < y, x += ulp
  2183. ++__hx;
  2184. }
  2185. else // x < 0
  2186. {
  2187. if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
  2188. --__hx;
  2189. else // x > y, x += ulp
  2190. ++__hx;
  2191. }
  2192. __hy = __hx & 0x7c00;
  2193. if (__hy >= 0x7c00)
  2194. __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
  2195. else if (__hy < 0x0400)
  2196. __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
  2197. __builtin_memcpy(&__x, &__hx, sizeof(__x));
  2198. return __x;
  2199. }
  2200. constexpr _Float16
  2201. remainder(_Float16 __x, _Float16 __y)
  2202. { return _Float16(__builtin_remainderf(__x, __y)); }
  2203. inline _Float16
  2204. remquo(_Float16 __x, _Float16 __y, int* __pquo)
  2205. { return _Float16(__builtin_remquof(__x, __y, __pquo)); }
  2206. constexpr _Float16
  2207. rint(_Float16 __x)
  2208. { return _Float16(__builtin_rintf(__x)); }
  2209. constexpr _Float16
  2210. round(_Float16 __x)
  2211. { return _Float16(__builtin_roundf(__x)); }
  2212. constexpr _Float16
  2213. scalbln(_Float16 __x, long __ex)
  2214. { return _Float16(__builtin_scalblnf(__x, __ex)); }
  2215. constexpr _Float16
  2216. scalbn(_Float16 __x, int __ex)
  2217. { return _Float16(__builtin_scalbnf(__x, __ex)); }
  2218. constexpr _Float16
  2219. tgamma(_Float16 __x)
  2220. { return _Float16(__builtin_tgammaf(__x)); }
  2221. constexpr _Float16
  2222. trunc(_Float16 __x)
  2223. { return _Float16(__builtin_truncf(__x)); }
  2224. #endif
  2225. #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2226. constexpr _Float32
  2227. acosh(_Float32 __x)
  2228. { return __builtin_acoshf(__x); }
  2229. constexpr _Float32
  2230. asinh(_Float32 __x)
  2231. { return __builtin_asinhf(__x); }
  2232. constexpr _Float32
  2233. atanh(_Float32 __x)
  2234. { return __builtin_atanhf(__x); }
  2235. constexpr _Float32
  2236. cbrt(_Float32 __x)
  2237. { return __builtin_cbrtf(__x); }
  2238. constexpr _Float32
  2239. copysign(_Float32 __x, _Float32 __y)
  2240. { return __builtin_copysignf(__x, __y); }
  2241. constexpr _Float32
  2242. erf(_Float32 __x)
  2243. { return __builtin_erff(__x); }
  2244. constexpr _Float32
  2245. erfc(_Float32 __x)
  2246. { return __builtin_erfcf(__x); }
  2247. constexpr _Float32
  2248. exp2(_Float32 __x)
  2249. { return __builtin_exp2f(__x); }
  2250. constexpr _Float32
  2251. expm1(_Float32 __x)
  2252. { return __builtin_expm1f(__x); }
  2253. constexpr _Float32
  2254. fdim(_Float32 __x, _Float32 __y)
  2255. { return __builtin_fdimf(__x, __y); }
  2256. constexpr _Float32
  2257. fma(_Float32 __x, _Float32 __y, _Float32 __z)
  2258. { return __builtin_fmaf(__x, __y, __z); }
  2259. constexpr _Float32
  2260. fmax(_Float32 __x, _Float32 __y)
  2261. { return __builtin_fmaxf(__x, __y); }
  2262. constexpr _Float32
  2263. fmin(_Float32 __x, _Float32 __y)
  2264. { return __builtin_fminf(__x, __y); }
  2265. constexpr _Float32
  2266. hypot(_Float32 __x, _Float32 __y)
  2267. { return __builtin_hypotf(__x, __y); }
  2268. constexpr int
  2269. ilogb(_Float32 __x)
  2270. { return __builtin_ilogbf(__x); }
  2271. constexpr _Float32
  2272. lgamma(_Float32 __x)
  2273. { return __builtin_lgammaf(__x); }
  2274. constexpr long long
  2275. llrint(_Float32 __x)
  2276. { return __builtin_llrintf(__x); }
  2277. constexpr long long
  2278. llround(_Float32 __x)
  2279. { return __builtin_llroundf(__x); }
  2280. constexpr _Float32
  2281. log1p(_Float32 __x)
  2282. { return __builtin_log1pf(__x); }
  2283. // DR 568.
  2284. constexpr _Float32
  2285. log2(_Float32 __x)
  2286. { return __builtin_log2f(__x); }
  2287. constexpr _Float32
  2288. logb(_Float32 __x)
  2289. { return __builtin_logbf(__x); }
  2290. constexpr long
  2291. lrint(_Float32 __x)
  2292. { return __builtin_lrintf(__x); }
  2293. constexpr long
  2294. lround(_Float32 __x)
  2295. { return __builtin_lroundf(__x); }
  2296. constexpr _Float32
  2297. nearbyint(_Float32 __x)
  2298. { return __builtin_nearbyintf(__x); }
  2299. constexpr _Float32
  2300. nextafter(_Float32 __x, _Float32 __y)
  2301. { return __builtin_nextafterf(__x, __y); }
  2302. constexpr _Float32
  2303. remainder(_Float32 __x, _Float32 __y)
  2304. { return __builtin_remainderf(__x, __y); }
  2305. inline _Float32
  2306. remquo(_Float32 __x, _Float32 __y, int* __pquo)
  2307. { return __builtin_remquof(__x, __y, __pquo); }
  2308. constexpr _Float32
  2309. rint(_Float32 __x)
  2310. { return __builtin_rintf(__x); }
  2311. constexpr _Float32
  2312. round(_Float32 __x)
  2313. { return __builtin_roundf(__x); }
  2314. constexpr _Float32
  2315. scalbln(_Float32 __x, long __ex)
  2316. { return __builtin_scalblnf(__x, __ex); }
  2317. constexpr _Float32
  2318. scalbn(_Float32 __x, int __ex)
  2319. { return __builtin_scalbnf(__x, __ex); }
  2320. constexpr _Float32
  2321. tgamma(_Float32 __x)
  2322. { return __builtin_tgammaf(__x); }
  2323. constexpr _Float32
  2324. trunc(_Float32 __x)
  2325. { return __builtin_truncf(__x); }
  2326. #endif
  2327. #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
  2328. constexpr _Float64
  2329. acosh(_Float64 __x)
  2330. { return __builtin_acosh(__x); }
  2331. constexpr _Float64
  2332. asinh(_Float64 __x)
  2333. { return __builtin_asinh(__x); }
  2334. constexpr _Float64
  2335. atanh(_Float64 __x)
  2336. { return __builtin_atanh(__x); }
  2337. constexpr _Float64
  2338. cbrt(_Float64 __x)
  2339. { return __builtin_cbrt(__x); }
  2340. constexpr _Float64
  2341. copysign(_Float64 __x, _Float64 __y)
  2342. { return __builtin_copysign(__x, __y); }
  2343. constexpr _Float64
  2344. erf(_Float64 __x)
  2345. { return __builtin_erf(__x); }
  2346. constexpr _Float64
  2347. erfc(_Float64 __x)
  2348. { return __builtin_erfc(__x); }
  2349. constexpr _Float64
  2350. exp2(_Float64 __x)
  2351. { return __builtin_exp2(__x); }
  2352. constexpr _Float64
  2353. expm1(_Float64 __x)
  2354. { return __builtin_expm1(__x); }
  2355. constexpr _Float64
  2356. fdim(_Float64 __x, _Float64 __y)
  2357. { return __builtin_fdim(__x, __y); }
  2358. constexpr _Float64
  2359. fma(_Float64 __x, _Float64 __y, _Float64 __z)
  2360. { return __builtin_fma(__x, __y, __z); }
  2361. constexpr _Float64
  2362. fmax(_Float64 __x, _Float64 __y)
  2363. { return __builtin_fmax(__x, __y); }
  2364. constexpr _Float64
  2365. fmin(_Float64 __x, _Float64 __y)
  2366. { return __builtin_fmin(__x, __y); }
  2367. constexpr _Float64
  2368. hypot(_Float64 __x, _Float64 __y)
  2369. { return __builtin_hypot(__x, __y); }
  2370. constexpr int
  2371. ilogb(_Float64 __x)
  2372. { return __builtin_ilogb(__x); }
  2373. constexpr _Float64
  2374. lgamma(_Float64 __x)
  2375. { return __builtin_lgamma(__x); }
  2376. constexpr long long
  2377. llrint(_Float64 __x)
  2378. { return __builtin_llrint(__x); }
  2379. constexpr long long
  2380. llround(_Float64 __x)
  2381. { return __builtin_llround(__x); }
  2382. constexpr _Float64
  2383. log1p(_Float64 __x)
  2384. { return __builtin_log1p(__x); }
  2385. // DR 568.
  2386. constexpr _Float64
  2387. log2(_Float64 __x)
  2388. { return __builtin_log2(__x); }
  2389. constexpr _Float64
  2390. logb(_Float64 __x)
  2391. { return __builtin_logb(__x); }
  2392. constexpr long
  2393. lrint(_Float64 __x)
  2394. { return __builtin_lrint(__x); }
  2395. constexpr long
  2396. lround(_Float64 __x)
  2397. { return __builtin_lround(__x); }
  2398. constexpr _Float64
  2399. nearbyint(_Float64 __x)
  2400. { return __builtin_nearbyint(__x); }
  2401. constexpr _Float64
  2402. nextafter(_Float64 __x, _Float64 __y)
  2403. { return __builtin_nextafter(__x, __y); }
  2404. constexpr _Float64
  2405. remainder(_Float64 __x, _Float64 __y)
  2406. { return __builtin_remainder(__x, __y); }
  2407. inline _Float64
  2408. remquo(_Float64 __x, _Float64 __y, int* __pquo)
  2409. { return __builtin_remquo(__x, __y, __pquo); }
  2410. constexpr _Float64
  2411. rint(_Float64 __x)
  2412. { return __builtin_rint(__x); }
  2413. constexpr _Float64
  2414. round(_Float64 __x)
  2415. { return __builtin_round(__x); }
  2416. constexpr _Float64
  2417. scalbln(_Float64 __x, long __ex)
  2418. { return __builtin_scalbln(__x, __ex); }
  2419. constexpr _Float64
  2420. scalbn(_Float64 __x, int __ex)
  2421. { return __builtin_scalbn(__x, __ex); }
  2422. constexpr _Float64
  2423. tgamma(_Float64 __x)
  2424. { return __builtin_tgamma(__x); }
  2425. constexpr _Float64
  2426. trunc(_Float64 __x)
  2427. { return __builtin_trunc(__x); }
  2428. #endif
  2429. #if defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128)
  2430. constexpr _Float128
  2431. acosh(_Float128 __x)
  2432. { return __builtin_acoshl(__x); }
  2433. constexpr _Float128
  2434. asinh(_Float128 __x)
  2435. { return __builtin_asinhl(__x); }
  2436. constexpr _Float128
  2437. atanh(_Float128 __x)
  2438. { return __builtin_atanhl(__x); }
  2439. constexpr _Float128
  2440. cbrt(_Float128 __x)
  2441. { return __builtin_cbrtl(__x); }
  2442. constexpr _Float128
  2443. copysign(_Float128 __x, _Float128 __y)
  2444. { return __builtin_copysignl(__x, __y); }
  2445. constexpr _Float128
  2446. erf(_Float128 __x)
  2447. { return __builtin_erfl(__x); }
  2448. constexpr _Float128
  2449. erfc(_Float128 __x)
  2450. { return __builtin_erfcl(__x); }
  2451. constexpr _Float128
  2452. exp2(_Float128 __x)
  2453. { return __builtin_exp2l(__x); }
  2454. constexpr _Float128
  2455. expm1(_Float128 __x)
  2456. { return __builtin_expm1l(__x); }
  2457. constexpr _Float128
  2458. fdim(_Float128 __x, _Float128 __y)
  2459. { return __builtin_fdiml(__x, __y); }
  2460. constexpr _Float128
  2461. fma(_Float128 __x, _Float128 __y, _Float128 __z)
  2462. { return __builtin_fmal(__x, __y, __z); }
  2463. constexpr _Float128
  2464. fmax(_Float128 __x, _Float128 __y)
  2465. { return __builtin_fmaxl(__x, __y); }
  2466. constexpr _Float128
  2467. fmin(_Float128 __x, _Float128 __y)
  2468. { return __builtin_fminl(__x, __y); }
  2469. constexpr _Float128
  2470. hypot(_Float128 __x, _Float128 __y)
  2471. { return __builtin_hypotl(__x, __y); }
  2472. constexpr int
  2473. ilogb(_Float128 __x)
  2474. { return __builtin_ilogbl(__x); }
  2475. constexpr _Float128
  2476. lgamma(_Float128 __x)
  2477. { return __builtin_lgammal(__x); }
  2478. constexpr long long
  2479. llrint(_Float128 __x)
  2480. { return __builtin_llrintl(__x); }
  2481. constexpr long long
  2482. llround(_Float128 __x)
  2483. { return __builtin_llroundl(__x); }
  2484. constexpr _Float128
  2485. log1p(_Float128 __x)
  2486. { return __builtin_log1pl(__x); }
  2487. // DR 568.
  2488. constexpr _Float128
  2489. log2(_Float128 __x)
  2490. { return __builtin_log2l(__x); }
  2491. constexpr _Float128
  2492. logb(_Float128 __x)
  2493. { return __builtin_logbl(__x); }
  2494. constexpr long
  2495. lrint(_Float128 __x)
  2496. { return __builtin_lrintl(__x); }
  2497. constexpr long
  2498. lround(_Float128 __x)
  2499. { return __builtin_lroundl(__x); }
  2500. constexpr _Float128
  2501. nearbyint(_Float128 __x)
  2502. { return __builtin_nearbyintl(__x); }
  2503. constexpr _Float128
  2504. nextafter(_Float128 __x, _Float128 __y)
  2505. { return __builtin_nextafterl(__x, __y); }
  2506. constexpr _Float128
  2507. remainder(_Float128 __x, _Float128 __y)
  2508. { return __builtin_remainderl(__x, __y); }
  2509. inline _Float128
  2510. remquo(_Float128 __x, _Float128 __y, int* __pquo)
  2511. { return __builtin_remquol(__x, __y, __pquo); }
  2512. constexpr _Float128
  2513. rint(_Float128 __x)
  2514. { return __builtin_rintl(__x); }
  2515. constexpr _Float128
  2516. round(_Float128 __x)
  2517. { return __builtin_roundl(__x); }
  2518. constexpr _Float128
  2519. scalbln(_Float128 __x, long __ex)
  2520. { return __builtin_scalblnl(__x, __ex); }
  2521. constexpr _Float128
  2522. scalbn(_Float128 __x, int __ex)
  2523. { return __builtin_scalbnl(__x, __ex); }
  2524. constexpr _Float128
  2525. tgamma(_Float128 __x)
  2526. { return __builtin_tgammal(__x); }
  2527. constexpr _Float128
  2528. trunc(_Float128 __x)
  2529. { return __builtin_truncl(__x); }
  2530. #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
  2531. constexpr _Float128
  2532. acosh(_Float128 __x)
  2533. { return __builtin_acoshf128(__x); }
  2534. constexpr _Float128
  2535. asinh(_Float128 __x)
  2536. { return __builtin_asinhf128(__x); }
  2537. constexpr _Float128
  2538. atanh(_Float128 __x)
  2539. { return __builtin_atanhf128(__x); }
  2540. constexpr _Float128
  2541. cbrt(_Float128 __x)
  2542. { return __builtin_cbrtf128(__x); }
  2543. constexpr _Float128
  2544. copysign(_Float128 __x, _Float128 __y)
  2545. { return __builtin_copysignf128(__x, __y); }
  2546. constexpr _Float128
  2547. erf(_Float128 __x)
  2548. { return __builtin_erff128(__x); }
  2549. constexpr _Float128
  2550. erfc(_Float128 __x)
  2551. { return __builtin_erfcf128(__x); }
  2552. constexpr _Float128
  2553. exp2(_Float128 __x)
  2554. { return __builtin_exp2f128(__x); }
  2555. constexpr _Float128
  2556. expm1(_Float128 __x)
  2557. { return __builtin_expm1f128(__x); }
  2558. constexpr _Float128
  2559. fdim(_Float128 __x, _Float128 __y)
  2560. { return __builtin_fdimf128(__x, __y); }
  2561. constexpr _Float128
  2562. fma(_Float128 __x, _Float128 __y, _Float128 __z)
  2563. { return __builtin_fmaf128(__x, __y, __z); }
  2564. constexpr _Float128
  2565. fmax(_Float128 __x, _Float128 __y)
  2566. { return __builtin_fmaxf128(__x, __y); }
  2567. constexpr _Float128
  2568. fmin(_Float128 __x, _Float128 __y)
  2569. { return __builtin_fminf128(__x, __y); }
  2570. constexpr _Float128
  2571. hypot(_Float128 __x, _Float128 __y)
  2572. { return __builtin_hypotf128(__x, __y); }
  2573. constexpr int
  2574. ilogb(_Float128 __x)
  2575. { return __builtin_ilogbf128(__x); }
  2576. constexpr _Float128
  2577. lgamma(_Float128 __x)
  2578. { return __builtin_lgammaf128(__x); }
  2579. constexpr long long
  2580. llrint(_Float128 __x)
  2581. { return __builtin_llrintf128(__x); }
  2582. constexpr long long
  2583. llround(_Float128 __x)
  2584. { return __builtin_llroundf128(__x); }
  2585. constexpr _Float128
  2586. log1p(_Float128 __x)
  2587. { return __builtin_log1pf128(__x); }
  2588. // DR 568.
  2589. constexpr _Float128
  2590. log2(_Float128 __x)
  2591. { return __builtin_log2f128(__x); }
  2592. constexpr _Float128
  2593. logb(_Float128 __x)
  2594. { return __builtin_logbf128(__x); }
  2595. constexpr long
  2596. lrint(_Float128 __x)
  2597. { return __builtin_lrintf128(__x); }
  2598. constexpr long
  2599. lround(_Float128 __x)
  2600. { return __builtin_lroundf128(__x); }
  2601. constexpr _Float128
  2602. nearbyint(_Float128 __x)
  2603. { return __builtin_nearbyintf128(__x); }
  2604. constexpr _Float128
  2605. nextafter(_Float128 __x, _Float128 __y)
  2606. { return __builtin_nextafterf128(__x, __y); }
  2607. constexpr _Float128
  2608. remainder(_Float128 __x, _Float128 __y)
  2609. { return __builtin_remainderf128(__x, __y); }
  2610. inline _Float128
  2611. remquo(_Float128 __x, _Float128 __y, int* __pquo)
  2612. { return __builtin_remquof128(__x, __y, __pquo); }
  2613. constexpr _Float128
  2614. rint(_Float128 __x)
  2615. { return __builtin_rintf128(__x); }
  2616. constexpr _Float128
  2617. round(_Float128 __x)
  2618. { return __builtin_roundf128(__x); }
  2619. constexpr _Float128
  2620. scalbln(_Float128 __x, long __ex)
  2621. { return __builtin_scalblnf128(__x, __ex); }
  2622. constexpr _Float128
  2623. scalbn(_Float128 __x, int __ex)
  2624. { return __builtin_scalbnf128(__x, __ex); }
  2625. constexpr _Float128
  2626. tgamma(_Float128 __x)
  2627. { return __builtin_tgammaf128(__x); }
  2628. constexpr _Float128
  2629. trunc(_Float128 __x)
  2630. { return __builtin_truncf128(__x); }
  2631. #endif
  2632. #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2633. constexpr __gnu_cxx::__bfloat16_t
  2634. acosh(__gnu_cxx::__bfloat16_t __x)
  2635. { return __gnu_cxx::__bfloat16_t(__builtin_acoshf(__x)); }
  2636. constexpr __gnu_cxx::__bfloat16_t
  2637. asinh(__gnu_cxx::__bfloat16_t __x)
  2638. { return __gnu_cxx::__bfloat16_t(__builtin_asinhf(__x)); }
  2639. constexpr __gnu_cxx::__bfloat16_t
  2640. atanh(__gnu_cxx::__bfloat16_t __x)
  2641. { return __gnu_cxx::__bfloat16_t(__builtin_atanhf(__x)); }
  2642. constexpr __gnu_cxx::__bfloat16_t
  2643. cbrt(__gnu_cxx::__bfloat16_t __x)
  2644. { return __gnu_cxx::__bfloat16_t(__builtin_cbrtf(__x)); }
  2645. constexpr __gnu_cxx::__bfloat16_t
  2646. copysign(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2647. { return __gnu_cxx::__bfloat16_t(__builtin_copysignf(__x, __y)); }
  2648. constexpr __gnu_cxx::__bfloat16_t
  2649. erf(__gnu_cxx::__bfloat16_t __x)
  2650. { return __gnu_cxx::__bfloat16_t(__builtin_erff(__x)); }
  2651. constexpr __gnu_cxx::__bfloat16_t
  2652. erfc(__gnu_cxx::__bfloat16_t __x)
  2653. { return __gnu_cxx::__bfloat16_t(__builtin_erfcf(__x)); }
  2654. constexpr __gnu_cxx::__bfloat16_t
  2655. exp2(__gnu_cxx::__bfloat16_t __x)
  2656. { return __gnu_cxx::__bfloat16_t(__builtin_exp2f(__x)); }
  2657. constexpr __gnu_cxx::__bfloat16_t
  2658. expm1(__gnu_cxx::__bfloat16_t __x)
  2659. { return __gnu_cxx::__bfloat16_t(__builtin_expm1f(__x)); }
  2660. constexpr __gnu_cxx::__bfloat16_t
  2661. fdim(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2662. { return __gnu_cxx::__bfloat16_t(__builtin_fdimf(__x, __y)); }
  2663. constexpr __gnu_cxx::__bfloat16_t
  2664. fma(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
  2665. { return __gnu_cxx::__bfloat16_t(__builtin_fmaf(__x, __y, __z)); }
  2666. constexpr __gnu_cxx::__bfloat16_t
  2667. fmax(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2668. { return __gnu_cxx::__bfloat16_t(__builtin_fmaxf(__x, __y)); }
  2669. constexpr __gnu_cxx::__bfloat16_t
  2670. fmin(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2671. { return __gnu_cxx::__bfloat16_t(__builtin_fminf(__x, __y)); }
  2672. constexpr __gnu_cxx::__bfloat16_t
  2673. hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2674. { return __gnu_cxx::__bfloat16_t(__builtin_hypotf(__x, __y)); }
  2675. constexpr int
  2676. ilogb(__gnu_cxx::__bfloat16_t __x)
  2677. { return __gnu_cxx::__bfloat16_t(__builtin_ilogbf(__x)); }
  2678. constexpr __gnu_cxx::__bfloat16_t
  2679. lgamma(__gnu_cxx::__bfloat16_t __x)
  2680. { return __gnu_cxx::__bfloat16_t(__builtin_lgammaf(__x)); }
  2681. constexpr long long
  2682. llrint(__gnu_cxx::__bfloat16_t __x)
  2683. { return __gnu_cxx::__bfloat16_t(__builtin_llrintf(__x)); }
  2684. constexpr long long
  2685. llround(__gnu_cxx::__bfloat16_t __x)
  2686. { return __gnu_cxx::__bfloat16_t(__builtin_llroundf(__x)); }
  2687. constexpr __gnu_cxx::__bfloat16_t
  2688. log1p(__gnu_cxx::__bfloat16_t __x)
  2689. { return __gnu_cxx::__bfloat16_t(__builtin_log1pf(__x)); }
  2690. // DR 568.
  2691. constexpr __gnu_cxx::__bfloat16_t
  2692. log2(__gnu_cxx::__bfloat16_t __x)
  2693. { return __gnu_cxx::__bfloat16_t(__builtin_log2f(__x)); }
  2694. constexpr __gnu_cxx::__bfloat16_t
  2695. logb(__gnu_cxx::__bfloat16_t __x)
  2696. { return __gnu_cxx::__bfloat16_t(__builtin_logbf(__x)); }
  2697. constexpr long
  2698. lrint(__gnu_cxx::__bfloat16_t __x)
  2699. { return __gnu_cxx::__bfloat16_t(__builtin_lrintf(__x)); }
  2700. constexpr long
  2701. lround(__gnu_cxx::__bfloat16_t __x)
  2702. { return __gnu_cxx::__bfloat16_t(__builtin_lroundf(__x)); }
  2703. constexpr __gnu_cxx::__bfloat16_t
  2704. nearbyint(__gnu_cxx::__bfloat16_t __x)
  2705. { return __gnu_cxx::__bfloat16_t(__builtin_nearbyintf(__x)); }
  2706. constexpr __gnu_cxx::__bfloat16_t
  2707. nextafter(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2708. {
  2709. if (std::__is_constant_evaluated())
  2710. return __builtin_nextafterf16b(__x, __y);
  2711. #ifdef __INT16_TYPE__
  2712. using __bfloat16_int_type = __INT16_TYPE__;
  2713. #else
  2714. using __bfloat16_int_type = short int;
  2715. #endif
  2716. __bfloat16_int_type __hx, __hy, __ix, __iy;
  2717. __builtin_memcpy(&__hx, &__x, sizeof(__x));
  2718. __builtin_memcpy(&__hy, &__y, sizeof(__x));
  2719. __ix = __hx & 0x7fff; // |x|
  2720. __iy = __hy & 0x7fff; // |y|
  2721. if (__ix > 0x7f80 || __iy > 0x7f80) // x or y is NaN
  2722. return __x + __y;
  2723. if (__x == __y)
  2724. return __y; // x == y, return y
  2725. if (__ix == 0) // x == 0
  2726. {
  2727. __hy = (__hy & 0x8000) | 1; // return +-__BFLT16_DENORM_MIN__
  2728. __builtin_memcpy(&__x, &__hy, sizeof(__x));
  2729. __builtin_nextafterf(0.0f, 1.0f); // raise underflow
  2730. return __x;
  2731. }
  2732. if (__hx >= 0) // x > 0
  2733. {
  2734. if (__hx > __hy) // x > y, x -= ulp
  2735. --__hx;
  2736. else // x < y, x += ulp
  2737. ++__hx;
  2738. }
  2739. else // x < 0
  2740. {
  2741. if (__hy >= 0 || __hx > __hy) // x < y, x -= ulp
  2742. --__hx;
  2743. else // x > y, x += ulp
  2744. ++__hx;
  2745. }
  2746. __hy = __hx & 0x7f80;
  2747. if (__hy >= 0x7f80)
  2748. __builtin_nextafterf(__FLT_MAX__, __builtin_inff()); // overflow
  2749. else if (__hy < 0x0080)
  2750. __builtin_nextafterf(__FLT_MIN__, 0.0f); // underflow
  2751. __builtin_memcpy(&__x, &__hx, sizeof(__x));
  2752. return __x;
  2753. }
  2754. constexpr __gnu_cxx::__bfloat16_t
  2755. remainder(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y)
  2756. { return __gnu_cxx::__bfloat16_t(__builtin_remainderf(__x, __y)); }
  2757. inline __gnu_cxx::__bfloat16_t
  2758. remquo(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, int* __pquo)
  2759. { return __gnu_cxx::__bfloat16_t(__builtin_remquof(__x, __y, __pquo)); }
  2760. constexpr __gnu_cxx::__bfloat16_t
  2761. rint(__gnu_cxx::__bfloat16_t __x)
  2762. { return __gnu_cxx::__bfloat16_t(__builtin_rintf(__x)); }
  2763. constexpr __gnu_cxx::__bfloat16_t
  2764. round(__gnu_cxx::__bfloat16_t __x)
  2765. { return __gnu_cxx::__bfloat16_t(__builtin_roundf(__x)); }
  2766. constexpr __gnu_cxx::__bfloat16_t
  2767. scalbln(__gnu_cxx::__bfloat16_t __x, long __ex)
  2768. { return __gnu_cxx::__bfloat16_t(__builtin_scalblnf(__x, __ex)); }
  2769. constexpr __gnu_cxx::__bfloat16_t
  2770. scalbn(__gnu_cxx::__bfloat16_t __x, int __ex)
  2771. { return __gnu_cxx::__bfloat16_t(__builtin_scalbnf(__x, __ex)); }
  2772. constexpr __gnu_cxx::__bfloat16_t
  2773. tgamma(__gnu_cxx::__bfloat16_t __x)
  2774. { return __gnu_cxx::__bfloat16_t(__builtin_tgammaf(__x)); }
  2775. constexpr __gnu_cxx::__bfloat16_t
  2776. trunc(__gnu_cxx::__bfloat16_t __x)
  2777. { return __gnu_cxx::__bfloat16_t(__builtin_truncf(__x)); }
  2778. #endif
  2779. #ifndef __CORRECT_ISO_CPP11_MATH_H_PROTO_INT
  2780. template<typename _Tp, typename _Up>
  2781. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2782. copysign(_Tp __x, _Up __y)
  2783. {
  2784. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2785. return copysign(__type(__x), __type(__y));
  2786. }
  2787. template<typename _Tp, typename _Up>
  2788. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2789. fdim(_Tp __x, _Up __y)
  2790. {
  2791. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2792. return fdim(__type(__x), __type(__y));
  2793. }
  2794. template<typename _Tp, typename _Up>
  2795. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2796. fmax(_Tp __x, _Up __y)
  2797. {
  2798. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2799. return fmax(__type(__x), __type(__y));
  2800. }
  2801. template<typename _Tp, typename _Up>
  2802. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2803. fmin(_Tp __x, _Up __y)
  2804. {
  2805. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2806. return fmin(__type(__x), __type(__y));
  2807. }
  2808. template<typename _Tp, typename _Up>
  2809. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2810. hypot(_Tp __x, _Up __y)
  2811. {
  2812. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2813. return hypot(__type(__x), __type(__y));
  2814. }
  2815. template<typename _Tp, typename _Up>
  2816. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2817. nextafter(_Tp __x, _Up __y)
  2818. {
  2819. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2820. return nextafter(__type(__x), __type(__y));
  2821. }
  2822. template<typename _Tp, typename _Up>
  2823. constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2824. remainder(_Tp __x, _Up __y)
  2825. {
  2826. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2827. return remainder(__type(__x), __type(__y));
  2828. }
  2829. template<typename _Tp, typename _Up>
  2830. inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
  2831. remquo(_Tp __x, _Up __y, int* __pquo)
  2832. {
  2833. typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
  2834. return remquo(__type(__x), __type(__y), __pquo);
  2835. }
  2836. template<typename _Tp, typename _Up, typename _Vp>
  2837. constexpr typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type
  2838. fma(_Tp __x, _Up __y, _Vp __z)
  2839. {
  2840. typedef typename __gnu_cxx::__promote_3<_Tp, _Up, _Vp>::__type __type;
  2841. return fma(__type(__x), __type(__y), __type(__z));
  2842. }
  2843. #endif
  2844. #endif // _GLIBCXX_USE_C99_MATH_TR1
  2845. #endif // C++11
  2846. #if __cplusplus >= 201703L
  2847. // [c.math.hypot3], three-dimensional hypotenuse
  2848. #define __cpp_lib_hypot 201603L
  2849. template<typename _Tp>
  2850. inline _Tp
  2851. __hypot3(_Tp __x, _Tp __y, _Tp __z)
  2852. {
  2853. __x = std::abs(__x);
  2854. __y = std::abs(__y);
  2855. __z = std::abs(__z);
  2856. if (_Tp __a = __x < __y ? __y < __z ? __z : __y : __x < __z ? __z : __x)
  2857. return __a * std::sqrt((__x / __a) * (__x / __a)
  2858. + (__y / __a) * (__y / __a)
  2859. + (__z / __a) * (__z / __a));
  2860. else
  2861. return {};
  2862. }
  2863. inline float
  2864. hypot(float __x, float __y, float __z)
  2865. { return std::__hypot3<float>(__x, __y, __z); }
  2866. inline double
  2867. hypot(double __x, double __y, double __z)
  2868. { return std::__hypot3<double>(__x, __y, __z); }
  2869. inline long double
  2870. hypot(long double __x, long double __y, long double __z)
  2871. { return std::__hypot3<long double>(__x, __y, __z); }
  2872. template<typename _Tp, typename _Up, typename _Vp>
  2873. __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>
  2874. hypot(_Tp __x, _Up __y, _Vp __z)
  2875. {
  2876. using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>;
  2877. return std::__hypot3<__type>(__x, __y, __z);
  2878. }
  2879. #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2880. inline _Float16
  2881. hypot(_Float16 __x, _Float16 __y, _Float16 __z)
  2882. { return std::__hypot3<_Float16>(__x, __y, __z); }
  2883. #endif
  2884. #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2885. inline _Float32
  2886. hypot(_Float32 __x, _Float32 __y, _Float32 __z)
  2887. { return std::__hypot3<_Float32>(__x, __y, __z); }
  2888. #endif
  2889. #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
  2890. inline _Float64
  2891. hypot(_Float64 __x, _Float64 __y, _Float64 __z)
  2892. { return std::__hypot3<_Float64>(__x, __y, __z); }
  2893. #endif
  2894. #if defined(__STDCPP_FLOAT128_T__) \
  2895. && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
  2896. || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
  2897. inline _Float128
  2898. hypot(_Float128 __x, _Float128 __y, _Float128 __z)
  2899. { return std::__hypot3<_Float128>(__x, __y, __z); }
  2900. #endif
  2901. #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2902. inline __gnu_cxx::__bfloat16_t
  2903. hypot(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z)
  2904. { return std::__hypot3<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
  2905. #endif
  2906. #endif // C++17
  2907. #if __cplusplus >= 202002L
  2908. // linear interpolation
  2909. # define __cpp_lib_interpolate 201902L
  2910. template<typename _Fp>
  2911. constexpr _Fp
  2912. __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept
  2913. {
  2914. if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
  2915. return __t * __b + (1 - __t) * __a;
  2916. if (__t == 1)
  2917. return __b; // exact
  2918. // Exact at __t=0, monotonic except near __t=1,
  2919. // bounded, determinate, and consistent:
  2920. const _Fp __x = __a + __t * (__b - __a);
  2921. return (__t > 1) == (__b > __a)
  2922. ? (__b < __x ? __x : __b)
  2923. : (__b > __x ? __x : __b); // monotonic near __t=1
  2924. }
  2925. constexpr float
  2926. lerp(float __a, float __b, float __t) noexcept
  2927. { return std::__lerp(__a, __b, __t); }
  2928. constexpr double
  2929. lerp(double __a, double __b, double __t) noexcept
  2930. { return std::__lerp(__a, __b, __t); }
  2931. constexpr long double
  2932. lerp(long double __a, long double __b, long double __t) noexcept
  2933. { return std::__lerp(__a, __b, __t); }
  2934. template<typename _Tp, typename _Up, typename _Vp>
  2935. constexpr __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>
  2936. lerp(_Tp __x, _Up __y, _Vp __z) noexcept
  2937. {
  2938. using __type = __gnu_cxx::__promoted_t<_Tp, _Up, _Vp>;
  2939. return std::__lerp<__type>(__x, __y, __z);
  2940. }
  2941. #if defined(__STDCPP_FLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2942. inline _Float16
  2943. lerp(_Float16 __x, _Float16 __y, _Float16 __z) noexcept
  2944. { return std::__lerp<_Float16>(__x, __y, __z); }
  2945. #endif
  2946. #if defined(__STDCPP_FLOAT32_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2947. inline _Float32
  2948. lerp(_Float32 __x, _Float32 __y, _Float32 __z) noexcept
  2949. { return std::__lerp<_Float32>(__x, __y, __z); }
  2950. #endif
  2951. #if defined(__STDCPP_FLOAT64_T__) && defined(_GLIBCXX_DOUBLE_IS_IEEE_BINARY64)
  2952. inline _Float64
  2953. lerp(_Float64 __x, _Float64 __y, _Float64 __z) noexcept
  2954. { return std::__lerp<_Float64>(__x, __y, __z); }
  2955. #endif
  2956. #if defined(__STDCPP_FLOAT128_T__) \
  2957. && (defined(_GLIBCXX_LDOUBLE_IS_IEEE_BINARY128) \
  2958. || defined(_GLIBCXX_HAVE_FLOAT128_MATH))
  2959. inline _Float128
  2960. lerp(_Float128 __x, _Float128 __y, _Float128 __z) noexcept
  2961. { return std::__lerp<_Float128>(__x, __y, __z); }
  2962. #endif
  2963. #if defined(__STDCPP_BFLOAT16_T__) && defined(_GLIBCXX_FLOAT_IS_IEEE_BINARY32)
  2964. inline __gnu_cxx::__bfloat16_t
  2965. lerp(__gnu_cxx::__bfloat16_t __x, __gnu_cxx::__bfloat16_t __y, __gnu_cxx::__bfloat16_t __z) noexcept
  2966. { return std::__lerp<__gnu_cxx::__bfloat16_t>(__x, __y, __z); }
  2967. #endif
  2968. #endif // C++20
  2969. _GLIBCXX_END_NAMESPACE_VERSION
  2970. } // namespace
  2971. #if _GLIBCXX_USE_STD_SPEC_FUNCS
  2972. # include <bits/specfun.h>
  2973. #endif
  2974. } // extern "C++"
  2975. #endif