all_test.go 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993
  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package math_test
  5. import (
  6. "fmt"
  7. . "math"
  8. "testing"
  9. )
  10. var vf = []float64{
  11. 4.9790119248836735e+00,
  12. 7.7388724745781045e+00,
  13. -2.7688005719200159e-01,
  14. -5.0106036182710749e+00,
  15. 9.6362937071984173e+00,
  16. 2.9263772392439646e+00,
  17. 5.2290834314593066e+00,
  18. 2.7279399104360102e+00,
  19. 1.8253080916808550e+00,
  20. -8.6859247685756013e+00,
  21. }
  22. // The expected results below were computed by the high precision calculators
  23. // at http://keisan.casio.com/. More exact input values (array vf[], above)
  24. // were obtained by printing them with "%.26f". The answers were calculated
  25. // to 26 digits (by using the "Digit number" drop-down control of each
  26. // calculator).
  27. var acos = []float64{
  28. 1.0496193546107222142571536e+00,
  29. 6.8584012813664425171660692e-01,
  30. 1.5984878714577160325521819e+00,
  31. 2.0956199361475859327461799e+00,
  32. 2.7053008467824138592616927e-01,
  33. 1.2738121680361776018155625e+00,
  34. 1.0205369421140629186287407e+00,
  35. 1.2945003481781246062157835e+00,
  36. 1.3872364345374451433846657e+00,
  37. 2.6231510803970463967294145e+00,
  38. }
  39. var acosh = []float64{
  40. 2.4743347004159012494457618e+00,
  41. 2.8576385344292769649802701e+00,
  42. 7.2796961502981066190593175e-01,
  43. 2.4796794418831451156471977e+00,
  44. 3.0552020742306061857212962e+00,
  45. 2.044238592688586588942468e+00,
  46. 2.5158701513104513595766636e+00,
  47. 1.99050839282411638174299e+00,
  48. 1.6988625798424034227205445e+00,
  49. 2.9611454842470387925531875e+00,
  50. }
  51. var asin = []float64{
  52. 5.2117697218417440497416805e-01,
  53. 8.8495619865825236751471477e-01,
  54. -02.769154466281941332086016e-02,
  55. -5.2482360935268931351485822e-01,
  56. 1.3002662421166552333051524e+00,
  57. 2.9698415875871901741575922e-01,
  58. 5.5025938468083370060258102e-01,
  59. 2.7629597861677201301553823e-01,
  60. 1.83559892257451475846656e-01,
  61. -1.0523547536021497774980928e+00,
  62. }
  63. var asinh = []float64{
  64. 2.3083139124923523427628243e+00,
  65. 2.743551594301593620039021e+00,
  66. -2.7345908534880091229413487e-01,
  67. -2.3145157644718338650499085e+00,
  68. 2.9613652154015058521951083e+00,
  69. 1.7949041616585821933067568e+00,
  70. 2.3564032905983506405561554e+00,
  71. 1.7287118790768438878045346e+00,
  72. 1.3626658083714826013073193e+00,
  73. -2.8581483626513914445234004e+00,
  74. }
  75. var atan = []float64{
  76. 1.372590262129621651920085e+00,
  77. 1.442290609645298083020664e+00,
  78. -2.7011324359471758245192595e-01,
  79. -1.3738077684543379452781531e+00,
  80. 1.4673921193587666049154681e+00,
  81. 1.2415173565870168649117764e+00,
  82. 1.3818396865615168979966498e+00,
  83. 1.2194305844639670701091426e+00,
  84. 1.0696031952318783760193244e+00,
  85. -1.4561721938838084990898679e+00,
  86. }
  87. var atanh = []float64{
  88. 5.4651163712251938116878204e-01,
  89. 1.0299474112843111224914709e+00,
  90. -2.7695084420740135145234906e-02,
  91. -5.5072096119207195480202529e-01,
  92. 1.9943940993171843235906642e+00,
  93. 3.01448604578089708203017e-01,
  94. 5.8033427206942188834370595e-01,
  95. 2.7987997499441511013958297e-01,
  96. 1.8459947964298794318714228e-01,
  97. -1.3273186910532645867272502e+00,
  98. }
  99. var atan2 = []float64{
  100. 1.1088291730037004444527075e+00,
  101. 9.1218183188715804018797795e-01,
  102. 1.5984772603216203736068915e+00,
  103. 2.0352918654092086637227327e+00,
  104. 8.0391819139044720267356014e-01,
  105. 1.2861075249894661588866752e+00,
  106. 1.0889904479131695712182587e+00,
  107. 1.3044821793397925293797357e+00,
  108. 1.3902530903455392306872261e+00,
  109. 2.2859857424479142655411058e+00,
  110. }
  111. var cbrt = []float64{
  112. 1.7075799841925094446722675e+00,
  113. 1.9779982212970353936691498e+00,
  114. -6.5177429017779910853339447e-01,
  115. -1.7111838886544019873338113e+00,
  116. 2.1279920909827937423960472e+00,
  117. 1.4303536770460741452312367e+00,
  118. 1.7357021059106154902341052e+00,
  119. 1.3972633462554328350552916e+00,
  120. 1.2221149580905388454977636e+00,
  121. -2.0556003730500069110343596e+00,
  122. }
  123. var ceil = []float64{
  124. 5.0000000000000000e+00,
  125. 8.0000000000000000e+00,
  126. 0.0000000000000000e+00,
  127. -5.0000000000000000e+00,
  128. 1.0000000000000000e+01,
  129. 3.0000000000000000e+00,
  130. 6.0000000000000000e+00,
  131. 3.0000000000000000e+00,
  132. 2.0000000000000000e+00,
  133. -8.0000000000000000e+00,
  134. }
  135. var copysign = []float64{
  136. -4.9790119248836735e+00,
  137. -7.7388724745781045e+00,
  138. -2.7688005719200159e-01,
  139. -5.0106036182710749e+00,
  140. -9.6362937071984173e+00,
  141. -2.9263772392439646e+00,
  142. -5.2290834314593066e+00,
  143. -2.7279399104360102e+00,
  144. -1.8253080916808550e+00,
  145. -8.6859247685756013e+00,
  146. }
  147. var cos = []float64{
  148. 2.634752140995199110787593e-01,
  149. 1.148551260848219865642039e-01,
  150. 9.6191297325640768154550453e-01,
  151. 2.938141150061714816890637e-01,
  152. -9.777138189897924126294461e-01,
  153. -9.7693041344303219127199518e-01,
  154. 4.940088096948647263961162e-01,
  155. -9.1565869021018925545016502e-01,
  156. -2.517729313893103197176091e-01,
  157. -7.39241351595676573201918e-01,
  158. }
  159. // Results for 100000 * Pi + vf[i]
  160. var cosLarge = []float64{
  161. 2.634752141185559426744e-01,
  162. 1.14855126055543100712e-01,
  163. 9.61912973266488928113e-01,
  164. 2.9381411499556122552e-01,
  165. -9.777138189880161924641e-01,
  166. -9.76930413445147608049e-01,
  167. 4.940088097314976789841e-01,
  168. -9.15658690217517835002e-01,
  169. -2.51772931436786954751e-01,
  170. -7.3924135157173099849e-01,
  171. }
  172. var cosh = []float64{
  173. 7.2668796942212842775517446e+01,
  174. 1.1479413465659254502011135e+03,
  175. 1.0385767908766418550935495e+00,
  176. 7.5000957789658051428857788e+01,
  177. 7.655246669605357888468613e+03,
  178. 9.3567491758321272072888257e+00,
  179. 9.331351599270605471131735e+01,
  180. 7.6833430994624643209296404e+00,
  181. 3.1829371625150718153881164e+00,
  182. 2.9595059261916188501640911e+03,
  183. }
  184. var erf = []float64{
  185. 5.1865354817738701906913566e-01,
  186. 7.2623875834137295116929844e-01,
  187. -3.123458688281309990629839e-02,
  188. -5.2143121110253302920437013e-01,
  189. 8.2704742671312902508629582e-01,
  190. 3.2101767558376376743993945e-01,
  191. 5.403990312223245516066252e-01,
  192. 3.0034702916738588551174831e-01,
  193. 2.0369924417882241241559589e-01,
  194. -7.8069386968009226729944677e-01,
  195. }
  196. var erfc = []float64{
  197. 4.8134645182261298093086434e-01,
  198. 2.7376124165862704883070156e-01,
  199. 1.0312345868828130999062984e+00,
  200. 1.5214312111025330292043701e+00,
  201. 1.7295257328687097491370418e-01,
  202. 6.7898232441623623256006055e-01,
  203. 4.596009687776754483933748e-01,
  204. 6.9965297083261411448825169e-01,
  205. 7.9630075582117758758440411e-01,
  206. 1.7806938696800922672994468e+00,
  207. }
  208. var exp = []float64{
  209. 1.4533071302642137507696589e+02,
  210. 2.2958822575694449002537581e+03,
  211. 7.5814542574851666582042306e-01,
  212. 6.6668778421791005061482264e-03,
  213. 1.5310493273896033740861206e+04,
  214. 1.8659907517999328638667732e+01,
  215. 1.8662167355098714543942057e+02,
  216. 1.5301332413189378961665788e+01,
  217. 6.2047063430646876349125085e+00,
  218. 1.6894712385826521111610438e-04,
  219. }
  220. var expm1 = []float64{
  221. 5.105047796122957327384770212e-02,
  222. 8.046199708567344080562675439e-02,
  223. -2.764970978891639815187418703e-03,
  224. -4.8871434888875355394330300273e-02,
  225. 1.0115864277221467777117227494e-01,
  226. 2.969616407795910726014621657e-02,
  227. 5.368214487944892300914037972e-02,
  228. 2.765488851131274068067445335e-02,
  229. 1.842068661871398836913874273e-02,
  230. -8.3193870863553801814961137573e-02,
  231. }
  232. var exp2 = []float64{
  233. 3.1537839463286288034313104e+01,
  234. 2.1361549283756232296144849e+02,
  235. 8.2537402562185562902577219e-01,
  236. 3.1021158628740294833424229e-02,
  237. 7.9581744110252191462569661e+02,
  238. 7.6019905892596359262696423e+00,
  239. 3.7506882048388096973183084e+01,
  240. 6.6250893439173561733216375e+00,
  241. 3.5438267900243941544605339e+00,
  242. 2.4281533133513300984289196e-03,
  243. }
  244. var fabs = []float64{
  245. 4.9790119248836735e+00,
  246. 7.7388724745781045e+00,
  247. 2.7688005719200159e-01,
  248. 5.0106036182710749e+00,
  249. 9.6362937071984173e+00,
  250. 2.9263772392439646e+00,
  251. 5.2290834314593066e+00,
  252. 2.7279399104360102e+00,
  253. 1.8253080916808550e+00,
  254. 8.6859247685756013e+00,
  255. }
  256. var fdim = []float64{
  257. 4.9790119248836735e+00,
  258. 7.7388724745781045e+00,
  259. 0.0000000000000000e+00,
  260. 0.0000000000000000e+00,
  261. 9.6362937071984173e+00,
  262. 2.9263772392439646e+00,
  263. 5.2290834314593066e+00,
  264. 2.7279399104360102e+00,
  265. 1.8253080916808550e+00,
  266. 0.0000000000000000e+00,
  267. }
  268. var floor = []float64{
  269. 4.0000000000000000e+00,
  270. 7.0000000000000000e+00,
  271. -1.0000000000000000e+00,
  272. -6.0000000000000000e+00,
  273. 9.0000000000000000e+00,
  274. 2.0000000000000000e+00,
  275. 5.0000000000000000e+00,
  276. 2.0000000000000000e+00,
  277. 1.0000000000000000e+00,
  278. -9.0000000000000000e+00,
  279. }
  280. var fmod = []float64{
  281. 4.197615023265299782906368e-02,
  282. 2.261127525421895434476482e+00,
  283. 3.231794108794261433104108e-02,
  284. 4.989396381728925078391512e+00,
  285. 3.637062928015826201999516e-01,
  286. 1.220868282268106064236690e+00,
  287. 4.770916568540693347699744e+00,
  288. 1.816180268691969246219742e+00,
  289. 8.734595415957246977711748e-01,
  290. 1.314075231424398637614104e+00,
  291. }
  292. type fi struct {
  293. f float64
  294. i int
  295. }
  296. var frexp = []fi{
  297. {6.2237649061045918750e-01, 3},
  298. {9.6735905932226306250e-01, 3},
  299. {-5.5376011438400318000e-01, -1},
  300. {-6.2632545228388436250e-01, 3},
  301. {6.02268356699901081250e-01, 4},
  302. {7.3159430981099115000e-01, 2},
  303. {6.5363542893241332500e-01, 3},
  304. {6.8198497760900255000e-01, 2},
  305. {9.1265404584042750000e-01, 1},
  306. {-5.4287029803597508250e-01, 4},
  307. }
  308. var gamma = []float64{
  309. 2.3254348370739963835386613898e+01,
  310. 2.991153837155317076427529816e+03,
  311. -4.561154336726758060575129109e+00,
  312. 7.719403468842639065959210984e-01,
  313. 1.6111876618855418534325755566e+05,
  314. 1.8706575145216421164173224946e+00,
  315. 3.4082787447257502836734201635e+01,
  316. 1.579733951448952054898583387e+00,
  317. 9.3834586598354592860187267089e-01,
  318. -2.093995902923148389186189429e-05,
  319. }
  320. var j0 = []float64{
  321. -1.8444682230601672018219338e-01,
  322. 2.27353668906331975435892e-01,
  323. 9.809259936157051116270273e-01,
  324. -1.741170131426226587841181e-01,
  325. -2.1389448451144143352039069e-01,
  326. -2.340905848928038763337414e-01,
  327. -1.0029099691890912094586326e-01,
  328. -1.5466726714884328135358907e-01,
  329. 3.252650187653420388714693e-01,
  330. -8.72218484409407250005360235e-03,
  331. }
  332. var j1 = []float64{
  333. -3.251526395295203422162967e-01,
  334. 1.893581711430515718062564e-01,
  335. -1.3711761352467242914491514e-01,
  336. 3.287486536269617297529617e-01,
  337. 1.3133899188830978473849215e-01,
  338. 3.660243417832986825301766e-01,
  339. -3.4436769271848174665420672e-01,
  340. 4.329481396640773768835036e-01,
  341. 5.8181350531954794639333955e-01,
  342. -2.7030574577733036112996607e-01,
  343. }
  344. var j2 = []float64{
  345. 5.3837518920137802565192769e-02,
  346. -1.7841678003393207281244667e-01,
  347. 9.521746934916464142495821e-03,
  348. 4.28958355470987397983072e-02,
  349. 2.4115371837854494725492872e-01,
  350. 4.842458532394520316844449e-01,
  351. -3.142145220618633390125946e-02,
  352. 4.720849184745124761189957e-01,
  353. 3.122312022520957042957497e-01,
  354. 7.096213118930231185707277e-02,
  355. }
  356. var jM3 = []float64{
  357. -3.684042080996403091021151e-01,
  358. 2.8157665936340887268092661e-01,
  359. 4.401005480841948348343589e-04,
  360. 3.629926999056814081597135e-01,
  361. 3.123672198825455192489266e-02,
  362. -2.958805510589623607540455e-01,
  363. -3.2033177696533233403289416e-01,
  364. -2.592737332129663376736604e-01,
  365. -1.0241334641061485092351251e-01,
  366. -2.3762660886100206491674503e-01,
  367. }
  368. var lgamma = []fi{
  369. {3.146492141244545774319734e+00, 1},
  370. {8.003414490659126375852113e+00, 1},
  371. {1.517575735509779707488106e+00, -1},
  372. {-2.588480028182145853558748e-01, 1},
  373. {1.1989897050205555002007985e+01, 1},
  374. {6.262899811091257519386906e-01, 1},
  375. {3.5287924899091566764846037e+00, 1},
  376. {4.5725644770161182299423372e-01, 1},
  377. {-6.363667087767961257654854e-02, 1},
  378. {-1.077385130910300066425564e+01, -1},
  379. }
  380. var log = []float64{
  381. 1.605231462693062999102599e+00,
  382. 2.0462560018708770653153909e+00,
  383. -1.2841708730962657801275038e+00,
  384. 1.6115563905281545116286206e+00,
  385. 2.2655365644872016636317461e+00,
  386. 1.0737652208918379856272735e+00,
  387. 1.6542360106073546632707956e+00,
  388. 1.0035467127723465801264487e+00,
  389. 6.0174879014578057187016475e-01,
  390. 2.161703872847352815363655e+00,
  391. }
  392. var logb = []float64{
  393. 2.0000000000000000e+00,
  394. 2.0000000000000000e+00,
  395. -2.0000000000000000e+00,
  396. 2.0000000000000000e+00,
  397. 3.0000000000000000e+00,
  398. 1.0000000000000000e+00,
  399. 2.0000000000000000e+00,
  400. 1.0000000000000000e+00,
  401. 0.0000000000000000e+00,
  402. 3.0000000000000000e+00,
  403. }
  404. var log10 = []float64{
  405. 6.9714316642508290997617083e-01,
  406. 8.886776901739320576279124e-01,
  407. -5.5770832400658929815908236e-01,
  408. 6.998900476822994346229723e-01,
  409. 9.8391002850684232013281033e-01,
  410. 4.6633031029295153334285302e-01,
  411. 7.1842557117242328821552533e-01,
  412. 4.3583479968917773161304553e-01,
  413. 2.6133617905227038228626834e-01,
  414. 9.3881606348649405716214241e-01,
  415. }
  416. var log1p = []float64{
  417. 4.8590257759797794104158205e-02,
  418. 7.4540265965225865330849141e-02,
  419. -2.7726407903942672823234024e-03,
  420. -5.1404917651627649094953380e-02,
  421. 9.1998280672258624681335010e-02,
  422. 2.8843762576593352865894824e-02,
  423. 5.0969534581863707268992645e-02,
  424. 2.6913947602193238458458594e-02,
  425. 1.8088493239630770262045333e-02,
  426. -9.0865245631588989681559268e-02,
  427. }
  428. var log2 = []float64{
  429. 2.3158594707062190618898251e+00,
  430. 2.9521233862883917703341018e+00,
  431. -1.8526669502700329984917062e+00,
  432. 2.3249844127278861543568029e+00,
  433. 3.268478366538305087466309e+00,
  434. 1.5491157592596970278166492e+00,
  435. 2.3865580889631732407886495e+00,
  436. 1.447811865817085365540347e+00,
  437. 8.6813999540425116282815557e-01,
  438. 3.118679457227342224364709e+00,
  439. }
  440. var modf = [][2]float64{
  441. {4.0000000000000000e+00, 9.7901192488367350108546816e-01},
  442. {7.0000000000000000e+00, 7.3887247457810456552351752e-01},
  443. {0.0000000000000000e+00, -2.7688005719200159404635997e-01},
  444. {-5.0000000000000000e+00, -1.060361827107492160848778e-02},
  445. {9.0000000000000000e+00, 6.3629370719841737980004837e-01},
  446. {2.0000000000000000e+00, 9.2637723924396464525443662e-01},
  447. {5.0000000000000000e+00, 2.2908343145930665230025625e-01},
  448. {2.0000000000000000e+00, 7.2793991043601025126008608e-01},
  449. {1.0000000000000000e+00, 8.2530809168085506044576505e-01},
  450. {-8.0000000000000000e+00, -6.8592476857560136238589621e-01},
  451. }
  452. var nextafter32 = []float32{
  453. 4.979012489318848e+00,
  454. 7.738873004913330e+00,
  455. -2.768800258636475e-01,
  456. -5.010602951049805e+00,
  457. 9.636294364929199e+00,
  458. 2.926377534866333e+00,
  459. 5.229084014892578e+00,
  460. 2.727940082550049e+00,
  461. 1.825308203697205e+00,
  462. -8.685923576354980e+00,
  463. }
  464. var nextafter64 = []float64{
  465. 4.97901192488367438926388786e+00,
  466. 7.73887247457810545370193722e+00,
  467. -2.7688005719200153853520874e-01,
  468. -5.01060361827107403343006808e+00,
  469. 9.63629370719841915615688777e+00,
  470. 2.92637723924396508934364647e+00,
  471. 5.22908343145930754047867595e+00,
  472. 2.72793991043601069534929593e+00,
  473. 1.82530809168085528249036997e+00,
  474. -8.68592476857559958602905681e+00,
  475. }
  476. var pow = []float64{
  477. 9.5282232631648411840742957e+04,
  478. 5.4811599352999901232411871e+07,
  479. 5.2859121715894396531132279e-01,
  480. 9.7587991957286474464259698e-06,
  481. 4.328064329346044846740467e+09,
  482. 8.4406761805034547437659092e+02,
  483. 1.6946633276191194947742146e+05,
  484. 5.3449040147551939075312879e+02,
  485. 6.688182138451414936380374e+01,
  486. 2.0609869004248742886827439e-09,
  487. }
  488. var remainder = []float64{
  489. 4.197615023265299782906368e-02,
  490. 2.261127525421895434476482e+00,
  491. 3.231794108794261433104108e-02,
  492. -2.120723654214984321697556e-02,
  493. 3.637062928015826201999516e-01,
  494. 1.220868282268106064236690e+00,
  495. -4.581668629186133046005125e-01,
  496. -9.117596417440410050403443e-01,
  497. 8.734595415957246977711748e-01,
  498. 1.314075231424398637614104e+00,
  499. }
  500. var signbit = []bool{
  501. false,
  502. false,
  503. true,
  504. true,
  505. false,
  506. false,
  507. false,
  508. false,
  509. false,
  510. true,
  511. }
  512. var sin = []float64{
  513. -9.6466616586009283766724726e-01,
  514. 9.9338225271646545763467022e-01,
  515. -2.7335587039794393342449301e-01,
  516. 9.5586257685042792878173752e-01,
  517. -2.099421066779969164496634e-01,
  518. 2.135578780799860532750616e-01,
  519. -8.694568971167362743327708e-01,
  520. 4.019566681155577786649878e-01,
  521. 9.6778633541687993721617774e-01,
  522. -6.734405869050344734943028e-01,
  523. }
  524. // Results for 100000 * Pi + vf[i]
  525. var sinLarge = []float64{
  526. -9.646661658548936063912e-01,
  527. 9.933822527198506903752e-01,
  528. -2.7335587036246899796e-01,
  529. 9.55862576853689321268e-01,
  530. -2.099421066862688873691e-01,
  531. 2.13557878070308981163e-01,
  532. -8.694568970959221300497e-01,
  533. 4.01956668098863248917e-01,
  534. 9.67786335404528727927e-01,
  535. -6.7344058693131973066e-01,
  536. }
  537. var sinh = []float64{
  538. 7.2661916084208532301448439e+01,
  539. 1.1479409110035194500526446e+03,
  540. -2.8043136512812518927312641e-01,
  541. -7.499429091181587232835164e+01,
  542. 7.6552466042906758523925934e+03,
  543. 9.3031583421672014313789064e+00,
  544. 9.330815755828109072810322e+01,
  545. 7.6179893137269146407361477e+00,
  546. 3.021769180549615819524392e+00,
  547. -2.95950575724449499189888e+03,
  548. }
  549. var sqrt = []float64{
  550. 2.2313699659365484748756904e+00,
  551. 2.7818829009464263511285458e+00,
  552. 5.2619393496314796848143251e-01,
  553. 2.2384377628763938724244104e+00,
  554. 3.1042380236055381099288487e+00,
  555. 1.7106657298385224403917771e+00,
  556. 2.286718922705479046148059e+00,
  557. 1.6516476350711159636222979e+00,
  558. 1.3510396336454586262419247e+00,
  559. 2.9471892997524949215723329e+00,
  560. }
  561. var tan = []float64{
  562. -3.661316565040227801781974e+00,
  563. 8.64900232648597589369854e+00,
  564. -2.8417941955033612725238097e-01,
  565. 3.253290185974728640827156e+00,
  566. 2.147275640380293804770778e-01,
  567. -2.18600910711067004921551e-01,
  568. -1.760002817872367935518928e+00,
  569. -4.389808914752818126249079e-01,
  570. -3.843885560201130679995041e+00,
  571. 9.10988793377685105753416e-01,
  572. }
  573. // Results for 100000 * Pi + vf[i]
  574. var tanLarge = []float64{
  575. -3.66131656475596512705e+00,
  576. 8.6490023287202547927e+00,
  577. -2.841794195104782406e-01,
  578. 3.2532901861033120983e+00,
  579. 2.14727564046880001365e-01,
  580. -2.18600910700688062874e-01,
  581. -1.760002817699722747043e+00,
  582. -4.38980891453536115952e-01,
  583. -3.84388555942723509071e+00,
  584. 9.1098879344275101051e-01,
  585. }
  586. var tanh = []float64{
  587. 9.9990531206936338549262119e-01,
  588. 9.9999962057085294197613294e-01,
  589. -2.7001505097318677233756845e-01,
  590. -9.9991110943061718603541401e-01,
  591. 9.9999999146798465745022007e-01,
  592. 9.9427249436125236705001048e-01,
  593. 9.9994257600983138572705076e-01,
  594. 9.9149409509772875982054701e-01,
  595. 9.4936501296239685514466577e-01,
  596. -9.9999994291374030946055701e-01,
  597. }
  598. var trunc = []float64{
  599. 4.0000000000000000e+00,
  600. 7.0000000000000000e+00,
  601. -0.0000000000000000e+00,
  602. -5.0000000000000000e+00,
  603. 9.0000000000000000e+00,
  604. 2.0000000000000000e+00,
  605. 5.0000000000000000e+00,
  606. 2.0000000000000000e+00,
  607. 1.0000000000000000e+00,
  608. -8.0000000000000000e+00,
  609. }
  610. var y0 = []float64{
  611. -3.053399153780788357534855e-01,
  612. 1.7437227649515231515503649e-01,
  613. -8.6221781263678836910392572e-01,
  614. -3.100664880987498407872839e-01,
  615. 1.422200649300982280645377e-01,
  616. 4.000004067997901144239363e-01,
  617. -3.3340749753099352392332536e-01,
  618. 4.5399790746668954555205502e-01,
  619. 4.8290004112497761007536522e-01,
  620. 2.7036697826604756229601611e-01,
  621. }
  622. var y1 = []float64{
  623. 0.15494213737457922210218611,
  624. -0.2165955142081145245075746,
  625. -2.4644949631241895201032829,
  626. 0.1442740489541836405154505,
  627. 0.2215379960518984777080163,
  628. 0.3038800915160754150565448,
  629. 0.0691107642452362383808547,
  630. 0.2380116417809914424860165,
  631. -0.20849492979459761009678934,
  632. 0.0242503179793232308250804,
  633. }
  634. var y2 = []float64{
  635. 0.3675780219390303613394936,
  636. -0.23034826393250119879267257,
  637. -16.939677983817727205631397,
  638. 0.367653980523052152867791,
  639. -0.0962401471767804440353136,
  640. -0.1923169356184851105200523,
  641. 0.35984072054267882391843766,
  642. -0.2794987252299739821654982,
  643. -0.7113490692587462579757954,
  644. -0.2647831587821263302087457,
  645. }
  646. var yM3 = []float64{
  647. -0.14035984421094849100895341,
  648. -0.097535139617792072703973,
  649. 242.25775994555580176377379,
  650. -0.1492267014802818619511046,
  651. 0.26148702629155918694500469,
  652. 0.56675383593895176530394248,
  653. -0.206150264009006981070575,
  654. 0.64784284687568332737963658,
  655. 1.3503631555901938037008443,
  656. 0.1461869756579956803341844,
  657. }
  658. // arguments and expected results for special cases
  659. var vfacosSC = []float64{
  660. -Pi,
  661. 1,
  662. Pi,
  663. NaN(),
  664. }
  665. var acosSC = []float64{
  666. NaN(),
  667. 0,
  668. NaN(),
  669. NaN(),
  670. }
  671. var vfacoshSC = []float64{
  672. Inf(-1),
  673. 0.5,
  674. 1,
  675. Inf(1),
  676. NaN(),
  677. }
  678. var acoshSC = []float64{
  679. NaN(),
  680. NaN(),
  681. 0,
  682. Inf(1),
  683. NaN(),
  684. }
  685. var vfasinSC = []float64{
  686. -Pi,
  687. Copysign(0, -1),
  688. 0,
  689. Pi,
  690. NaN(),
  691. }
  692. var asinSC = []float64{
  693. NaN(),
  694. Copysign(0, -1),
  695. 0,
  696. NaN(),
  697. NaN(),
  698. }
  699. var vfasinhSC = []float64{
  700. Inf(-1),
  701. Copysign(0, -1),
  702. 0,
  703. Inf(1),
  704. NaN(),
  705. }
  706. var asinhSC = []float64{
  707. Inf(-1),
  708. Copysign(0, -1),
  709. 0,
  710. Inf(1),
  711. NaN(),
  712. }
  713. var vfatanSC = []float64{
  714. Inf(-1),
  715. Copysign(0, -1),
  716. 0,
  717. Inf(1),
  718. NaN(),
  719. }
  720. var atanSC = []float64{
  721. -Pi / 2,
  722. Copysign(0, -1),
  723. 0,
  724. Pi / 2,
  725. NaN(),
  726. }
  727. var vfatanhSC = []float64{
  728. Inf(-1),
  729. -Pi,
  730. -1,
  731. Copysign(0, -1),
  732. 0,
  733. 1,
  734. Pi,
  735. Inf(1),
  736. NaN(),
  737. }
  738. var atanhSC = []float64{
  739. NaN(),
  740. NaN(),
  741. Inf(-1),
  742. Copysign(0, -1),
  743. 0,
  744. Inf(1),
  745. NaN(),
  746. NaN(),
  747. NaN(),
  748. }
  749. var vfatan2SC = [][2]float64{
  750. {Inf(-1), Inf(-1)},
  751. {Inf(-1), -Pi},
  752. {Inf(-1), 0},
  753. {Inf(-1), +Pi},
  754. {Inf(-1), Inf(1)},
  755. {Inf(-1), NaN()},
  756. {-Pi, Inf(-1)},
  757. {-Pi, 0},
  758. {-Pi, Inf(1)},
  759. {-Pi, NaN()},
  760. {Copysign(0, -1), Inf(-1)},
  761. {Copysign(0, -1), -Pi},
  762. {Copysign(0, -1), Copysign(0, -1)},
  763. {Copysign(0, -1), 0},
  764. {Copysign(0, -1), +Pi},
  765. {Copysign(0, -1), Inf(1)},
  766. {Copysign(0, -1), NaN()},
  767. {0, Inf(-1)},
  768. {0, -Pi},
  769. {0, Copysign(0, -1)},
  770. {0, 0},
  771. {0, +Pi},
  772. {0, Inf(1)},
  773. {0, NaN()},
  774. {+Pi, Inf(-1)},
  775. {+Pi, 0},
  776. {+Pi, Inf(1)},
  777. {+Pi, NaN()},
  778. {Inf(1), Inf(-1)},
  779. {Inf(1), -Pi},
  780. {Inf(1), 0},
  781. {Inf(1), +Pi},
  782. {Inf(1), Inf(1)},
  783. {Inf(1), NaN()},
  784. {NaN(), NaN()},
  785. }
  786. var atan2SC = []float64{
  787. -3 * Pi / 4, // atan2(-Inf, -Inf)
  788. -Pi / 2, // atan2(-Inf, -Pi)
  789. -Pi / 2, // atan2(-Inf, +0)
  790. -Pi / 2, // atan2(-Inf, +Pi)
  791. -Pi / 4, // atan2(-Inf, +Inf)
  792. NaN(), // atan2(-Inf, NaN)
  793. -Pi, // atan2(-Pi, -Inf)
  794. -Pi / 2, // atan2(-Pi, +0)
  795. Copysign(0, -1), // atan2(-Pi, Inf)
  796. NaN(), // atan2(-Pi, NaN)
  797. -Pi, // atan2(-0, -Inf)
  798. -Pi, // atan2(-0, -Pi)
  799. -Pi, // atan2(-0, -0)
  800. Copysign(0, -1), // atan2(-0, +0)
  801. Copysign(0, -1), // atan2(-0, +Pi)
  802. Copysign(0, -1), // atan2(-0, +Inf)
  803. NaN(), // atan2(-0, NaN)
  804. Pi, // atan2(+0, -Inf)
  805. Pi, // atan2(+0, -Pi)
  806. Pi, // atan2(+0, -0)
  807. 0, // atan2(+0, +0)
  808. 0, // atan2(+0, +Pi)
  809. 0, // atan2(+0, +Inf)
  810. NaN(), // atan2(+0, NaN)
  811. Pi, // atan2(+Pi, -Inf)
  812. Pi / 2, // atan2(+Pi, +0)
  813. 0, // atan2(+Pi, +Inf)
  814. NaN(), // atan2(+Pi, NaN)
  815. 3 * Pi / 4, // atan2(+Inf, -Inf)
  816. Pi / 2, // atan2(+Inf, -Pi)
  817. Pi / 2, // atan2(+Inf, +0)
  818. Pi / 2, // atan2(+Inf, +Pi)
  819. Pi / 4, // atan2(+Inf, +Inf)
  820. NaN(), // atan2(+Inf, NaN)
  821. NaN(), // atan2(NaN, NaN)
  822. }
  823. var vfcbrtSC = []float64{
  824. Inf(-1),
  825. Copysign(0, -1),
  826. 0,
  827. Inf(1),
  828. NaN(),
  829. }
  830. var cbrtSC = []float64{
  831. Inf(-1),
  832. Copysign(0, -1),
  833. 0,
  834. Inf(1),
  835. NaN(),
  836. }
  837. var vfceilSC = []float64{
  838. Inf(-1),
  839. Copysign(0, -1),
  840. 0,
  841. Inf(1),
  842. NaN(),
  843. }
  844. var ceilSC = []float64{
  845. Inf(-1),
  846. Copysign(0, -1),
  847. 0,
  848. Inf(1),
  849. NaN(),
  850. }
  851. var vfcopysignSC = []float64{
  852. Inf(-1),
  853. Inf(1),
  854. NaN(),
  855. }
  856. var copysignSC = []float64{
  857. Inf(-1),
  858. Inf(-1),
  859. NaN(),
  860. }
  861. var vfcosSC = []float64{
  862. Inf(-1),
  863. Inf(1),
  864. NaN(),
  865. }
  866. var cosSC = []float64{
  867. NaN(),
  868. NaN(),
  869. NaN(),
  870. }
  871. var vfcoshSC = []float64{
  872. Inf(-1),
  873. Copysign(0, -1),
  874. 0,
  875. Inf(1),
  876. NaN(),
  877. }
  878. var coshSC = []float64{
  879. Inf(1),
  880. 1,
  881. 1,
  882. Inf(1),
  883. NaN(),
  884. }
  885. var vferfSC = []float64{
  886. Inf(-1),
  887. Copysign(0, -1),
  888. 0,
  889. Inf(1),
  890. NaN(),
  891. }
  892. var erfSC = []float64{
  893. -1,
  894. Copysign(0, -1),
  895. 0,
  896. 1,
  897. NaN(),
  898. }
  899. var vferfcSC = []float64{
  900. Inf(-1),
  901. Inf(1),
  902. NaN(),
  903. }
  904. var erfcSC = []float64{
  905. 2,
  906. 0,
  907. NaN(),
  908. }
  909. var vfexpSC = []float64{
  910. Inf(-1),
  911. -2000,
  912. 2000,
  913. Inf(1),
  914. NaN(),
  915. }
  916. var expSC = []float64{
  917. 0,
  918. 0,
  919. Inf(1),
  920. Inf(1),
  921. NaN(),
  922. }
  923. var vfexpm1SC = []float64{
  924. Inf(-1),
  925. Copysign(0, -1),
  926. 0,
  927. Inf(1),
  928. NaN(),
  929. }
  930. var expm1SC = []float64{
  931. -1,
  932. Copysign(0, -1),
  933. 0,
  934. Inf(1),
  935. NaN(),
  936. }
  937. var vffabsSC = []float64{
  938. Inf(-1),
  939. Copysign(0, -1),
  940. 0,
  941. Inf(1),
  942. NaN(),
  943. }
  944. var fabsSC = []float64{
  945. Inf(1),
  946. 0,
  947. 0,
  948. Inf(1),
  949. NaN(),
  950. }
  951. var vffdimSC = [][2]float64{
  952. {Inf(-1), Inf(-1)},
  953. {Inf(-1), Inf(1)},
  954. {Inf(-1), NaN()},
  955. {Copysign(0, -1), Copysign(0, -1)},
  956. {Copysign(0, -1), 0},
  957. {0, Copysign(0, -1)},
  958. {0, 0},
  959. {Inf(1), Inf(-1)},
  960. {Inf(1), Inf(1)},
  961. {Inf(1), NaN()},
  962. {NaN(), Inf(-1)},
  963. {NaN(), Copysign(0, -1)},
  964. {NaN(), 0},
  965. {NaN(), Inf(1)},
  966. {NaN(), NaN()},
  967. }
  968. var fdimSC = []float64{
  969. NaN(),
  970. 0,
  971. NaN(),
  972. 0,
  973. 0,
  974. 0,
  975. 0,
  976. Inf(1),
  977. NaN(),
  978. NaN(),
  979. NaN(),
  980. NaN(),
  981. NaN(),
  982. NaN(),
  983. NaN(),
  984. }
  985. var fmaxSC = []float64{
  986. Inf(-1),
  987. Inf(1),
  988. NaN(),
  989. Copysign(0, -1),
  990. 0,
  991. 0,
  992. 0,
  993. Inf(1),
  994. Inf(1),
  995. Inf(1),
  996. NaN(),
  997. NaN(),
  998. NaN(),
  999. Inf(1),
  1000. NaN(),
  1001. }
  1002. var fminSC = []float64{
  1003. Inf(-1),
  1004. Inf(-1),
  1005. Inf(-1),
  1006. Copysign(0, -1),
  1007. Copysign(0, -1),
  1008. Copysign(0, -1),
  1009. 0,
  1010. Inf(-1),
  1011. Inf(1),
  1012. NaN(),
  1013. Inf(-1),
  1014. NaN(),
  1015. NaN(),
  1016. NaN(),
  1017. NaN(),
  1018. }
  1019. var vffmodSC = [][2]float64{
  1020. {Inf(-1), Inf(-1)},
  1021. {Inf(-1), -Pi},
  1022. {Inf(-1), 0},
  1023. {Inf(-1), Pi},
  1024. {Inf(-1), Inf(1)},
  1025. {Inf(-1), NaN()},
  1026. {-Pi, Inf(-1)},
  1027. {-Pi, 0},
  1028. {-Pi, Inf(1)},
  1029. {-Pi, NaN()},
  1030. {Copysign(0, -1), Inf(-1)},
  1031. {Copysign(0, -1), 0},
  1032. {Copysign(0, -1), Inf(1)},
  1033. {Copysign(0, -1), NaN()},
  1034. {0, Inf(-1)},
  1035. {0, 0},
  1036. {0, Inf(1)},
  1037. {0, NaN()},
  1038. {Pi, Inf(-1)},
  1039. {Pi, 0},
  1040. {Pi, Inf(1)},
  1041. {Pi, NaN()},
  1042. {Inf(1), Inf(-1)},
  1043. {Inf(1), -Pi},
  1044. {Inf(1), 0},
  1045. {Inf(1), Pi},
  1046. {Inf(1), Inf(1)},
  1047. {Inf(1), NaN()},
  1048. {NaN(), Inf(-1)},
  1049. {NaN(), -Pi},
  1050. {NaN(), 0},
  1051. {NaN(), Pi},
  1052. {NaN(), Inf(1)},
  1053. {NaN(), NaN()},
  1054. }
  1055. var fmodSC = []float64{
  1056. NaN(), // fmod(-Inf, -Inf)
  1057. NaN(), // fmod(-Inf, -Pi)
  1058. NaN(), // fmod(-Inf, 0)
  1059. NaN(), // fmod(-Inf, Pi)
  1060. NaN(), // fmod(-Inf, +Inf)
  1061. NaN(), // fmod(-Inf, NaN)
  1062. -Pi, // fmod(-Pi, -Inf)
  1063. NaN(), // fmod(-Pi, 0)
  1064. -Pi, // fmod(-Pi, +Inf)
  1065. NaN(), // fmod(-Pi, NaN)
  1066. Copysign(0, -1), // fmod(-0, -Inf)
  1067. NaN(), // fmod(-0, 0)
  1068. Copysign(0, -1), // fmod(-0, Inf)
  1069. NaN(), // fmod(-0, NaN)
  1070. 0, // fmod(0, -Inf)
  1071. NaN(), // fmod(0, 0)
  1072. 0, // fmod(0, +Inf)
  1073. NaN(), // fmod(0, NaN)
  1074. Pi, // fmod(Pi, -Inf)
  1075. NaN(), // fmod(Pi, 0)
  1076. Pi, // fmod(Pi, +Inf)
  1077. NaN(), // fmod(Pi, NaN)
  1078. NaN(), // fmod(+Inf, -Inf)
  1079. NaN(), // fmod(+Inf, -Pi)
  1080. NaN(), // fmod(+Inf, 0)
  1081. NaN(), // fmod(+Inf, Pi)
  1082. NaN(), // fmod(+Inf, +Inf)
  1083. NaN(), // fmod(+Inf, NaN)
  1084. NaN(), // fmod(NaN, -Inf)
  1085. NaN(), // fmod(NaN, -Pi)
  1086. NaN(), // fmod(NaN, 0)
  1087. NaN(), // fmod(NaN, Pi)
  1088. NaN(), // fmod(NaN, +Inf)
  1089. NaN(), // fmod(NaN, NaN)
  1090. }
  1091. var vffrexpSC = []float64{
  1092. Inf(-1),
  1093. Copysign(0, -1),
  1094. 0,
  1095. Inf(1),
  1096. NaN(),
  1097. }
  1098. var frexpSC = []fi{
  1099. {Inf(-1), 0},
  1100. {Copysign(0, -1), 0},
  1101. {0, 0},
  1102. {Inf(1), 0},
  1103. {NaN(), 0},
  1104. }
  1105. var vfgammaSC = []float64{
  1106. Inf(-1),
  1107. -3,
  1108. Copysign(0, -1),
  1109. 0,
  1110. Inf(1),
  1111. NaN(),
  1112. }
  1113. var gammaSC = []float64{
  1114. NaN(),
  1115. NaN(),
  1116. Inf(-1),
  1117. Inf(1),
  1118. Inf(1),
  1119. NaN(),
  1120. }
  1121. var vfhypotSC = [][2]float64{
  1122. {Inf(-1), Inf(-1)},
  1123. {Inf(-1), 0},
  1124. {Inf(-1), Inf(1)},
  1125. {Inf(-1), NaN()},
  1126. {Copysign(0, -1), Copysign(0, -1)},
  1127. {Copysign(0, -1), 0},
  1128. {0, Copysign(0, -1)},
  1129. {0, 0}, // +0, +0
  1130. {0, Inf(-1)},
  1131. {0, Inf(1)},
  1132. {0, NaN()},
  1133. {Inf(1), Inf(-1)},
  1134. {Inf(1), 0},
  1135. {Inf(1), Inf(1)},
  1136. {Inf(1), NaN()},
  1137. {NaN(), Inf(-1)},
  1138. {NaN(), 0},
  1139. {NaN(), Inf(1)},
  1140. {NaN(), NaN()},
  1141. }
  1142. var hypotSC = []float64{
  1143. Inf(1),
  1144. Inf(1),
  1145. Inf(1),
  1146. Inf(1),
  1147. 0,
  1148. 0,
  1149. 0,
  1150. 0,
  1151. Inf(1),
  1152. Inf(1),
  1153. NaN(),
  1154. Inf(1),
  1155. Inf(1),
  1156. Inf(1),
  1157. Inf(1),
  1158. Inf(1),
  1159. NaN(),
  1160. Inf(1),
  1161. NaN(),
  1162. }
  1163. var vfilogbSC = []float64{
  1164. Inf(-1),
  1165. 0,
  1166. Inf(1),
  1167. NaN(),
  1168. }
  1169. var ilogbSC = []int{
  1170. MaxInt32,
  1171. MinInt32,
  1172. MaxInt32,
  1173. MaxInt32,
  1174. }
  1175. var vfj0SC = []float64{
  1176. Inf(-1),
  1177. 0,
  1178. Inf(1),
  1179. NaN(),
  1180. }
  1181. var j0SC = []float64{
  1182. 0,
  1183. 1,
  1184. 0,
  1185. NaN(),
  1186. }
  1187. var j1SC = []float64{
  1188. 0,
  1189. 0,
  1190. 0,
  1191. NaN(),
  1192. }
  1193. var j2SC = []float64{
  1194. 0,
  1195. 0,
  1196. 0,
  1197. NaN(),
  1198. }
  1199. var jM3SC = []float64{
  1200. 0,
  1201. 0,
  1202. 0,
  1203. NaN(),
  1204. }
  1205. var vfldexpSC = []fi{
  1206. {0, 0},
  1207. {0, -1075},
  1208. {0, 1024},
  1209. {Copysign(0, -1), 0},
  1210. {Copysign(0, -1), -1075},
  1211. {Copysign(0, -1), 1024},
  1212. {Inf(1), 0},
  1213. {Inf(1), -1024},
  1214. {Inf(-1), 0},
  1215. {Inf(-1), -1024},
  1216. {NaN(), -1024},
  1217. }
  1218. var ldexpSC = []float64{
  1219. 0,
  1220. 0,
  1221. 0,
  1222. Copysign(0, -1),
  1223. Copysign(0, -1),
  1224. Copysign(0, -1),
  1225. Inf(1),
  1226. Inf(1),
  1227. Inf(-1),
  1228. Inf(-1),
  1229. NaN(),
  1230. }
  1231. var vflgammaSC = []float64{
  1232. Inf(-1),
  1233. -3,
  1234. 0,
  1235. 1,
  1236. 2,
  1237. Inf(1),
  1238. NaN(),
  1239. }
  1240. var lgammaSC = []fi{
  1241. {Inf(-1), 1},
  1242. {Inf(1), 1},
  1243. {Inf(1), 1},
  1244. {0, 1},
  1245. {0, 1},
  1246. {Inf(1), 1},
  1247. {NaN(), 1},
  1248. }
  1249. var vflogSC = []float64{
  1250. Inf(-1),
  1251. -Pi,
  1252. Copysign(0, -1),
  1253. 0,
  1254. 1,
  1255. Inf(1),
  1256. NaN(),
  1257. }
  1258. var logSC = []float64{
  1259. NaN(),
  1260. NaN(),
  1261. Inf(-1),
  1262. Inf(-1),
  1263. 0,
  1264. Inf(1),
  1265. NaN(),
  1266. }
  1267. var vflogbSC = []float64{
  1268. Inf(-1),
  1269. 0,
  1270. Inf(1),
  1271. NaN(),
  1272. }
  1273. var logbSC = []float64{
  1274. Inf(1),
  1275. Inf(-1),
  1276. Inf(1),
  1277. NaN(),
  1278. }
  1279. var vflog1pSC = []float64{
  1280. Inf(-1),
  1281. -Pi,
  1282. -1,
  1283. Copysign(0, -1),
  1284. 0,
  1285. Inf(1),
  1286. NaN(),
  1287. }
  1288. var log1pSC = []float64{
  1289. NaN(),
  1290. NaN(),
  1291. Inf(-1),
  1292. Copysign(0, -1),
  1293. 0,
  1294. Inf(1),
  1295. NaN(),
  1296. }
  1297. var vfmodfSC = []float64{
  1298. Inf(-1),
  1299. Inf(1),
  1300. NaN(),
  1301. }
  1302. var modfSC = [][2]float64{
  1303. {Inf(-1), NaN()}, // [2]float64{Copysign(0, -1), Inf(-1)},
  1304. {Inf(1), NaN()}, // [2]float64{0, Inf(1)},
  1305. {NaN(), NaN()},
  1306. }
  1307. var vfnextafter32SC = [][2]float32{
  1308. {0, 0},
  1309. {0, float32(Copysign(0, -1))},
  1310. {0, -1},
  1311. {0, float32(NaN())},
  1312. {float32(Copysign(0, -1)), 1},
  1313. {float32(Copysign(0, -1)), 0},
  1314. {float32(Copysign(0, -1)), float32(Copysign(0, -1))},
  1315. {float32(Copysign(0, -1)), -1},
  1316. {float32(NaN()), 0},
  1317. {float32(NaN()), float32(NaN())},
  1318. }
  1319. var nextafter32SC = []float32{
  1320. 0,
  1321. 0,
  1322. -1.401298464e-45, // Float32frombits(0x80000001)
  1323. float32(NaN()),
  1324. 1.401298464e-45, // Float32frombits(0x00000001)
  1325. float32(Copysign(0, -1)),
  1326. float32(Copysign(0, -1)),
  1327. -1.401298464e-45, // Float32frombits(0x80000001)
  1328. float32(NaN()),
  1329. float32(NaN()),
  1330. }
  1331. var vfnextafter64SC = [][2]float64{
  1332. {0, 0},
  1333. {0, Copysign(0, -1)},
  1334. {0, -1},
  1335. {0, NaN()},
  1336. {Copysign(0, -1), 1},
  1337. {Copysign(0, -1), 0},
  1338. {Copysign(0, -1), Copysign(0, -1)},
  1339. {Copysign(0, -1), -1},
  1340. {NaN(), 0},
  1341. {NaN(), NaN()},
  1342. }
  1343. var nextafter64SC = []float64{
  1344. 0,
  1345. 0,
  1346. -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
  1347. NaN(),
  1348. 4.9406564584124654418e-324, // Float64frombits(0x0000000000000001)
  1349. Copysign(0, -1),
  1350. Copysign(0, -1),
  1351. -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
  1352. NaN(),
  1353. NaN(),
  1354. }
  1355. var vfpowSC = [][2]float64{
  1356. {Inf(-1), -Pi},
  1357. {Inf(-1), -3},
  1358. {Inf(-1), Copysign(0, -1)},
  1359. {Inf(-1), 0},
  1360. {Inf(-1), 1},
  1361. {Inf(-1), 3},
  1362. {Inf(-1), Pi},
  1363. {Inf(-1), NaN()},
  1364. {-Pi, Inf(-1)},
  1365. {-Pi, -Pi},
  1366. {-Pi, Copysign(0, -1)},
  1367. {-Pi, 0},
  1368. {-Pi, 1},
  1369. {-Pi, Pi},
  1370. {-Pi, Inf(1)},
  1371. {-Pi, NaN()},
  1372. {-1, Inf(-1)},
  1373. {-1, Inf(1)},
  1374. {-1, NaN()},
  1375. {-1 / 2, Inf(-1)},
  1376. {-1 / 2, Inf(1)},
  1377. {Copysign(0, -1), Inf(-1)},
  1378. {Copysign(0, -1), -Pi},
  1379. {Copysign(0, -1), -3},
  1380. {Copysign(0, -1), 3},
  1381. {Copysign(0, -1), Pi},
  1382. {Copysign(0, -1), Inf(1)},
  1383. {0, Inf(-1)},
  1384. {0, -Pi},
  1385. {0, -3},
  1386. {0, Copysign(0, -1)},
  1387. {0, 0},
  1388. {0, 3},
  1389. {0, Pi},
  1390. {0, Inf(1)},
  1391. {0, NaN()},
  1392. {1 / 2, Inf(-1)},
  1393. {1 / 2, Inf(1)},
  1394. {1, Inf(-1)},
  1395. {1, Inf(1)},
  1396. {1, NaN()},
  1397. {Pi, Inf(-1)},
  1398. {Pi, Copysign(0, -1)},
  1399. {Pi, 0},
  1400. {Pi, 1},
  1401. {Pi, Inf(1)},
  1402. {Pi, NaN()},
  1403. {Inf(1), -Pi},
  1404. {Inf(1), Copysign(0, -1)},
  1405. {Inf(1), 0},
  1406. {Inf(1), 1},
  1407. {Inf(1), Pi},
  1408. {Inf(1), NaN()},
  1409. {NaN(), -Pi},
  1410. {NaN(), Copysign(0, -1)},
  1411. {NaN(), 0},
  1412. {NaN(), 1},
  1413. {NaN(), Pi},
  1414. {NaN(), NaN()},
  1415. }
  1416. var powSC = []float64{
  1417. 0, // pow(-Inf, -Pi)
  1418. Copysign(0, -1), // pow(-Inf, -3)
  1419. 1, // pow(-Inf, -0)
  1420. 1, // pow(-Inf, +0)
  1421. Inf(-1), // pow(-Inf, 1)
  1422. Inf(-1), // pow(-Inf, 3)
  1423. Inf(1), // pow(-Inf, Pi)
  1424. NaN(), // pow(-Inf, NaN)
  1425. 0, // pow(-Pi, -Inf)
  1426. NaN(), // pow(-Pi, -Pi)
  1427. 1, // pow(-Pi, -0)
  1428. 1, // pow(-Pi, +0)
  1429. -Pi, // pow(-Pi, 1)
  1430. NaN(), // pow(-Pi, Pi)
  1431. Inf(1), // pow(-Pi, +Inf)
  1432. NaN(), // pow(-Pi, NaN)
  1433. 1, // pow(-1, -Inf) IEEE 754-2008
  1434. 1, // pow(-1, +Inf) IEEE 754-2008
  1435. NaN(), // pow(-1, NaN)
  1436. Inf(1), // pow(-1/2, -Inf)
  1437. 0, // pow(-1/2, +Inf)
  1438. Inf(1), // pow(-0, -Inf)
  1439. Inf(1), // pow(-0, -Pi)
  1440. Inf(-1), // pow(-0, -3) IEEE 754-2008
  1441. Copysign(0, -1), // pow(-0, 3) IEEE 754-2008
  1442. 0, // pow(-0, +Pi)
  1443. 0, // pow(-0, +Inf)
  1444. Inf(1), // pow(+0, -Inf)
  1445. Inf(1), // pow(+0, -Pi)
  1446. Inf(1), // pow(+0, -3)
  1447. 1, // pow(+0, -0)
  1448. 1, // pow(+0, +0)
  1449. 0, // pow(+0, 3)
  1450. 0, // pow(+0, +Pi)
  1451. 0, // pow(+0, +Inf)
  1452. NaN(), // pow(+0, NaN)
  1453. Inf(1), // pow(1/2, -Inf)
  1454. 0, // pow(1/2, +Inf)
  1455. 1, // pow(1, -Inf) IEEE 754-2008
  1456. 1, // pow(1, +Inf) IEEE 754-2008
  1457. 1, // pow(1, NaN) IEEE 754-2008
  1458. 0, // pow(+Pi, -Inf)
  1459. 1, // pow(+Pi, -0)
  1460. 1, // pow(+Pi, +0)
  1461. Pi, // pow(+Pi, 1)
  1462. Inf(1), // pow(+Pi, +Inf)
  1463. NaN(), // pow(+Pi, NaN)
  1464. 0, // pow(+Inf, -Pi)
  1465. 1, // pow(+Inf, -0)
  1466. 1, // pow(+Inf, +0)
  1467. Inf(1), // pow(+Inf, 1)
  1468. Inf(1), // pow(+Inf, Pi)
  1469. NaN(), // pow(+Inf, NaN)
  1470. NaN(), // pow(NaN, -Pi)
  1471. 1, // pow(NaN, -0)
  1472. 1, // pow(NaN, +0)
  1473. NaN(), // pow(NaN, 1)
  1474. NaN(), // pow(NaN, +Pi)
  1475. NaN(), // pow(NaN, NaN)
  1476. }
  1477. var vfpow10SC = []int{
  1478. MinInt32,
  1479. MaxInt32,
  1480. -325,
  1481. 309,
  1482. }
  1483. var pow10SC = []float64{
  1484. 0, // pow10(MinInt32)
  1485. Inf(1), // pow10(MaxInt32)
  1486. 0, // pow10(-325)
  1487. Inf(1), // pow10(309)
  1488. }
  1489. var vfsignbitSC = []float64{
  1490. Inf(-1),
  1491. Copysign(0, -1),
  1492. 0,
  1493. Inf(1),
  1494. NaN(),
  1495. }
  1496. var signbitSC = []bool{
  1497. true,
  1498. true,
  1499. false,
  1500. false,
  1501. false,
  1502. }
  1503. var vfsinSC = []float64{
  1504. Inf(-1),
  1505. Copysign(0, -1),
  1506. 0,
  1507. Inf(1),
  1508. NaN(),
  1509. }
  1510. var sinSC = []float64{
  1511. NaN(),
  1512. Copysign(0, -1),
  1513. 0,
  1514. NaN(),
  1515. NaN(),
  1516. }
  1517. var vfsinhSC = []float64{
  1518. Inf(-1),
  1519. Copysign(0, -1),
  1520. 0,
  1521. Inf(1),
  1522. NaN(),
  1523. }
  1524. var sinhSC = []float64{
  1525. Inf(-1),
  1526. Copysign(0, -1),
  1527. 0,
  1528. Inf(1),
  1529. NaN(),
  1530. }
  1531. var vfsqrtSC = []float64{
  1532. Inf(-1),
  1533. -Pi,
  1534. Copysign(0, -1),
  1535. 0,
  1536. Inf(1),
  1537. NaN(),
  1538. }
  1539. var sqrtSC = []float64{
  1540. NaN(),
  1541. NaN(),
  1542. Copysign(0, -1),
  1543. 0,
  1544. Inf(1),
  1545. NaN(),
  1546. }
  1547. var vftanhSC = []float64{
  1548. Inf(-1),
  1549. Copysign(0, -1),
  1550. 0,
  1551. Inf(1),
  1552. NaN(),
  1553. }
  1554. var tanhSC = []float64{
  1555. -1,
  1556. Copysign(0, -1),
  1557. 0,
  1558. 1,
  1559. NaN(),
  1560. }
  1561. var vfy0SC = []float64{
  1562. Inf(-1),
  1563. 0,
  1564. Inf(1),
  1565. NaN(),
  1566. }
  1567. var y0SC = []float64{
  1568. NaN(),
  1569. Inf(-1),
  1570. 0,
  1571. NaN(),
  1572. }
  1573. var y1SC = []float64{
  1574. NaN(),
  1575. Inf(-1),
  1576. 0,
  1577. NaN(),
  1578. }
  1579. var y2SC = []float64{
  1580. NaN(),
  1581. Inf(-1),
  1582. 0,
  1583. NaN(),
  1584. }
  1585. var yM3SC = []float64{
  1586. NaN(),
  1587. Inf(1),
  1588. 0,
  1589. NaN(),
  1590. }
  1591. // arguments and expected results for boundary cases
  1592. const (
  1593. SmallestNormalFloat64 = 2.2250738585072014e-308 // 2**-1022
  1594. LargestSubnormalFloat64 = SmallestNormalFloat64 - SmallestNonzeroFloat64
  1595. )
  1596. var vffrexpBC = []float64{
  1597. SmallestNormalFloat64,
  1598. LargestSubnormalFloat64,
  1599. SmallestNonzeroFloat64,
  1600. MaxFloat64,
  1601. -SmallestNormalFloat64,
  1602. -LargestSubnormalFloat64,
  1603. -SmallestNonzeroFloat64,
  1604. -MaxFloat64,
  1605. }
  1606. var frexpBC = []fi{
  1607. {0.5, -1021},
  1608. {0.99999999999999978, -1022},
  1609. {0.5, -1073},
  1610. {0.99999999999999989, 1024},
  1611. {-0.5, -1021},
  1612. {-0.99999999999999978, -1022},
  1613. {-0.5, -1073},
  1614. {-0.99999999999999989, 1024},
  1615. }
  1616. var vfldexpBC = []fi{
  1617. {SmallestNormalFloat64, -52},
  1618. {LargestSubnormalFloat64, -51},
  1619. {SmallestNonzeroFloat64, 1074},
  1620. {MaxFloat64, -(1023 + 1074)},
  1621. {1, -1075},
  1622. {-1, -1075},
  1623. {1, 1024},
  1624. {-1, 1024},
  1625. }
  1626. var ldexpBC = []float64{
  1627. SmallestNonzeroFloat64,
  1628. 1e-323, // 2**-1073
  1629. 1,
  1630. 1e-323, // 2**-1073
  1631. 0,
  1632. Copysign(0, -1),
  1633. Inf(1),
  1634. Inf(-1),
  1635. }
  1636. var logbBC = []float64{
  1637. -1022,
  1638. -1023,
  1639. -1074,
  1640. 1023,
  1641. -1022,
  1642. -1023,
  1643. -1074,
  1644. 1023,
  1645. }
  1646. func tolerance(a, b, e float64) bool {
  1647. d := a - b
  1648. if d < 0 {
  1649. d = -d
  1650. }
  1651. if a != 0 {
  1652. e = e * a
  1653. if e < 0 {
  1654. e = -e
  1655. }
  1656. }
  1657. return d < e
  1658. }
  1659. func kindaclose(a, b float64) bool { return tolerance(a, b, 1e-8) }
  1660. func close(a, b float64) bool { return tolerance(a, b, 1e-14) }
  1661. func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
  1662. func soclose(a, b, e float64) bool { return tolerance(a, b, e) }
  1663. func alike(a, b float64) bool {
  1664. switch {
  1665. case IsNaN(a) && IsNaN(b):
  1666. return true
  1667. case a == b:
  1668. return Signbit(a) == Signbit(b)
  1669. }
  1670. return false
  1671. }
  1672. func TestNaN(t *testing.T) {
  1673. f64 := NaN()
  1674. if f64 == f64 {
  1675. t.Fatalf("NaN() returns %g, expected NaN", f64)
  1676. }
  1677. f32 := float32(f64)
  1678. if f32 == f32 {
  1679. t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
  1680. }
  1681. }
  1682. func TestAcos(t *testing.T) {
  1683. for i := 0; i < len(vf); i++ {
  1684. a := vf[i] / 10
  1685. if f := Acos(a); !close(acos[i], f) {
  1686. t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
  1687. }
  1688. }
  1689. for i := 0; i < len(vfacosSC); i++ {
  1690. if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
  1691. t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosSC[i])
  1692. }
  1693. }
  1694. }
  1695. func TestAcosh(t *testing.T) {
  1696. for i := 0; i < len(vf); i++ {
  1697. a := 1 + Abs(vf[i])
  1698. if f := Acosh(a); !veryclose(acosh[i], f) {
  1699. t.Errorf("Acosh(%g) = %g, want %g", a, f, acosh[i])
  1700. }
  1701. }
  1702. for i := 0; i < len(vfacoshSC); i++ {
  1703. if f := Acosh(vfacoshSC[i]); !alike(acoshSC[i], f) {
  1704. t.Errorf("Acosh(%g) = %g, want %g", vfacoshSC[i], f, acoshSC[i])
  1705. }
  1706. }
  1707. }
  1708. func TestAsin(t *testing.T) {
  1709. for i := 0; i < len(vf); i++ {
  1710. a := vf[i] / 10
  1711. if f := Asin(a); !veryclose(asin[i], f) {
  1712. t.Errorf("Asin(%g) = %g, want %g", a, f, asin[i])
  1713. }
  1714. }
  1715. for i := 0; i < len(vfasinSC); i++ {
  1716. if f := Asin(vfasinSC[i]); !alike(asinSC[i], f) {
  1717. t.Errorf("Asin(%g) = %g, want %g", vfasinSC[i], f, asinSC[i])
  1718. }
  1719. }
  1720. }
  1721. func TestAsinh(t *testing.T) {
  1722. for i := 0; i < len(vf); i++ {
  1723. if f := Asinh(vf[i]); !veryclose(asinh[i], f) {
  1724. t.Errorf("Asinh(%g) = %g, want %g", vf[i], f, asinh[i])
  1725. }
  1726. }
  1727. for i := 0; i < len(vfasinhSC); i++ {
  1728. if f := Asinh(vfasinhSC[i]); !alike(asinhSC[i], f) {
  1729. t.Errorf("Asinh(%g) = %g, want %g", vfasinhSC[i], f, asinhSC[i])
  1730. }
  1731. }
  1732. }
  1733. func TestAtan(t *testing.T) {
  1734. for i := 0; i < len(vf); i++ {
  1735. if f := Atan(vf[i]); !veryclose(atan[i], f) {
  1736. t.Errorf("Atan(%g) = %g, want %g", vf[i], f, atan[i])
  1737. }
  1738. }
  1739. for i := 0; i < len(vfatanSC); i++ {
  1740. if f := Atan(vfatanSC[i]); !alike(atanSC[i], f) {
  1741. t.Errorf("Atan(%g) = %g, want %g", vfatanSC[i], f, atanSC[i])
  1742. }
  1743. }
  1744. }
  1745. func TestAtanh(t *testing.T) {
  1746. for i := 0; i < len(vf); i++ {
  1747. a := vf[i] / 10
  1748. if f := Atanh(a); !veryclose(atanh[i], f) {
  1749. t.Errorf("Atanh(%g) = %g, want %g", a, f, atanh[i])
  1750. }
  1751. }
  1752. for i := 0; i < len(vfatanhSC); i++ {
  1753. if f := Atanh(vfatanhSC[i]); !alike(atanhSC[i], f) {
  1754. t.Errorf("Atanh(%g) = %g, want %g", vfatanhSC[i], f, atanhSC[i])
  1755. }
  1756. }
  1757. }
  1758. func TestAtan2(t *testing.T) {
  1759. for i := 0; i < len(vf); i++ {
  1760. if f := Atan2(10, vf[i]); !veryclose(atan2[i], f) {
  1761. t.Errorf("Atan2(10, %g) = %g, want %g", vf[i], f, atan2[i])
  1762. }
  1763. }
  1764. for i := 0; i < len(vfatan2SC); i++ {
  1765. if f := Atan2(vfatan2SC[i][0], vfatan2SC[i][1]); !alike(atan2SC[i], f) {
  1766. t.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC[i][0], vfatan2SC[i][1], f, atan2SC[i])
  1767. }
  1768. }
  1769. }
  1770. func TestCbrt(t *testing.T) {
  1771. for i := 0; i < len(vf); i++ {
  1772. if f := Cbrt(vf[i]); !veryclose(cbrt[i], f) {
  1773. t.Errorf("Cbrt(%g) = %g, want %g", vf[i], f, cbrt[i])
  1774. }
  1775. }
  1776. for i := 0; i < len(vfcbrtSC); i++ {
  1777. if f := Cbrt(vfcbrtSC[i]); !alike(cbrtSC[i], f) {
  1778. t.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC[i], f, cbrtSC[i])
  1779. }
  1780. }
  1781. }
  1782. func TestCeil(t *testing.T) {
  1783. for i := 0; i < len(vf); i++ {
  1784. if f := Ceil(vf[i]); ceil[i] != f {
  1785. t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
  1786. }
  1787. }
  1788. for i := 0; i < len(vfceilSC); i++ {
  1789. if f := Ceil(vfceilSC[i]); !alike(ceilSC[i], f) {
  1790. t.Errorf("Ceil(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
  1791. }
  1792. }
  1793. }
  1794. func TestCopysign(t *testing.T) {
  1795. for i := 0; i < len(vf); i++ {
  1796. if f := Copysign(vf[i], -1); copysign[i] != f {
  1797. t.Errorf("Copysign(%g, -1) = %g, want %g", vf[i], f, copysign[i])
  1798. }
  1799. }
  1800. for i := 0; i < len(vf); i++ {
  1801. if f := Copysign(vf[i], 1); -copysign[i] != f {
  1802. t.Errorf("Copysign(%g, 1) = %g, want %g", vf[i], f, -copysign[i])
  1803. }
  1804. }
  1805. for i := 0; i < len(vfcopysignSC); i++ {
  1806. if f := Copysign(vfcopysignSC[i], -1); !alike(copysignSC[i], f) {
  1807. t.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC[i], f, copysignSC[i])
  1808. }
  1809. }
  1810. }
  1811. func TestCos(t *testing.T) {
  1812. for i := 0; i < len(vf); i++ {
  1813. if f := Cos(vf[i]); !veryclose(cos[i], f) {
  1814. t.Errorf("Cos(%g) = %g, want %g", vf[i], f, cos[i])
  1815. }
  1816. }
  1817. for i := 0; i < len(vfcosSC); i++ {
  1818. if f := Cos(vfcosSC[i]); !alike(cosSC[i], f) {
  1819. t.Errorf("Cos(%g) = %g, want %g", vfcosSC[i], f, cosSC[i])
  1820. }
  1821. }
  1822. }
  1823. func TestCosh(t *testing.T) {
  1824. for i := 0; i < len(vf); i++ {
  1825. if f := Cosh(vf[i]); !close(cosh[i], f) {
  1826. t.Errorf("Cosh(%g) = %g, want %g", vf[i], f, cosh[i])
  1827. }
  1828. }
  1829. for i := 0; i < len(vfcoshSC); i++ {
  1830. if f := Cosh(vfcoshSC[i]); !alike(coshSC[i], f) {
  1831. t.Errorf("Cosh(%g) = %g, want %g", vfcoshSC[i], f, coshSC[i])
  1832. }
  1833. }
  1834. }
  1835. func TestErf(t *testing.T) {
  1836. for i := 0; i < len(vf); i++ {
  1837. a := vf[i] / 10
  1838. if f := Erf(a); !veryclose(erf[i], f) {
  1839. t.Errorf("Erf(%g) = %g, want %g", a, f, erf[i])
  1840. }
  1841. }
  1842. for i := 0; i < len(vferfSC); i++ {
  1843. if f := Erf(vferfSC[i]); !alike(erfSC[i], f) {
  1844. t.Errorf("Erf(%g) = %g, want %g", vferfSC[i], f, erfSC[i])
  1845. }
  1846. }
  1847. }
  1848. func TestErfc(t *testing.T) {
  1849. for i := 0; i < len(vf); i++ {
  1850. a := vf[i] / 10
  1851. if f := Erfc(a); !veryclose(erfc[i], f) {
  1852. t.Errorf("Erfc(%g) = %g, want %g", a, f, erfc[i])
  1853. }
  1854. }
  1855. for i := 0; i < len(vferfcSC); i++ {
  1856. if f := Erfc(vferfcSC[i]); !alike(erfcSC[i], f) {
  1857. t.Errorf("Erfc(%g) = %g, want %g", vferfcSC[i], f, erfcSC[i])
  1858. }
  1859. }
  1860. }
  1861. func TestExp(t *testing.T) {
  1862. testExp(t, Exp, "Exp")
  1863. testExp(t, ExpGo, "ExpGo")
  1864. }
  1865. func testExp(t *testing.T, Exp func(float64) float64, name string) {
  1866. for i := 0; i < len(vf); i++ {
  1867. if f := Exp(vf[i]); !close(exp[i], f) {
  1868. t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp[i])
  1869. }
  1870. }
  1871. for i := 0; i < len(vfexpSC); i++ {
  1872. if f := Exp(vfexpSC[i]); !alike(expSC[i], f) {
  1873. t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
  1874. }
  1875. }
  1876. }
  1877. func TestExpm1(t *testing.T) {
  1878. for i := 0; i < len(vf); i++ {
  1879. a := vf[i] / 100
  1880. if f := Expm1(a); !veryclose(expm1[i], f) {
  1881. t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1[i])
  1882. }
  1883. }
  1884. for i := 0; i < len(vfexpm1SC); i++ {
  1885. if f := Expm1(vfexpm1SC[i]); !alike(expm1SC[i], f) {
  1886. t.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC[i], f, expm1SC[i])
  1887. }
  1888. }
  1889. }
  1890. func TestExp2(t *testing.T) {
  1891. testExp2(t, Exp2, "Exp2")
  1892. testExp2(t, Exp2Go, "Exp2Go")
  1893. }
  1894. func testExp2(t *testing.T, Exp2 func(float64) float64, name string) {
  1895. for i := 0; i < len(vf); i++ {
  1896. if f := Exp2(vf[i]); !close(exp2[i], f) {
  1897. t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp2[i])
  1898. }
  1899. }
  1900. for i := 0; i < len(vfexpSC); i++ {
  1901. if f := Exp2(vfexpSC[i]); !alike(expSC[i], f) {
  1902. t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
  1903. }
  1904. }
  1905. for n := -1074; n < 1024; n++ {
  1906. f := Exp2(float64(n))
  1907. vf := Ldexp(1, n)
  1908. if f != vf {
  1909. t.Errorf("%s(%d) = %g, want %g", name, n, f, vf)
  1910. }
  1911. }
  1912. }
  1913. func TestAbs(t *testing.T) {
  1914. for i := 0; i < len(vf); i++ {
  1915. if f := Abs(vf[i]); fabs[i] != f {
  1916. t.Errorf("Abs(%g) = %g, want %g", vf[i], f, fabs[i])
  1917. }
  1918. }
  1919. for i := 0; i < len(vffabsSC); i++ {
  1920. if f := Abs(vffabsSC[i]); !alike(fabsSC[i], f) {
  1921. t.Errorf("Abs(%g) = %g, want %g", vffabsSC[i], f, fabsSC[i])
  1922. }
  1923. }
  1924. }
  1925. func TestDim(t *testing.T) {
  1926. for i := 0; i < len(vf); i++ {
  1927. if f := Dim(vf[i], 0); fdim[i] != f {
  1928. t.Errorf("Dim(%g, %g) = %g, want %g", vf[i], 0.0, f, fdim[i])
  1929. }
  1930. }
  1931. for i := 0; i < len(vffdimSC); i++ {
  1932. if f := Dim(vffdimSC[i][0], vffdimSC[i][1]); !alike(fdimSC[i], f) {
  1933. t.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fdimSC[i])
  1934. }
  1935. }
  1936. }
  1937. func TestFloor(t *testing.T) {
  1938. for i := 0; i < len(vf); i++ {
  1939. if f := Floor(vf[i]); floor[i] != f {
  1940. t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
  1941. }
  1942. }
  1943. for i := 0; i < len(vfceilSC); i++ {
  1944. if f := Floor(vfceilSC[i]); !alike(ceilSC[i], f) {
  1945. t.Errorf("Floor(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
  1946. }
  1947. }
  1948. }
  1949. func TestMax(t *testing.T) {
  1950. for i := 0; i < len(vf); i++ {
  1951. if f := Max(vf[i], ceil[i]); ceil[i] != f {
  1952. t.Errorf("Max(%g, %g) = %g, want %g", vf[i], ceil[i], f, ceil[i])
  1953. }
  1954. }
  1955. for i := 0; i < len(vffdimSC); i++ {
  1956. if f := Max(vffdimSC[i][0], vffdimSC[i][1]); !alike(fmaxSC[i], f) {
  1957. t.Errorf("Max(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fmaxSC[i])
  1958. }
  1959. }
  1960. }
  1961. func TestMin(t *testing.T) {
  1962. for i := 0; i < len(vf); i++ {
  1963. if f := Min(vf[i], floor[i]); floor[i] != f {
  1964. t.Errorf("Min(%g, %g) = %g, want %g", vf[i], floor[i], f, floor[i])
  1965. }
  1966. }
  1967. for i := 0; i < len(vffdimSC); i++ {
  1968. if f := Min(vffdimSC[i][0], vffdimSC[i][1]); !alike(fminSC[i], f) {
  1969. t.Errorf("Min(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fminSC[i])
  1970. }
  1971. }
  1972. }
  1973. func TestMod(t *testing.T) {
  1974. for i := 0; i < len(vf); i++ {
  1975. if f := Mod(10, vf[i]); fmod[i] != f {
  1976. t.Errorf("Mod(10, %g) = %g, want %g", vf[i], f, fmod[i])
  1977. }
  1978. }
  1979. for i := 0; i < len(vffmodSC); i++ {
  1980. if f := Mod(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
  1981. t.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
  1982. }
  1983. }
  1984. }
  1985. func TestFrexp(t *testing.T) {
  1986. for i := 0; i < len(vf); i++ {
  1987. if f, j := Frexp(vf[i]); !veryclose(frexp[i].f, f) || frexp[i].i != j {
  1988. t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf[i], f, j, frexp[i].f, frexp[i].i)
  1989. }
  1990. }
  1991. for i := 0; i < len(vffrexpSC); i++ {
  1992. if f, j := Frexp(vffrexpSC[i]); !alike(frexpSC[i].f, f) || frexpSC[i].i != j {
  1993. t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC[i], f, j, frexpSC[i].f, frexpSC[i].i)
  1994. }
  1995. }
  1996. for i := 0; i < len(vffrexpBC); i++ {
  1997. if f, j := Frexp(vffrexpBC[i]); !alike(frexpBC[i].f, f) || frexpBC[i].i != j {
  1998. t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC[i], f, j, frexpBC[i].f, frexpBC[i].i)
  1999. }
  2000. }
  2001. }
  2002. func TestGamma(t *testing.T) {
  2003. for i := 0; i < len(vf); i++ {
  2004. if f := Gamma(vf[i]); !close(gamma[i], f) {
  2005. t.Errorf("Gamma(%g) = %g, want %g", vf[i], f, gamma[i])
  2006. }
  2007. }
  2008. for i := 0; i < len(vfgammaSC); i++ {
  2009. if f := Gamma(vfgammaSC[i]); !alike(gammaSC[i], f) {
  2010. t.Errorf("Gamma(%g) = %g, want %g", vfgammaSC[i], f, gammaSC[i])
  2011. }
  2012. }
  2013. }
  2014. func TestHypot(t *testing.T) {
  2015. for i := 0; i < len(vf); i++ {
  2016. a := Abs(1e200 * tanh[i] * Sqrt(2))
  2017. if f := Hypot(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
  2018. t.Errorf("Hypot(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
  2019. }
  2020. }
  2021. for i := 0; i < len(vfhypotSC); i++ {
  2022. if f := Hypot(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
  2023. t.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
  2024. }
  2025. }
  2026. }
  2027. func TestHypotGo(t *testing.T) {
  2028. for i := 0; i < len(vf); i++ {
  2029. a := Abs(1e200 * tanh[i] * Sqrt(2))
  2030. if f := HypotGo(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
  2031. t.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
  2032. }
  2033. }
  2034. for i := 0; i < len(vfhypotSC); i++ {
  2035. if f := HypotGo(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
  2036. t.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
  2037. }
  2038. }
  2039. }
  2040. func TestIlogb(t *testing.T) {
  2041. for i := 0; i < len(vf); i++ {
  2042. a := frexp[i].i - 1 // adjust because fr in the interval [½, 1)
  2043. if e := Ilogb(vf[i]); a != e {
  2044. t.Errorf("Ilogb(%g) = %d, want %d", vf[i], e, a)
  2045. }
  2046. }
  2047. for i := 0; i < len(vflogbSC); i++ {
  2048. if e := Ilogb(vflogbSC[i]); ilogbSC[i] != e {
  2049. t.Errorf("Ilogb(%g) = %d, want %d", vflogbSC[i], e, ilogbSC[i])
  2050. }
  2051. }
  2052. for i := 0; i < len(vffrexpBC); i++ {
  2053. if e := Ilogb(vffrexpBC[i]); int(logbBC[i]) != e {
  2054. t.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC[i], e, int(logbBC[i]))
  2055. }
  2056. }
  2057. }
  2058. func TestJ0(t *testing.T) {
  2059. for i := 0; i < len(vf); i++ {
  2060. if f := J0(vf[i]); !soclose(j0[i], f, 4e-14) {
  2061. t.Errorf("J0(%g) = %g, want %g", vf[i], f, j0[i])
  2062. }
  2063. }
  2064. for i := 0; i < len(vfj0SC); i++ {
  2065. if f := J0(vfj0SC[i]); !alike(j0SC[i], f) {
  2066. t.Errorf("J0(%g) = %g, want %g", vfj0SC[i], f, j0SC[i])
  2067. }
  2068. }
  2069. }
  2070. func TestJ1(t *testing.T) {
  2071. for i := 0; i < len(vf); i++ {
  2072. if f := J1(vf[i]); !close(j1[i], f) {
  2073. t.Errorf("J1(%g) = %g, want %g", vf[i], f, j1[i])
  2074. }
  2075. }
  2076. for i := 0; i < len(vfj0SC); i++ {
  2077. if f := J1(vfj0SC[i]); !alike(j1SC[i], f) {
  2078. t.Errorf("J1(%g) = %g, want %g", vfj0SC[i], f, j1SC[i])
  2079. }
  2080. }
  2081. }
  2082. func TestJn(t *testing.T) {
  2083. for i := 0; i < len(vf); i++ {
  2084. if f := Jn(2, vf[i]); !close(j2[i], f) {
  2085. t.Errorf("Jn(2, %g) = %g, want %g", vf[i], f, j2[i])
  2086. }
  2087. if f := Jn(-3, vf[i]); !close(jM3[i], f) {
  2088. t.Errorf("Jn(-3, %g) = %g, want %g", vf[i], f, jM3[i])
  2089. }
  2090. }
  2091. for i := 0; i < len(vfj0SC); i++ {
  2092. if f := Jn(2, vfj0SC[i]); !alike(j2SC[i], f) {
  2093. t.Errorf("Jn(2, %g) = %g, want %g", vfj0SC[i], f, j2SC[i])
  2094. }
  2095. if f := Jn(-3, vfj0SC[i]); !alike(jM3SC[i], f) {
  2096. t.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC[i], f, jM3SC[i])
  2097. }
  2098. }
  2099. }
  2100. func TestLdexp(t *testing.T) {
  2101. for i := 0; i < len(vf); i++ {
  2102. if f := Ldexp(frexp[i].f, frexp[i].i); !veryclose(vf[i], f) {
  2103. t.Errorf("Ldexp(%g, %d) = %g, want %g", frexp[i].f, frexp[i].i, f, vf[i])
  2104. }
  2105. }
  2106. for i := 0; i < len(vffrexpSC); i++ {
  2107. if f := Ldexp(frexpSC[i].f, frexpSC[i].i); !alike(vffrexpSC[i], f) {
  2108. t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC[i].f, frexpSC[i].i, f, vffrexpSC[i])
  2109. }
  2110. }
  2111. for i := 0; i < len(vfldexpSC); i++ {
  2112. if f := Ldexp(vfldexpSC[i].f, vfldexpSC[i].i); !alike(ldexpSC[i], f) {
  2113. t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC[i].f, vfldexpSC[i].i, f, ldexpSC[i])
  2114. }
  2115. }
  2116. for i := 0; i < len(vffrexpBC); i++ {
  2117. if f := Ldexp(frexpBC[i].f, frexpBC[i].i); !alike(vffrexpBC[i], f) {
  2118. t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC[i].f, frexpBC[i].i, f, vffrexpBC[i])
  2119. }
  2120. }
  2121. for i := 0; i < len(vfldexpBC); i++ {
  2122. if f := Ldexp(vfldexpBC[i].f, vfldexpBC[i].i); !alike(ldexpBC[i], f) {
  2123. t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC[i].f, vfldexpBC[i].i, f, ldexpBC[i])
  2124. }
  2125. }
  2126. }
  2127. func TestLgamma(t *testing.T) {
  2128. for i := 0; i < len(vf); i++ {
  2129. if f, s := Lgamma(vf[i]); !close(lgamma[i].f, f) || lgamma[i].i != s {
  2130. t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf[i], f, s, lgamma[i].f, lgamma[i].i)
  2131. }
  2132. }
  2133. for i := 0; i < len(vflgammaSC); i++ {
  2134. if f, s := Lgamma(vflgammaSC[i]); !alike(lgammaSC[i].f, f) || lgammaSC[i].i != s {
  2135. t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC[i], f, s, lgammaSC[i].f, lgammaSC[i].i)
  2136. }
  2137. }
  2138. }
  2139. func TestLog(t *testing.T) {
  2140. for i := 0; i < len(vf); i++ {
  2141. a := Abs(vf[i])
  2142. if f := Log(a); log[i] != f {
  2143. t.Errorf("Log(%g) = %g, want %g", a, f, log[i])
  2144. }
  2145. }
  2146. if f := Log(10); f != Ln10 {
  2147. t.Errorf("Log(%g) = %g, want %g", 10.0, f, Ln10)
  2148. }
  2149. for i := 0; i < len(vflogSC); i++ {
  2150. if f := Log(vflogSC[i]); !alike(logSC[i], f) {
  2151. t.Errorf("Log(%g) = %g, want %g", vflogSC[i], f, logSC[i])
  2152. }
  2153. }
  2154. }
  2155. func TestLogb(t *testing.T) {
  2156. for i := 0; i < len(vf); i++ {
  2157. if f := Logb(vf[i]); logb[i] != f {
  2158. t.Errorf("Logb(%g) = %g, want %g", vf[i], f, logb[i])
  2159. }
  2160. }
  2161. for i := 0; i < len(vflogbSC); i++ {
  2162. if f := Logb(vflogbSC[i]); !alike(logbSC[i], f) {
  2163. t.Errorf("Logb(%g) = %g, want %g", vflogbSC[i], f, logbSC[i])
  2164. }
  2165. }
  2166. for i := 0; i < len(vffrexpBC); i++ {
  2167. if f := Logb(vffrexpBC[i]); !alike(logbBC[i], f) {
  2168. t.Errorf("Logb(%g) = %g, want %g", vffrexpBC[i], f, logbBC[i])
  2169. }
  2170. }
  2171. }
  2172. func TestLog10(t *testing.T) {
  2173. for i := 0; i < len(vf); i++ {
  2174. a := Abs(vf[i])
  2175. if f := Log10(a); !veryclose(log10[i], f) {
  2176. t.Errorf("Log10(%g) = %g, want %g", a, f, log10[i])
  2177. }
  2178. }
  2179. if f := Log10(E); f != Log10E {
  2180. t.Errorf("Log10(%g) = %g, want %g", E, f, Log10E)
  2181. }
  2182. for i := 0; i < len(vflogSC); i++ {
  2183. if f := Log10(vflogSC[i]); !alike(logSC[i], f) {
  2184. t.Errorf("Log10(%g) = %g, want %g", vflogSC[i], f, logSC[i])
  2185. }
  2186. }
  2187. }
  2188. func TestLog1p(t *testing.T) {
  2189. for i := 0; i < len(vf); i++ {
  2190. a := vf[i] / 100
  2191. if f := Log1p(a); !veryclose(log1p[i], f) {
  2192. t.Errorf("Log1p(%g) = %g, want %g", a, f, log1p[i])
  2193. }
  2194. }
  2195. a := 9.0
  2196. if f := Log1p(a); f != Ln10 {
  2197. t.Errorf("Log1p(%g) = %g, want %g", a, f, Ln10)
  2198. }
  2199. for i := 0; i < len(vflogSC); i++ {
  2200. if f := Log1p(vflog1pSC[i]); !alike(log1pSC[i], f) {
  2201. t.Errorf("Log1p(%g) = %g, want %g", vflog1pSC[i], f, log1pSC[i])
  2202. }
  2203. }
  2204. }
  2205. func TestLog2(t *testing.T) {
  2206. for i := 0; i < len(vf); i++ {
  2207. a := Abs(vf[i])
  2208. if f := Log2(a); !veryclose(log2[i], f) {
  2209. t.Errorf("Log2(%g) = %g, want %g", a, f, log2[i])
  2210. }
  2211. }
  2212. if f := Log2(E); f != Log2E {
  2213. t.Errorf("Log2(%g) = %g, want %g", E, f, Log2E)
  2214. }
  2215. for i := 0; i < len(vflogSC); i++ {
  2216. if f := Log2(vflogSC[i]); !alike(logSC[i], f) {
  2217. t.Errorf("Log2(%g) = %g, want %g", vflogSC[i], f, logSC[i])
  2218. }
  2219. }
  2220. for i := -1074; i <= 1023; i++ {
  2221. f := Ldexp(1, i)
  2222. l := Log2(f)
  2223. if l != float64(i) {
  2224. t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
  2225. }
  2226. }
  2227. }
  2228. func TestModf(t *testing.T) {
  2229. for i := 0; i < len(vf); i++ {
  2230. if f, g := Modf(vf[i]); !veryclose(modf[i][0], f) || !veryclose(modf[i][1], g) {
  2231. t.Errorf("Modf(%g) = %g, %g, want %g, %g", vf[i], f, g, modf[i][0], modf[i][1])
  2232. }
  2233. }
  2234. for i := 0; i < len(vfmodfSC); i++ {
  2235. if f, g := Modf(vfmodfSC[i]); !alike(modfSC[i][0], f) || !alike(modfSC[i][1], g) {
  2236. t.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC[i], f, g, modfSC[i][0], modfSC[i][1])
  2237. }
  2238. }
  2239. }
  2240. func TestNextafter32(t *testing.T) {
  2241. for i := 0; i < len(vf); i++ {
  2242. vfi := float32(vf[i])
  2243. if f := Nextafter32(vfi, 10); nextafter32[i] != f {
  2244. t.Errorf("Nextafter32(%g, %g) = %g want %g", vfi, 10.0, f, nextafter32[i])
  2245. }
  2246. }
  2247. for i := 0; i < len(vfnextafter32SC); i++ {
  2248. if f := Nextafter32(vfnextafter32SC[i][0], vfnextafter32SC[i][1]); !alike(float64(nextafter32SC[i]), float64(f)) {
  2249. t.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC[i][0], vfnextafter32SC[i][1], f, nextafter32SC[i])
  2250. }
  2251. }
  2252. }
  2253. func TestNextafter64(t *testing.T) {
  2254. for i := 0; i < len(vf); i++ {
  2255. if f := Nextafter(vf[i], 10); nextafter64[i] != f {
  2256. t.Errorf("Nextafter64(%g, %g) = %g want %g", vf[i], 10.0, f, nextafter64[i])
  2257. }
  2258. }
  2259. for i := 0; i < len(vfnextafter64SC); i++ {
  2260. if f := Nextafter(vfnextafter64SC[i][0], vfnextafter64SC[i][1]); !alike(nextafter64SC[i], f) {
  2261. t.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC[i][0], vfnextafter64SC[i][1], f, nextafter64SC[i])
  2262. }
  2263. }
  2264. }
  2265. func TestPow(t *testing.T) {
  2266. for i := 0; i < len(vf); i++ {
  2267. if f := Pow(10, vf[i]); !close(pow[i], f) {
  2268. t.Errorf("Pow(10, %g) = %g, want %g", vf[i], f, pow[i])
  2269. }
  2270. }
  2271. for i := 0; i < len(vfpowSC); i++ {
  2272. if f := Pow(vfpowSC[i][0], vfpowSC[i][1]); !alike(powSC[i], f) {
  2273. t.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC[i][0], vfpowSC[i][1], f, powSC[i])
  2274. }
  2275. }
  2276. }
  2277. func TestPow10(t *testing.T) {
  2278. for i := 0; i < len(vfpow10SC); i++ {
  2279. if f := Pow10(vfpow10SC[i]); !alike(pow10SC[i], f) {
  2280. t.Errorf("Pow10(%d) = %g, want %g", vfpow10SC[i], f, pow10SC[i])
  2281. }
  2282. }
  2283. }
  2284. func TestRemainder(t *testing.T) {
  2285. for i := 0; i < len(vf); i++ {
  2286. if f := Remainder(10, vf[i]); remainder[i] != f {
  2287. t.Errorf("Remainder(10, %g) = %g, want %g", vf[i], f, remainder[i])
  2288. }
  2289. }
  2290. for i := 0; i < len(vffmodSC); i++ {
  2291. if f := Remainder(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
  2292. t.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
  2293. }
  2294. }
  2295. }
  2296. func TestSignbit(t *testing.T) {
  2297. for i := 0; i < len(vf); i++ {
  2298. if f := Signbit(vf[i]); signbit[i] != f {
  2299. t.Errorf("Signbit(%g) = %t, want %t", vf[i], f, signbit[i])
  2300. }
  2301. }
  2302. for i := 0; i < len(vfsignbitSC); i++ {
  2303. if f := Signbit(vfsignbitSC[i]); signbitSC[i] != f {
  2304. t.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC[i], f, signbitSC[i])
  2305. }
  2306. }
  2307. }
  2308. func TestSin(t *testing.T) {
  2309. for i := 0; i < len(vf); i++ {
  2310. if f := Sin(vf[i]); !veryclose(sin[i], f) {
  2311. t.Errorf("Sin(%g) = %g, want %g", vf[i], f, sin[i])
  2312. }
  2313. }
  2314. for i := 0; i < len(vfsinSC); i++ {
  2315. if f := Sin(vfsinSC[i]); !alike(sinSC[i], f) {
  2316. t.Errorf("Sin(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
  2317. }
  2318. }
  2319. }
  2320. func TestSincos(t *testing.T) {
  2321. for i := 0; i < len(vf); i++ {
  2322. if s, c := Sincos(vf[i]); !veryclose(sin[i], s) || !veryclose(cos[i], c) {
  2323. t.Errorf("Sincos(%g) = %g, %g want %g, %g", vf[i], s, c, sin[i], cos[i])
  2324. }
  2325. }
  2326. }
  2327. func TestSinh(t *testing.T) {
  2328. for i := 0; i < len(vf); i++ {
  2329. if f := Sinh(vf[i]); !close(sinh[i], f) {
  2330. t.Errorf("Sinh(%g) = %g, want %g", vf[i], f, sinh[i])
  2331. }
  2332. }
  2333. for i := 0; i < len(vfsinhSC); i++ {
  2334. if f := Sinh(vfsinhSC[i]); !alike(sinhSC[i], f) {
  2335. t.Errorf("Sinh(%g) = %g, want %g", vfsinhSC[i], f, sinhSC[i])
  2336. }
  2337. }
  2338. }
  2339. func TestSqrt(t *testing.T) {
  2340. for i := 0; i < len(vf); i++ {
  2341. a := Abs(vf[i])
  2342. if f := SqrtGo(a); sqrt[i] != f {
  2343. t.Errorf("SqrtGo(%g) = %g, want %g", a, f, sqrt[i])
  2344. }
  2345. a = Abs(vf[i])
  2346. if f := Sqrt(a); sqrt[i] != f {
  2347. t.Errorf("Sqrt(%g) = %g, want %g", a, f, sqrt[i])
  2348. }
  2349. }
  2350. for i := 0; i < len(vfsqrtSC); i++ {
  2351. if f := SqrtGo(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
  2352. t.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
  2353. }
  2354. if f := Sqrt(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
  2355. t.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
  2356. }
  2357. }
  2358. }
  2359. func TestTan(t *testing.T) {
  2360. for i := 0; i < len(vf); i++ {
  2361. if f := Tan(vf[i]); !veryclose(tan[i], f) {
  2362. t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
  2363. }
  2364. }
  2365. // same special cases as Sin
  2366. for i := 0; i < len(vfsinSC); i++ {
  2367. if f := Tan(vfsinSC[i]); !alike(sinSC[i], f) {
  2368. t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
  2369. }
  2370. }
  2371. }
  2372. func TestTanh(t *testing.T) {
  2373. for i := 0; i < len(vf); i++ {
  2374. if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
  2375. t.Errorf("Tanh(%g) = %g, want %g", vf[i], f, tanh[i])
  2376. }
  2377. }
  2378. for i := 0; i < len(vftanhSC); i++ {
  2379. if f := Tanh(vftanhSC[i]); !alike(tanhSC[i], f) {
  2380. t.Errorf("Tanh(%g) = %g, want %g", vftanhSC[i], f, tanhSC[i])
  2381. }
  2382. }
  2383. }
  2384. func TestTrunc(t *testing.T) {
  2385. for i := 0; i < len(vf); i++ {
  2386. if f := Trunc(vf[i]); trunc[i] != f {
  2387. t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
  2388. }
  2389. }
  2390. for i := 0; i < len(vfceilSC); i++ {
  2391. if f := Trunc(vfceilSC[i]); !alike(ceilSC[i], f) {
  2392. t.Errorf("Trunc(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
  2393. }
  2394. }
  2395. }
  2396. func TestY0(t *testing.T) {
  2397. for i := 0; i < len(vf); i++ {
  2398. a := Abs(vf[i])
  2399. if f := Y0(a); !close(y0[i], f) {
  2400. t.Errorf("Y0(%g) = %g, want %g", a, f, y0[i])
  2401. }
  2402. }
  2403. for i := 0; i < len(vfy0SC); i++ {
  2404. if f := Y0(vfy0SC[i]); !alike(y0SC[i], f) {
  2405. t.Errorf("Y0(%g) = %g, want %g", vfy0SC[i], f, y0SC[i])
  2406. }
  2407. }
  2408. }
  2409. func TestY1(t *testing.T) {
  2410. for i := 0; i < len(vf); i++ {
  2411. a := Abs(vf[i])
  2412. if f := Y1(a); !soclose(y1[i], f, 2e-14) {
  2413. t.Errorf("Y1(%g) = %g, want %g", a, f, y1[i])
  2414. }
  2415. }
  2416. for i := 0; i < len(vfy0SC); i++ {
  2417. if f := Y1(vfy0SC[i]); !alike(y1SC[i], f) {
  2418. t.Errorf("Y1(%g) = %g, want %g", vfy0SC[i], f, y1SC[i])
  2419. }
  2420. }
  2421. }
  2422. func TestYn(t *testing.T) {
  2423. for i := 0; i < len(vf); i++ {
  2424. a := Abs(vf[i])
  2425. if f := Yn(2, a); !close(y2[i], f) {
  2426. t.Errorf("Yn(2, %g) = %g, want %g", a, f, y2[i])
  2427. }
  2428. if f := Yn(-3, a); !close(yM3[i], f) {
  2429. t.Errorf("Yn(-3, %g) = %g, want %g", a, f, yM3[i])
  2430. }
  2431. }
  2432. for i := 0; i < len(vfy0SC); i++ {
  2433. if f := Yn(2, vfy0SC[i]); !alike(y2SC[i], f) {
  2434. t.Errorf("Yn(2, %g) = %g, want %g", vfy0SC[i], f, y2SC[i])
  2435. }
  2436. if f := Yn(-3, vfy0SC[i]); !alike(yM3SC[i], f) {
  2437. t.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC[i], f, yM3SC[i])
  2438. }
  2439. }
  2440. }
  2441. // Check that math functions of high angle values
  2442. // return accurate results. [Since (vf[i] + large) - large != vf[i],
  2443. // testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
  2444. // a multiple of 2*Pi, is misleading.]
  2445. func TestLargeCos(t *testing.T) {
  2446. large := float64(100000 * Pi)
  2447. for i := 0; i < len(vf); i++ {
  2448. f1 := cosLarge[i]
  2449. f2 := Cos(vf[i] + large)
  2450. if !close(f1, f2) {
  2451. t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
  2452. }
  2453. }
  2454. }
  2455. func TestLargeSin(t *testing.T) {
  2456. large := float64(100000 * Pi)
  2457. for i := 0; i < len(vf); i++ {
  2458. f1 := sinLarge[i]
  2459. f2 := Sin(vf[i] + large)
  2460. if !close(f1, f2) {
  2461. t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
  2462. }
  2463. }
  2464. }
  2465. func TestLargeSincos(t *testing.T) {
  2466. large := float64(100000 * Pi)
  2467. for i := 0; i < len(vf); i++ {
  2468. f1, g1 := sinLarge[i], cosLarge[i]
  2469. f2, g2 := Sincos(vf[i] + large)
  2470. if !close(f1, f2) || !close(g1, g2) {
  2471. t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
  2472. }
  2473. }
  2474. }
  2475. func TestLargeTan(t *testing.T) {
  2476. large := float64(100000 * Pi)
  2477. for i := 0; i < len(vf); i++ {
  2478. f1 := tanLarge[i]
  2479. f2 := Tan(vf[i] + large)
  2480. if !close(f1, f2) {
  2481. t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
  2482. }
  2483. }
  2484. }
  2485. // Check that math constants are accepted by compiler
  2486. // and have right value (assumes strconv.ParseFloat works).
  2487. // http://code.google.com/p/go/issues/detail?id=201
  2488. type floatTest struct {
  2489. val interface{}
  2490. name string
  2491. str string
  2492. }
  2493. var floatTests = []floatTest{
  2494. {float64(MaxFloat64), "MaxFloat64", "1.7976931348623157e+308"},
  2495. {float64(SmallestNonzeroFloat64), "SmallestNonzeroFloat64", "5e-324"},
  2496. {float32(MaxFloat32), "MaxFloat32", "3.4028235e+38"},
  2497. {float32(SmallestNonzeroFloat32), "SmallestNonzeroFloat32", "1e-45"},
  2498. }
  2499. func TestFloatMinMax(t *testing.T) {
  2500. for _, tt := range floatTests {
  2501. s := fmt.Sprint(tt.val)
  2502. if s != tt.str {
  2503. t.Errorf("Sprint(%v) = %s, want %s", tt.name, s, tt.str)
  2504. }
  2505. }
  2506. }
  2507. // Benchmarks
  2508. func BenchmarkAcos(b *testing.B) {
  2509. for i := 0; i < b.N; i++ {
  2510. Acos(.5)
  2511. }
  2512. }
  2513. func BenchmarkAcosh(b *testing.B) {
  2514. for i := 0; i < b.N; i++ {
  2515. Acosh(1.5)
  2516. }
  2517. }
  2518. func BenchmarkAsin(b *testing.B) {
  2519. for i := 0; i < b.N; i++ {
  2520. Asin(.5)
  2521. }
  2522. }
  2523. func BenchmarkAsinh(b *testing.B) {
  2524. for i := 0; i < b.N; i++ {
  2525. Asinh(.5)
  2526. }
  2527. }
  2528. func BenchmarkAtan(b *testing.B) {
  2529. for i := 0; i < b.N; i++ {
  2530. Atan(.5)
  2531. }
  2532. }
  2533. func BenchmarkAtanh(b *testing.B) {
  2534. for i := 0; i < b.N; i++ {
  2535. Atanh(.5)
  2536. }
  2537. }
  2538. func BenchmarkAtan2(b *testing.B) {
  2539. for i := 0; i < b.N; i++ {
  2540. Atan2(.5, 1)
  2541. }
  2542. }
  2543. func BenchmarkCbrt(b *testing.B) {
  2544. for i := 0; i < b.N; i++ {
  2545. Cbrt(10)
  2546. }
  2547. }
  2548. func BenchmarkCeil(b *testing.B) {
  2549. for i := 0; i < b.N; i++ {
  2550. Ceil(.5)
  2551. }
  2552. }
  2553. func BenchmarkCopysign(b *testing.B) {
  2554. for i := 0; i < b.N; i++ {
  2555. Copysign(.5, -1)
  2556. }
  2557. }
  2558. func BenchmarkCos(b *testing.B) {
  2559. for i := 0; i < b.N; i++ {
  2560. Cos(.5)
  2561. }
  2562. }
  2563. func BenchmarkCosh(b *testing.B) {
  2564. for i := 0; i < b.N; i++ {
  2565. Cosh(2.5)
  2566. }
  2567. }
  2568. func BenchmarkErf(b *testing.B) {
  2569. for i := 0; i < b.N; i++ {
  2570. Erf(.5)
  2571. }
  2572. }
  2573. func BenchmarkErfc(b *testing.B) {
  2574. for i := 0; i < b.N; i++ {
  2575. Erfc(.5)
  2576. }
  2577. }
  2578. func BenchmarkExp(b *testing.B) {
  2579. for i := 0; i < b.N; i++ {
  2580. Exp(.5)
  2581. }
  2582. }
  2583. func BenchmarkExpGo(b *testing.B) {
  2584. for i := 0; i < b.N; i++ {
  2585. ExpGo(.5)
  2586. }
  2587. }
  2588. func BenchmarkExpm1(b *testing.B) {
  2589. for i := 0; i < b.N; i++ {
  2590. Expm1(.5)
  2591. }
  2592. }
  2593. func BenchmarkExp2(b *testing.B) {
  2594. for i := 0; i < b.N; i++ {
  2595. Exp2(.5)
  2596. }
  2597. }
  2598. func BenchmarkExp2Go(b *testing.B) {
  2599. for i := 0; i < b.N; i++ {
  2600. Exp2Go(.5)
  2601. }
  2602. }
  2603. func BenchmarkAbs(b *testing.B) {
  2604. for i := 0; i < b.N; i++ {
  2605. Abs(.5)
  2606. }
  2607. }
  2608. func BenchmarkDim(b *testing.B) {
  2609. for i := 0; i < b.N; i++ {
  2610. Dim(10, 3)
  2611. }
  2612. }
  2613. func BenchmarkFloor(b *testing.B) {
  2614. for i := 0; i < b.N; i++ {
  2615. Floor(.5)
  2616. }
  2617. }
  2618. func BenchmarkMax(b *testing.B) {
  2619. for i := 0; i < b.N; i++ {
  2620. Max(10, 3)
  2621. }
  2622. }
  2623. func BenchmarkMin(b *testing.B) {
  2624. for i := 0; i < b.N; i++ {
  2625. Min(10, 3)
  2626. }
  2627. }
  2628. func BenchmarkMod(b *testing.B) {
  2629. for i := 0; i < b.N; i++ {
  2630. Mod(10, 3)
  2631. }
  2632. }
  2633. func BenchmarkFrexp(b *testing.B) {
  2634. for i := 0; i < b.N; i++ {
  2635. Frexp(8)
  2636. }
  2637. }
  2638. func BenchmarkGamma(b *testing.B) {
  2639. for i := 0; i < b.N; i++ {
  2640. Gamma(2.5)
  2641. }
  2642. }
  2643. func BenchmarkHypot(b *testing.B) {
  2644. for i := 0; i < b.N; i++ {
  2645. Hypot(3, 4)
  2646. }
  2647. }
  2648. func BenchmarkHypotGo(b *testing.B) {
  2649. for i := 0; i < b.N; i++ {
  2650. HypotGo(3, 4)
  2651. }
  2652. }
  2653. func BenchmarkIlogb(b *testing.B) {
  2654. for i := 0; i < b.N; i++ {
  2655. Ilogb(.5)
  2656. }
  2657. }
  2658. func BenchmarkJ0(b *testing.B) {
  2659. for i := 0; i < b.N; i++ {
  2660. J0(2.5)
  2661. }
  2662. }
  2663. func BenchmarkJ1(b *testing.B) {
  2664. for i := 0; i < b.N; i++ {
  2665. J1(2.5)
  2666. }
  2667. }
  2668. func BenchmarkJn(b *testing.B) {
  2669. for i := 0; i < b.N; i++ {
  2670. Jn(2, 2.5)
  2671. }
  2672. }
  2673. func BenchmarkLdexp(b *testing.B) {
  2674. for i := 0; i < b.N; i++ {
  2675. Ldexp(.5, 2)
  2676. }
  2677. }
  2678. func BenchmarkLgamma(b *testing.B) {
  2679. for i := 0; i < b.N; i++ {
  2680. Lgamma(2.5)
  2681. }
  2682. }
  2683. func BenchmarkLog(b *testing.B) {
  2684. for i := 0; i < b.N; i++ {
  2685. Log(.5)
  2686. }
  2687. }
  2688. func BenchmarkLogb(b *testing.B) {
  2689. for i := 0; i < b.N; i++ {
  2690. Logb(.5)
  2691. }
  2692. }
  2693. func BenchmarkLog1p(b *testing.B) {
  2694. for i := 0; i < b.N; i++ {
  2695. Log1p(.5)
  2696. }
  2697. }
  2698. func BenchmarkLog10(b *testing.B) {
  2699. for i := 0; i < b.N; i++ {
  2700. Log10(.5)
  2701. }
  2702. }
  2703. func BenchmarkLog2(b *testing.B) {
  2704. for i := 0; i < b.N; i++ {
  2705. Log2(.5)
  2706. }
  2707. }
  2708. func BenchmarkModf(b *testing.B) {
  2709. for i := 0; i < b.N; i++ {
  2710. Modf(1.5)
  2711. }
  2712. }
  2713. func BenchmarkNextafter32(b *testing.B) {
  2714. for i := 0; i < b.N; i++ {
  2715. Nextafter32(.5, 1)
  2716. }
  2717. }
  2718. func BenchmarkNextafter64(b *testing.B) {
  2719. for i := 0; i < b.N; i++ {
  2720. Nextafter(.5, 1)
  2721. }
  2722. }
  2723. func BenchmarkPowInt(b *testing.B) {
  2724. for i := 0; i < b.N; i++ {
  2725. Pow(2, 2)
  2726. }
  2727. }
  2728. func BenchmarkPowFrac(b *testing.B) {
  2729. for i := 0; i < b.N; i++ {
  2730. Pow(2.5, 1.5)
  2731. }
  2732. }
  2733. func BenchmarkPow10Pos(b *testing.B) {
  2734. for i := 0; i < b.N; i++ {
  2735. Pow10(300)
  2736. }
  2737. }
  2738. func BenchmarkPow10Neg(b *testing.B) {
  2739. for i := 0; i < b.N; i++ {
  2740. Pow10(-300)
  2741. }
  2742. }
  2743. func BenchmarkRemainder(b *testing.B) {
  2744. for i := 0; i < b.N; i++ {
  2745. Remainder(10, 3)
  2746. }
  2747. }
  2748. func BenchmarkSignbit(b *testing.B) {
  2749. for i := 0; i < b.N; i++ {
  2750. Signbit(2.5)
  2751. }
  2752. }
  2753. func BenchmarkSin(b *testing.B) {
  2754. for i := 0; i < b.N; i++ {
  2755. Sin(.5)
  2756. }
  2757. }
  2758. func BenchmarkSincos(b *testing.B) {
  2759. for i := 0; i < b.N; i++ {
  2760. Sincos(.5)
  2761. }
  2762. }
  2763. func BenchmarkSinh(b *testing.B) {
  2764. for i := 0; i < b.N; i++ {
  2765. Sinh(2.5)
  2766. }
  2767. }
  2768. func BenchmarkSqrt(b *testing.B) {
  2769. for i := 0; i < b.N; i++ {
  2770. Sqrt(10)
  2771. }
  2772. }
  2773. func BenchmarkSqrtGo(b *testing.B) {
  2774. for i := 0; i < b.N; i++ {
  2775. SqrtGo(10)
  2776. }
  2777. }
  2778. func BenchmarkTan(b *testing.B) {
  2779. for i := 0; i < b.N; i++ {
  2780. Tan(.5)
  2781. }
  2782. }
  2783. func BenchmarkTanh(b *testing.B) {
  2784. for i := 0; i < b.N; i++ {
  2785. Tanh(2.5)
  2786. }
  2787. }
  2788. func BenchmarkTrunc(b *testing.B) {
  2789. for i := 0; i < b.N; i++ {
  2790. Trunc(.5)
  2791. }
  2792. }
  2793. func BenchmarkY0(b *testing.B) {
  2794. for i := 0; i < b.N; i++ {
  2795. Y0(2.5)
  2796. }
  2797. }
  2798. func BenchmarkY1(b *testing.B) {
  2799. for i := 0; i < b.N; i++ {
  2800. Y1(2.5)
  2801. }
  2802. }
  2803. func BenchmarkYn(b *testing.B) {
  2804. for i := 0; i < b.N; i++ {
  2805. Yn(2, 2.5)
  2806. }
  2807. }