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.
15 4.9790119248836735e+00,
16 7.7388724745781045e+00,
17 -2.7688005719200159e-01,
18 -5.0106036182710749e+00,
19 9.6362937071984173e+00,
20 2.9263772392439646e+00,
21 5.2290834314593066e+00,
22 2.7279399104360102e+00,
23 1.8253080916808550e+00,
24 -8.6859247685756013e+00,
27 // The expected results below were computed by the high precision calculators
28 // at https://keisan.casio.com/. More exact input values (array vf[], above)
29 // were obtained by printing them with "%.26f". The answers were calculated
30 // to 26 digits (by using the "Digit number" drop-down control of each
33 1.0496193546107222142571536e+00,
34 6.8584012813664425171660692e-01,
35 1.5984878714577160325521819e+00,
36 2.0956199361475859327461799e+00,
37 2.7053008467824138592616927e-01,
38 1.2738121680361776018155625e+00,
39 1.0205369421140629186287407e+00,
40 1.2945003481781246062157835e+00,
41 1.3872364345374451433846657e+00,
42 2.6231510803970463967294145e+00,
44 var acosh = []float64{
45 2.4743347004159012494457618e+00,
46 2.8576385344292769649802701e+00,
47 7.2796961502981066190593175e-01,
48 2.4796794418831451156471977e+00,
49 3.0552020742306061857212962e+00,
50 2.044238592688586588942468e+00,
51 2.5158701513104513595766636e+00,
52 1.99050839282411638174299e+00,
53 1.6988625798424034227205445e+00,
54 2.9611454842470387925531875e+00,
57 5.2117697218417440497416805e-01,
58 8.8495619865825236751471477e-01,
59 -02.769154466281941332086016e-02,
60 -5.2482360935268931351485822e-01,
61 1.3002662421166552333051524e+00,
62 2.9698415875871901741575922e-01,
63 5.5025938468083370060258102e-01,
64 2.7629597861677201301553823e-01,
65 1.83559892257451475846656e-01,
66 -1.0523547536021497774980928e+00,
68 var asinh = []float64{
69 2.3083139124923523427628243e+00,
70 2.743551594301593620039021e+00,
71 -2.7345908534880091229413487e-01,
72 -2.3145157644718338650499085e+00,
73 2.9613652154015058521951083e+00,
74 1.7949041616585821933067568e+00,
75 2.3564032905983506405561554e+00,
76 1.7287118790768438878045346e+00,
77 1.3626658083714826013073193e+00,
78 -2.8581483626513914445234004e+00,
81 1.372590262129621651920085e+00,
82 1.442290609645298083020664e+00,
83 -2.7011324359471758245192595e-01,
84 -1.3738077684543379452781531e+00,
85 1.4673921193587666049154681e+00,
86 1.2415173565870168649117764e+00,
87 1.3818396865615168979966498e+00,
88 1.2194305844639670701091426e+00,
89 1.0696031952318783760193244e+00,
90 -1.4561721938838084990898679e+00,
92 var atanh = []float64{
93 5.4651163712251938116878204e-01,
94 1.0299474112843111224914709e+00,
95 -2.7695084420740135145234906e-02,
96 -5.5072096119207195480202529e-01,
97 1.9943940993171843235906642e+00,
98 3.01448604578089708203017e-01,
99 5.8033427206942188834370595e-01,
100 2.7987997499441511013958297e-01,
101 1.8459947964298794318714228e-01,
102 -1.3273186910532645867272502e+00,
104 var atan2 = []float64{
105 1.1088291730037004444527075e+00,
106 9.1218183188715804018797795e-01,
107 1.5984772603216203736068915e+00,
108 2.0352918654092086637227327e+00,
109 8.0391819139044720267356014e-01,
110 1.2861075249894661588866752e+00,
111 1.0889904479131695712182587e+00,
112 1.3044821793397925293797357e+00,
113 1.3902530903455392306872261e+00,
114 2.2859857424479142655411058e+00,
116 var cbrt = []float64{
117 1.7075799841925094446722675e+00,
118 1.9779982212970353936691498e+00,
119 -6.5177429017779910853339447e-01,
120 -1.7111838886544019873338113e+00,
121 2.1279920909827937423960472e+00,
122 1.4303536770460741452312367e+00,
123 1.7357021059106154902341052e+00,
124 1.3972633462554328350552916e+00,
125 1.2221149580905388454977636e+00,
126 -2.0556003730500069110343596e+00,
128 var ceil = []float64{
129 5.0000000000000000e+00,
130 8.0000000000000000e+00,
132 -5.0000000000000000e+00,
133 1.0000000000000000e+01,
134 3.0000000000000000e+00,
135 6.0000000000000000e+00,
136 3.0000000000000000e+00,
137 2.0000000000000000e+00,
138 -8.0000000000000000e+00,
140 var copysign = []float64{
141 -4.9790119248836735e+00,
142 -7.7388724745781045e+00,
143 -2.7688005719200159e-01,
144 -5.0106036182710749e+00,
145 -9.6362937071984173e+00,
146 -2.9263772392439646e+00,
147 -5.2290834314593066e+00,
148 -2.7279399104360102e+00,
149 -1.8253080916808550e+00,
150 -8.6859247685756013e+00,
153 2.634752140995199110787593e-01,
154 1.148551260848219865642039e-01,
155 9.6191297325640768154550453e-01,
156 2.938141150061714816890637e-01,
157 -9.777138189897924126294461e-01,
158 -9.7693041344303219127199518e-01,
159 4.940088096948647263961162e-01,
160 -9.1565869021018925545016502e-01,
161 -2.517729313893103197176091e-01,
162 -7.39241351595676573201918e-01,
165 // Results for 100000 * Pi + vf[i]
166 var cosLarge = []float64{
167 2.634752141185559426744e-01,
168 1.14855126055543100712e-01,
169 9.61912973266488928113e-01,
170 2.9381411499556122552e-01,
171 -9.777138189880161924641e-01,
172 -9.76930413445147608049e-01,
173 4.940088097314976789841e-01,
174 -9.15658690217517835002e-01,
175 -2.51772931436786954751e-01,
176 -7.3924135157173099849e-01,
179 var cosh = []float64{
180 7.2668796942212842775517446e+01,
181 1.1479413465659254502011135e+03,
182 1.0385767908766418550935495e+00,
183 7.5000957789658051428857788e+01,
184 7.655246669605357888468613e+03,
185 9.3567491758321272072888257e+00,
186 9.331351599270605471131735e+01,
187 7.6833430994624643209296404e+00,
188 3.1829371625150718153881164e+00,
189 2.9595059261916188501640911e+03,
192 5.1865354817738701906913566e-01,
193 7.2623875834137295116929844e-01,
194 -3.123458688281309990629839e-02,
195 -5.2143121110253302920437013e-01,
196 8.2704742671312902508629582e-01,
197 3.2101767558376376743993945e-01,
198 5.403990312223245516066252e-01,
199 3.0034702916738588551174831e-01,
200 2.0369924417882241241559589e-01,
201 -7.8069386968009226729944677e-01,
203 var erfc = []float64{
204 4.8134645182261298093086434e-01,
205 2.7376124165862704883070156e-01,
206 1.0312345868828130999062984e+00,
207 1.5214312111025330292043701e+00,
208 1.7295257328687097491370418e-01,
209 6.7898232441623623256006055e-01,
210 4.596009687776754483933748e-01,
211 6.9965297083261411448825169e-01,
212 7.9630075582117758758440411e-01,
213 1.7806938696800922672994468e+00,
215 var erfinv = []float64{
216 4.746037673358033586786350696e-01,
217 8.559054432692110956388764172e-01,
218 -2.45427830571707336251331946e-02,
219 -4.78116683518973366268905506e-01,
220 1.479804430319470983648120853e+00,
221 2.654485787128896161882650211e-01,
222 5.027444534221520197823192493e-01,
223 2.466703532707627818954585670e-01,
224 1.632011465103005426240343116e-01,
225 -1.06672334642196900710000389e+00,
228 1.4533071302642137507696589e+02,
229 2.2958822575694449002537581e+03,
230 7.5814542574851666582042306e-01,
231 6.6668778421791005061482264e-03,
232 1.5310493273896033740861206e+04,
233 1.8659907517999328638667732e+01,
234 1.8662167355098714543942057e+02,
235 1.5301332413189378961665788e+01,
236 6.2047063430646876349125085e+00,
237 1.6894712385826521111610438e-04,
239 var expm1 = []float64{
240 5.105047796122957327384770212e-02,
241 8.046199708567344080562675439e-02,
242 -2.764970978891639815187418703e-03,
243 -4.8871434888875355394330300273e-02,
244 1.0115864277221467777117227494e-01,
245 2.969616407795910726014621657e-02,
246 5.368214487944892300914037972e-02,
247 2.765488851131274068067445335e-02,
248 1.842068661871398836913874273e-02,
249 -8.3193870863553801814961137573e-02,
251 var expm1Large = []float64{
252 4.2031418113550844e+21,
253 4.0690789717473863e+33,
254 -0.9372627915981363e+00,
256 7.077694784145933e+41,
257 5.117936223839153e+12,
258 5.124137759001189e+22,
259 7.03546003972584e+11,
260 8.456921800389698e+07,
263 var exp2 = []float64{
264 3.1537839463286288034313104e+01,
265 2.1361549283756232296144849e+02,
266 8.2537402562185562902577219e-01,
267 3.1021158628740294833424229e-02,
268 7.9581744110252191462569661e+02,
269 7.6019905892596359262696423e+00,
270 3.7506882048388096973183084e+01,
271 6.6250893439173561733216375e+00,
272 3.5438267900243941544605339e+00,
273 2.4281533133513300984289196e-03,
275 var fabs = []float64{
276 4.9790119248836735e+00,
277 7.7388724745781045e+00,
278 2.7688005719200159e-01,
279 5.0106036182710749e+00,
280 9.6362937071984173e+00,
281 2.9263772392439646e+00,
282 5.2290834314593066e+00,
283 2.7279399104360102e+00,
284 1.8253080916808550e+00,
285 8.6859247685756013e+00,
287 var fdim = []float64{
288 4.9790119248836735e+00,
289 7.7388724745781045e+00,
290 0.0000000000000000e+00,
291 0.0000000000000000e+00,
292 9.6362937071984173e+00,
293 2.9263772392439646e+00,
294 5.2290834314593066e+00,
295 2.7279399104360102e+00,
296 1.8253080916808550e+00,
297 0.0000000000000000e+00,
299 var floor = []float64{
300 4.0000000000000000e+00,
301 7.0000000000000000e+00,
302 -1.0000000000000000e+00,
303 -6.0000000000000000e+00,
304 9.0000000000000000e+00,
305 2.0000000000000000e+00,
306 5.0000000000000000e+00,
307 2.0000000000000000e+00,
308 1.0000000000000000e+00,
309 -9.0000000000000000e+00,
311 var fmod = []float64{
312 4.197615023265299782906368e-02,
313 2.261127525421895434476482e+00,
314 3.231794108794261433104108e-02,
315 4.989396381728925078391512e+00,
316 3.637062928015826201999516e-01,
317 1.220868282268106064236690e+00,
318 4.770916568540693347699744e+00,
319 1.816180268691969246219742e+00,
320 8.734595415957246977711748e-01,
321 1.314075231424398637614104e+00,
330 {6.2237649061045918750e-01, 3},
331 {9.6735905932226306250e-01, 3},
332 {-5.5376011438400318000e-01, -1},
333 {-6.2632545228388436250e-01, 3},
334 {6.02268356699901081250e-01, 4},
335 {7.3159430981099115000e-01, 2},
336 {6.5363542893241332500e-01, 3},
337 {6.8198497760900255000e-01, 2},
338 {9.1265404584042750000e-01, 1},
339 {-5.4287029803597508250e-01, 4},
341 var gamma = []float64{
342 2.3254348370739963835386613898e+01,
343 2.991153837155317076427529816e+03,
344 -4.561154336726758060575129109e+00,
345 7.719403468842639065959210984e-01,
346 1.6111876618855418534325755566e+05,
347 1.8706575145216421164173224946e+00,
348 3.4082787447257502836734201635e+01,
349 1.579733951448952054898583387e+00,
350 9.3834586598354592860187267089e-01,
351 -2.093995902923148389186189429e-05,
354 -1.8444682230601672018219338e-01,
355 2.27353668906331975435892e-01,
356 9.809259936157051116270273e-01,
357 -1.741170131426226587841181e-01,
358 -2.1389448451144143352039069e-01,
359 -2.340905848928038763337414e-01,
360 -1.0029099691890912094586326e-01,
361 -1.5466726714884328135358907e-01,
362 3.252650187653420388714693e-01,
363 -8.72218484409407250005360235e-03,
366 -3.251526395295203422162967e-01,
367 1.893581711430515718062564e-01,
368 -1.3711761352467242914491514e-01,
369 3.287486536269617297529617e-01,
370 1.3133899188830978473849215e-01,
371 3.660243417832986825301766e-01,
372 -3.4436769271848174665420672e-01,
373 4.329481396640773768835036e-01,
374 5.8181350531954794639333955e-01,
375 -2.7030574577733036112996607e-01,
378 5.3837518920137802565192769e-02,
379 -1.7841678003393207281244667e-01,
380 9.521746934916464142495821e-03,
381 4.28958355470987397983072e-02,
382 2.4115371837854494725492872e-01,
383 4.842458532394520316844449e-01,
384 -3.142145220618633390125946e-02,
385 4.720849184745124761189957e-01,
386 3.122312022520957042957497e-01,
387 7.096213118930231185707277e-02,
390 -3.684042080996403091021151e-01,
391 2.8157665936340887268092661e-01,
392 4.401005480841948348343589e-04,
393 3.629926999056814081597135e-01,
394 3.123672198825455192489266e-02,
395 -2.958805510589623607540455e-01,
396 -3.2033177696533233403289416e-01,
397 -2.592737332129663376736604e-01,
398 -1.0241334641061485092351251e-01,
399 -2.3762660886100206491674503e-01,
402 {3.146492141244545774319734e+00, 1},
403 {8.003414490659126375852113e+00, 1},
404 {1.517575735509779707488106e+00, -1},
405 {-2.588480028182145853558748e-01, 1},
406 {1.1989897050205555002007985e+01, 1},
407 {6.262899811091257519386906e-01, 1},
408 {3.5287924899091566764846037e+00, 1},
409 {4.5725644770161182299423372e-01, 1},
410 {-6.363667087767961257654854e-02, 1},
411 {-1.077385130910300066425564e+01, -1},
414 1.605231462693062999102599e+00,
415 2.0462560018708770653153909e+00,
416 -1.2841708730962657801275038e+00,
417 1.6115563905281545116286206e+00,
418 2.2655365644872016636317461e+00,
419 1.0737652208918379856272735e+00,
420 1.6542360106073546632707956e+00,
421 1.0035467127723465801264487e+00,
422 6.0174879014578057187016475e-01,
423 2.161703872847352815363655e+00,
425 var logb = []float64{
426 2.0000000000000000e+00,
427 2.0000000000000000e+00,
428 -2.0000000000000000e+00,
429 2.0000000000000000e+00,
430 3.0000000000000000e+00,
431 1.0000000000000000e+00,
432 2.0000000000000000e+00,
433 1.0000000000000000e+00,
434 0.0000000000000000e+00,
435 3.0000000000000000e+00,
437 var log10 = []float64{
438 6.9714316642508290997617083e-01,
439 8.886776901739320576279124e-01,
440 -5.5770832400658929815908236e-01,
441 6.998900476822994346229723e-01,
442 9.8391002850684232013281033e-01,
443 4.6633031029295153334285302e-01,
444 7.1842557117242328821552533e-01,
445 4.3583479968917773161304553e-01,
446 2.6133617905227038228626834e-01,
447 9.3881606348649405716214241e-01,
449 var log1p = []float64{
450 4.8590257759797794104158205e-02,
451 7.4540265965225865330849141e-02,
452 -2.7726407903942672823234024e-03,
453 -5.1404917651627649094953380e-02,
454 9.1998280672258624681335010e-02,
455 2.8843762576593352865894824e-02,
456 5.0969534581863707268992645e-02,
457 2.6913947602193238458458594e-02,
458 1.8088493239630770262045333e-02,
459 -9.0865245631588989681559268e-02,
461 var log2 = []float64{
462 2.3158594707062190618898251e+00,
463 2.9521233862883917703341018e+00,
464 -1.8526669502700329984917062e+00,
465 2.3249844127278861543568029e+00,
466 3.268478366538305087466309e+00,
467 1.5491157592596970278166492e+00,
468 2.3865580889631732407886495e+00,
469 1.447811865817085365540347e+00,
470 8.6813999540425116282815557e-01,
471 3.118679457227342224364709e+00,
473 var modf = [][2]float64{
474 {4.0000000000000000e+00, 9.7901192488367350108546816e-01},
475 {7.0000000000000000e+00, 7.3887247457810456552351752e-01},
476 {Copysign(0, -1), -2.7688005719200159404635997e-01},
477 {-5.0000000000000000e+00, -1.060361827107492160848778e-02},
478 {9.0000000000000000e+00, 6.3629370719841737980004837e-01},
479 {2.0000000000000000e+00, 9.2637723924396464525443662e-01},
480 {5.0000000000000000e+00, 2.2908343145930665230025625e-01},
481 {2.0000000000000000e+00, 7.2793991043601025126008608e-01},
482 {1.0000000000000000e+00, 8.2530809168085506044576505e-01},
483 {-8.0000000000000000e+00, -6.8592476857560136238589621e-01},
485 var nextafter32 = []float32{
486 4.979012489318848e+00,
487 7.738873004913330e+00,
488 -2.768800258636475e-01,
489 -5.010602951049805e+00,
490 9.636294364929199e+00,
491 2.926377534866333e+00,
492 5.229084014892578e+00,
493 2.727940082550049e+00,
494 1.825308203697205e+00,
495 -8.685923576354980e+00,
497 var nextafter64 = []float64{
498 4.97901192488367438926388786e+00,
499 7.73887247457810545370193722e+00,
500 -2.7688005719200153853520874e-01,
501 -5.01060361827107403343006808e+00,
502 9.63629370719841915615688777e+00,
503 2.92637723924396508934364647e+00,
504 5.22908343145930754047867595e+00,
505 2.72793991043601069534929593e+00,
506 1.82530809168085528249036997e+00,
507 -8.68592476857559958602905681e+00,
510 9.5282232631648411840742957e+04,
511 5.4811599352999901232411871e+07,
512 5.2859121715894396531132279e-01,
513 9.7587991957286474464259698e-06,
514 4.328064329346044846740467e+09,
515 8.4406761805034547437659092e+02,
516 1.6946633276191194947742146e+05,
517 5.3449040147551939075312879e+02,
518 6.688182138451414936380374e+01,
519 2.0609869004248742886827439e-09,
521 var remainder = []float64{
522 4.197615023265299782906368e-02,
523 2.261127525421895434476482e+00,
524 3.231794108794261433104108e-02,
525 -2.120723654214984321697556e-02,
526 3.637062928015826201999516e-01,
527 1.220868282268106064236690e+00,
528 -4.581668629186133046005125e-01,
529 -9.117596417440410050403443e-01,
530 8.734595415957246977711748e-01,
531 1.314075231424398637614104e+00,
533 var round = []float64{
545 var signbit = []bool{
558 -9.6466616586009283766724726e-01,
559 9.9338225271646545763467022e-01,
560 -2.7335587039794393342449301e-01,
561 9.5586257685042792878173752e-01,
562 -2.099421066779969164496634e-01,
563 2.135578780799860532750616e-01,
564 -8.694568971167362743327708e-01,
565 4.019566681155577786649878e-01,
566 9.6778633541687993721617774e-01,
567 -6.734405869050344734943028e-01,
570 // Results for 100000 * Pi + vf[i]
571 var sinLarge = []float64{
572 -9.646661658548936063912e-01,
573 9.933822527198506903752e-01,
574 -2.7335587036246899796e-01,
575 9.55862576853689321268e-01,
576 -2.099421066862688873691e-01,
577 2.13557878070308981163e-01,
578 -8.694568970959221300497e-01,
579 4.01956668098863248917e-01,
580 9.67786335404528727927e-01,
581 -6.7344058693131973066e-01,
583 var sinh = []float64{
584 7.2661916084208532301448439e+01,
585 1.1479409110035194500526446e+03,
586 -2.8043136512812518927312641e-01,
587 -7.499429091181587232835164e+01,
588 7.6552466042906758523925934e+03,
589 9.3031583421672014313789064e+00,
590 9.330815755828109072810322e+01,
591 7.6179893137269146407361477e+00,
592 3.021769180549615819524392e+00,
593 -2.95950575724449499189888e+03,
595 var sqrt = []float64{
596 2.2313699659365484748756904e+00,
597 2.7818829009464263511285458e+00,
598 5.2619393496314796848143251e-01,
599 2.2384377628763938724244104e+00,
600 3.1042380236055381099288487e+00,
601 1.7106657298385224403917771e+00,
602 2.286718922705479046148059e+00,
603 1.6516476350711159636222979e+00,
604 1.3510396336454586262419247e+00,
605 2.9471892997524949215723329e+00,
608 -3.661316565040227801781974e+00,
609 8.64900232648597589369854e+00,
610 -2.8417941955033612725238097e-01,
611 3.253290185974728640827156e+00,
612 2.147275640380293804770778e-01,
613 -2.18600910711067004921551e-01,
614 -1.760002817872367935518928e+00,
615 -4.389808914752818126249079e-01,
616 -3.843885560201130679995041e+00,
617 9.10988793377685105753416e-01,
620 // Results for 100000 * Pi + vf[i]
621 var tanLarge = []float64{
622 -3.66131656475596512705e+00,
623 8.6490023287202547927e+00,
624 -2.841794195104782406e-01,
625 3.2532901861033120983e+00,
626 2.14727564046880001365e-01,
627 -2.18600910700688062874e-01,
628 -1.760002817699722747043e+00,
629 -4.38980891453536115952e-01,
630 -3.84388555942723509071e+00,
631 9.1098879344275101051e-01,
633 var tanh = []float64{
634 9.9990531206936338549262119e-01,
635 9.9999962057085294197613294e-01,
636 -2.7001505097318677233756845e-01,
637 -9.9991110943061718603541401e-01,
638 9.9999999146798465745022007e-01,
639 9.9427249436125236705001048e-01,
640 9.9994257600983138572705076e-01,
641 9.9149409509772875982054701e-01,
642 9.4936501296239685514466577e-01,
643 -9.9999994291374030946055701e-01,
645 var trunc = []float64{
646 4.0000000000000000e+00,
647 7.0000000000000000e+00,
649 -5.0000000000000000e+00,
650 9.0000000000000000e+00,
651 2.0000000000000000e+00,
652 5.0000000000000000e+00,
653 2.0000000000000000e+00,
654 1.0000000000000000e+00,
655 -8.0000000000000000e+00,
658 -3.053399153780788357534855e-01,
659 1.7437227649515231515503649e-01,
660 -8.6221781263678836910392572e-01,
661 -3.100664880987498407872839e-01,
662 1.422200649300982280645377e-01,
663 4.000004067997901144239363e-01,
664 -3.3340749753099352392332536e-01,
665 4.5399790746668954555205502e-01,
666 4.8290004112497761007536522e-01,
667 2.7036697826604756229601611e-01,
670 0.15494213737457922210218611,
671 -0.2165955142081145245075746,
672 -2.4644949631241895201032829,
673 0.1442740489541836405154505,
674 0.2215379960518984777080163,
675 0.3038800915160754150565448,
676 0.0691107642452362383808547,
677 0.2380116417809914424860165,
678 -0.20849492979459761009678934,
679 0.0242503179793232308250804,
682 0.3675780219390303613394936,
683 -0.23034826393250119879267257,
684 -16.939677983817727205631397,
685 0.367653980523052152867791,
686 -0.0962401471767804440353136,
687 -0.1923169356184851105200523,
688 0.35984072054267882391843766,
689 -0.2794987252299739821654982,
690 -0.7113490692587462579757954,
691 -0.2647831587821263302087457,
694 -0.14035984421094849100895341,
695 -0.097535139617792072703973,
696 242.25775994555580176377379,
697 -0.1492267014802818619511046,
698 0.26148702629155918694500469,
699 0.56675383593895176530394248,
700 -0.206150264009006981070575,
701 0.64784284687568332737963658,
702 1.3503631555901938037008443,
703 0.1461869756579956803341844,
706 // arguments and expected results for special cases
707 var vfacosSC = []float64{
713 var acosSC = []float64{
720 var vfacoshSC = []float64{
727 var acoshSC = []float64{
735 var vfasinSC = []float64{
742 var asinSC = []float64{
750 var vfasinhSC = []float64{
757 var asinhSC = []float64{
765 var vfatanSC = []float64{
772 var atanSC = []float64{
780 var vfatanhSC = []float64{
791 var atanhSC = []float64{
802 var vfatan2SC = [][2]float64{
813 {Copysign(0, -1), Inf(-1)},
814 {Copysign(0, -1), -Pi},
815 {Copysign(0, -1), Copysign(0, -1)},
816 {Copysign(0, -1), 0},
817 {Copysign(0, -1), +Pi},
818 {Copysign(0, -1), Inf(1)},
819 {Copysign(0, -1), NaN()},
822 {0, Copysign(0, -1)},
841 var atan2SC = []float64{
842 -3 * Pi / 4, // atan2(-Inf, -Inf)
843 -Pi / 2, // atan2(-Inf, -Pi)
844 -Pi / 2, // atan2(-Inf, +0)
845 -Pi / 2, // atan2(-Inf, +Pi)
846 -Pi / 4, // atan2(-Inf, +Inf)
847 NaN(), // atan2(-Inf, NaN)
848 -Pi, // atan2(-Pi, -Inf)
849 -Pi / 2, // atan2(-Pi, +0)
850 Copysign(0, -1), // atan2(-Pi, Inf)
851 NaN(), // atan2(-Pi, NaN)
852 -Pi, // atan2(-0, -Inf)
853 -Pi, // atan2(-0, -Pi)
854 -Pi, // atan2(-0, -0)
855 Copysign(0, -1), // atan2(-0, +0)
856 Copysign(0, -1), // atan2(-0, +Pi)
857 Copysign(0, -1), // atan2(-0, +Inf)
858 NaN(), // atan2(-0, NaN)
859 Pi, // atan2(+0, -Inf)
860 Pi, // atan2(+0, -Pi)
864 0, // atan2(+0, +Inf)
865 NaN(), // atan2(+0, NaN)
866 Pi, // atan2(+Pi, -Inf)
867 Pi / 2, // atan2(+Pi, +0)
868 0, // atan2(+Pi, +Inf)
869 0, // atan2(+1, +Inf)
870 Copysign(0, -1), // atan2(-1, +Inf)
871 NaN(), // atan2(+Pi, NaN)
872 3 * Pi / 4, // atan2(+Inf, -Inf)
873 Pi / 2, // atan2(+Inf, -Pi)
874 Pi / 2, // atan2(+Inf, +0)
875 Pi / 2, // atan2(+Inf, +Pi)
876 Pi / 4, // atan2(+Inf, +Inf)
877 NaN(), // atan2(+Inf, NaN)
878 NaN(), // atan2(NaN, NaN)
881 var vfcbrtSC = []float64{
888 var cbrtSC = []float64{
896 var vfceilSC = []float64{
903 var ceilSC = []float64{
911 var vfcopysignSC = []float64{
916 var copysignSC = []float64{
922 var vfcosSC = []float64{
927 var cosSC = []float64{
933 var vfcoshSC = []float64{
940 var coshSC = []float64{
948 var vferfSC = []float64{
957 var erfSC = []float64{
967 var vferfcSC = []float64{
974 var erfcSC = []float64{
982 var vferfinvSC = []float64{
990 var erfinvSC = []float64{
999 var vferfcinvSC = []float64{
1007 var erfcinvSC = []float64{
1016 var vfexpSC = []float64{
1022 // smallest float64 that overflows Exp(x)
1023 7.097827128933841e+02,
1029 3.725290298461915e-09,
1033 var expSC = []float64{
1047 var vfexp2SC = []float64{
1053 // smallest float64 that overflows Exp2(x)
1056 -1.07399999999999e+03,
1058 3.725290298461915e-09,
1060 var exp2SC = []float64{
1071 var vfexpm1SC = []float64{
1080 var expm1SC = []float64{
1090 var vffabsSC = []float64{
1097 var fabsSC = []float64{
1105 var vffdimSC = [][2]float64{
1109 {Copysign(0, -1), Copysign(0, -1)},
1110 {Copysign(0, -1), 0},
1111 {0, Copysign(0, -1)},
1117 {NaN(), Copysign(0, -1)},
1122 var nan = Float64frombits(0xFFF8000000000000) // SSE2 DIVSD 0/0
1123 var vffdim2SC = [][2]float64{
1127 {Copysign(0, -1), Copysign(0, -1)},
1128 {Copysign(0, -1), 0},
1129 {0, Copysign(0, -1)},
1135 {nan, Copysign(0, -1)},
1140 var fdimSC = []float64{
1157 var fmaxSC = []float64{
1174 var fminSC = []float64{
1192 var vffmodSC = [][2]float64{
1203 {Copysign(0, -1), Inf(-1)},
1204 {Copysign(0, -1), 0},
1205 {Copysign(0, -1), Inf(1)},
1206 {Copysign(0, -1), NaN()},
1228 var fmodSC = []float64{
1229 NaN(), // fmod(-Inf, -Inf)
1230 NaN(), // fmod(-Inf, -Pi)
1231 NaN(), // fmod(-Inf, 0)
1232 NaN(), // fmod(-Inf, Pi)
1233 NaN(), // fmod(-Inf, +Inf)
1234 NaN(), // fmod(-Inf, NaN)
1235 -Pi, // fmod(-Pi, -Inf)
1236 NaN(), // fmod(-Pi, 0)
1237 -Pi, // fmod(-Pi, +Inf)
1238 NaN(), // fmod(-Pi, NaN)
1239 Copysign(0, -1), // fmod(-0, -Inf)
1240 NaN(), // fmod(-0, 0)
1241 Copysign(0, -1), // fmod(-0, Inf)
1242 NaN(), // fmod(-0, NaN)
1244 NaN(), // fmod(0, 0)
1246 NaN(), // fmod(0, NaN)
1247 Pi, // fmod(Pi, -Inf)
1248 NaN(), // fmod(Pi, 0)
1249 Pi, // fmod(Pi, +Inf)
1250 NaN(), // fmod(Pi, NaN)
1251 NaN(), // fmod(+Inf, -Inf)
1252 NaN(), // fmod(+Inf, -Pi)
1253 NaN(), // fmod(+Inf, 0)
1254 NaN(), // fmod(+Inf, Pi)
1255 NaN(), // fmod(+Inf, +Inf)
1256 NaN(), // fmod(+Inf, NaN)
1257 NaN(), // fmod(NaN, -Inf)
1258 NaN(), // fmod(NaN, -Pi)
1259 NaN(), // fmod(NaN, 0)
1260 NaN(), // fmod(NaN, Pi)
1261 NaN(), // fmod(NaN, +Inf)
1262 NaN(), // fmod(NaN, NaN)
1265 var vffrexpSC = []float64{
1274 {Copysign(0, -1), 0},
1280 var vfgamma = [][2]float64{
1284 {Copysign(0, -1), Inf(-1)},
1293 // Test inputs inspired by Python test suite.
1294 // Outputs computed at high precision by PARI/GP.
1295 // If recomputing table entries, be careful to use
1296 // high-precision (%.1000g) formatting of the float64 inputs.
1297 // For example, -2.0000000000000004 is the float64 with exact value
1298 // -2.00000000000000044408920985626161695, and
1299 // gamma(-2.0000000000000004) = -1249999999999999.5386078562728167651513, while
1300 // gamma(-2.00000000000000044408920985626161695) = -1125899906826907.2044875028130093136826.
1301 // Thus the table lists -1.1258999068426235e+15 as the answer.
1302 {0.5, 1.772453850905516},
1303 {1.5, 0.886226925452758},
1304 {2.5, 1.329340388179137},
1305 {3.5, 3.3233509704478426},
1306 {-0.5, -3.544907701811032},
1307 {-1.5, 2.363271801207355},
1308 {-2.5, -0.9453087204829419},
1309 {-3.5, 0.2700882058522691},
1310 {0.1, 9.51350769866873},
1311 {0.01, 99.4325851191506},
1312 {1e-08, 9.999999942278434e+07},
1314 {0.001, 999.4237724845955},
1317 {5.6e-309, 1.7857142857142864e+308},
1322 {-0.1, -10.686287021193193},
1323 {-0.01, -100.58719796441078},
1324 {-1e-08, -1.0000000057721567e+08},
1326 {-0.001, -1000.5782056293586},
1329 {-5.6e-309, -1.7857142857142864e+308},
1330 {-5.5e-309, Inf(-1)},
1334 {-0.9999999999999999, -9.007199254740992e+15},
1335 {-1.0000000000000002, 4.5035996273704955e+15},
1336 {-1.9999999999999998, 2.2517998136852485e+15},
1337 {-2.0000000000000004, -1.1258999068426235e+15},
1338 {-100.00000000000001, -7.540083334883109e-145},
1339 {-99.99999999999999, 7.540083334884096e-145},
1340 {17, 2.0922789888e+13},
1341 {171, 7.257415615307999e+306},
1342 {171.6, 1.5858969096672565e+308},
1343 {171.624, 1.7942117599248104e+308},
1347 {-100.5, -3.3536908198076787e-159},
1348 {-160.5, -5.255546447007829e-286},
1349 {-170.5, -3.3127395215386074e-308},
1350 {-171.5, 1.9316265431712e-310},
1351 {-176.5, -1.196e-321},
1353 {-178.5, Copysign(0, -1)},
1356 {-202.9999, Copysign(0, -1)},
1357 {-1000.5, Copysign(0, -1)},
1358 {-1.0000000003e+09, Copysign(0, -1)},
1359 {-4.5035996273704955e+15, 0},
1360 {-63.349078729022985, 4.177797167776188e-88},
1361 {-127.45117632943295, 1.183111089623681e-214},
1364 var vfhypotSC = [][2]float64{
1369 {Copysign(0, -1), Copysign(0, -1)},
1370 {Copysign(0, -1), 0},
1371 {0, Copysign(0, -1)},
1385 var hypotSC = []float64{
1407 var ilogbSC = []int{
1414 var vfj0SC = []float64{
1420 var j0SC = []float64{
1426 var j1SC = []float64{
1432 var j2SC = []float64{
1438 var jM3SC = []float64{
1445 var vfldexpSC = []fi{
1449 {Copysign(0, -1), 0},
1450 {Copysign(0, -1), -1075},
1451 {Copysign(0, -1), 1024},
1457 {10, int(1) << (uint64(unsafe.Sizeof(0)-1) * 8)},
1458 {10, -(int(1) << (uint64(unsafe.Sizeof(0)-1) * 8))},
1460 var ldexpSC = []float64{
1476 var vflgammaSC = []float64{
1485 var lgammaSC = []fi{
1495 var vflogSC = []float64{
1504 var logSC = []float64{
1514 var vflogbSC = []float64{
1520 var logbSC = []float64{
1527 var vflog1pSC = []float64{
1535 4503599627370496.5, // Issue #29488
1537 var log1pSC = []float64{
1545 36.04365338911715, // Issue #29488
1548 var vfmodfSC = []float64{
1554 var modfSC = [][2]float64{
1555 {Inf(-1), NaN()}, // [2]float64{Copysign(0, -1), Inf(-1)},
1556 {Copysign(0, -1), Copysign(0, -1)},
1557 {Inf(1), NaN()}, // [2]float64{0, Inf(1)},
1561 var vfnextafter32SC = [][2]float32{
1563 {0, float32(Copysign(0, -1))},
1565 {0, float32(NaN())},
1566 {float32(Copysign(0, -1)), 1},
1567 {float32(Copysign(0, -1)), 0},
1568 {float32(Copysign(0, -1)), float32(Copysign(0, -1))},
1569 {float32(Copysign(0, -1)), -1},
1570 {float32(NaN()), 0},
1571 {float32(NaN()), float32(NaN())},
1573 var nextafter32SC = []float32{
1576 -1.401298464e-45, // Float32frombits(0x80000001)
1578 1.401298464e-45, // Float32frombits(0x00000001)
1579 float32(Copysign(0, -1)),
1580 float32(Copysign(0, -1)),
1581 -1.401298464e-45, // Float32frombits(0x80000001)
1586 var vfnextafter64SC = [][2]float64{
1588 {0, Copysign(0, -1)},
1591 {Copysign(0, -1), 1},
1592 {Copysign(0, -1), 0},
1593 {Copysign(0, -1), Copysign(0, -1)},
1594 {Copysign(0, -1), -1},
1598 var nextafter64SC = []float64{
1601 -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1603 4.9406564584124654418e-324, // Float64frombits(0x0000000000000001)
1606 -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1611 var vfpowSC = [][2]float64{
1614 {Inf(-1), Copysign(0, -1)},
1624 {-Pi, Copysign(0, -1)},
1636 {Copysign(0, -1), Inf(-1)},
1637 {Copysign(0, -1), -Pi},
1638 {Copysign(0, -1), -0.5},
1639 {Copysign(0, -1), -3},
1640 {Copysign(0, -1), 3},
1641 {Copysign(0, -1), Pi},
1642 {Copysign(0, -1), 0.5},
1643 {Copysign(0, -1), Inf(1)},
1648 {0, Copysign(0, -1)},
1662 {Pi, Copysign(0, -1)},
1668 {Inf(1), Copysign(0, -1)},
1674 {NaN(), Copysign(0, -1)},
1680 // Issue #7394 overflow checks
1681 {2, float64(1 << 32)},
1682 {2, -float64(1 << 32)},
1683 {-2, float64(1<<32 + 1)},
1684 {0.5, float64(1 << 45)},
1685 {0.5, -float64(1 << 45)},
1686 {Nextafter(1, 2), float64(1 << 63)},
1687 {Nextafter(1, -2), float64(1 << 63)},
1688 {Nextafter(-1, 2), float64(1 << 63)},
1689 {Nextafter(-1, -2), float64(1 << 63)},
1692 {Copysign(0, -1), 1e19},
1693 {Copysign(0, -1), -1e19},
1694 {Copysign(0, -1), 1<<53 - 1},
1695 {Copysign(0, -1), -(1<<53 - 1)},
1697 var powSC = []float64{
1698 0, // pow(-Inf, -Pi)
1699 Copysign(0, -1), // pow(-Inf, -3)
1702 Inf(-1), // pow(-Inf, 1)
1703 Inf(-1), // pow(-Inf, 3)
1704 Inf(1), // pow(-Inf, Pi)
1705 Inf(1), // pow(-Inf, 0.5)
1706 NaN(), // pow(-Inf, NaN)
1707 0, // pow(-Pi, -Inf)
1708 NaN(), // pow(-Pi, -Pi)
1712 NaN(), // pow(-Pi, Pi)
1713 Inf(1), // pow(-Pi, +Inf)
1714 NaN(), // pow(-Pi, NaN)
1715 1, // pow(-1, -Inf) IEEE 754-2008
1716 1, // pow(-1, +Inf) IEEE 754-2008
1717 NaN(), // pow(-1, NaN)
1718 Inf(1), // pow(-1/2, -Inf)
1719 0, // pow(-1/2, +Inf)
1720 Inf(1), // pow(-0, -Inf)
1721 Inf(1), // pow(-0, -Pi)
1722 Inf(1), // pow(-0, -0.5)
1723 Inf(-1), // pow(-0, -3) IEEE 754-2008
1724 Copysign(0, -1), // pow(-0, 3) IEEE 754-2008
1728 Inf(1), // pow(+0, -Inf)
1729 Inf(1), // pow(+0, -Pi)
1730 Inf(1), // pow(+0, -3)
1736 NaN(), // pow(+0, NaN)
1737 Inf(1), // pow(1/2, -Inf)
1738 0, // pow(1/2, +Inf)
1739 1, // pow(1, -Inf) IEEE 754-2008
1740 1, // pow(1, +Inf) IEEE 754-2008
1741 1, // pow(1, NaN) IEEE 754-2008
1742 0, // pow(+Pi, -Inf)
1746 Inf(1), // pow(+Pi, +Inf)
1747 NaN(), // pow(+Pi, NaN)
1748 0, // pow(+Inf, -Pi)
1751 Inf(1), // pow(+Inf, 1)
1752 Inf(1), // pow(+Inf, Pi)
1753 NaN(), // pow(+Inf, NaN)
1754 NaN(), // pow(NaN, -Pi)
1757 NaN(), // pow(NaN, 1)
1758 NaN(), // pow(NaN, +Pi)
1759 NaN(), // pow(NaN, NaN)
1761 // Issue #7394 overflow checks
1762 Inf(1), // pow(2, float64(1 << 32))
1763 0, // pow(2, -float64(1 << 32))
1764 Inf(-1), // pow(-2, float64(1<<32 + 1))
1765 0, // pow(1/2, float64(1 << 45))
1766 Inf(1), // pow(1/2, -float64(1 << 45))
1767 Inf(1), // pow(Nextafter(1, 2), float64(1 << 63))
1768 0, // pow(Nextafter(1, -2), float64(1 << 63))
1769 0, // pow(Nextafter(-1, 2), float64(1 << 63))
1770 Inf(1), // pow(Nextafter(-1, -2), float64(1 << 63))
1774 Inf(1), // pow(-0, -1e19)
1775 Copysign(0, -1), // pow(-0, 1<<53 -1)
1776 Inf(-1), // pow(-0, -(1<<53 -1))
1779 var vfpow10SC = []int{
1797 var pow10SC = []float64{
1798 0, // pow10(MinInt32)
1800 1.0e-323, // pow10(-323)
1801 1.0e-50, // pow10(-50)
1802 1.0e-22, // pow10(-22)
1803 1.0e-1, // pow10(-1)
1806 1.0e22, // pow10(22)
1807 1.0e50, // pow10(50)
1808 1.0e100, // pow10(100)
1809 1.0e200, // pow10(200)
1810 1.0e308, // pow10(308)
1811 Inf(1), // pow10(309)
1812 Inf(1), // pow10(MaxInt32)
1815 var vfroundSC = [][2]float64{
1817 {1.390671161567e-309, 0}, // denormal
1818 {0.49999999999999994, 0}, // 0.5-epsilon
1820 {0.5000000000000001, 1}, // 0.5+epsilon
1825 {2251799813685249.5, 2251799813685250}, // 1 bit fraction
1826 {2251799813685250.5, 2251799813685251},
1827 {4503599627370495.5, 4503599627370496}, // 1 bit fraction, rounding to 0 bit fraction
1828 {4503599627370497, 4503599627370497}, // large integer
1830 var vfroundEvenSC = [][2]float64{
1832 {1.390671161567e-309, 0}, // denormal
1833 {0.49999999999999994, 0}, // 0.5-epsilon
1835 {0.5000000000000001, 1}, // 0.5+epsilon
1840 {2251799813685249.5, 2251799813685250}, // 1 bit fraction
1841 {2251799813685250.5, 2251799813685250},
1842 {4503599627370495.5, 4503599627370496}, // 1 bit fraction, rounding to 0 bit fraction
1843 {4503599627370497, 4503599627370497}, // large integer
1846 var vfsignbitSC = []float64{
1853 var signbitSC = []bool{
1861 var vfsinSC = []float64{
1868 var sinSC = []float64{
1876 var vfsinhSC = []float64{
1883 var sinhSC = []float64{
1891 var vfsqrtSC = []float64{
1898 Float64frombits(2), // subnormal; see https://golang.org/issue/13013
1900 var sqrtSC = []float64{
1907 3.1434555694052576e-162,
1910 var vftanhSC = []float64{
1917 var tanhSC = []float64{
1925 var vfy0SC = []float64{
1932 var y0SC = []float64{
1939 var y1SC = []float64{
1946 var y2SC = []float64{
1953 var yM3SC = []float64{
1961 // arguments and expected results for boundary cases
1963 SmallestNormalFloat64 = 2.2250738585072014e-308 // 2**-1022
1964 LargestSubnormalFloat64 = SmallestNormalFloat64 - SmallestNonzeroFloat64
1967 var vffrexpBC = []float64{
1968 SmallestNormalFloat64,
1969 LargestSubnormalFloat64,
1970 SmallestNonzeroFloat64,
1972 -SmallestNormalFloat64,
1973 -LargestSubnormalFloat64,
1974 -SmallestNonzeroFloat64,
1979 {0.99999999999999978, -1022},
1981 {0.99999999999999989, 1024},
1983 {-0.99999999999999978, -1022},
1985 {-0.99999999999999989, 1024},
1988 var vfldexpBC = []fi{
1989 {SmallestNormalFloat64, -52},
1990 {LargestSubnormalFloat64, -51},
1991 {SmallestNonzeroFloat64, 1074},
1992 {MaxFloat64, -(1023 + 1074)},
1997 {1.0000000000000002, -1075},
2000 var ldexpBC = []float64{
2001 SmallestNonzeroFloat64,
2009 SmallestNonzeroFloat64,
2013 var logbBC = []float64{
2024 // Test cases were generated with Berkeley TestFloat-3e/testfloat_gen.
2025 // http://www.jhauser.us/arithmetic/TestFloat.html.
2026 // The default rounding mode is selected (nearest/even), and exception flags are ignored.
2027 var fmaC = []struct{ x, y, z, want float64 }{
2028 // Large exponent spread
2029 {-3.999999999999087, -1.1123914289620494e-16, -7.999877929687506, -7.999877929687505},
2030 {-262112.0000004768, -0.06251525855623184, 1.1102230248837136e-16, 16385.99945072085},
2031 {-6.462348523533467e-27, -2.3763644720331857e-211, 4.000000000931324, 4.000000000931324},
2033 // Effective addition
2034 {-2.0000000037252907, 6.7904383376e-313, -3.3951933161e-313, -1.697607001654e-312},
2035 {-0.12499999999999999, 512.007568359375, -1.4193627164960366e-16, -64.00094604492188},
2036 {-2.7550648847397148e-39, -3.4028301595800694e+38, 0.9960937495343386, 1.9335955376735676},
2037 {5.723369164769208e+24, 3.8149300927159385e-06, 1.84489958778182e+19, 4.028324913621874e+19},
2038 {-0.4843749999990904, -3.6893487872543293e+19, 9.223653786709391e+18, 2.7093936974938993e+19},
2039 {-3.8146972665201165e-06, 4.2949672959999385e+09, -2.2204460489938386e-16, -16384.000003844263},
2040 {6.98156394130982e-309, -1.1072962560000002e+09, -4.4414561548793455e-308, -7.73065965765153e-300},
2042 // Effective subtraction
2043 {5e-324, 4.5, -2e-323, 0},
2044 {5e-324, 7, -3.5e-323, 0},
2045 {5e-324, 0.5000000000000001, -5e-324, Copysign(0, -1)},
2046 {-2.1240680525e-314, -1.233647078189316e+308, -0.25781249999954525, -0.25780987964919844},
2047 {8.579992955364441e-308, 0.6037391876780558, -4.4501307410480706e-308, 7.29947236107098e-309},
2048 {-4.450143471986689e-308, -0.9960937499927239, -4.450419332475649e-308, -1.7659233458788e-310},
2049 {1.4932076393918112, -2.2248022430460833e-308, 4.449875571054211e-308, 1.127783865601762e-308},
2052 {-2.288020632214759e+38, -8.98846570988901e+307, 1.7696041796300924e+308, Inf(0)},
2053 {1.4888652783208255e+308, -9.007199254742012e+15, -6.807282911929205e+38, Inf(-1)},
2054 {9.142703268902826e+192, -1.3504889569802838e+296, -1.9082200803806996e-89, Inf(-1)},
2056 // Finite x and y, but non-finite z.
2057 {31.99218749627471, -1.7976930544991702e+308, Inf(0), Inf(0)},
2058 {-1.7976931281784667e+308, -2.0009765625002265, Inf(-1), Inf(-1)},
2062 {-1.1754226043408471e-38, NaN(), Inf(0), NaN()},
2063 {0, 0, 2.22507385643494e-308, 2.22507385643494e-308},
2064 {-8.65697792e+09, NaN(), -7.516192799999999e+09, NaN()},
2065 {-0.00012207403779029757, 3.221225471996093e+09, NaN(), NaN()},
2066 {Inf(-1), 0.1252441407414153, -1.387184532981584e-76, Inf(-1)},
2067 {Inf(0), 1.525878907671432e-05, -9.214364835452549e+18, Inf(0)},
2070 {0.1777916152213626, -32.000015266239636, -2.2204459148334633e-16, -5.689334401293007},
2071 {-2.0816681711722314e-16, -0.4997558592585846, -0.9465627129124969, -0.9465627129124968},
2072 {-1.9999997615814211, 1.8518819259933516e+19, 16.874999999999996, -3.703763410463646e+19},
2073 {-0.12499994039717421, 32767.99999976135, -2.0752587082923246e+19, -2.075258708292325e+19},
2074 {7.705600568510257e-34, -1.801432979000528e+16, -0.17224197722973714, -0.17224197722973716},
2075 {3.8988133103758913e-308, -0.9848632812499999, 3.893879244098556e-308, 5.40811742605814e-310},
2076 {-0.012651981190687427, 6.911985574912436e+38, 6.669240527007144e+18, -8.745031148409496e+36},
2077 {4.612811918325842e+18, 1.4901161193847641e-08, 2.6077032311277997e-08, 6.873625395187494e+10},
2078 {-9.094947033611148e-13, 4.450691014249257e-308, 2.086006742350485e-308, 2.086006742346437e-308},
2079 {-7.751454006381804e-05, 5.588653777189071e-308, -2.2207280111272877e-308, -2.2211612130544025e-308},
2082 var sqrt32 = []float32{
2084 float32(Copysign(0, -1)),
2091 4.9790119248836735e+00,
2092 7.7388724745781045e+00,
2093 -2.7688005719200159e-01,
2094 -5.0106036182710749e+00,
2097 type compareTest[F float32 | float64] struct {
2102 func compareCases[F float32 | float64]() []compareTest[F] {
2103 zero, nan, inf := F(0.0), F(NaN()), F(Inf(0))
2104 return []compareTest[F]{
2124 func tolerance(a, b, e float64) bool {
2125 // Multiplying by e here can underflow denormal values to zero.
2126 // Check a==b so that at least if a and b are small and identical
2127 // we say they match.
2136 // note: b is correct (expected) value, a is actual value.
2137 // make error tolerance a fraction of b, not a.
2146 func close(a, b float64) bool { return tolerance(a, b, 1e-14) }
2147 func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
2148 func soclose(a, b, e float64) bool { return tolerance(a, b, e) }
2149 func alike(a, b float64) bool {
2151 case IsNaN(a) && IsNaN(b):
2154 return Signbit(a) == Signbit(b)
2159 func TestNaN(t *testing.T) {
2162 t.Fatalf("NaN() returns %g, expected NaN", f64)
2166 t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
2170 func TestAcos(t *testing.T) {
2171 for i := 0; i < len(vf); i++ {
2173 if f := Acos(a); !close(acos[i], f) {
2174 t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
2177 for i := 0; i < len(vfacosSC); i++ {
2178 if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
2179 t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosSC[i])
2184 func TestAcosh(t *testing.T) {
2185 for i := 0; i < len(vf); i++ {
2187 if f := Acosh(a); !veryclose(acosh[i], f) {
2188 t.Errorf("Acosh(%g) = %g, want %g", a, f, acosh[i])
2191 for i := 0; i < len(vfacoshSC); i++ {
2192 if f := Acosh(vfacoshSC[i]); !alike(acoshSC[i], f) {
2193 t.Errorf("Acosh(%g) = %g, want %g", vfacoshSC[i], f, acoshSC[i])
2198 func TestAsin(t *testing.T) {
2199 for i := 0; i < len(vf); i++ {
2201 if f := Asin(a); !veryclose(asin[i], f) {
2202 t.Errorf("Asin(%g) = %g, want %g", a, f, asin[i])
2205 for i := 0; i < len(vfasinSC); i++ {
2206 if f := Asin(vfasinSC[i]); !alike(asinSC[i], f) {
2207 t.Errorf("Asin(%g) = %g, want %g", vfasinSC[i], f, asinSC[i])
2212 func TestAsinh(t *testing.T) {
2213 for i := 0; i < len(vf); i++ {
2214 if f := Asinh(vf[i]); !veryclose(asinh[i], f) {
2215 t.Errorf("Asinh(%g) = %g, want %g", vf[i], f, asinh[i])
2218 for i := 0; i < len(vfasinhSC); i++ {
2219 if f := Asinh(vfasinhSC[i]); !alike(asinhSC[i], f) {
2220 t.Errorf("Asinh(%g) = %g, want %g", vfasinhSC[i], f, asinhSC[i])
2225 func TestAtan(t *testing.T) {
2226 for i := 0; i < len(vf); i++ {
2227 if f := Atan(vf[i]); !veryclose(atan[i], f) {
2228 t.Errorf("Atan(%g) = %g, want %g", vf[i], f, atan[i])
2231 for i := 0; i < len(vfatanSC); i++ {
2232 if f := Atan(vfatanSC[i]); !alike(atanSC[i], f) {
2233 t.Errorf("Atan(%g) = %g, want %g", vfatanSC[i], f, atanSC[i])
2238 func TestAtanh(t *testing.T) {
2239 for i := 0; i < len(vf); i++ {
2241 if f := Atanh(a); !veryclose(atanh[i], f) {
2242 t.Errorf("Atanh(%g) = %g, want %g", a, f, atanh[i])
2245 for i := 0; i < len(vfatanhSC); i++ {
2246 if f := Atanh(vfatanhSC[i]); !alike(atanhSC[i], f) {
2247 t.Errorf("Atanh(%g) = %g, want %g", vfatanhSC[i], f, atanhSC[i])
2252 func TestAtan2(t *testing.T) {
2253 for i := 0; i < len(vf); i++ {
2254 if f := Atan2(10, vf[i]); !veryclose(atan2[i], f) {
2255 t.Errorf("Atan2(10, %g) = %g, want %g", vf[i], f, atan2[i])
2258 for i := 0; i < len(vfatan2SC); i++ {
2259 if f := Atan2(vfatan2SC[i][0], vfatan2SC[i][1]); !alike(atan2SC[i], f) {
2260 t.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC[i][0], vfatan2SC[i][1], f, atan2SC[i])
2265 func TestCbrt(t *testing.T) {
2266 for i := 0; i < len(vf); i++ {
2267 if f := Cbrt(vf[i]); !veryclose(cbrt[i], f) {
2268 t.Errorf("Cbrt(%g) = %g, want %g", vf[i], f, cbrt[i])
2271 for i := 0; i < len(vfcbrtSC); i++ {
2272 if f := Cbrt(vfcbrtSC[i]); !alike(cbrtSC[i], f) {
2273 t.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC[i], f, cbrtSC[i])
2278 func TestCeil(t *testing.T) {
2279 for i := 0; i < len(vf); i++ {
2280 if f := Ceil(vf[i]); !alike(ceil[i], f) {
2281 t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
2284 for i := 0; i < len(vfceilSC); i++ {
2285 if f := Ceil(vfceilSC[i]); !alike(ceilSC[i], f) {
2286 t.Errorf("Ceil(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2291 func TestCompare(t *testing.T) {
2292 // -NaN < -∞ < -3.14 < -0 < 0 < 3.14 < ∞ < NaN
2293 for _, c := range compareCases[float64]() {
2294 cmp := Compare(c.x, c.y)
2296 t.Errorf("Compare(%v, %v) = %d, want %v", c.x, c.y, cmp, c.want)
2299 for _, c := range compareCases[float32]() {
2300 cmp := Compare32(c.x, c.y)
2302 t.Errorf("Compare32(%v, %v) = %d, want %v", c.x, c.y, cmp, c.want)
2307 func TestCopysign(t *testing.T) {
2308 for i := 0; i < len(vf); i++ {
2309 if f := Copysign(vf[i], -1); copysign[i] != f {
2310 t.Errorf("Copysign(%g, -1) = %g, want %g", vf[i], f, copysign[i])
2313 for i := 0; i < len(vf); i++ {
2314 if f := Copysign(vf[i], 1); -copysign[i] != f {
2315 t.Errorf("Copysign(%g, 1) = %g, want %g", vf[i], f, -copysign[i])
2318 for i := 0; i < len(vfcopysignSC); i++ {
2319 if f := Copysign(vfcopysignSC[i], -1); !alike(copysignSC[i], f) {
2320 t.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC[i], f, copysignSC[i])
2325 func TestCos(t *testing.T) {
2326 for i := 0; i < len(vf); i++ {
2327 if f := Cos(vf[i]); !veryclose(cos[i], f) {
2328 t.Errorf("Cos(%g) = %g, want %g", vf[i], f, cos[i])
2331 for i := 0; i < len(vfcosSC); i++ {
2332 if f := Cos(vfcosSC[i]); !alike(cosSC[i], f) {
2333 t.Errorf("Cos(%g) = %g, want %g", vfcosSC[i], f, cosSC[i])
2338 func TestCosh(t *testing.T) {
2339 for i := 0; i < len(vf); i++ {
2340 if f := Cosh(vf[i]); !close(cosh[i], f) {
2341 t.Errorf("Cosh(%g) = %g, want %g", vf[i], f, cosh[i])
2344 for i := 0; i < len(vfcoshSC); i++ {
2345 if f := Cosh(vfcoshSC[i]); !alike(coshSC[i], f) {
2346 t.Errorf("Cosh(%g) = %g, want %g", vfcoshSC[i], f, coshSC[i])
2351 func TestErf(t *testing.T) {
2352 for i := 0; i < len(vf); i++ {
2354 if f := Erf(a); !veryclose(erf[i], f) {
2355 t.Errorf("Erf(%g) = %g, want %g", a, f, erf[i])
2358 for i := 0; i < len(vferfSC); i++ {
2359 if f := Erf(vferfSC[i]); !alike(erfSC[i], f) {
2360 t.Errorf("Erf(%g) = %g, want %g", vferfSC[i], f, erfSC[i])
2365 func TestErfc(t *testing.T) {
2366 for i := 0; i < len(vf); i++ {
2368 if f := Erfc(a); !veryclose(erfc[i], f) {
2369 t.Errorf("Erfc(%g) = %g, want %g", a, f, erfc[i])
2372 for i := 0; i < len(vferfcSC); i++ {
2373 if f := Erfc(vferfcSC[i]); !alike(erfcSC[i], f) {
2374 t.Errorf("Erfc(%g) = %g, want %g", vferfcSC[i], f, erfcSC[i])
2379 func TestErfinv(t *testing.T) {
2380 for i := 0; i < len(vf); i++ {
2382 if f := Erfinv(a); !veryclose(erfinv[i], f) {
2383 t.Errorf("Erfinv(%g) = %g, want %g", a, f, erfinv[i])
2386 for i := 0; i < len(vferfinvSC); i++ {
2387 if f := Erfinv(vferfinvSC[i]); !alike(erfinvSC[i], f) {
2388 t.Errorf("Erfinv(%g) = %g, want %g", vferfinvSC[i], f, erfinvSC[i])
2391 for x := -0.9; x <= 0.90; x += 1e-2 {
2392 if f := Erf(Erfinv(x)); !close(x, f) {
2393 t.Errorf("Erf(Erfinv(%g)) = %g, want %g", x, f, x)
2396 for x := -0.9; x <= 0.90; x += 1e-2 {
2397 if f := Erfinv(Erf(x)); !close(x, f) {
2398 t.Errorf("Erfinv(Erf(%g)) = %g, want %g", x, f, x)
2403 func TestErfcinv(t *testing.T) {
2404 for i := 0; i < len(vf); i++ {
2405 a := 1.0 - (vf[i] / 10)
2406 if f := Erfcinv(a); !veryclose(erfinv[i], f) {
2407 t.Errorf("Erfcinv(%g) = %g, want %g", a, f, erfinv[i])
2410 for i := 0; i < len(vferfcinvSC); i++ {
2411 if f := Erfcinv(vferfcinvSC[i]); !alike(erfcinvSC[i], f) {
2412 t.Errorf("Erfcinv(%g) = %g, want %g", vferfcinvSC[i], f, erfcinvSC[i])
2415 for x := 0.1; x <= 1.9; x += 1e-2 {
2416 if f := Erfc(Erfcinv(x)); !close(x, f) {
2417 t.Errorf("Erfc(Erfcinv(%g)) = %g, want %g", x, f, x)
2420 for x := 0.1; x <= 1.9; x += 1e-2 {
2421 if f := Erfcinv(Erfc(x)); !close(x, f) {
2422 t.Errorf("Erfcinv(Erfc(%g)) = %g, want %g", x, f, x)
2427 func TestExp(t *testing.T) {
2428 testExp(t, Exp, "Exp")
2429 testExp(t, ExpGo, "ExpGo")
2432 func testExp(t *testing.T, Exp func(float64) float64, name string) {
2433 for i := 0; i < len(vf); i++ {
2434 if f := Exp(vf[i]); !veryclose(exp[i], f) {
2435 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp[i])
2438 for i := 0; i < len(vfexpSC); i++ {
2439 if f := Exp(vfexpSC[i]); !alike(expSC[i], f) {
2440 t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
2445 func TestExpm1(t *testing.T) {
2446 for i := 0; i < len(vf); i++ {
2448 if f := Expm1(a); !veryclose(expm1[i], f) {
2449 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1[i])
2452 for i := 0; i < len(vf); i++ {
2454 if f := Expm1(a); !close(expm1Large[i], f) {
2455 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1Large[i])
2458 for i := 0; i < len(vfexpm1SC); i++ {
2459 if f := Expm1(vfexpm1SC[i]); !alike(expm1SC[i], f) {
2460 t.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC[i], f, expm1SC[i])
2465 func TestExp2(t *testing.T) {
2466 testExp2(t, Exp2, "Exp2")
2467 testExp2(t, Exp2Go, "Exp2Go")
2470 func testExp2(t *testing.T, Exp2 func(float64) float64, name string) {
2471 for i := 0; i < len(vf); i++ {
2472 if f := Exp2(vf[i]); !close(exp2[i], f) {
2473 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp2[i])
2476 for i := 0; i < len(vfexp2SC); i++ {
2477 if f := Exp2(vfexp2SC[i]); !alike(exp2SC[i], f) {
2478 t.Errorf("%s(%g) = %g, want %g", name, vfexp2SC[i], f, exp2SC[i])
2481 for n := -1074; n < 1024; n++ {
2482 f := Exp2(float64(n))
2485 t.Errorf("%s(%d) = %g, want %g", name, n, f, vf)
2490 func TestAbs(t *testing.T) {
2491 for i := 0; i < len(vf); i++ {
2492 if f := Abs(vf[i]); fabs[i] != f {
2493 t.Errorf("Abs(%g) = %g, want %g", vf[i], f, fabs[i])
2496 for i := 0; i < len(vffabsSC); i++ {
2497 if f := Abs(vffabsSC[i]); !alike(fabsSC[i], f) {
2498 t.Errorf("Abs(%g) = %g, want %g", vffabsSC[i], f, fabsSC[i])
2503 func TestDim(t *testing.T) {
2504 for i := 0; i < len(vf); i++ {
2505 if f := Dim(vf[i], 0); fdim[i] != f {
2506 t.Errorf("Dim(%g, %g) = %g, want %g", vf[i], 0.0, f, fdim[i])
2509 for i := 0; i < len(vffdimSC); i++ {
2510 if f := Dim(vffdimSC[i][0], vffdimSC[i][1]); !alike(fdimSC[i], f) {
2511 t.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fdimSC[i])
2514 for i := 0; i < len(vffdim2SC); i++ {
2515 if f := Dim(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fdimSC[i], f) {
2516 t.Errorf("Dim(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fdimSC[i])
2521 func TestFloor(t *testing.T) {
2522 for i := 0; i < len(vf); i++ {
2523 if f := Floor(vf[i]); !alike(floor[i], f) {
2524 t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
2527 for i := 0; i < len(vfceilSC); i++ {
2528 if f := Floor(vfceilSC[i]); !alike(ceilSC[i], f) {
2529 t.Errorf("Floor(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2534 func TestMax(t *testing.T) {
2535 for i := 0; i < len(vf); i++ {
2536 if f := Max(vf[i], ceil[i]); ceil[i] != f {
2537 t.Errorf("Max(%g, %g) = %g, want %g", vf[i], ceil[i], f, ceil[i])
2540 for i := 0; i < len(vffdimSC); i++ {
2541 if f := Max(vffdimSC[i][0], vffdimSC[i][1]); !alike(fmaxSC[i], f) {
2542 t.Errorf("Max(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fmaxSC[i])
2545 for i := 0; i < len(vffdim2SC); i++ {
2546 if f := Max(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fmaxSC[i], f) {
2547 t.Errorf("Max(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fmaxSC[i])
2552 func TestMin(t *testing.T) {
2553 for i := 0; i < len(vf); i++ {
2554 if f := Min(vf[i], floor[i]); floor[i] != f {
2555 t.Errorf("Min(%g, %g) = %g, want %g", vf[i], floor[i], f, floor[i])
2558 for i := 0; i < len(vffdimSC); i++ {
2559 if f := Min(vffdimSC[i][0], vffdimSC[i][1]); !alike(fminSC[i], f) {
2560 t.Errorf("Min(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fminSC[i])
2563 for i := 0; i < len(vffdim2SC); i++ {
2564 if f := Min(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fminSC[i], f) {
2565 t.Errorf("Min(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fminSC[i])
2570 func TestMod(t *testing.T) {
2571 for i := 0; i < len(vf); i++ {
2572 if f := Mod(10, vf[i]); fmod[i] != f {
2573 t.Errorf("Mod(10, %g) = %g, want %g", vf[i], f, fmod[i])
2576 for i := 0; i < len(vffmodSC); i++ {
2577 if f := Mod(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2578 t.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2581 // verify precision of result for extreme inputs
2582 if f := Mod(5.9790119248836734e+200, 1.1258465975523544); 0.6447968302508578 != f {
2583 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want 0.6447968302508578", f)
2587 func TestFrexp(t *testing.T) {
2588 for i := 0; i < len(vf); i++ {
2589 if f, j := Frexp(vf[i]); !veryclose(frexp[i].f, f) || frexp[i].i != j {
2590 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf[i], f, j, frexp[i].f, frexp[i].i)
2593 for i := 0; i < len(vffrexpSC); i++ {
2594 if f, j := Frexp(vffrexpSC[i]); !alike(frexpSC[i].f, f) || frexpSC[i].i != j {
2595 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC[i], f, j, frexpSC[i].f, frexpSC[i].i)
2598 for i := 0; i < len(vffrexpBC); i++ {
2599 if f, j := Frexp(vffrexpBC[i]); !alike(frexpBC[i].f, f) || frexpBC[i].i != j {
2600 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC[i], f, j, frexpBC[i].f, frexpBC[i].i)
2605 func TestGamma(t *testing.T) {
2606 for i := 0; i < len(vf); i++ {
2607 if f := Gamma(vf[i]); !close(gamma[i], f) {
2608 t.Errorf("Gamma(%g) = %g, want %g", vf[i], f, gamma[i])
2611 for _, g := range vfgamma {
2614 if IsNaN(g[1]) || IsInf(g[1], 0) || g[1] == 0 || f == 0 {
2616 } else if g[0] > -50 && g[0] <= 171 {
2617 ok = veryclose(g[1], f)
2622 t.Errorf("Gamma(%g) = %g, want %g", g[0], f, g[1])
2627 func TestHypot(t *testing.T) {
2628 for i := 0; i < len(vf); i++ {
2629 a := Abs(1e200 * tanh[i] * Sqrt(2))
2630 if f := Hypot(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2631 t.Errorf("Hypot(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2634 for i := 0; i < len(vfhypotSC); i++ {
2635 if f := Hypot(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2636 t.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2641 func TestHypotGo(t *testing.T) {
2642 for i := 0; i < len(vf); i++ {
2643 a := Abs(1e200 * tanh[i] * Sqrt(2))
2644 if f := HypotGo(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2645 t.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2648 for i := 0; i < len(vfhypotSC); i++ {
2649 if f := HypotGo(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2650 t.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2655 func TestIlogb(t *testing.T) {
2656 for i := 0; i < len(vf); i++ {
2657 a := frexp[i].i - 1 // adjust because fr in the interval [½, 1)
2658 if e := Ilogb(vf[i]); a != e {
2659 t.Errorf("Ilogb(%g) = %d, want %d", vf[i], e, a)
2662 for i := 0; i < len(vflogbSC); i++ {
2663 if e := Ilogb(vflogbSC[i]); ilogbSC[i] != e {
2664 t.Errorf("Ilogb(%g) = %d, want %d", vflogbSC[i], e, ilogbSC[i])
2667 for i := 0; i < len(vffrexpBC); i++ {
2668 if e := Ilogb(vffrexpBC[i]); int(logbBC[i]) != e {
2669 t.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC[i], e, int(logbBC[i]))
2674 func TestJ0(t *testing.T) {
2675 for i := 0; i < len(vf); i++ {
2676 if f := J0(vf[i]); !soclose(j0[i], f, 4e-14) {
2677 t.Errorf("J0(%g) = %g, want %g", vf[i], f, j0[i])
2680 for i := 0; i < len(vfj0SC); i++ {
2681 if f := J0(vfj0SC[i]); !alike(j0SC[i], f) {
2682 t.Errorf("J0(%g) = %g, want %g", vfj0SC[i], f, j0SC[i])
2687 func TestJ1(t *testing.T) {
2688 for i := 0; i < len(vf); i++ {
2689 if f := J1(vf[i]); !close(j1[i], f) {
2690 t.Errorf("J1(%g) = %g, want %g", vf[i], f, j1[i])
2693 for i := 0; i < len(vfj0SC); i++ {
2694 if f := J1(vfj0SC[i]); !alike(j1SC[i], f) {
2695 t.Errorf("J1(%g) = %g, want %g", vfj0SC[i], f, j1SC[i])
2700 func TestJn(t *testing.T) {
2701 for i := 0; i < len(vf); i++ {
2702 if f := Jn(2, vf[i]); !close(j2[i], f) {
2703 t.Errorf("Jn(2, %g) = %g, want %g", vf[i], f, j2[i])
2705 if f := Jn(-3, vf[i]); !close(jM3[i], f) {
2706 t.Errorf("Jn(-3, %g) = %g, want %g", vf[i], f, jM3[i])
2709 for i := 0; i < len(vfj0SC); i++ {
2710 if f := Jn(2, vfj0SC[i]); !alike(j2SC[i], f) {
2711 t.Errorf("Jn(2, %g) = %g, want %g", vfj0SC[i], f, j2SC[i])
2713 if f := Jn(-3, vfj0SC[i]); !alike(jM3SC[i], f) {
2714 t.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC[i], f, jM3SC[i])
2719 func TestLdexp(t *testing.T) {
2720 for i := 0; i < len(vf); i++ {
2721 if f := Ldexp(frexp[i].f, frexp[i].i); !veryclose(vf[i], f) {
2722 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexp[i].f, frexp[i].i, f, vf[i])
2725 for i := 0; i < len(vffrexpSC); i++ {
2726 if f := Ldexp(frexpSC[i].f, frexpSC[i].i); !alike(vffrexpSC[i], f) {
2727 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC[i].f, frexpSC[i].i, f, vffrexpSC[i])
2730 for i := 0; i < len(vfldexpSC); i++ {
2731 if f := Ldexp(vfldexpSC[i].f, vfldexpSC[i].i); !alike(ldexpSC[i], f) {
2732 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC[i].f, vfldexpSC[i].i, f, ldexpSC[i])
2735 for i := 0; i < len(vffrexpBC); i++ {
2736 if f := Ldexp(frexpBC[i].f, frexpBC[i].i); !alike(vffrexpBC[i], f) {
2737 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC[i].f, frexpBC[i].i, f, vffrexpBC[i])
2740 for i := 0; i < len(vfldexpBC); i++ {
2741 if f := Ldexp(vfldexpBC[i].f, vfldexpBC[i].i); !alike(ldexpBC[i], f) {
2742 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC[i].f, vfldexpBC[i].i, f, ldexpBC[i])
2747 func TestLgamma(t *testing.T) {
2748 for i := 0; i < len(vf); i++ {
2749 if f, s := Lgamma(vf[i]); !close(lgamma[i].f, f) || lgamma[i].i != s {
2750 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf[i], f, s, lgamma[i].f, lgamma[i].i)
2753 for i := 0; i < len(vflgammaSC); i++ {
2754 if f, s := Lgamma(vflgammaSC[i]); !alike(lgammaSC[i].f, f) || lgammaSC[i].i != s {
2755 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC[i], f, s, lgammaSC[i].f, lgammaSC[i].i)
2760 func TestLog(t *testing.T) {
2761 for i := 0; i < len(vf); i++ {
2763 if f := Log(a); log[i] != f {
2764 t.Errorf("Log(%g) = %g, want %g", a, f, log[i])
2767 if f := Log(10); f != Ln10 {
2768 t.Errorf("Log(%g) = %g, want %g", 10.0, f, Ln10)
2770 for i := 0; i < len(vflogSC); i++ {
2771 if f := Log(vflogSC[i]); !alike(logSC[i], f) {
2772 t.Errorf("Log(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2777 func TestLogb(t *testing.T) {
2778 for i := 0; i < len(vf); i++ {
2779 if f := Logb(vf[i]); logb[i] != f {
2780 t.Errorf("Logb(%g) = %g, want %g", vf[i], f, logb[i])
2783 for i := 0; i < len(vflogbSC); i++ {
2784 if f := Logb(vflogbSC[i]); !alike(logbSC[i], f) {
2785 t.Errorf("Logb(%g) = %g, want %g", vflogbSC[i], f, logbSC[i])
2788 for i := 0; i < len(vffrexpBC); i++ {
2789 if f := Logb(vffrexpBC[i]); !alike(logbBC[i], f) {
2790 t.Errorf("Logb(%g) = %g, want %g", vffrexpBC[i], f, logbBC[i])
2795 func TestLog10(t *testing.T) {
2796 for i := 0; i < len(vf); i++ {
2798 if f := Log10(a); !veryclose(log10[i], f) {
2799 t.Errorf("Log10(%g) = %g, want %g", a, f, log10[i])
2802 if f := Log10(E); f != Log10E {
2803 t.Errorf("Log10(%g) = %g, want %g", E, f, Log10E)
2805 for i := 0; i < len(vflogSC); i++ {
2806 if f := Log10(vflogSC[i]); !alike(logSC[i], f) {
2807 t.Errorf("Log10(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2812 func TestLog1p(t *testing.T) {
2813 for i := 0; i < len(vf); i++ {
2815 if f := Log1p(a); !veryclose(log1p[i], f) {
2816 t.Errorf("Log1p(%g) = %g, want %g", a, f, log1p[i])
2820 if f := Log1p(a); f != Ln10 {
2821 t.Errorf("Log1p(%g) = %g, want %g", a, f, Ln10)
2823 for i := 0; i < len(vflogSC); i++ {
2824 if f := Log1p(vflog1pSC[i]); !alike(log1pSC[i], f) {
2825 t.Errorf("Log1p(%g) = %g, want %g", vflog1pSC[i], f, log1pSC[i])
2830 func TestLog2(t *testing.T) {
2831 for i := 0; i < len(vf); i++ {
2833 if f := Log2(a); !veryclose(log2[i], f) {
2834 t.Errorf("Log2(%g) = %g, want %g", a, f, log2[i])
2837 if f := Log2(E); f != Log2E {
2838 t.Errorf("Log2(%g) = %g, want %g", E, f, Log2E)
2840 for i := 0; i < len(vflogSC); i++ {
2841 if f := Log2(vflogSC[i]); !alike(logSC[i], f) {
2842 t.Errorf("Log2(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2845 for i := -1074; i <= 1023; i++ {
2848 if l != float64(i) {
2849 t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
2854 func TestModf(t *testing.T) {
2855 for i := 0; i < len(vf); i++ {
2856 if f, g := Modf(vf[i]); !veryclose(modf[i][0], f) || !veryclose(modf[i][1], g) {
2857 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vf[i], f, g, modf[i][0], modf[i][1])
2860 for i := 0; i < len(vfmodfSC); i++ {
2861 if f, g := Modf(vfmodfSC[i]); !alike(modfSC[i][0], f) || !alike(modfSC[i][1], g) {
2862 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC[i], f, g, modfSC[i][0], modfSC[i][1])
2867 func TestNextafter32(t *testing.T) {
2868 for i := 0; i < len(vf); i++ {
2869 vfi := float32(vf[i])
2870 if f := Nextafter32(vfi, 10); nextafter32[i] != f {
2871 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfi, 10.0, f, nextafter32[i])
2874 for i := 0; i < len(vfnextafter32SC); i++ {
2875 if f := Nextafter32(vfnextafter32SC[i][0], vfnextafter32SC[i][1]); !alike(float64(nextafter32SC[i]), float64(f)) {
2876 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC[i][0], vfnextafter32SC[i][1], f, nextafter32SC[i])
2881 func TestNextafter64(t *testing.T) {
2882 for i := 0; i < len(vf); i++ {
2883 if f := Nextafter(vf[i], 10); nextafter64[i] != f {
2884 t.Errorf("Nextafter64(%g, %g) = %g want %g", vf[i], 10.0, f, nextafter64[i])
2887 for i := 0; i < len(vfnextafter64SC); i++ {
2888 if f := Nextafter(vfnextafter64SC[i][0], vfnextafter64SC[i][1]); !alike(nextafter64SC[i], f) {
2889 t.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC[i][0], vfnextafter64SC[i][1], f, nextafter64SC[i])
2894 func TestPow(t *testing.T) {
2895 for i := 0; i < len(vf); i++ {
2896 if f := Pow(10, vf[i]); !close(pow[i], f) {
2897 t.Errorf("Pow(10, %g) = %g, want %g", vf[i], f, pow[i])
2900 for i := 0; i < len(vfpowSC); i++ {
2901 if f := Pow(vfpowSC[i][0], vfpowSC[i][1]); !alike(powSC[i], f) {
2902 t.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC[i][0], vfpowSC[i][1], f, powSC[i])
2907 func TestPow10(t *testing.T) {
2908 for i := 0; i < len(vfpow10SC); i++ {
2909 if f := Pow10(vfpow10SC[i]); !alike(pow10SC[i], f) {
2910 t.Errorf("Pow10(%d) = %g, want %g", vfpow10SC[i], f, pow10SC[i])
2915 func TestRemainder(t *testing.T) {
2916 for i := 0; i < len(vf); i++ {
2917 if f := Remainder(10, vf[i]); remainder[i] != f {
2918 t.Errorf("Remainder(10, %g) = %g, want %g", vf[i], f, remainder[i])
2921 for i := 0; i < len(vffmodSC); i++ {
2922 if f := Remainder(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2923 t.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2926 // verify precision of result for extreme inputs
2927 if f := Remainder(5.9790119248836734e+200, 1.1258465975523544); -0.4810497673014966 != f {
2928 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want -0.4810497673014966", f)
2930 // verify that sign is correct when r == 0.
2931 test := func(x, y float64) {
2932 if r := Remainder(x, y); r == 0 && Signbit(r) != Signbit(x) {
2933 t.Errorf("Remainder(x=%f, y=%f) = %f, sign of (zero) result should agree with sign of x", x, y, r)
2936 for x := 0.0; x <= 3.0; x += 1 {
2937 for y := 1.0; y <= 3.0; y += 1 {
2946 func TestRound(t *testing.T) {
2947 for i := 0; i < len(vf); i++ {
2948 if f := Round(vf[i]); !alike(round[i], f) {
2949 t.Errorf("Round(%g) = %g, want %g", vf[i], f, round[i])
2952 for i := 0; i < len(vfroundSC); i++ {
2953 if f := Round(vfroundSC[i][0]); !alike(vfroundSC[i][1], f) {
2954 t.Errorf("Round(%g) = %g, want %g", vfroundSC[i][0], f, vfroundSC[i][1])
2959 func TestRoundToEven(t *testing.T) {
2960 for i := 0; i < len(vf); i++ {
2961 if f := RoundToEven(vf[i]); !alike(round[i], f) {
2962 t.Errorf("RoundToEven(%g) = %g, want %g", vf[i], f, round[i])
2965 for i := 0; i < len(vfroundEvenSC); i++ {
2966 if f := RoundToEven(vfroundEvenSC[i][0]); !alike(vfroundEvenSC[i][1], f) {
2967 t.Errorf("RoundToEven(%g) = %g, want %g", vfroundEvenSC[i][0], f, vfroundEvenSC[i][1])
2972 func TestSignbit(t *testing.T) {
2973 for i := 0; i < len(vf); i++ {
2974 if f := Signbit(vf[i]); signbit[i] != f {
2975 t.Errorf("Signbit(%g) = %t, want %t", vf[i], f, signbit[i])
2978 for i := 0; i < len(vfsignbitSC); i++ {
2979 if f := Signbit(vfsignbitSC[i]); signbitSC[i] != f {
2980 t.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC[i], f, signbitSC[i])
2984 func TestSin(t *testing.T) {
2985 for i := 0; i < len(vf); i++ {
2986 if f := Sin(vf[i]); !veryclose(sin[i], f) {
2987 t.Errorf("Sin(%g) = %g, want %g", vf[i], f, sin[i])
2990 for i := 0; i < len(vfsinSC); i++ {
2991 if f := Sin(vfsinSC[i]); !alike(sinSC[i], f) {
2992 t.Errorf("Sin(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
2997 func TestSincos(t *testing.T) {
2998 for i := 0; i < len(vf); i++ {
2999 if s, c := Sincos(vf[i]); !veryclose(sin[i], s) || !veryclose(cos[i], c) {
3000 t.Errorf("Sincos(%g) = %g, %g want %g, %g", vf[i], s, c, sin[i], cos[i])
3005 func TestSinh(t *testing.T) {
3006 for i := 0; i < len(vf); i++ {
3007 if f := Sinh(vf[i]); !close(sinh[i], f) {
3008 t.Errorf("Sinh(%g) = %g, want %g", vf[i], f, sinh[i])
3011 for i := 0; i < len(vfsinhSC); i++ {
3012 if f := Sinh(vfsinhSC[i]); !alike(sinhSC[i], f) {
3013 t.Errorf("Sinh(%g) = %g, want %g", vfsinhSC[i], f, sinhSC[i])
3018 func TestSqrt(t *testing.T) {
3019 for i := 0; i < len(vf); i++ {
3021 if f := SqrtGo(a); sqrt[i] != f {
3022 t.Errorf("SqrtGo(%g) = %g, want %g", a, f, sqrt[i])
3025 if f := Sqrt(a); sqrt[i] != f {
3026 t.Errorf("Sqrt(%g) = %g, want %g", a, f, sqrt[i])
3029 for i := 0; i < len(vfsqrtSC); i++ {
3030 if f := SqrtGo(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
3031 t.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
3033 if f := Sqrt(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
3034 t.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
3039 func TestTan(t *testing.T) {
3040 for i := 0; i < len(vf); i++ {
3041 if f := Tan(vf[i]); !veryclose(tan[i], f) {
3042 t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
3045 // same special cases as Sin
3046 for i := 0; i < len(vfsinSC); i++ {
3047 if f := Tan(vfsinSC[i]); !alike(sinSC[i], f) {
3048 t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
3053 func TestTanh(t *testing.T) {
3054 for i := 0; i < len(vf); i++ {
3055 if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
3056 t.Errorf("Tanh(%g) = %g, want %g", vf[i], f, tanh[i])
3059 for i := 0; i < len(vftanhSC); i++ {
3060 if f := Tanh(vftanhSC[i]); !alike(tanhSC[i], f) {
3061 t.Errorf("Tanh(%g) = %g, want %g", vftanhSC[i], f, tanhSC[i])
3066 func TestTrunc(t *testing.T) {
3067 for i := 0; i < len(vf); i++ {
3068 if f := Trunc(vf[i]); !alike(trunc[i], f) {
3069 t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
3072 for i := 0; i < len(vfceilSC); i++ {
3073 if f := Trunc(vfceilSC[i]); !alike(ceilSC[i], f) {
3074 t.Errorf("Trunc(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
3079 func TestY0(t *testing.T) {
3080 for i := 0; i < len(vf); i++ {
3082 if f := Y0(a); !close(y0[i], f) {
3083 t.Errorf("Y0(%g) = %g, want %g", a, f, y0[i])
3086 for i := 0; i < len(vfy0SC); i++ {
3087 if f := Y0(vfy0SC[i]); !alike(y0SC[i], f) {
3088 t.Errorf("Y0(%g) = %g, want %g", vfy0SC[i], f, y0SC[i])
3093 func TestY1(t *testing.T) {
3094 for i := 0; i < len(vf); i++ {
3096 if f := Y1(a); !soclose(y1[i], f, 2e-14) {
3097 t.Errorf("Y1(%g) = %g, want %g", a, f, y1[i])
3100 for i := 0; i < len(vfy0SC); i++ {
3101 if f := Y1(vfy0SC[i]); !alike(y1SC[i], f) {
3102 t.Errorf("Y1(%g) = %g, want %g", vfy0SC[i], f, y1SC[i])
3107 func TestYn(t *testing.T) {
3108 for i := 0; i < len(vf); i++ {
3110 if f := Yn(2, a); !close(y2[i], f) {
3111 t.Errorf("Yn(2, %g) = %g, want %g", a, f, y2[i])
3113 if f := Yn(-3, a); !close(yM3[i], f) {
3114 t.Errorf("Yn(-3, %g) = %g, want %g", a, f, yM3[i])
3117 for i := 0; i < len(vfy0SC); i++ {
3118 if f := Yn(2, vfy0SC[i]); !alike(y2SC[i], f) {
3119 t.Errorf("Yn(2, %g) = %g, want %g", vfy0SC[i], f, y2SC[i])
3121 if f := Yn(-3, vfy0SC[i]); !alike(yM3SC[i], f) {
3122 t.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC[i], f, yM3SC[i])
3125 if f := Yn(0, 0); !alike(Inf(-1), f) {
3126 t.Errorf("Yn(0, 0) = %g, want %g", f, Inf(-1))
3130 var PortableFMA = FMA // hide call from compiler intrinsic; falls back to portable code
3132 func TestFMA(t *testing.T) {
3133 for _, c := range fmaC {
3134 got := FMA(c.x, c.y, c.z)
3135 if !alike(got, c.want) {
3136 t.Errorf("FMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3138 got = PortableFMA(c.x, c.y, c.z)
3139 if !alike(got, c.want) {
3140 t.Errorf("PortableFMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3145 // Check that math functions of high angle values
3146 // return accurate results. [Since (vf[i] + large) - large != vf[i],
3147 // testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
3148 // a multiple of 2*Pi, is misleading.]
3149 func TestLargeCos(t *testing.T) {
3150 large := float64(100000 * Pi)
3151 for i := 0; i < len(vf); i++ {
3153 f2 := Cos(vf[i] + large)
3155 t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
3160 func TestLargeSin(t *testing.T) {
3161 large := float64(100000 * Pi)
3162 for i := 0; i < len(vf); i++ {
3164 f2 := Sin(vf[i] + large)
3166 t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
3171 func TestLargeSincos(t *testing.T) {
3172 large := float64(100000 * Pi)
3173 for i := 0; i < len(vf); i++ {
3174 f1, g1 := sinLarge[i], cosLarge[i]
3175 f2, g2 := Sincos(vf[i] + large)
3176 if !close(f1, f2) || !close(g1, g2) {
3177 t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
3182 func TestLargeTan(t *testing.T) {
3183 large := float64(100000 * Pi)
3184 for i := 0; i < len(vf); i++ {
3186 f2 := Tan(vf[i] + large)
3188 t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
3193 // Check that trigReduce matches the standard reduction results for input values
3194 // below reduceThreshold.
3195 func TestTrigReduce(t *testing.T) {
3196 inputs := make([]float64, len(vf))
3197 // all of the standard inputs
3199 // all of the large inputs
3200 large := float64(100000 * Pi)
3201 for _, v := range vf {
3202 inputs = append(inputs, v+large)
3204 // Also test some special inputs, Pi and right below the reduceThreshold
3205 inputs = append(inputs, Pi, Nextafter(ReduceThreshold, 0))
3206 for _, x := range inputs {
3207 // reduce the value to compare
3208 j, z := TrigReduce(x)
3209 xred := float64(j)*(Pi/4) + z
3211 if f, fred := Sin(x), Sin(xred); !close(f, fred) {
3212 t.Errorf("Sin(trigReduce(%g)) != Sin(%g), got %g, want %g", x, x, fred, f)
3214 if f, fred := Cos(x), Cos(xred); !close(f, fred) {
3215 t.Errorf("Cos(trigReduce(%g)) != Cos(%g), got %g, want %g", x, x, fred, f)
3217 if f, fred := Tan(x), Tan(xred); !close(f, fred) {
3218 t.Errorf(" Tan(trigReduce(%g)) != Tan(%g), got %g, want %g", x, x, fred, f)
3221 fred, gred := Sincos(xred)
3222 if !close(f, fred) || !close(g, gred) {
3223 t.Errorf(" Sincos(trigReduce(%g)) != Sincos(%g), got %g, %g, want %g, %g", x, x, fred, gred, f, g)
3228 // Check that math constants are accepted by compiler
3229 // and have right value (assumes strconv.ParseFloat works).
3230 // https://golang.org/issue/201
3232 type floatTest struct {
3238 var floatTests = []floatTest{
3239 {float64(MaxFloat64), "MaxFloat64", "1.7976931348623157e+308"},
3240 {float64(SmallestNonzeroFloat64), "SmallestNonzeroFloat64", "5e-324"},
3241 {float32(MaxFloat32), "MaxFloat32", "3.4028235e+38"},
3242 {float32(SmallestNonzeroFloat32), "SmallestNonzeroFloat32", "1e-45"},
3245 func TestFloatMinMax(t *testing.T) {
3246 for _, tt := range floatTests {
3247 s := fmt.Sprint(tt.val)
3249 t.Errorf("Sprint(%v) = %s, want %s", tt.name, s, tt.str)
3254 func TestFloatMinima(t *testing.T) {
3255 if q := float32(SmallestNonzeroFloat32 / 2); q != 0 {
3256 t.Errorf("float32(SmallestNonzeroFloat32 / 2) = %g, want 0", q)
3258 if q := float64(SmallestNonzeroFloat64 / 2); q != 0 {
3259 t.Errorf("float64(SmallestNonzeroFloat64 / 2) = %g, want 0", q)
3263 var indirectSqrt = Sqrt
3265 // TestFloat32Sqrt checks the correctness of the float32 square root optimization result.
3266 func TestFloat32Sqrt(t *testing.T) {
3267 for _, v := range sqrt32 {
3268 want := float32(indirectSqrt(float64(v)))
3269 got := float32(Sqrt(float64(v)))
3270 if IsNaN(float64(want)) {
3271 if !IsNaN(float64(got)) {
3272 t.Errorf("got=%#v want=NaN, v=%#v", got, v)
3277 t.Errorf("got=%#v want=%#v, v=%#v", got, want, v)
3284 // Global exported variables are used to store the
3285 // return values of functions measured in the benchmarks.
3286 // Storing the results in these variables prevents the compiler
3287 // from completely optimizing the benchmarked functions away.
3294 func BenchmarkAcos(b *testing.B) {
3296 for i := 0; i < b.N; i++ {
3302 func BenchmarkAcosh(b *testing.B) {
3304 for i := 0; i < b.N; i++ {
3310 func BenchmarkAsin(b *testing.B) {
3312 for i := 0; i < b.N; i++ {
3318 func BenchmarkAsinh(b *testing.B) {
3320 for i := 0; i < b.N; i++ {
3326 func BenchmarkAtan(b *testing.B) {
3328 for i := 0; i < b.N; i++ {
3334 func BenchmarkAtanh(b *testing.B) {
3336 for i := 0; i < b.N; i++ {
3342 func BenchmarkAtan2(b *testing.B) {
3344 for i := 0; i < b.N; i++ {
3350 func BenchmarkCbrt(b *testing.B) {
3352 for i := 0; i < b.N; i++ {
3358 func BenchmarkCeil(b *testing.B) {
3360 for i := 0; i < b.N; i++ {
3366 func BenchmarkCompare(b *testing.B) {
3368 for i := 0; i < b.N; i++ {
3369 x = Compare(1.5, 2.5)
3374 func BenchmarkCompare32(b *testing.B) {
3376 for i := 0; i < b.N; i++ {
3377 x = Compare32(1.5, 2.5)
3382 var copysignNeg = -1.0
3384 func BenchmarkCopysign(b *testing.B) {
3386 for i := 0; i < b.N; i++ {
3387 x = Copysign(.5, copysignNeg)
3392 func BenchmarkCos(b *testing.B) {
3394 for i := 0; i < b.N; i++ {
3400 func BenchmarkCosh(b *testing.B) {
3402 for i := 0; i < b.N; i++ {
3408 func BenchmarkErf(b *testing.B) {
3410 for i := 0; i < b.N; i++ {
3416 func BenchmarkErfc(b *testing.B) {
3418 for i := 0; i < b.N; i++ {
3424 func BenchmarkErfinv(b *testing.B) {
3426 for i := 0; i < b.N; i++ {
3432 func BenchmarkErfcinv(b *testing.B) {
3434 for i := 0; i < b.N; i++ {
3440 func BenchmarkExp(b *testing.B) {
3442 for i := 0; i < b.N; i++ {
3448 func BenchmarkExpGo(b *testing.B) {
3450 for i := 0; i < b.N; i++ {
3456 func BenchmarkExpm1(b *testing.B) {
3458 for i := 0; i < b.N; i++ {
3464 func BenchmarkExp2(b *testing.B) {
3466 for i := 0; i < b.N; i++ {
3472 func BenchmarkExp2Go(b *testing.B) {
3474 for i := 0; i < b.N; i++ {
3482 func BenchmarkAbs(b *testing.B) {
3484 for i := 0; i < b.N; i++ {
3491 func BenchmarkDim(b *testing.B) {
3493 for i := 0; i < b.N; i++ {
3499 func BenchmarkFloor(b *testing.B) {
3501 for i := 0; i < b.N; i++ {
3507 func BenchmarkMax(b *testing.B) {
3509 for i := 0; i < b.N; i++ {
3515 func BenchmarkMin(b *testing.B) {
3517 for i := 0; i < b.N; i++ {
3523 func BenchmarkMod(b *testing.B) {
3525 for i := 0; i < b.N; i++ {
3531 func BenchmarkFrexp(b *testing.B) {
3534 for i := 0; i < b.N; i++ {
3541 func BenchmarkGamma(b *testing.B) {
3543 for i := 0; i < b.N; i++ {
3549 func BenchmarkHypot(b *testing.B) {
3551 for i := 0; i < b.N; i++ {
3557 func BenchmarkHypotGo(b *testing.B) {
3559 for i := 0; i < b.N; i++ {
3565 func BenchmarkIlogb(b *testing.B) {
3567 for i := 0; i < b.N; i++ {
3573 func BenchmarkJ0(b *testing.B) {
3575 for i := 0; i < b.N; i++ {
3581 func BenchmarkJ1(b *testing.B) {
3583 for i := 0; i < b.N; i++ {
3589 func BenchmarkJn(b *testing.B) {
3591 for i := 0; i < b.N; i++ {
3597 func BenchmarkLdexp(b *testing.B) {
3599 for i := 0; i < b.N; i++ {
3605 func BenchmarkLgamma(b *testing.B) {
3608 for i := 0; i < b.N; i++ {
3615 func BenchmarkLog(b *testing.B) {
3617 for i := 0; i < b.N; i++ {
3623 func BenchmarkLogb(b *testing.B) {
3625 for i := 0; i < b.N; i++ {
3631 func BenchmarkLog1p(b *testing.B) {
3633 for i := 0; i < b.N; i++ {
3639 func BenchmarkLog10(b *testing.B) {
3641 for i := 0; i < b.N; i++ {
3647 func BenchmarkLog2(b *testing.B) {
3649 for i := 0; i < b.N; i++ {
3655 func BenchmarkModf(b *testing.B) {
3658 for i := 0; i < b.N; i++ {
3665 func BenchmarkNextafter32(b *testing.B) {
3667 for i := 0; i < b.N; i++ {
3668 x = Nextafter32(.5, 1)
3670 GlobalF = float64(x)
3673 func BenchmarkNextafter64(b *testing.B) {
3675 for i := 0; i < b.N; i++ {
3676 x = Nextafter(.5, 1)
3681 func BenchmarkPowInt(b *testing.B) {
3683 for i := 0; i < b.N; i++ {
3689 func BenchmarkPowFrac(b *testing.B) {
3691 for i := 0; i < b.N; i++ {
3697 var pow10pos = int(300)
3699 func BenchmarkPow10Pos(b *testing.B) {
3701 for i := 0; i < b.N; i++ {
3707 var pow10neg = int(-300)
3709 func BenchmarkPow10Neg(b *testing.B) {
3711 for i := 0; i < b.N; i++ {
3717 var roundNeg = float64(-2.5)
3719 func BenchmarkRound(b *testing.B) {
3721 for i := 0; i < b.N; i++ {
3727 func BenchmarkRoundToEven(b *testing.B) {
3729 for i := 0; i < b.N; i++ {
3730 x = RoundToEven(roundNeg)
3735 func BenchmarkRemainder(b *testing.B) {
3737 for i := 0; i < b.N; i++ {
3738 x = Remainder(10, 3)
3743 var signbitPos = 2.5
3745 func BenchmarkSignbit(b *testing.B) {
3747 for i := 0; i < b.N; i++ {
3748 x = Signbit(signbitPos)
3753 func BenchmarkSin(b *testing.B) {
3755 for i := 0; i < b.N; i++ {
3761 func BenchmarkSincos(b *testing.B) {
3764 for i := 0; i < b.N; i++ {
3771 func BenchmarkSinh(b *testing.B) {
3773 for i := 0; i < b.N; i++ {
3779 func BenchmarkSqrtIndirect(b *testing.B) {
3782 for i := 0; i < b.N; i++ {
3788 func BenchmarkSqrtLatency(b *testing.B) {
3790 for i := 0; i < b.N; i++ {
3796 func BenchmarkSqrtIndirectLatency(b *testing.B) {
3799 for i := 0; i < b.N; i++ {
3805 func BenchmarkSqrtGoLatency(b *testing.B) {
3807 for i := 0; i < b.N; i++ {
3813 func isPrime(i int) bool {
3814 // Yes, this is a dumb way to write this code,
3815 // but calling Sqrt repeatedly in this way demonstrates
3816 // the benefit of using a direct SQRT instruction on systems
3817 // that have one, whereas the obvious loop seems not to
3818 // demonstrate such a benefit.
3819 for j := 2; float64(j) <= Sqrt(float64(i)); j++ {
3827 func BenchmarkSqrtPrime(b *testing.B) {
3829 for i := 0; i < b.N; i++ {
3835 func BenchmarkTan(b *testing.B) {
3837 for i := 0; i < b.N; i++ {
3843 func BenchmarkTanh(b *testing.B) {
3845 for i := 0; i < b.N; i++ {
3850 func BenchmarkTrunc(b *testing.B) {
3852 for i := 0; i < b.N; i++ {
3858 func BenchmarkY0(b *testing.B) {
3860 for i := 0; i < b.N; i++ {
3866 func BenchmarkY1(b *testing.B) {
3868 for i := 0; i < b.N; i++ {
3874 func BenchmarkYn(b *testing.B) {
3876 for i := 0; i < b.N; i++ {
3882 func BenchmarkFloat64bits(b *testing.B) {
3884 for i := 0; i < b.N; i++ {
3885 y = Float64bits(roundNeg)
3890 var roundUint64 = uint64(5)
3892 func BenchmarkFloat64frombits(b *testing.B) {
3894 for i := 0; i < b.N; i++ {
3895 x = Float64frombits(roundUint64)
3900 var roundFloat32 = float32(-2.5)
3902 func BenchmarkFloat32bits(b *testing.B) {
3904 for i := 0; i < b.N; i++ {
3905 y = Float32bits(roundFloat32)
3910 var roundUint32 = uint32(5)
3912 func BenchmarkFloat32frombits(b *testing.B) {
3914 for i := 0; i < b.N; i++ {
3915 x = Float32frombits(roundUint32)
3917 GlobalF = float64(x)
3920 func BenchmarkFMA(b *testing.B) {
3922 for i := 0; i < b.N; i++ {