Source file
src/math/all_test.go
1
2
3
4
5 package math_test
6
7 import (
8 "fmt"
9 . "math"
10 "testing"
11 "unsafe"
12 )
13
14 var vf = []float64{
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,
25 }
26
27
28
29
30
31
32 var acos = []float64{
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,
43 }
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,
55 }
56 var asin = []float64{
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,
67 }
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,
79 }
80 var atan = []float64{
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,
91 }
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,
103 }
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,
115 }
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,
127 }
128 var ceil = []float64{
129 5.0000000000000000e+00,
130 8.0000000000000000e+00,
131 Copysign(0, -1),
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,
139 }
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,
151 }
152 var cos = []float64{
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,
163 }
164
165
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,
177 }
178
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,
190 }
191 var erf = []float64{
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,
202 }
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,
214 }
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,
226 }
227 var exp = []float64{
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,
238 }
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,
250 }
251 var expm1Large = []float64{
252 4.2031418113550844e+21,
253 4.0690789717473863e+33,
254 -0.9372627915981363e+00,
255 -1.0,
256 7.077694784145933e+41,
257 5.117936223839153e+12,
258 5.124137759001189e+22,
259 7.03546003972584e+11,
260 8.456921800389698e+07,
261 -1.0,
262 }
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,
274 }
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,
286 }
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,
298 }
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,
310 }
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,
322 }
323
324 type fi struct {
325 f float64
326 i int
327 }
328
329 var frexp = []fi{
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},
340 }
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,
352 }
353 var j0 = []float64{
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,
364 }
365 var j1 = []float64{
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,
376 }
377 var j2 = []float64{
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,
388 }
389 var jM3 = []float64{
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,
400 }
401 var lgamma = []fi{
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},
412 }
413 var log = []float64{
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,
424 }
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,
436 }
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,
448 }
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,
460 }
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,
472 }
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},
484 }
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,
496 }
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,
508 }
509 var pow = []float64{
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,
520 }
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,
532 }
533 var round = []float64{
534 5,
535 8,
536 Copysign(0, -1),
537 -5,
538 10,
539 3,
540 5,
541 3,
542 2,
543 -9,
544 }
545 var signbit = []bool{
546 false,
547 false,
548 true,
549 true,
550 false,
551 false,
552 false,
553 false,
554 false,
555 true,
556 }
557 var sin = []float64{
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,
568 }
569
570
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,
582 }
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,
594 }
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,
606 }
607 var tan = []float64{
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,
618 }
619
620
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,
632 }
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,
644 }
645 var trunc = []float64{
646 4.0000000000000000e+00,
647 7.0000000000000000e+00,
648 Copysign(0, -1),
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,
656 }
657 var y0 = []float64{
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,
668 }
669 var y1 = []float64{
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,
680 }
681 var y2 = []float64{
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,
692 }
693 var yM3 = []float64{
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,
704 }
705
706
707 var vfacosSC = []float64{
708 -Pi,
709 1,
710 Pi,
711 NaN(),
712 }
713 var acosSC = []float64{
714 NaN(),
715 0,
716 NaN(),
717 NaN(),
718 }
719
720 var vfacoshSC = []float64{
721 Inf(-1),
722 0.5,
723 1,
724 Inf(1),
725 NaN(),
726 }
727 var acoshSC = []float64{
728 NaN(),
729 NaN(),
730 0,
731 Inf(1),
732 NaN(),
733 }
734
735 var vfasinSC = []float64{
736 -Pi,
737 Copysign(0, -1),
738 0,
739 Pi,
740 NaN(),
741 }
742 var asinSC = []float64{
743 NaN(),
744 Copysign(0, -1),
745 0,
746 NaN(),
747 NaN(),
748 }
749
750 var vfasinhSC = []float64{
751 Inf(-1),
752 Copysign(0, -1),
753 0,
754 Inf(1),
755 NaN(),
756 }
757 var asinhSC = []float64{
758 Inf(-1),
759 Copysign(0, -1),
760 0,
761 Inf(1),
762 NaN(),
763 }
764
765 var vfatanSC = []float64{
766 Inf(-1),
767 Copysign(0, -1),
768 0,
769 Inf(1),
770 NaN(),
771 }
772 var atanSC = []float64{
773 -Pi / 2,
774 Copysign(0, -1),
775 0,
776 Pi / 2,
777 NaN(),
778 }
779
780 var vfatanhSC = []float64{
781 Inf(-1),
782 -Pi,
783 -1,
784 Copysign(0, -1),
785 0,
786 1,
787 Pi,
788 Inf(1),
789 NaN(),
790 }
791 var atanhSC = []float64{
792 NaN(),
793 NaN(),
794 Inf(-1),
795 Copysign(0, -1),
796 0,
797 Inf(1),
798 NaN(),
799 NaN(),
800 NaN(),
801 }
802 var vfatan2SC = [][2]float64{
803 {Inf(-1), Inf(-1)},
804 {Inf(-1), -Pi},
805 {Inf(-1), 0},
806 {Inf(-1), +Pi},
807 {Inf(-1), Inf(1)},
808 {Inf(-1), NaN()},
809 {-Pi, Inf(-1)},
810 {-Pi, 0},
811 {-Pi, Inf(1)},
812 {-Pi, NaN()},
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()},
820 {0, Inf(-1)},
821 {0, -Pi},
822 {0, Copysign(0, -1)},
823 {0, 0},
824 {0, +Pi},
825 {0, Inf(1)},
826 {0, NaN()},
827 {+Pi, Inf(-1)},
828 {+Pi, 0},
829 {+Pi, Inf(1)},
830 {1.0, Inf(1)},
831 {-1.0, Inf(1)},
832 {+Pi, NaN()},
833 {Inf(1), Inf(-1)},
834 {Inf(1), -Pi},
835 {Inf(1), 0},
836 {Inf(1), +Pi},
837 {Inf(1), Inf(1)},
838 {Inf(1), NaN()},
839 {NaN(), NaN()},
840 }
841 var atan2SC = []float64{
842 -3 * Pi / 4,
843 -Pi / 2,
844 -Pi / 2,
845 -Pi / 2,
846 -Pi / 4,
847 NaN(),
848 -Pi,
849 -Pi / 2,
850 Copysign(0, -1),
851 NaN(),
852 -Pi,
853 -Pi,
854 -Pi,
855 Copysign(0, -1),
856 Copysign(0, -1),
857 Copysign(0, -1),
858 NaN(),
859 Pi,
860 Pi,
861 Pi,
862 0,
863 0,
864 0,
865 NaN(),
866 Pi,
867 Pi / 2,
868 0,
869 0,
870 Copysign(0, -1),
871 NaN(),
872 3 * Pi / 4,
873 Pi / 2,
874 Pi / 2,
875 Pi / 2,
876 Pi / 4,
877 NaN(),
878 NaN(),
879 }
880
881 var vfcbrtSC = []float64{
882 Inf(-1),
883 Copysign(0, -1),
884 0,
885 Inf(1),
886 NaN(),
887 }
888 var cbrtSC = []float64{
889 Inf(-1),
890 Copysign(0, -1),
891 0,
892 Inf(1),
893 NaN(),
894 }
895
896 var vfceilSC = []float64{
897 Inf(-1),
898 Copysign(0, -1),
899 0,
900 Inf(1),
901 NaN(),
902 1<<52 - 1,
903 1<<52 - 0.5,
904 1 << 52,
905 -1 << 52,
906 -1<<52 + 0.5,
907 -1<<52 + 1,
908 1 << 53,
909 -1 << 53,
910 }
911
912 var ceilBaseSC = []float64{
913 Inf(-1),
914 Copysign(0, -1),
915 0,
916 Inf(1),
917 NaN(),
918 }
919
920 var ceilSC = append(ceilBaseSC,
921 1<<52-1,
922 1<<52,
923 1<<52,
924 -1<<52,
925 -1<<52+1,
926 -1<<52+1,
927 1<<53,
928 -1<<53,
929 )
930
931 var floorSC = append(ceilBaseSC,
932 1<<52-1,
933 1<<52-1,
934 1<<52,
935 -1<<52,
936 -1<<52,
937 -1<<52+1,
938 1<<53,
939 -1<<53,
940 )
941
942 var truncSC = append(ceilBaseSC,
943 1<<52-1,
944 1<<52-1,
945 1<<52,
946 -1<<52,
947 -1<<52+1,
948 -1<<52+1,
949 1<<53,
950 -1<<53,
951 )
952
953 var vfcopysignSC = []float64{
954 Inf(-1),
955 Inf(1),
956 NaN(),
957 }
958 var copysignSC = []float64{
959 Inf(-1),
960 Inf(-1),
961 NaN(),
962 }
963
964 var vfcosSC = []float64{
965 Inf(-1),
966 Inf(1),
967 NaN(),
968 }
969 var cosSC = []float64{
970 NaN(),
971 NaN(),
972 NaN(),
973 }
974
975 var vfcoshSC = []float64{
976 Inf(-1),
977 Copysign(0, -1),
978 0,
979 Inf(1),
980 NaN(),
981 }
982 var coshSC = []float64{
983 Inf(1),
984 1,
985 1,
986 Inf(1),
987 NaN(),
988 }
989
990 var vferfSC = []float64{
991 Inf(-1),
992 Copysign(0, -1),
993 0,
994 Inf(1),
995 NaN(),
996 -1000,
997 1000,
998 }
999 var erfSC = []float64{
1000 -1,
1001 Copysign(0, -1),
1002 0,
1003 1,
1004 NaN(),
1005 -1,
1006 1,
1007 }
1008
1009 var vferfcSC = []float64{
1010 Inf(-1),
1011 Inf(1),
1012 NaN(),
1013 -1000,
1014 1000,
1015 }
1016 var erfcSC = []float64{
1017 2,
1018 0,
1019 NaN(),
1020 2,
1021 0,
1022 }
1023
1024 var vferfinvSC = []float64{
1025 1,
1026 -1,
1027 0,
1028 Inf(-1),
1029 Inf(1),
1030 NaN(),
1031 }
1032 var erfinvSC = []float64{
1033 Inf(+1),
1034 Inf(-1),
1035 0,
1036 NaN(),
1037 NaN(),
1038 NaN(),
1039 }
1040
1041 var vferfcinvSC = []float64{
1042 0,
1043 2,
1044 1,
1045 Inf(1),
1046 Inf(-1),
1047 NaN(),
1048 }
1049 var erfcinvSC = []float64{
1050 Inf(+1),
1051 Inf(-1),
1052 0,
1053 NaN(),
1054 NaN(),
1055 NaN(),
1056 }
1057
1058 var vfexpSC = []float64{
1059 Inf(-1),
1060 -2000,
1061 2000,
1062 Inf(1),
1063 NaN(),
1064
1065 7.097827128933841e+02,
1066
1067 1.48852223e+09,
1068 1.4885222e+09,
1069 1,
1070
1071 3.725290298461915e-09,
1072
1073 -740,
1074 }
1075 var expSC = []float64{
1076 0,
1077 0,
1078 Inf(1),
1079 Inf(1),
1080 NaN(),
1081 Inf(1),
1082 Inf(1),
1083 Inf(1),
1084 2.718281828459045,
1085 1.0000000037252903,
1086 4.2e-322,
1087 }
1088
1089 var vfexp2SC = []float64{
1090 Inf(-1),
1091 -2000,
1092 2000,
1093 Inf(1),
1094 NaN(),
1095
1096 1024,
1097
1098 -1.07399999999999e+03,
1099
1100 3.725290298461915e-09,
1101 }
1102 var exp2SC = []float64{
1103 0,
1104 0,
1105 Inf(1),
1106 Inf(1),
1107 NaN(),
1108 Inf(1),
1109 5e-324,
1110 1.0000000025821745,
1111 }
1112
1113 var vfexpm1SC = []float64{
1114 Inf(-1),
1115 -710,
1116 Copysign(0, -1),
1117 0,
1118 710,
1119 Inf(1),
1120 NaN(),
1121 }
1122 var expm1SC = []float64{
1123 -1,
1124 -1,
1125 Copysign(0, -1),
1126 0,
1127 Inf(1),
1128 Inf(1),
1129 NaN(),
1130 }
1131
1132 var vffabsSC = []float64{
1133 Inf(-1),
1134 Copysign(0, -1),
1135 0,
1136 Inf(1),
1137 NaN(),
1138 }
1139 var fabsSC = []float64{
1140 Inf(1),
1141 0,
1142 0,
1143 Inf(1),
1144 NaN(),
1145 }
1146
1147 var vffdimSC = [][2]float64{
1148 {Inf(-1), Inf(-1)},
1149 {Inf(-1), Inf(1)},
1150 {Inf(-1), NaN()},
1151 {Copysign(0, -1), Copysign(0, -1)},
1152 {Copysign(0, -1), 0},
1153 {0, Copysign(0, -1)},
1154 {0, 0},
1155 {Inf(1), Inf(-1)},
1156 {Inf(1), Inf(1)},
1157 {Inf(1), NaN()},
1158 {NaN(), Inf(-1)},
1159 {NaN(), Copysign(0, -1)},
1160 {NaN(), 0},
1161 {NaN(), Inf(1)},
1162 {NaN(), NaN()},
1163 }
1164 var nan = Float64frombits(0xFFF8000000000000)
1165 var vffdim2SC = [][2]float64{
1166 {Inf(-1), Inf(-1)},
1167 {Inf(-1), Inf(1)},
1168 {Inf(-1), nan},
1169 {Copysign(0, -1), Copysign(0, -1)},
1170 {Copysign(0, -1), 0},
1171 {0, Copysign(0, -1)},
1172 {0, 0},
1173 {Inf(1), Inf(-1)},
1174 {Inf(1), Inf(1)},
1175 {Inf(1), nan},
1176 {nan, Inf(-1)},
1177 {nan, Copysign(0, -1)},
1178 {nan, 0},
1179 {nan, Inf(1)},
1180 {nan, nan},
1181 }
1182 var fdimSC = []float64{
1183 NaN(),
1184 0,
1185 NaN(),
1186 0,
1187 0,
1188 0,
1189 0,
1190 Inf(1),
1191 NaN(),
1192 NaN(),
1193 NaN(),
1194 NaN(),
1195 NaN(),
1196 NaN(),
1197 NaN(),
1198 }
1199 var fmaxSC = []float64{
1200 Inf(-1),
1201 Inf(1),
1202 NaN(),
1203 Copysign(0, -1),
1204 0,
1205 0,
1206 0,
1207 Inf(1),
1208 Inf(1),
1209 Inf(1),
1210 NaN(),
1211 NaN(),
1212 NaN(),
1213 Inf(1),
1214 NaN(),
1215 }
1216 var fminSC = []float64{
1217 Inf(-1),
1218 Inf(-1),
1219 Inf(-1),
1220 Copysign(0, -1),
1221 Copysign(0, -1),
1222 Copysign(0, -1),
1223 0,
1224 Inf(-1),
1225 Inf(1),
1226 NaN(),
1227 Inf(-1),
1228 NaN(),
1229 NaN(),
1230 NaN(),
1231 NaN(),
1232 }
1233
1234 var vffmodSC = [][2]float64{
1235 {Inf(-1), Inf(-1)},
1236 {Inf(-1), -Pi},
1237 {Inf(-1), 0},
1238 {Inf(-1), Pi},
1239 {Inf(-1), Inf(1)},
1240 {Inf(-1), NaN()},
1241 {-Pi, Inf(-1)},
1242 {-Pi, 0},
1243 {-Pi, Inf(1)},
1244 {-Pi, NaN()},
1245 {Copysign(0, -1), Inf(-1)},
1246 {Copysign(0, -1), 0},
1247 {Copysign(0, -1), Inf(1)},
1248 {Copysign(0, -1), NaN()},
1249 {0, Inf(-1)},
1250 {0, 0},
1251 {0, Inf(1)},
1252 {0, NaN()},
1253 {Pi, Inf(-1)},
1254 {Pi, 0},
1255 {Pi, Inf(1)},
1256 {Pi, NaN()},
1257 {Inf(1), Inf(-1)},
1258 {Inf(1), -Pi},
1259 {Inf(1), 0},
1260 {Inf(1), Pi},
1261 {Inf(1), Inf(1)},
1262 {Inf(1), NaN()},
1263 {NaN(), Inf(-1)},
1264 {NaN(), -Pi},
1265 {NaN(), 0},
1266 {NaN(), Pi},
1267 {NaN(), Inf(1)},
1268 {NaN(), NaN()},
1269 }
1270 var fmodSC = []float64{
1271 NaN(),
1272 NaN(),
1273 NaN(),
1274 NaN(),
1275 NaN(),
1276 NaN(),
1277 -Pi,
1278 NaN(),
1279 -Pi,
1280 NaN(),
1281 Copysign(0, -1),
1282 NaN(),
1283 Copysign(0, -1),
1284 NaN(),
1285 0,
1286 NaN(),
1287 0,
1288 NaN(),
1289 Pi,
1290 NaN(),
1291 Pi,
1292 NaN(),
1293 NaN(),
1294 NaN(),
1295 NaN(),
1296 NaN(),
1297 NaN(),
1298 NaN(),
1299 NaN(),
1300 NaN(),
1301 NaN(),
1302 NaN(),
1303 NaN(),
1304 NaN(),
1305 }
1306
1307 var vffrexpSC = []float64{
1308 Inf(-1),
1309 Copysign(0, -1),
1310 0,
1311 Inf(1),
1312 NaN(),
1313 }
1314 var frexpSC = []fi{
1315 {Inf(-1), 0},
1316 {Copysign(0, -1), 0},
1317 {0, 0},
1318 {Inf(1), 0},
1319 {NaN(), 0},
1320 }
1321
1322 var vfgamma = [][2]float64{
1323 {Inf(1), Inf(1)},
1324 {Inf(-1), NaN()},
1325 {0, Inf(1)},
1326 {Copysign(0, -1), Inf(-1)},
1327 {NaN(), NaN()},
1328 {-1, NaN()},
1329 {-2, NaN()},
1330 {-3, NaN()},
1331 {-1e16, NaN()},
1332 {-1e300, NaN()},
1333 {1.7e308, Inf(1)},
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344 {0.5, 1.772453850905516},
1345 {1.5, 0.886226925452758},
1346 {2.5, 1.329340388179137},
1347 {3.5, 3.3233509704478426},
1348 {-0.5, -3.544907701811032},
1349 {-1.5, 2.363271801207355},
1350 {-2.5, -0.9453087204829419},
1351 {-3.5, 0.2700882058522691},
1352 {0.1, 9.51350769866873},
1353 {0.01, 99.4325851191506},
1354 {1e-08, 9.999999942278434e+07},
1355 {1e-16, 1e+16},
1356 {0.001, 999.4237724845955},
1357 {1e-16, 1e+16},
1358 {1e-308, 1e+308},
1359 {5.6e-309, 1.7857142857142864e+308},
1360 {5.5e-309, Inf(1)},
1361 {1e-309, Inf(1)},
1362 {1e-323, Inf(1)},
1363 {5e-324, Inf(1)},
1364 {-0.1, -10.686287021193193},
1365 {-0.01, -100.58719796441078},
1366 {-1e-08, -1.0000000057721567e+08},
1367 {-1e-16, -1e+16},
1368 {-0.001, -1000.5782056293586},
1369 {-1e-16, -1e+16},
1370 {-1e-308, -1e+308},
1371 {-5.6e-309, -1.7857142857142864e+308},
1372 {-5.5e-309, Inf(-1)},
1373 {-1e-309, Inf(-1)},
1374 {-1e-323, Inf(-1)},
1375 {-5e-324, Inf(-1)},
1376 {-0.9999999999999999, -9.007199254740992e+15},
1377 {-1.0000000000000002, 4.5035996273704955e+15},
1378 {-1.9999999999999998, 2.2517998136852485e+15},
1379 {-2.0000000000000004, -1.1258999068426235e+15},
1380 {-100.00000000000001, -7.540083334883109e-145},
1381 {-99.99999999999999, 7.540083334884096e-145},
1382 {17, 2.0922789888e+13},
1383 {171, 7.257415615307999e+306},
1384 {171.6, 1.5858969096672565e+308},
1385 {171.624, 1.7942117599248104e+308},
1386 {171.625, Inf(1)},
1387 {172, Inf(1)},
1388 {2000, Inf(1)},
1389 {-100.5, -3.3536908198076787e-159},
1390 {-160.5, -5.255546447007829e-286},
1391 {-170.5, -3.3127395215386074e-308},
1392 {-171.5, 1.9316265431712e-310},
1393 {-176.5, -1.196e-321},
1394 {-177.5, 5e-324},
1395 {-178.5, Copysign(0, -1)},
1396 {-179.5, 0},
1397 {-201.0001, 0},
1398 {-202.9999, Copysign(0, -1)},
1399 {-1000.5, Copysign(0, -1)},
1400 {-1.0000000003e+09, Copysign(0, -1)},
1401 {-4.5035996273704955e+15, 0},
1402 {-63.349078729022985, 4.177797167776188e-88},
1403 {-127.45117632943295, 1.183111089623681e-214},
1404 }
1405
1406 var vfhypotSC = [][2]float64{
1407 {Inf(-1), Inf(-1)},
1408 {Inf(-1), 0},
1409 {Inf(-1), Inf(1)},
1410 {Inf(-1), NaN()},
1411 {Copysign(0, -1), Copysign(0, -1)},
1412 {Copysign(0, -1), 0},
1413 {0, Copysign(0, -1)},
1414 {0, 0},
1415 {0, Inf(-1)},
1416 {0, Inf(1)},
1417 {0, NaN()},
1418 {Inf(1), Inf(-1)},
1419 {Inf(1), 0},
1420 {Inf(1), Inf(1)},
1421 {Inf(1), NaN()},
1422 {NaN(), Inf(-1)},
1423 {NaN(), 0},
1424 {NaN(), Inf(1)},
1425 {NaN(), NaN()},
1426 }
1427 var hypotSC = []float64{
1428 Inf(1),
1429 Inf(1),
1430 Inf(1),
1431 Inf(1),
1432 0,
1433 0,
1434 0,
1435 0,
1436 Inf(1),
1437 Inf(1),
1438 NaN(),
1439 Inf(1),
1440 Inf(1),
1441 Inf(1),
1442 Inf(1),
1443 Inf(1),
1444 NaN(),
1445 Inf(1),
1446 NaN(),
1447 }
1448
1449 var ilogbSC = []int{
1450 MaxInt32,
1451 MinInt32,
1452 MaxInt32,
1453 MaxInt32,
1454 }
1455
1456 var vfj0SC = []float64{
1457 Inf(-1),
1458 0,
1459 Inf(1),
1460 NaN(),
1461 }
1462 var j0SC = []float64{
1463 0,
1464 1,
1465 0,
1466 NaN(),
1467 }
1468 var j1SC = []float64{
1469 0,
1470 0,
1471 0,
1472 NaN(),
1473 }
1474 var j2SC = []float64{
1475 0,
1476 0,
1477 0,
1478 NaN(),
1479 }
1480 var jM3SC = []float64{
1481 0,
1482 0,
1483 0,
1484 NaN(),
1485 }
1486
1487 var vfldexpSC = []fi{
1488 {0, 0},
1489 {0, -1075},
1490 {0, 1024},
1491 {Copysign(0, -1), 0},
1492 {Copysign(0, -1), -1075},
1493 {Copysign(0, -1), 1024},
1494 {Inf(1), 0},
1495 {Inf(1), -1024},
1496 {Inf(-1), 0},
1497 {Inf(-1), -1024},
1498 {NaN(), -1024},
1499 {10, int(1) << (uint64(unsafe.Sizeof(0)-1) * 8)},
1500 {10, -(int(1) << (uint64(unsafe.Sizeof(0)-1) * 8))},
1501 }
1502 var ldexpSC = []float64{
1503 0,
1504 0,
1505 0,
1506 Copysign(0, -1),
1507 Copysign(0, -1),
1508 Copysign(0, -1),
1509 Inf(1),
1510 Inf(1),
1511 Inf(-1),
1512 Inf(-1),
1513 NaN(),
1514 Inf(1),
1515 0,
1516 }
1517
1518 var vflgammaSC = []float64{
1519 Inf(-1),
1520 -3,
1521 0,
1522 1,
1523 2,
1524 Inf(1),
1525 NaN(),
1526 }
1527 var lgammaSC = []fi{
1528 {Inf(-1), 1},
1529 {Inf(1), 1},
1530 {Inf(1), 1},
1531 {0, 1},
1532 {0, 1},
1533 {Inf(1), 1},
1534 {NaN(), 1},
1535 }
1536
1537 var vflogSC = []float64{
1538 Inf(-1),
1539 -Pi,
1540 Copysign(0, -1),
1541 0,
1542 1,
1543 Inf(1),
1544 NaN(),
1545 }
1546 var logSC = []float64{
1547 NaN(),
1548 NaN(),
1549 Inf(-1),
1550 Inf(-1),
1551 0,
1552 Inf(1),
1553 NaN(),
1554 }
1555
1556 var vflogbSC = []float64{
1557 Inf(-1),
1558 0,
1559 Inf(1),
1560 NaN(),
1561 }
1562 var logbSC = []float64{
1563 Inf(1),
1564 Inf(-1),
1565 Inf(1),
1566 NaN(),
1567 }
1568
1569 var vflog1pSC = []float64{
1570 Inf(-1),
1571 -Pi,
1572 -1,
1573 Copysign(0, -1),
1574 0,
1575 Inf(1),
1576 NaN(),
1577 4503599627370496.5,
1578 }
1579 var log1pSC = []float64{
1580 NaN(),
1581 NaN(),
1582 Inf(-1),
1583 Copysign(0, -1),
1584 0,
1585 Inf(1),
1586 NaN(),
1587 36.04365338911715,
1588 }
1589
1590 var vfmodfSC = []float64{
1591 Inf(-1),
1592 Copysign(0, -1),
1593 Inf(1),
1594 NaN(),
1595 }
1596 var modfSC = [][2]float64{
1597 {Inf(-1), NaN()},
1598 {Copysign(0, -1), Copysign(0, -1)},
1599 {Inf(1), NaN()},
1600 {NaN(), NaN()},
1601 }
1602
1603 var vfnextafter32SC = [][2]float32{
1604 {0, 0},
1605 {0, float32(Copysign(0, -1))},
1606 {0, -1},
1607 {0, float32(NaN())},
1608 {float32(Copysign(0, -1)), 1},
1609 {float32(Copysign(0, -1)), 0},
1610 {float32(Copysign(0, -1)), float32(Copysign(0, -1))},
1611 {float32(Copysign(0, -1)), -1},
1612 {float32(NaN()), 0},
1613 {float32(NaN()), float32(NaN())},
1614 }
1615 var nextafter32SC = []float32{
1616 0,
1617 0,
1618 -1.401298464e-45,
1619 float32(NaN()),
1620 1.401298464e-45,
1621 float32(Copysign(0, -1)),
1622 float32(Copysign(0, -1)),
1623 -1.401298464e-45,
1624 float32(NaN()),
1625 float32(NaN()),
1626 }
1627
1628 var vfnextafter64SC = [][2]float64{
1629 {0, 0},
1630 {0, Copysign(0, -1)},
1631 {0, -1},
1632 {0, NaN()},
1633 {Copysign(0, -1), 1},
1634 {Copysign(0, -1), 0},
1635 {Copysign(0, -1), Copysign(0, -1)},
1636 {Copysign(0, -1), -1},
1637 {NaN(), 0},
1638 {NaN(), NaN()},
1639 }
1640 var nextafter64SC = []float64{
1641 0,
1642 0,
1643 -4.9406564584124654418e-324,
1644 NaN(),
1645 4.9406564584124654418e-324,
1646 Copysign(0, -1),
1647 Copysign(0, -1),
1648 -4.9406564584124654418e-324,
1649 NaN(),
1650 NaN(),
1651 }
1652
1653 var vfpowSC = [][2]float64{
1654 {Inf(-1), -Pi},
1655 {Inf(-1), -3},
1656 {Inf(-1), Copysign(0, -1)},
1657 {Inf(-1), 0},
1658 {Inf(-1), 1},
1659 {Inf(-1), 3},
1660 {Inf(-1), Pi},
1661 {Inf(-1), 0.5},
1662 {Inf(-1), NaN()},
1663
1664 {-Pi, Inf(-1)},
1665 {-Pi, -Pi},
1666 {-Pi, Copysign(0, -1)},
1667 {-Pi, 0},
1668 {-Pi, 1},
1669 {-Pi, Pi},
1670 {-Pi, Inf(1)},
1671 {-Pi, NaN()},
1672
1673 {-1, Inf(-1)},
1674 {-1, Inf(1)},
1675 {-1, NaN()},
1676 {-0.5, Inf(-1)},
1677 {-0.5, Inf(1)},
1678 {Copysign(0, -1), Inf(-1)},
1679 {Copysign(0, -1), -Pi},
1680 {Copysign(0, -1), -0.5},
1681 {Copysign(0, -1), -3},
1682 {Copysign(0, -1), 3},
1683 {Copysign(0, -1), Pi},
1684 {Copysign(0, -1), 0.5},
1685 {Copysign(0, -1), Inf(1)},
1686
1687 {0, Inf(-1)},
1688 {0, -Pi},
1689 {0, -3},
1690 {0, Copysign(0, -1)},
1691 {0, 0},
1692 {0, 3},
1693 {0, Pi},
1694 {0, Inf(1)},
1695 {0, NaN()},
1696
1697 {0.5, Inf(-1)},
1698 {0.5, Inf(1)},
1699 {1, Inf(-1)},
1700 {1, Inf(1)},
1701 {1, NaN()},
1702
1703 {Pi, Inf(-1)},
1704 {Pi, Copysign(0, -1)},
1705 {Pi, 0},
1706 {Pi, 1},
1707 {Pi, Inf(1)},
1708 {Pi, NaN()},
1709 {Inf(1), -Pi},
1710 {Inf(1), Copysign(0, -1)},
1711 {Inf(1), 0},
1712 {Inf(1), 1},
1713 {Inf(1), Pi},
1714 {Inf(1), NaN()},
1715 {NaN(), -Pi},
1716 {NaN(), Copysign(0, -1)},
1717 {NaN(), 0},
1718 {NaN(), 1},
1719 {NaN(), Pi},
1720 {NaN(), NaN()},
1721
1722
1723 {2, float64(1 << 32)},
1724 {2, -float64(1 << 32)},
1725 {-2, float64(1<<32 + 1)},
1726 {0.5, float64(1 << 45)},
1727 {0.5, -float64(1 << 45)},
1728 {Nextafter(1, 2), float64(1 << 63)},
1729 {Nextafter(1, -2), float64(1 << 63)},
1730 {Nextafter(-1, 2), float64(1 << 63)},
1731 {Nextafter(-1, -2), float64(1 << 63)},
1732
1733
1734 {Copysign(0, -1), 1e19},
1735 {Copysign(0, -1), -1e19},
1736 {Copysign(0, -1), 1<<53 - 1},
1737 {Copysign(0, -1), -(1<<53 - 1)},
1738 }
1739 var powSC = []float64{
1740 0,
1741 Copysign(0, -1),
1742 1,
1743 1,
1744 Inf(-1),
1745 Inf(-1),
1746 Inf(1),
1747 Inf(1),
1748 NaN(),
1749 0,
1750 NaN(),
1751 1,
1752 1,
1753 -Pi,
1754 NaN(),
1755 Inf(1),
1756 NaN(),
1757 1,
1758 1,
1759 NaN(),
1760 Inf(1),
1761 0,
1762 Inf(1),
1763 Inf(1),
1764 Inf(1),
1765 Inf(-1),
1766 Copysign(0, -1),
1767 0,
1768 0,
1769 0,
1770 Inf(1),
1771 Inf(1),
1772 Inf(1),
1773 1,
1774 1,
1775 0,
1776 0,
1777 0,
1778 NaN(),
1779 Inf(1),
1780 0,
1781 1,
1782 1,
1783 1,
1784 0,
1785 1,
1786 1,
1787 Pi,
1788 Inf(1),
1789 NaN(),
1790 0,
1791 1,
1792 1,
1793 Inf(1),
1794 Inf(1),
1795 NaN(),
1796 NaN(),
1797 1,
1798 1,
1799 NaN(),
1800 NaN(),
1801 NaN(),
1802
1803
1804 Inf(1),
1805 0,
1806 Inf(-1),
1807 0,
1808 Inf(1),
1809 Inf(1),
1810 0,
1811 0,
1812 Inf(1),
1813
1814
1815 0,
1816 Inf(1),
1817 Copysign(0, -1),
1818 Inf(-1),
1819 }
1820
1821 var vfpow10SC = []int{
1822 MinInt32,
1823 -324,
1824 -323,
1825 -50,
1826 -22,
1827 -1,
1828 0,
1829 1,
1830 22,
1831 50,
1832 100,
1833 200,
1834 308,
1835 309,
1836 MaxInt32,
1837 }
1838
1839 var pow10SC = []float64{
1840 0,
1841 0,
1842 1.0e-323,
1843 1.0e-50,
1844 1.0e-22,
1845 1.0e-1,
1846 1.0e0,
1847 1.0e1,
1848 1.0e22,
1849 1.0e50,
1850 1.0e100,
1851 1.0e200,
1852 1.0e308,
1853 Inf(1),
1854 Inf(1),
1855 }
1856
1857 var vfroundSC = [][2]float64{
1858 {0, 0},
1859 {1.390671161567e-309, 0},
1860 {0.49999999999999994, 0},
1861 {0.5, 1},
1862 {0.5000000000000001, 1},
1863 {-1.5, -2},
1864 {-2.5, -3},
1865 {NaN(), NaN()},
1866 {Inf(1), Inf(1)},
1867 {2251799813685249.5, 2251799813685250},
1868 {2251799813685250.5, 2251799813685251},
1869 {4503599627370495.5, 4503599627370496},
1870 {4503599627370497, 4503599627370497},
1871 }
1872 var vfroundEvenSC = [][2]float64{
1873 {0, 0},
1874 {1.390671161567e-309, 0},
1875 {0.49999999999999994, 0},
1876 {0.5, 0},
1877 {0.5000000000000001, 1},
1878 {-1.5, -2},
1879 {-2.5, -2},
1880 {NaN(), NaN()},
1881 {Inf(1), Inf(1)},
1882 {2251799813685249.5, 2251799813685250},
1883 {2251799813685250.5, 2251799813685250},
1884 {4503599627370495.5, 4503599627370496},
1885 {4503599627370497, 4503599627370497},
1886 }
1887
1888 var vfsignbitSC = []float64{
1889 Inf(-1),
1890 Copysign(0, -1),
1891 0,
1892 Inf(1),
1893 NaN(),
1894 }
1895 var signbitSC = []bool{
1896 true,
1897 true,
1898 false,
1899 false,
1900 false,
1901 }
1902
1903 var vfsinSC = []float64{
1904 Inf(-1),
1905 Copysign(0, -1),
1906 0,
1907 Inf(1),
1908 NaN(),
1909 }
1910 var sinSC = []float64{
1911 NaN(),
1912 Copysign(0, -1),
1913 0,
1914 NaN(),
1915 NaN(),
1916 }
1917
1918 var vfsinhSC = []float64{
1919 Inf(-1),
1920 Copysign(0, -1),
1921 0,
1922 Inf(1),
1923 NaN(),
1924 }
1925 var sinhSC = []float64{
1926 Inf(-1),
1927 Copysign(0, -1),
1928 0,
1929 Inf(1),
1930 NaN(),
1931 }
1932
1933 var vfsqrtSC = []float64{
1934 Inf(-1),
1935 -Pi,
1936 Copysign(0, -1),
1937 0,
1938 Inf(1),
1939 NaN(),
1940 Float64frombits(2),
1941 }
1942 var sqrtSC = []float64{
1943 NaN(),
1944 NaN(),
1945 Copysign(0, -1),
1946 0,
1947 Inf(1),
1948 NaN(),
1949 3.1434555694052576e-162,
1950 }
1951
1952 var vftanhSC = []float64{
1953 Inf(-1),
1954 Copysign(0, -1),
1955 0,
1956 Inf(1),
1957 NaN(),
1958 }
1959 var tanhSC = []float64{
1960 -1,
1961 Copysign(0, -1),
1962 0,
1963 1,
1964 NaN(),
1965 }
1966
1967 var vfy0SC = []float64{
1968 Inf(-1),
1969 0,
1970 Inf(1),
1971 NaN(),
1972 -1,
1973 }
1974 var y0SC = []float64{
1975 NaN(),
1976 Inf(-1),
1977 0,
1978 NaN(),
1979 NaN(),
1980 }
1981 var y1SC = []float64{
1982 NaN(),
1983 Inf(-1),
1984 0,
1985 NaN(),
1986 NaN(),
1987 }
1988 var y2SC = []float64{
1989 NaN(),
1990 Inf(-1),
1991 0,
1992 NaN(),
1993 NaN(),
1994 }
1995 var yM3SC = []float64{
1996 NaN(),
1997 Inf(1),
1998 0,
1999 NaN(),
2000 NaN(),
2001 }
2002
2003
2004 const (
2005 SmallestNormalFloat64 = 2.2250738585072014e-308
2006 LargestSubnormalFloat64 = SmallestNormalFloat64 - SmallestNonzeroFloat64
2007 )
2008
2009 var vffrexpBC = []float64{
2010 SmallestNormalFloat64,
2011 LargestSubnormalFloat64,
2012 SmallestNonzeroFloat64,
2013 MaxFloat64,
2014 -SmallestNormalFloat64,
2015 -LargestSubnormalFloat64,
2016 -SmallestNonzeroFloat64,
2017 -MaxFloat64,
2018 }
2019 var frexpBC = []fi{
2020 {0.5, -1021},
2021 {0.99999999999999978, -1022},
2022 {0.5, -1073},
2023 {0.99999999999999989, 1024},
2024 {-0.5, -1021},
2025 {-0.99999999999999978, -1022},
2026 {-0.5, -1073},
2027 {-0.99999999999999989, 1024},
2028 }
2029
2030 var vfldexpBC = []fi{
2031 {SmallestNormalFloat64, -52},
2032 {LargestSubnormalFloat64, -51},
2033 {SmallestNonzeroFloat64, 1074},
2034 {MaxFloat64, -(1023 + 1074)},
2035 {1, -1075},
2036 {-1, -1075},
2037 {1, 1024},
2038 {-1, 1024},
2039 {1.0000000000000002, -1075},
2040 {1, -1075},
2041 }
2042 var ldexpBC = []float64{
2043 SmallestNonzeroFloat64,
2044 1e-323,
2045 1,
2046 1e-323,
2047 0,
2048 Copysign(0, -1),
2049 Inf(1),
2050 Inf(-1),
2051 SmallestNonzeroFloat64,
2052 0,
2053 }
2054
2055 var logbBC = []float64{
2056 -1022,
2057 -1023,
2058 -1074,
2059 1023,
2060 -1022,
2061 -1023,
2062 -1074,
2063 1023,
2064 }
2065
2066
2067
2068
2069 var fmaC = []struct{ x, y, z, want float64 }{
2070
2071 {-3.999999999999087, -1.1123914289620494e-16, -7.999877929687506, -7.999877929687505},
2072 {-262112.0000004768, -0.06251525855623184, 1.1102230248837136e-16, 16385.99945072085},
2073 {-6.462348523533467e-27, -2.3763644720331857e-211, 4.000000000931324, 4.000000000931324},
2074
2075
2076 {-2.0000000037252907, 6.7904383376e-313, -3.3951933161e-313, -1.697607001654e-312},
2077 {-0.12499999999999999, 512.007568359375, -1.4193627164960366e-16, -64.00094604492188},
2078 {-2.7550648847397148e-39, -3.4028301595800694e+38, 0.9960937495343386, 1.9335955376735676},
2079 {5.723369164769208e+24, 3.8149300927159385e-06, 1.84489958778182e+19, 4.028324913621874e+19},
2080 {-0.4843749999990904, -3.6893487872543293e+19, 9.223653786709391e+18, 2.7093936974938993e+19},
2081 {-3.8146972665201165e-06, 4.2949672959999385e+09, -2.2204460489938386e-16, -16384.000003844263},
2082 {6.98156394130982e-309, -1.1072962560000002e+09, -4.4414561548793455e-308, -7.73065965765153e-300},
2083
2084
2085 {5e-324, 4.5, -2e-323, 0},
2086 {5e-324, 7, -3.5e-323, 0},
2087 {5e-324, 0.5000000000000001, -5e-324, Copysign(0, -1)},
2088 {-2.1240680525e-314, -1.233647078189316e+308, -0.25781249999954525, -0.25780987964919844},
2089 {8.579992955364441e-308, 0.6037391876780558, -4.4501307410480706e-308, 7.29947236107098e-309},
2090 {-4.450143471986689e-308, -0.9960937499927239, -4.450419332475649e-308, -1.7659233458788e-310},
2091 {1.4932076393918112, -2.2248022430460833e-308, 4.449875571054211e-308, 1.127783865601762e-308},
2092
2093
2094 {-2.288020632214759e+38, -8.98846570988901e+307, 1.7696041796300924e+308, Inf(0)},
2095 {1.4888652783208255e+308, -9.007199254742012e+15, -6.807282911929205e+38, Inf(-1)},
2096 {9.142703268902826e+192, -1.3504889569802838e+296, -1.9082200803806996e-89, Inf(-1)},
2097
2098
2099 {31.99218749627471, -1.7976930544991702e+308, Inf(0), Inf(0)},
2100 {-1.7976931281784667e+308, -2.0009765625002265, Inf(-1), Inf(-1)},
2101
2102
2103 {0, 0, 0, 0},
2104 {Copysign(0, -1), 0, 0, 0},
2105 {0, 0, Copysign(0, -1), 0},
2106 {Copysign(0, -1), 0, Copysign(0, -1), Copysign(0, -1)},
2107 {-1.1754226043408471e-38, NaN(), Inf(0), NaN()},
2108 {0, 0, 2.22507385643494e-308, 2.22507385643494e-308},
2109 {-8.65697792e+09, NaN(), -7.516192799999999e+09, NaN()},
2110 {-0.00012207403779029757, 3.221225471996093e+09, NaN(), NaN()},
2111 {Inf(-1), 0.1252441407414153, -1.387184532981584e-76, Inf(-1)},
2112 {Inf(0), 1.525878907671432e-05, -9.214364835452549e+18, Inf(0)},
2113
2114
2115 {0.1777916152213626, -32.000015266239636, -2.2204459148334633e-16, -5.689334401293007},
2116 {-2.0816681711722314e-16, -0.4997558592585846, -0.9465627129124969, -0.9465627129124968},
2117 {-1.9999997615814211, 1.8518819259933516e+19, 16.874999999999996, -3.703763410463646e+19},
2118 {-0.12499994039717421, 32767.99999976135, -2.0752587082923246e+19, -2.075258708292325e+19},
2119 {7.705600568510257e-34, -1.801432979000528e+16, -0.17224197722973714, -0.17224197722973716},
2120 {3.8988133103758913e-308, -0.9848632812499999, 3.893879244098556e-308, 5.40811742605814e-310},
2121 {-0.012651981190687427, 6.911985574912436e+38, 6.669240527007144e+18, -8.745031148409496e+36},
2122 {4.612811918325842e+18, 1.4901161193847641e-08, 2.6077032311277997e-08, 6.873625395187494e+10},
2123 {-9.094947033611148e-13, 4.450691014249257e-308, 2.086006742350485e-308, 2.086006742346437e-308},
2124 {-7.751454006381804e-05, 5.588653777189071e-308, -2.2207280111272877e-308, -2.2211612130544025e-308},
2125
2126
2127 {-1, 1, 1, 0},
2128 {1, 1, -1, 0},
2129 }
2130
2131 var sqrt32 = []float32{
2132 0,
2133 float32(Copysign(0, -1)),
2134 float32(NaN()),
2135 float32(Inf(1)),
2136 float32(Inf(-1)),
2137 1,
2138 2,
2139 -2,
2140 4.9790119248836735e+00,
2141 7.7388724745781045e+00,
2142 -2.7688005719200159e-01,
2143 -5.0106036182710749e+00,
2144 }
2145
2146 func tolerance(a, b, e float64) bool {
2147
2148
2149
2150 if a == b {
2151 return true
2152 }
2153 d := a - b
2154 if d < 0 {
2155 d = -d
2156 }
2157
2158
2159
2160 if b != 0 {
2161 e = e * b
2162 if e < 0 {
2163 e = -e
2164 }
2165 }
2166 return d < e
2167 }
2168 func close(a, b float64) bool { return tolerance(a, b, 1e-14) }
2169 func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
2170 func soclose(a, b, e float64) bool { return tolerance(a, b, e) }
2171 func alike(a, b float64) bool {
2172 switch {
2173 case IsNaN(a) && IsNaN(b):
2174 return true
2175 case a == b:
2176 return Signbit(a) == Signbit(b)
2177 }
2178 return false
2179 }
2180
2181 func TestNaN(t *testing.T) {
2182 f64 := NaN()
2183 if f64 == f64 {
2184 t.Fatalf("NaN() returns %g, expected NaN", f64)
2185 }
2186 f32 := float32(f64)
2187 if f32 == f32 {
2188 t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
2189 }
2190 }
2191
2192 func TestAcos(t *testing.T) {
2193 for i := 0; i < len(vf); i++ {
2194 a := vf[i] / 10
2195 if f := Acos(a); !close(acos[i], f) {
2196 t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
2197 }
2198 }
2199 for i := 0; i < len(vfacosSC); i++ {
2200 if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
2201 t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosSC[i])
2202 }
2203 }
2204 }
2205
2206 func TestAcosh(t *testing.T) {
2207 for i := 0; i < len(vf); i++ {
2208 a := 1 + Abs(vf[i])
2209 if f := Acosh(a); !veryclose(acosh[i], f) {
2210 t.Errorf("Acosh(%g) = %g, want %g", a, f, acosh[i])
2211 }
2212 }
2213 for i := 0; i < len(vfacoshSC); i++ {
2214 if f := Acosh(vfacoshSC[i]); !alike(acoshSC[i], f) {
2215 t.Errorf("Acosh(%g) = %g, want %g", vfacoshSC[i], f, acoshSC[i])
2216 }
2217 }
2218 }
2219
2220 func TestAsin(t *testing.T) {
2221 for i := 0; i < len(vf); i++ {
2222 a := vf[i] / 10
2223 if f := Asin(a); !veryclose(asin[i], f) {
2224 t.Errorf("Asin(%g) = %g, want %g", a, f, asin[i])
2225 }
2226 }
2227 for i := 0; i < len(vfasinSC); i++ {
2228 if f := Asin(vfasinSC[i]); !alike(asinSC[i], f) {
2229 t.Errorf("Asin(%g) = %g, want %g", vfasinSC[i], f, asinSC[i])
2230 }
2231 }
2232 }
2233
2234 func TestAsinh(t *testing.T) {
2235 for i := 0; i < len(vf); i++ {
2236 if f := Asinh(vf[i]); !veryclose(asinh[i], f) {
2237 t.Errorf("Asinh(%g) = %g, want %g", vf[i], f, asinh[i])
2238 }
2239 }
2240 for i := 0; i < len(vfasinhSC); i++ {
2241 if f := Asinh(vfasinhSC[i]); !alike(asinhSC[i], f) {
2242 t.Errorf("Asinh(%g) = %g, want %g", vfasinhSC[i], f, asinhSC[i])
2243 }
2244 }
2245 }
2246
2247 func TestAtan(t *testing.T) {
2248 for i := 0; i < len(vf); i++ {
2249 if f := Atan(vf[i]); !veryclose(atan[i], f) {
2250 t.Errorf("Atan(%g) = %g, want %g", vf[i], f, atan[i])
2251 }
2252 }
2253 for i := 0; i < len(vfatanSC); i++ {
2254 if f := Atan(vfatanSC[i]); !alike(atanSC[i], f) {
2255 t.Errorf("Atan(%g) = %g, want %g", vfatanSC[i], f, atanSC[i])
2256 }
2257 }
2258 }
2259
2260 func TestAtanh(t *testing.T) {
2261 for i := 0; i < len(vf); i++ {
2262 a := vf[i] / 10
2263 if f := Atanh(a); !veryclose(atanh[i], f) {
2264 t.Errorf("Atanh(%g) = %g, want %g", a, f, atanh[i])
2265 }
2266 }
2267 for i := 0; i < len(vfatanhSC); i++ {
2268 if f := Atanh(vfatanhSC[i]); !alike(atanhSC[i], f) {
2269 t.Errorf("Atanh(%g) = %g, want %g", vfatanhSC[i], f, atanhSC[i])
2270 }
2271 }
2272 }
2273
2274 func TestAtan2(t *testing.T) {
2275 for i := 0; i < len(vf); i++ {
2276 if f := Atan2(10, vf[i]); !veryclose(atan2[i], f) {
2277 t.Errorf("Atan2(10, %g) = %g, want %g", vf[i], f, atan2[i])
2278 }
2279 }
2280 for i := 0; i < len(vfatan2SC); i++ {
2281 if f := Atan2(vfatan2SC[i][0], vfatan2SC[i][1]); !alike(atan2SC[i], f) {
2282 t.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC[i][0], vfatan2SC[i][1], f, atan2SC[i])
2283 }
2284 }
2285 }
2286
2287 func TestCbrt(t *testing.T) {
2288 for i := 0; i < len(vf); i++ {
2289 if f := Cbrt(vf[i]); !veryclose(cbrt[i], f) {
2290 t.Errorf("Cbrt(%g) = %g, want %g", vf[i], f, cbrt[i])
2291 }
2292 }
2293 for i := 0; i < len(vfcbrtSC); i++ {
2294 if f := Cbrt(vfcbrtSC[i]); !alike(cbrtSC[i], f) {
2295 t.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC[i], f, cbrtSC[i])
2296 }
2297 }
2298 }
2299
2300 func TestCeil(t *testing.T) {
2301 for i := 0; i < len(vf); i++ {
2302 if f := Ceil(vf[i]); !alike(ceil[i], f) {
2303 t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
2304 }
2305 }
2306 for i := 0; i < len(vfceilSC); i++ {
2307 if f := Ceil(vfceilSC[i]); !alike(ceilSC[i], f) {
2308 t.Errorf("Ceil(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2309 }
2310 }
2311 }
2312
2313 func TestCopysign(t *testing.T) {
2314 for i := 0; i < len(vf); i++ {
2315 if f := Copysign(vf[i], -1); copysign[i] != f {
2316 t.Errorf("Copysign(%g, -1) = %g, want %g", vf[i], f, copysign[i])
2317 }
2318 }
2319 for i := 0; i < len(vf); i++ {
2320 if f := Copysign(vf[i], 1); -copysign[i] != f {
2321 t.Errorf("Copysign(%g, 1) = %g, want %g", vf[i], f, -copysign[i])
2322 }
2323 }
2324 for i := 0; i < len(vfcopysignSC); i++ {
2325 if f := Copysign(vfcopysignSC[i], -1); !alike(copysignSC[i], f) {
2326 t.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC[i], f, copysignSC[i])
2327 }
2328 }
2329 }
2330
2331 func TestCos(t *testing.T) {
2332 for i := 0; i < len(vf); i++ {
2333 if f := Cos(vf[i]); !veryclose(cos[i], f) {
2334 t.Errorf("Cos(%g) = %g, want %g", vf[i], f, cos[i])
2335 }
2336 }
2337 for i := 0; i < len(vfcosSC); i++ {
2338 if f := Cos(vfcosSC[i]); !alike(cosSC[i], f) {
2339 t.Errorf("Cos(%g) = %g, want %g", vfcosSC[i], f, cosSC[i])
2340 }
2341 }
2342 }
2343
2344 func TestCosh(t *testing.T) {
2345 for i := 0; i < len(vf); i++ {
2346 if f := Cosh(vf[i]); !close(cosh[i], f) {
2347 t.Errorf("Cosh(%g) = %g, want %g", vf[i], f, cosh[i])
2348 }
2349 }
2350 for i := 0; i < len(vfcoshSC); i++ {
2351 if f := Cosh(vfcoshSC[i]); !alike(coshSC[i], f) {
2352 t.Errorf("Cosh(%g) = %g, want %g", vfcoshSC[i], f, coshSC[i])
2353 }
2354 }
2355 }
2356
2357 func TestErf(t *testing.T) {
2358 for i := 0; i < len(vf); i++ {
2359 a := vf[i] / 10
2360 if f := Erf(a); !veryclose(erf[i], f) {
2361 t.Errorf("Erf(%g) = %g, want %g", a, f, erf[i])
2362 }
2363 }
2364 for i := 0; i < len(vferfSC); i++ {
2365 if f := Erf(vferfSC[i]); !alike(erfSC[i], f) {
2366 t.Errorf("Erf(%g) = %g, want %g", vferfSC[i], f, erfSC[i])
2367 }
2368 }
2369 }
2370
2371 func TestErfc(t *testing.T) {
2372 for i := 0; i < len(vf); i++ {
2373 a := vf[i] / 10
2374 if f := Erfc(a); !veryclose(erfc[i], f) {
2375 t.Errorf("Erfc(%g) = %g, want %g", a, f, erfc[i])
2376 }
2377 }
2378 for i := 0; i < len(vferfcSC); i++ {
2379 if f := Erfc(vferfcSC[i]); !alike(erfcSC[i], f) {
2380 t.Errorf("Erfc(%g) = %g, want %g", vferfcSC[i], f, erfcSC[i])
2381 }
2382 }
2383 }
2384
2385 func TestErfinv(t *testing.T) {
2386 for i := 0; i < len(vf); i++ {
2387 a := vf[i] / 10
2388 if f := Erfinv(a); !veryclose(erfinv[i], f) {
2389 t.Errorf("Erfinv(%g) = %g, want %g", a, f, erfinv[i])
2390 }
2391 }
2392 for i := 0; i < len(vferfinvSC); i++ {
2393 if f := Erfinv(vferfinvSC[i]); !alike(erfinvSC[i], f) {
2394 t.Errorf("Erfinv(%g) = %g, want %g", vferfinvSC[i], f, erfinvSC[i])
2395 }
2396 }
2397 for x := -0.9; x <= 0.90; x += 1e-2 {
2398 if f := Erf(Erfinv(x)); !close(x, f) {
2399 t.Errorf("Erf(Erfinv(%g)) = %g, want %g", x, f, x)
2400 }
2401 }
2402 for x := -0.9; x <= 0.90; x += 1e-2 {
2403 if f := Erfinv(Erf(x)); !close(x, f) {
2404 t.Errorf("Erfinv(Erf(%g)) = %g, want %g", x, f, x)
2405 }
2406 }
2407 }
2408
2409 func TestErfcinv(t *testing.T) {
2410 for i := 0; i < len(vf); i++ {
2411 a := 1.0 - (vf[i] / 10)
2412 if f := Erfcinv(a); !veryclose(erfinv[i], f) {
2413 t.Errorf("Erfcinv(%g) = %g, want %g", a, f, erfinv[i])
2414 }
2415 }
2416 for i := 0; i < len(vferfcinvSC); i++ {
2417 if f := Erfcinv(vferfcinvSC[i]); !alike(erfcinvSC[i], f) {
2418 t.Errorf("Erfcinv(%g) = %g, want %g", vferfcinvSC[i], f, erfcinvSC[i])
2419 }
2420 }
2421 for x := 0.1; x <= 1.9; x += 1e-2 {
2422 if f := Erfc(Erfcinv(x)); !close(x, f) {
2423 t.Errorf("Erfc(Erfcinv(%g)) = %g, want %g", x, f, x)
2424 }
2425 }
2426 for x := 0.1; x <= 1.9; x += 1e-2 {
2427 if f := Erfcinv(Erfc(x)); !close(x, f) {
2428 t.Errorf("Erfcinv(Erfc(%g)) = %g, want %g", x, f, x)
2429 }
2430 }
2431 }
2432
2433 func TestExp(t *testing.T) {
2434 testExp(t, Exp, "Exp")
2435 testExp(t, ExpGo, "ExpGo")
2436 }
2437
2438 func testExp(t *testing.T, Exp func(float64) float64, name string) {
2439 for i := 0; i < len(vf); i++ {
2440 if f := Exp(vf[i]); !veryclose(exp[i], f) {
2441 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp[i])
2442 }
2443 }
2444 for i := 0; i < len(vfexpSC); i++ {
2445 if f := Exp(vfexpSC[i]); !alike(expSC[i], f) {
2446 t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
2447 }
2448 }
2449 }
2450
2451 func TestExpm1(t *testing.T) {
2452 for i := 0; i < len(vf); i++ {
2453 a := vf[i] / 100
2454 if f := Expm1(a); !veryclose(expm1[i], f) {
2455 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1[i])
2456 }
2457 }
2458 for i := 0; i < len(vf); i++ {
2459 a := vf[i] * 10
2460 if f := Expm1(a); !close(expm1Large[i], f) {
2461 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1Large[i])
2462 }
2463 }
2464 for i := 0; i < len(vfexpm1SC); i++ {
2465 if f := Expm1(vfexpm1SC[i]); !alike(expm1SC[i], f) {
2466 t.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC[i], f, expm1SC[i])
2467 }
2468 }
2469 }
2470
2471 func TestExp2(t *testing.T) {
2472 testExp2(t, Exp2, "Exp2")
2473 testExp2(t, Exp2Go, "Exp2Go")
2474 }
2475
2476 func testExp2(t *testing.T, Exp2 func(float64) float64, name string) {
2477 for i := 0; i < len(vf); i++ {
2478 if f := Exp2(vf[i]); !close(exp2[i], f) {
2479 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp2[i])
2480 }
2481 }
2482 for i := 0; i < len(vfexp2SC); i++ {
2483 if f := Exp2(vfexp2SC[i]); !alike(exp2SC[i], f) {
2484 t.Errorf("%s(%g) = %g, want %g", name, vfexp2SC[i], f, exp2SC[i])
2485 }
2486 }
2487 for n := -1074; n < 1024; n++ {
2488 f := Exp2(float64(n))
2489 vf := Ldexp(1, n)
2490 if f != vf {
2491 t.Errorf("%s(%d) = %g, want %g", name, n, f, vf)
2492 }
2493 }
2494 }
2495
2496 func TestAbs(t *testing.T) {
2497 for i := 0; i < len(vf); i++ {
2498 if f := Abs(vf[i]); fabs[i] != f {
2499 t.Errorf("Abs(%g) = %g, want %g", vf[i], f, fabs[i])
2500 }
2501 }
2502 for i := 0; i < len(vffabsSC); i++ {
2503 if f := Abs(vffabsSC[i]); !alike(fabsSC[i], f) {
2504 t.Errorf("Abs(%g) = %g, want %g", vffabsSC[i], f, fabsSC[i])
2505 }
2506 }
2507 }
2508
2509 func TestDim(t *testing.T) {
2510 for i := 0; i < len(vf); i++ {
2511 if f := Dim(vf[i], 0); fdim[i] != f {
2512 t.Errorf("Dim(%g, %g) = %g, want %g", vf[i], 0.0, f, fdim[i])
2513 }
2514 }
2515 for i := 0; i < len(vffdimSC); i++ {
2516 if f := Dim(vffdimSC[i][0], vffdimSC[i][1]); !alike(fdimSC[i], f) {
2517 t.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fdimSC[i])
2518 }
2519 }
2520 for i := 0; i < len(vffdim2SC); i++ {
2521 if f := Dim(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fdimSC[i], f) {
2522 t.Errorf("Dim(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fdimSC[i])
2523 }
2524 }
2525 }
2526
2527 func TestFloor(t *testing.T) {
2528 for i := 0; i < len(vf); i++ {
2529 if f := Floor(vf[i]); !alike(floor[i], f) {
2530 t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
2531 }
2532 }
2533 for i := 0; i < len(vfceilSC); i++ {
2534 if f := Floor(vfceilSC[i]); !alike(floorSC[i], f) {
2535 t.Errorf("Floor(%g) = %g, want %g", vfceilSC[i], f, floorSC[i])
2536 }
2537 }
2538 }
2539
2540 func TestMax(t *testing.T) {
2541 for i := 0; i < len(vf); i++ {
2542 if f := Max(vf[i], ceil[i]); ceil[i] != f {
2543 t.Errorf("Max(%g, %g) = %g, want %g", vf[i], ceil[i], f, ceil[i])
2544 }
2545 }
2546 for i := 0; i < len(vffdimSC); i++ {
2547 if f := Max(vffdimSC[i][0], vffdimSC[i][1]); !alike(fmaxSC[i], f) {
2548 t.Errorf("Max(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fmaxSC[i])
2549 }
2550 }
2551 for i := 0; i < len(vffdim2SC); i++ {
2552 if f := Max(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fmaxSC[i], f) {
2553 t.Errorf("Max(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fmaxSC[i])
2554 }
2555 }
2556 }
2557
2558 func TestMin(t *testing.T) {
2559 for i := 0; i < len(vf); i++ {
2560 if f := Min(vf[i], floor[i]); floor[i] != f {
2561 t.Errorf("Min(%g, %g) = %g, want %g", vf[i], floor[i], f, floor[i])
2562 }
2563 }
2564 for i := 0; i < len(vffdimSC); i++ {
2565 if f := Min(vffdimSC[i][0], vffdimSC[i][1]); !alike(fminSC[i], f) {
2566 t.Errorf("Min(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fminSC[i])
2567 }
2568 }
2569 for i := 0; i < len(vffdim2SC); i++ {
2570 if f := Min(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fminSC[i], f) {
2571 t.Errorf("Min(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fminSC[i])
2572 }
2573 }
2574 }
2575
2576 func TestMod(t *testing.T) {
2577 for i := 0; i < len(vf); i++ {
2578 if f := Mod(10, vf[i]); fmod[i] != f {
2579 t.Errorf("Mod(10, %g) = %g, want %g", vf[i], f, fmod[i])
2580 }
2581 }
2582 for i := 0; i < len(vffmodSC); i++ {
2583 if f := Mod(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2584 t.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2585 }
2586 }
2587
2588 if f := Mod(5.9790119248836734e+200, 1.1258465975523544); 0.6447968302508578 != f {
2589 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want 0.6447968302508578", f)
2590 }
2591 }
2592
2593 func TestFrexp(t *testing.T) {
2594 for i := 0; i < len(vf); i++ {
2595 if f, j := Frexp(vf[i]); !veryclose(frexp[i].f, f) || frexp[i].i != j {
2596 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf[i], f, j, frexp[i].f, frexp[i].i)
2597 }
2598 }
2599 for i := 0; i < len(vffrexpSC); i++ {
2600 if f, j := Frexp(vffrexpSC[i]); !alike(frexpSC[i].f, f) || frexpSC[i].i != j {
2601 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC[i], f, j, frexpSC[i].f, frexpSC[i].i)
2602 }
2603 }
2604 for i := 0; i < len(vffrexpBC); i++ {
2605 if f, j := Frexp(vffrexpBC[i]); !alike(frexpBC[i].f, f) || frexpBC[i].i != j {
2606 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC[i], f, j, frexpBC[i].f, frexpBC[i].i)
2607 }
2608 }
2609 }
2610
2611 func TestGamma(t *testing.T) {
2612 for i := 0; i < len(vf); i++ {
2613 if f := Gamma(vf[i]); !close(gamma[i], f) {
2614 t.Errorf("Gamma(%g) = %g, want %g", vf[i], f, gamma[i])
2615 }
2616 }
2617 for _, g := range vfgamma {
2618 f := Gamma(g[0])
2619 var ok bool
2620 if IsNaN(g[1]) || IsInf(g[1], 0) || g[1] == 0 || f == 0 {
2621 ok = alike(g[1], f)
2622 } else if g[0] > -50 && g[0] <= 171 {
2623 ok = veryclose(g[1], f)
2624 } else {
2625 ok = close(g[1], f)
2626 }
2627 if !ok {
2628 t.Errorf("Gamma(%g) = %g, want %g", g[0], f, g[1])
2629 }
2630 }
2631 }
2632
2633 func TestHypot(t *testing.T) {
2634 for i := 0; i < len(vf); i++ {
2635 a := Abs(1e200 * tanh[i] * Sqrt(2))
2636 if f := Hypot(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2637 t.Errorf("Hypot(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2638 }
2639 }
2640 for i := 0; i < len(vfhypotSC); i++ {
2641 if f := Hypot(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2642 t.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2643 }
2644 }
2645 }
2646
2647 func TestHypotGo(t *testing.T) {
2648 for i := 0; i < len(vf); i++ {
2649 a := Abs(1e200 * tanh[i] * Sqrt(2))
2650 if f := HypotGo(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2651 t.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2652 }
2653 }
2654 for i := 0; i < len(vfhypotSC); i++ {
2655 if f := HypotGo(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2656 t.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2657 }
2658 }
2659 }
2660
2661 func TestIlogb(t *testing.T) {
2662 for i := 0; i < len(vf); i++ {
2663 a := frexp[i].i - 1
2664 if e := Ilogb(vf[i]); a != e {
2665 t.Errorf("Ilogb(%g) = %d, want %d", vf[i], e, a)
2666 }
2667 }
2668 for i := 0; i < len(vflogbSC); i++ {
2669 if e := Ilogb(vflogbSC[i]); ilogbSC[i] != e {
2670 t.Errorf("Ilogb(%g) = %d, want %d", vflogbSC[i], e, ilogbSC[i])
2671 }
2672 }
2673 for i := 0; i < len(vffrexpBC); i++ {
2674 if e := Ilogb(vffrexpBC[i]); int(logbBC[i]) != e {
2675 t.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC[i], e, int(logbBC[i]))
2676 }
2677 }
2678 }
2679
2680 func TestJ0(t *testing.T) {
2681 for i := 0; i < len(vf); i++ {
2682 if f := J0(vf[i]); !soclose(j0[i], f, 4e-14) {
2683 t.Errorf("J0(%g) = %g, want %g", vf[i], f, j0[i])
2684 }
2685 }
2686 for i := 0; i < len(vfj0SC); i++ {
2687 if f := J0(vfj0SC[i]); !alike(j0SC[i], f) {
2688 t.Errorf("J0(%g) = %g, want %g", vfj0SC[i], f, j0SC[i])
2689 }
2690 }
2691 }
2692
2693 func TestJ1(t *testing.T) {
2694 for i := 0; i < len(vf); i++ {
2695 if f := J1(vf[i]); !close(j1[i], f) {
2696 t.Errorf("J1(%g) = %g, want %g", vf[i], f, j1[i])
2697 }
2698 }
2699 for i := 0; i < len(vfj0SC); i++ {
2700 if f := J1(vfj0SC[i]); !alike(j1SC[i], f) {
2701 t.Errorf("J1(%g) = %g, want %g", vfj0SC[i], f, j1SC[i])
2702 }
2703 }
2704 }
2705
2706 func TestJn(t *testing.T) {
2707 for i := 0; i < len(vf); i++ {
2708 if f := Jn(2, vf[i]); !close(j2[i], f) {
2709 t.Errorf("Jn(2, %g) = %g, want %g", vf[i], f, j2[i])
2710 }
2711 if f := Jn(-3, vf[i]); !close(jM3[i], f) {
2712 t.Errorf("Jn(-3, %g) = %g, want %g", vf[i], f, jM3[i])
2713 }
2714 }
2715 for i := 0; i < len(vfj0SC); i++ {
2716 if f := Jn(2, vfj0SC[i]); !alike(j2SC[i], f) {
2717 t.Errorf("Jn(2, %g) = %g, want %g", vfj0SC[i], f, j2SC[i])
2718 }
2719 if f := Jn(-3, vfj0SC[i]); !alike(jM3SC[i], f) {
2720 t.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC[i], f, jM3SC[i])
2721 }
2722 }
2723 }
2724
2725 func TestLdexp(t *testing.T) {
2726 for i := 0; i < len(vf); i++ {
2727 if f := Ldexp(frexp[i].f, frexp[i].i); !veryclose(vf[i], f) {
2728 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexp[i].f, frexp[i].i, f, vf[i])
2729 }
2730 }
2731 for i := 0; i < len(vffrexpSC); i++ {
2732 if f := Ldexp(frexpSC[i].f, frexpSC[i].i); !alike(vffrexpSC[i], f) {
2733 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC[i].f, frexpSC[i].i, f, vffrexpSC[i])
2734 }
2735 }
2736 for i := 0; i < len(vfldexpSC); i++ {
2737 if f := Ldexp(vfldexpSC[i].f, vfldexpSC[i].i); !alike(ldexpSC[i], f) {
2738 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC[i].f, vfldexpSC[i].i, f, ldexpSC[i])
2739 }
2740 }
2741 for i := 0; i < len(vffrexpBC); i++ {
2742 if f := Ldexp(frexpBC[i].f, frexpBC[i].i); !alike(vffrexpBC[i], f) {
2743 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC[i].f, frexpBC[i].i, f, vffrexpBC[i])
2744 }
2745 }
2746 for i := 0; i < len(vfldexpBC); i++ {
2747 if f := Ldexp(vfldexpBC[i].f, vfldexpBC[i].i); !alike(ldexpBC[i], f) {
2748 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC[i].f, vfldexpBC[i].i, f, ldexpBC[i])
2749 }
2750 }
2751 }
2752
2753 func TestLgamma(t *testing.T) {
2754 for i := 0; i < len(vf); i++ {
2755 if f, s := Lgamma(vf[i]); !close(lgamma[i].f, f) || lgamma[i].i != s {
2756 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf[i], f, s, lgamma[i].f, lgamma[i].i)
2757 }
2758 }
2759 for i := 0; i < len(vflgammaSC); i++ {
2760 if f, s := Lgamma(vflgammaSC[i]); !alike(lgammaSC[i].f, f) || lgammaSC[i].i != s {
2761 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC[i], f, s, lgammaSC[i].f, lgammaSC[i].i)
2762 }
2763 }
2764 }
2765
2766 func TestLog(t *testing.T) {
2767 for i := 0; i < len(vf); i++ {
2768 a := Abs(vf[i])
2769 if f := Log(a); log[i] != f {
2770 t.Errorf("Log(%g) = %g, want %g", a, f, log[i])
2771 }
2772 }
2773 if f := Log(10); f != Ln10 {
2774 t.Errorf("Log(%g) = %g, want %g", 10.0, f, Ln10)
2775 }
2776 for i := 0; i < len(vflogSC); i++ {
2777 if f := Log(vflogSC[i]); !alike(logSC[i], f) {
2778 t.Errorf("Log(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2779 }
2780 }
2781 }
2782
2783 func TestLogb(t *testing.T) {
2784 for i := 0; i < len(vf); i++ {
2785 if f := Logb(vf[i]); logb[i] != f {
2786 t.Errorf("Logb(%g) = %g, want %g", vf[i], f, logb[i])
2787 }
2788 }
2789 for i := 0; i < len(vflogbSC); i++ {
2790 if f := Logb(vflogbSC[i]); !alike(logbSC[i], f) {
2791 t.Errorf("Logb(%g) = %g, want %g", vflogbSC[i], f, logbSC[i])
2792 }
2793 }
2794 for i := 0; i < len(vffrexpBC); i++ {
2795 if f := Logb(vffrexpBC[i]); !alike(logbBC[i], f) {
2796 t.Errorf("Logb(%g) = %g, want %g", vffrexpBC[i], f, logbBC[i])
2797 }
2798 }
2799 }
2800
2801 func TestLog10(t *testing.T) {
2802 for i := 0; i < len(vf); i++ {
2803 a := Abs(vf[i])
2804 if f := Log10(a); !veryclose(log10[i], f) {
2805 t.Errorf("Log10(%g) = %g, want %g", a, f, log10[i])
2806 }
2807 }
2808 if f := Log10(E); f != Log10E {
2809 t.Errorf("Log10(%g) = %g, want %g", E, f, Log10E)
2810 }
2811 for i := 0; i < len(vflogSC); i++ {
2812 if f := Log10(vflogSC[i]); !alike(logSC[i], f) {
2813 t.Errorf("Log10(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2814 }
2815 }
2816 }
2817
2818 func TestLog1p(t *testing.T) {
2819 for i := 0; i < len(vf); i++ {
2820 a := vf[i] / 100
2821 if f := Log1p(a); !veryclose(log1p[i], f) {
2822 t.Errorf("Log1p(%g) = %g, want %g", a, f, log1p[i])
2823 }
2824 }
2825 a := 9.0
2826 if f := Log1p(a); f != Ln10 {
2827 t.Errorf("Log1p(%g) = %g, want %g", a, f, Ln10)
2828 }
2829 for i := 0; i < len(vflogSC); i++ {
2830 if f := Log1p(vflog1pSC[i]); !alike(log1pSC[i], f) {
2831 t.Errorf("Log1p(%g) = %g, want %g", vflog1pSC[i], f, log1pSC[i])
2832 }
2833 }
2834 }
2835
2836 func TestLog2(t *testing.T) {
2837 for i := 0; i < len(vf); i++ {
2838 a := Abs(vf[i])
2839 if f := Log2(a); !veryclose(log2[i], f) {
2840 t.Errorf("Log2(%g) = %g, want %g", a, f, log2[i])
2841 }
2842 }
2843 if f := Log2(E); f != Log2E {
2844 t.Errorf("Log2(%g) = %g, want %g", E, f, Log2E)
2845 }
2846 for i := 0; i < len(vflogSC); i++ {
2847 if f := Log2(vflogSC[i]); !alike(logSC[i], f) {
2848 t.Errorf("Log2(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2849 }
2850 }
2851 for i := -1074; i <= 1023; i++ {
2852 f := Ldexp(1, i)
2853 l := Log2(f)
2854 if l != float64(i) {
2855 t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
2856 }
2857 }
2858 }
2859
2860 func TestModf(t *testing.T) {
2861 for i := 0; i < len(vf); i++ {
2862 if f, g := Modf(vf[i]); !veryclose(modf[i][0], f) || !veryclose(modf[i][1], g) {
2863 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vf[i], f, g, modf[i][0], modf[i][1])
2864 }
2865 }
2866 for i := 0; i < len(vfmodfSC); i++ {
2867 if f, g := Modf(vfmodfSC[i]); !alike(modfSC[i][0], f) || !alike(modfSC[i][1], g) {
2868 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC[i], f, g, modfSC[i][0], modfSC[i][1])
2869 }
2870 }
2871 }
2872
2873 func TestNextafter32(t *testing.T) {
2874 for i := 0; i < len(vf); i++ {
2875 vfi := float32(vf[i])
2876 if f := Nextafter32(vfi, 10); nextafter32[i] != f {
2877 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfi, 10.0, f, nextafter32[i])
2878 }
2879 }
2880 for i := 0; i < len(vfnextafter32SC); i++ {
2881 if f := Nextafter32(vfnextafter32SC[i][0], vfnextafter32SC[i][1]); !alike(float64(nextafter32SC[i]), float64(f)) {
2882 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC[i][0], vfnextafter32SC[i][1], f, nextafter32SC[i])
2883 }
2884 }
2885 }
2886
2887 func TestNextafter64(t *testing.T) {
2888 for i := 0; i < len(vf); i++ {
2889 if f := Nextafter(vf[i], 10); nextafter64[i] != f {
2890 t.Errorf("Nextafter64(%g, %g) = %g want %g", vf[i], 10.0, f, nextafter64[i])
2891 }
2892 }
2893 for i := 0; i < len(vfnextafter64SC); i++ {
2894 if f := Nextafter(vfnextafter64SC[i][0], vfnextafter64SC[i][1]); !alike(nextafter64SC[i], f) {
2895 t.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC[i][0], vfnextafter64SC[i][1], f, nextafter64SC[i])
2896 }
2897 }
2898 }
2899
2900 func TestPow(t *testing.T) {
2901 for i := 0; i < len(vf); i++ {
2902 if f := Pow(10, vf[i]); !close(pow[i], f) {
2903 t.Errorf("Pow(10, %g) = %g, want %g", vf[i], f, pow[i])
2904 }
2905 }
2906 for i := 0; i < len(vfpowSC); i++ {
2907 if f := Pow(vfpowSC[i][0], vfpowSC[i][1]); !alike(powSC[i], f) {
2908 t.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC[i][0], vfpowSC[i][1], f, powSC[i])
2909 }
2910 }
2911 }
2912
2913 func TestPow10(t *testing.T) {
2914 for i := 0; i < len(vfpow10SC); i++ {
2915 if f := Pow10(vfpow10SC[i]); !alike(pow10SC[i], f) {
2916 t.Errorf("Pow10(%d) = %g, want %g", vfpow10SC[i], f, pow10SC[i])
2917 }
2918 }
2919 }
2920
2921 func TestRemainder(t *testing.T) {
2922 for i := 0; i < len(vf); i++ {
2923 if f := Remainder(10, vf[i]); remainder[i] != f {
2924 t.Errorf("Remainder(10, %g) = %g, want %g", vf[i], f, remainder[i])
2925 }
2926 }
2927 for i := 0; i < len(vffmodSC); i++ {
2928 if f := Remainder(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2929 t.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2930 }
2931 }
2932
2933 if f := Remainder(5.9790119248836734e+200, 1.1258465975523544); -0.4810497673014966 != f {
2934 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want -0.4810497673014966", f)
2935 }
2936
2937 test := func(x, y float64) {
2938 if r := Remainder(x, y); r == 0 && Signbit(r) != Signbit(x) {
2939 t.Errorf("Remainder(x=%f, y=%f) = %f, sign of (zero) result should agree with sign of x", x, y, r)
2940 }
2941 }
2942 for x := 0.0; x <= 3.0; x += 1 {
2943 for y := 1.0; y <= 3.0; y += 1 {
2944 test(x, y)
2945 test(x, -y)
2946 test(-x, y)
2947 test(-x, -y)
2948 }
2949 }
2950 }
2951
2952 func TestRound(t *testing.T) {
2953 for i := 0; i < len(vf); i++ {
2954 if f := Round(vf[i]); !alike(round[i], f) {
2955 t.Errorf("Round(%g) = %g, want %g", vf[i], f, round[i])
2956 }
2957 }
2958 for i := 0; i < len(vfroundSC); i++ {
2959 if f := Round(vfroundSC[i][0]); !alike(vfroundSC[i][1], f) {
2960 t.Errorf("Round(%g) = %g, want %g", vfroundSC[i][0], f, vfroundSC[i][1])
2961 }
2962 }
2963 }
2964
2965 func TestRoundToEven(t *testing.T) {
2966 for i := 0; i < len(vf); i++ {
2967 if f := RoundToEven(vf[i]); !alike(round[i], f) {
2968 t.Errorf("RoundToEven(%g) = %g, want %g", vf[i], f, round[i])
2969 }
2970 }
2971 for i := 0; i < len(vfroundEvenSC); i++ {
2972 if f := RoundToEven(vfroundEvenSC[i][0]); !alike(vfroundEvenSC[i][1], f) {
2973 t.Errorf("RoundToEven(%g) = %g, want %g", vfroundEvenSC[i][0], f, vfroundEvenSC[i][1])
2974 }
2975 }
2976 }
2977
2978 func TestSignbit(t *testing.T) {
2979 for i := 0; i < len(vf); i++ {
2980 if f := Signbit(vf[i]); signbit[i] != f {
2981 t.Errorf("Signbit(%g) = %t, want %t", vf[i], f, signbit[i])
2982 }
2983 }
2984 for i := 0; i < len(vfsignbitSC); i++ {
2985 if f := Signbit(vfsignbitSC[i]); signbitSC[i] != f {
2986 t.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC[i], f, signbitSC[i])
2987 }
2988 }
2989 }
2990 func TestSin(t *testing.T) {
2991 for i := 0; i < len(vf); i++ {
2992 if f := Sin(vf[i]); !veryclose(sin[i], f) {
2993 t.Errorf("Sin(%g) = %g, want %g", vf[i], f, sin[i])
2994 }
2995 }
2996 for i := 0; i < len(vfsinSC); i++ {
2997 if f := Sin(vfsinSC[i]); !alike(sinSC[i], f) {
2998 t.Errorf("Sin(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
2999 }
3000 }
3001 }
3002
3003 func TestSincos(t *testing.T) {
3004 for i := 0; i < len(vf); i++ {
3005 if s, c := Sincos(vf[i]); !veryclose(sin[i], s) || !veryclose(cos[i], c) {
3006 t.Errorf("Sincos(%g) = %g, %g want %g, %g", vf[i], s, c, sin[i], cos[i])
3007 }
3008 }
3009 }
3010
3011 func TestSinh(t *testing.T) {
3012 for i := 0; i < len(vf); i++ {
3013 if f := Sinh(vf[i]); !close(sinh[i], f) {
3014 t.Errorf("Sinh(%g) = %g, want %g", vf[i], f, sinh[i])
3015 }
3016 }
3017 for i := 0; i < len(vfsinhSC); i++ {
3018 if f := Sinh(vfsinhSC[i]); !alike(sinhSC[i], f) {
3019 t.Errorf("Sinh(%g) = %g, want %g", vfsinhSC[i], f, sinhSC[i])
3020 }
3021 }
3022 }
3023
3024 func TestSqrt(t *testing.T) {
3025 for i := 0; i < len(vf); i++ {
3026 a := Abs(vf[i])
3027 if f := SqrtGo(a); sqrt[i] != f {
3028 t.Errorf("SqrtGo(%g) = %g, want %g", a, f, sqrt[i])
3029 }
3030 a = Abs(vf[i])
3031 if f := Sqrt(a); sqrt[i] != f {
3032 t.Errorf("Sqrt(%g) = %g, want %g", a, f, sqrt[i])
3033 }
3034 }
3035 for i := 0; i < len(vfsqrtSC); i++ {
3036 if f := SqrtGo(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
3037 t.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
3038 }
3039 if f := Sqrt(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
3040 t.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
3041 }
3042 }
3043 }
3044
3045 func TestTan(t *testing.T) {
3046 for i := 0; i < len(vf); i++ {
3047 if f := Tan(vf[i]); !veryclose(tan[i], f) {
3048 t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
3049 }
3050 }
3051
3052 for i := 0; i < len(vfsinSC); i++ {
3053 if f := Tan(vfsinSC[i]); !alike(sinSC[i], f) {
3054 t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
3055 }
3056 }
3057 }
3058
3059 func TestTanh(t *testing.T) {
3060 for i := 0; i < len(vf); i++ {
3061 if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
3062 t.Errorf("Tanh(%g) = %g, want %g", vf[i], f, tanh[i])
3063 }
3064 }
3065 for i := 0; i < len(vftanhSC); i++ {
3066 if f := Tanh(vftanhSC[i]); !alike(tanhSC[i], f) {
3067 t.Errorf("Tanh(%g) = %g, want %g", vftanhSC[i], f, tanhSC[i])
3068 }
3069 }
3070 }
3071
3072 func TestTrunc(t *testing.T) {
3073 for i := 0; i < len(vf); i++ {
3074 if f := Trunc(vf[i]); !alike(trunc[i], f) {
3075 t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
3076 }
3077 }
3078 for i := 0; i < len(vfceilSC); i++ {
3079 if f := Trunc(vfceilSC[i]); !alike(truncSC[i], f) {
3080 t.Errorf("Trunc(%g) = %g, want %g", vfceilSC[i], f, truncSC[i])
3081 }
3082 }
3083 }
3084
3085 func TestY0(t *testing.T) {
3086 for i := 0; i < len(vf); i++ {
3087 a := Abs(vf[i])
3088 if f := Y0(a); !close(y0[i], f) {
3089 t.Errorf("Y0(%g) = %g, want %g", a, f, y0[i])
3090 }
3091 }
3092 for i := 0; i < len(vfy0SC); i++ {
3093 if f := Y0(vfy0SC[i]); !alike(y0SC[i], f) {
3094 t.Errorf("Y0(%g) = %g, want %g", vfy0SC[i], f, y0SC[i])
3095 }
3096 }
3097 }
3098
3099 func TestY1(t *testing.T) {
3100 for i := 0; i < len(vf); i++ {
3101 a := Abs(vf[i])
3102 if f := Y1(a); !soclose(y1[i], f, 2e-14) {
3103 t.Errorf("Y1(%g) = %g, want %g", a, f, y1[i])
3104 }
3105 }
3106 for i := 0; i < len(vfy0SC); i++ {
3107 if f := Y1(vfy0SC[i]); !alike(y1SC[i], f) {
3108 t.Errorf("Y1(%g) = %g, want %g", vfy0SC[i], f, y1SC[i])
3109 }
3110 }
3111 }
3112
3113 func TestYn(t *testing.T) {
3114 for i := 0; i < len(vf); i++ {
3115 a := Abs(vf[i])
3116 if f := Yn(2, a); !close(y2[i], f) {
3117 t.Errorf("Yn(2, %g) = %g, want %g", a, f, y2[i])
3118 }
3119 if f := Yn(-3, a); !close(yM3[i], f) {
3120 t.Errorf("Yn(-3, %g) = %g, want %g", a, f, yM3[i])
3121 }
3122 }
3123 for i := 0; i < len(vfy0SC); i++ {
3124 if f := Yn(2, vfy0SC[i]); !alike(y2SC[i], f) {
3125 t.Errorf("Yn(2, %g) = %g, want %g", vfy0SC[i], f, y2SC[i])
3126 }
3127 if f := Yn(-3, vfy0SC[i]); !alike(yM3SC[i], f) {
3128 t.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC[i], f, yM3SC[i])
3129 }
3130 }
3131 if f := Yn(0, 0); !alike(Inf(-1), f) {
3132 t.Errorf("Yn(0, 0) = %g, want %g", f, Inf(-1))
3133 }
3134 }
3135
3136 var PortableFMA = FMA
3137
3138 func TestFMA(t *testing.T) {
3139 for _, c := range fmaC {
3140 got := FMA(c.x, c.y, c.z)
3141 if !alike(got, c.want) {
3142 t.Errorf("FMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3143 }
3144 got = PortableFMA(c.x, c.y, c.z)
3145 if !alike(got, c.want) {
3146 t.Errorf("PortableFMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3147 }
3148 }
3149 }
3150
3151
3152 func fmsub(x, y, z float64) float64 {
3153 return FMA(x, y, -z)
3154 }
3155
3156
3157 func fnmsub(x, y, z float64) float64 {
3158 return FMA(-x, y, z)
3159 }
3160
3161
3162 func fnmadd(x, y, z float64) float64 {
3163 return FMA(-x, y, -z)
3164 }
3165
3166 func TestFMANegativeArgs(t *testing.T) {
3167
3168
3169
3170
3171 for _, c := range fmaC {
3172 want := PortableFMA(c.x, c.y, -c.z)
3173 got := fmsub(c.x, c.y, c.z)
3174 if !alike(got, want) {
3175 t.Errorf("FMA(%g, %g, -(%g)) == %g, want %g", c.x, c.y, c.z, got, want)
3176 }
3177 want = PortableFMA(-c.x, c.y, c.z)
3178 got = fnmsub(c.x, c.y, c.z)
3179 if !alike(got, want) {
3180 t.Errorf("FMA(-(%g), %g, %g) == %g, want %g", c.x, c.y, c.z, got, want)
3181 }
3182 want = PortableFMA(-c.x, c.y, -c.z)
3183 got = fnmadd(c.x, c.y, c.z)
3184 if !alike(got, want) {
3185 t.Errorf("FMA(-(%g), %g, -(%g)) == %g, want %g", c.x, c.y, c.z, got, want)
3186 }
3187 }
3188 }
3189
3190
3191
3192
3193
3194 func TestLargeCos(t *testing.T) {
3195 large := float64(100000 * Pi)
3196 for i := 0; i < len(vf); i++ {
3197 f1 := cosLarge[i]
3198 f2 := Cos(vf[i] + large)
3199 if !close(f1, f2) {
3200 t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
3201 }
3202 }
3203 }
3204
3205 func TestLargeSin(t *testing.T) {
3206 large := float64(100000 * Pi)
3207 for i := 0; i < len(vf); i++ {
3208 f1 := sinLarge[i]
3209 f2 := Sin(vf[i] + large)
3210 if !close(f1, f2) {
3211 t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
3212 }
3213 }
3214 }
3215
3216 func TestLargeSincos(t *testing.T) {
3217 large := float64(100000 * Pi)
3218 for i := 0; i < len(vf); i++ {
3219 f1, g1 := sinLarge[i], cosLarge[i]
3220 f2, g2 := Sincos(vf[i] + large)
3221 if !close(f1, f2) || !close(g1, g2) {
3222 t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
3223 }
3224 }
3225 }
3226
3227 func TestLargeTan(t *testing.T) {
3228 large := float64(100000 * Pi)
3229 for i := 0; i < len(vf); i++ {
3230 f1 := tanLarge[i]
3231 f2 := Tan(vf[i] + large)
3232 if !close(f1, f2) {
3233 t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
3234 }
3235 }
3236 }
3237
3238
3239
3240 func TestTrigReduce(t *testing.T) {
3241 inputs := make([]float64, len(vf))
3242
3243 copy(inputs, vf)
3244
3245 large := float64(100000 * Pi)
3246 for _, v := range vf {
3247 inputs = append(inputs, v+large)
3248 }
3249
3250 inputs = append(inputs, Pi, Nextafter(ReduceThreshold, 0))
3251 for _, x := range inputs {
3252
3253 j, z := TrigReduce(x)
3254 xred := float64(j)*(Pi/4) + z
3255
3256 if f, fred := Sin(x), Sin(xred); !close(f, fred) {
3257 t.Errorf("Sin(trigReduce(%g)) != Sin(%g), got %g, want %g", x, x, fred, f)
3258 }
3259 if f, fred := Cos(x), Cos(xred); !close(f, fred) {
3260 t.Errorf("Cos(trigReduce(%g)) != Cos(%g), got %g, want %g", x, x, fred, f)
3261 }
3262 if f, fred := Tan(x), Tan(xred); !close(f, fred) {
3263 t.Errorf(" Tan(trigReduce(%g)) != Tan(%g), got %g, want %g", x, x, fred, f)
3264 }
3265 f, g := Sincos(x)
3266 fred, gred := Sincos(xred)
3267 if !close(f, fred) || !close(g, gred) {
3268 t.Errorf(" Sincos(trigReduce(%g)) != Sincos(%g), got %g, %g, want %g, %g", x, x, fred, gred, f, g)
3269 }
3270 }
3271 }
3272
3273
3274
3275
3276
3277 type floatTest struct {
3278 val any
3279 name string
3280 str string
3281 }
3282
3283 var floatTests = []floatTest{
3284 {float64(MaxFloat64), "MaxFloat64", "1.7976931348623157e+308"},
3285 {float64(SmallestNonzeroFloat64), "SmallestNonzeroFloat64", "5e-324"},
3286 {float32(MaxFloat32), "MaxFloat32", "3.4028235e+38"},
3287 {float32(SmallestNonzeroFloat32), "SmallestNonzeroFloat32", "1e-45"},
3288 }
3289
3290 func TestFloatMinMax(t *testing.T) {
3291 for _, tt := range floatTests {
3292 s := fmt.Sprint(tt.val)
3293 if s != tt.str {
3294 t.Errorf("Sprint(%v) = %s, want %s", tt.name, s, tt.str)
3295 }
3296 }
3297 }
3298
3299 func TestFloatMinima(t *testing.T) {
3300 if q := float32(SmallestNonzeroFloat32 / 2); q != 0 {
3301 t.Errorf("float32(SmallestNonzeroFloat32 / 2) = %g, want 0", q)
3302 }
3303 if q := float64(SmallestNonzeroFloat64 / 2); q != 0 {
3304 t.Errorf("float64(SmallestNonzeroFloat64 / 2) = %g, want 0", q)
3305 }
3306 }
3307
3308 var indirectSqrt = Sqrt
3309
3310
3311 func TestFloat32Sqrt(t *testing.T) {
3312 for _, v := range sqrt32 {
3313 want := float32(indirectSqrt(float64(v)))
3314 got := float32(Sqrt(float64(v)))
3315 if IsNaN(float64(want)) {
3316 if !IsNaN(float64(got)) {
3317 t.Errorf("got=%#v want=NaN, v=%#v", got, v)
3318 }
3319 continue
3320 }
3321 if got != want {
3322 t.Errorf("got=%#v want=%#v, v=%#v", got, want, v)
3323 }
3324 }
3325 }
3326
3327
3328
3329
3330
3331
3332
3333 var (
3334 GlobalI int
3335 GlobalB bool
3336 GlobalF float64
3337 )
3338
3339 func BenchmarkAcos(b *testing.B) {
3340 x := 0.0
3341 for i := 0; i < b.N; i++ {
3342 x = Acos(.5)
3343 }
3344 GlobalF = x
3345 }
3346
3347 func BenchmarkAcosh(b *testing.B) {
3348 x := 0.0
3349 for i := 0; i < b.N; i++ {
3350 x = Acosh(1.5)
3351 }
3352 GlobalF = x
3353 }
3354
3355 func BenchmarkAsin(b *testing.B) {
3356 x := 0.0
3357 for i := 0; i < b.N; i++ {
3358 x = Asin(.5)
3359 }
3360 GlobalF = x
3361 }
3362
3363 func BenchmarkAsinh(b *testing.B) {
3364 x := 0.0
3365 for i := 0; i < b.N; i++ {
3366 x = Asinh(.5)
3367 }
3368 GlobalF = x
3369 }
3370
3371 func BenchmarkAtan(b *testing.B) {
3372 x := 0.0
3373 for i := 0; i < b.N; i++ {
3374 x = Atan(.5)
3375 }
3376 GlobalF = x
3377 }
3378
3379 func BenchmarkAtanh(b *testing.B) {
3380 x := 0.0
3381 for i := 0; i < b.N; i++ {
3382 x = Atanh(.5)
3383 }
3384 GlobalF = x
3385 }
3386
3387 func BenchmarkAtan2(b *testing.B) {
3388 x := 0.0
3389 for i := 0; i < b.N; i++ {
3390 x = Atan2(.5, 1)
3391 }
3392 GlobalF = x
3393 }
3394
3395 func BenchmarkCbrt(b *testing.B) {
3396 x := 0.0
3397 for i := 0; i < b.N; i++ {
3398 x = Cbrt(10)
3399 }
3400 GlobalF = x
3401 }
3402
3403 func BenchmarkCeil(b *testing.B) {
3404 x := 0.0
3405 for i := 0; i < b.N; i++ {
3406 x = Ceil(.5)
3407 }
3408 GlobalF = x
3409 }
3410
3411 var copysignNeg = -1.0
3412
3413 func BenchmarkCopysign(b *testing.B) {
3414 x := 0.0
3415 for i := 0; i < b.N; i++ {
3416 x = Copysign(.5, copysignNeg)
3417 }
3418 GlobalF = x
3419 }
3420
3421 func BenchmarkCos(b *testing.B) {
3422 x := 0.0
3423 for i := 0; i < b.N; i++ {
3424 x = Cos(.5)
3425 }
3426 GlobalF = x
3427 }
3428
3429 func BenchmarkCosh(b *testing.B) {
3430 x := 0.0
3431 for i := 0; i < b.N; i++ {
3432 x = Cosh(2.5)
3433 }
3434 GlobalF = x
3435 }
3436
3437 func BenchmarkErf(b *testing.B) {
3438 x := 0.0
3439 for i := 0; i < b.N; i++ {
3440 x = Erf(.5)
3441 }
3442 GlobalF = x
3443 }
3444
3445 func BenchmarkErfc(b *testing.B) {
3446 x := 0.0
3447 for i := 0; i < b.N; i++ {
3448 x = Erfc(.5)
3449 }
3450 GlobalF = x
3451 }
3452
3453 func BenchmarkErfinv(b *testing.B) {
3454 x := 0.0
3455 for i := 0; i < b.N; i++ {
3456 x = Erfinv(.5)
3457 }
3458 GlobalF = x
3459 }
3460
3461 func BenchmarkErfcinv(b *testing.B) {
3462 x := 0.0
3463 for i := 0; i < b.N; i++ {
3464 x = Erfcinv(.5)
3465 }
3466 GlobalF = x
3467 }
3468
3469 func BenchmarkExp(b *testing.B) {
3470 x := 0.0
3471 for i := 0; i < b.N; i++ {
3472 x = Exp(.5)
3473 }
3474 GlobalF = x
3475 }
3476
3477 func BenchmarkExpGo(b *testing.B) {
3478 x := 0.0
3479 for i := 0; i < b.N; i++ {
3480 x = ExpGo(.5)
3481 }
3482 GlobalF = x
3483 }
3484
3485 func BenchmarkExpm1(b *testing.B) {
3486 x := 0.0
3487 for i := 0; i < b.N; i++ {
3488 x = Expm1(.5)
3489 }
3490 GlobalF = x
3491 }
3492
3493 func BenchmarkExp2(b *testing.B) {
3494 x := 0.0
3495 for i := 0; i < b.N; i++ {
3496 x = Exp2(.5)
3497 }
3498 GlobalF = x
3499 }
3500
3501 func BenchmarkExp2Go(b *testing.B) {
3502 x := 0.0
3503 for i := 0; i < b.N; i++ {
3504 x = Exp2Go(.5)
3505 }
3506 GlobalF = x
3507 }
3508
3509 var absPos = .5
3510
3511 func BenchmarkAbs(b *testing.B) {
3512 x := 0.0
3513 for i := 0; i < b.N; i++ {
3514 x = Abs(absPos)
3515 }
3516 GlobalF = x
3517
3518 }
3519
3520 func BenchmarkDim(b *testing.B) {
3521 x := 0.0
3522 for i := 0; i < b.N; i++ {
3523 x = Dim(GlobalF, x)
3524 }
3525 GlobalF = x
3526 }
3527
3528 func BenchmarkFloor(b *testing.B) {
3529 x := 0.0
3530 for i := 0; i < b.N; i++ {
3531 x = Floor(.5)
3532 }
3533 GlobalF = x
3534 }
3535
3536 func BenchmarkMax(b *testing.B) {
3537 x := 0.0
3538 for i := 0; i < b.N; i++ {
3539 x = Max(10, 3)
3540 }
3541 GlobalF = x
3542 }
3543
3544 func BenchmarkMin(b *testing.B) {
3545 x := 0.0
3546 for i := 0; i < b.N; i++ {
3547 x = Min(10, 3)
3548 }
3549 GlobalF = x
3550 }
3551
3552 func BenchmarkMod(b *testing.B) {
3553 x := 0.0
3554 for i := 0; i < b.N; i++ {
3555 x = Mod(10, 3)
3556 }
3557 GlobalF = x
3558 }
3559
3560 func BenchmarkFrexp(b *testing.B) {
3561 x := 0.0
3562 y := 0
3563 for i := 0; i < b.N; i++ {
3564 x, y = Frexp(8)
3565 }
3566 GlobalF = x
3567 GlobalI = y
3568 }
3569
3570 func BenchmarkGamma(b *testing.B) {
3571 x := 0.0
3572 for i := 0; i < b.N; i++ {
3573 x = Gamma(2.5)
3574 }
3575 GlobalF = x
3576 }
3577
3578 func BenchmarkHypot(b *testing.B) {
3579 x := 0.0
3580 for i := 0; i < b.N; i++ {
3581 x = Hypot(3, 4)
3582 }
3583 GlobalF = x
3584 }
3585
3586 func BenchmarkHypotGo(b *testing.B) {
3587 x := 0.0
3588 for i := 0; i < b.N; i++ {
3589 x = HypotGo(3, 4)
3590 }
3591 GlobalF = x
3592 }
3593
3594 func BenchmarkIlogb(b *testing.B) {
3595 x := 0
3596 for i := 0; i < b.N; i++ {
3597 x = Ilogb(.5)
3598 }
3599 GlobalI = x
3600 }
3601
3602 func BenchmarkJ0(b *testing.B) {
3603 x := 0.0
3604 for i := 0; i < b.N; i++ {
3605 x = J0(2.5)
3606 }
3607 GlobalF = x
3608 }
3609
3610 func BenchmarkJ1(b *testing.B) {
3611 x := 0.0
3612 for i := 0; i < b.N; i++ {
3613 x = J1(2.5)
3614 }
3615 GlobalF = x
3616 }
3617
3618 func BenchmarkJn(b *testing.B) {
3619 x := 0.0
3620 for i := 0; i < b.N; i++ {
3621 x = Jn(2, 2.5)
3622 }
3623 GlobalF = x
3624 }
3625
3626 func BenchmarkLdexp(b *testing.B) {
3627 x := 0.0
3628 for i := 0; i < b.N; i++ {
3629 x = Ldexp(.5, 2)
3630 }
3631 GlobalF = x
3632 }
3633
3634 func BenchmarkLgamma(b *testing.B) {
3635 x := 0.0
3636 y := 0
3637 for i := 0; i < b.N; i++ {
3638 x, y = Lgamma(2.5)
3639 }
3640 GlobalF = x
3641 GlobalI = y
3642 }
3643
3644 func BenchmarkLog(b *testing.B) {
3645 x := 0.0
3646 for i := 0; i < b.N; i++ {
3647 x = Log(.5)
3648 }
3649 GlobalF = x
3650 }
3651
3652 func BenchmarkLogb(b *testing.B) {
3653 x := 0.0
3654 for i := 0; i < b.N; i++ {
3655 x = Logb(.5)
3656 }
3657 GlobalF = x
3658 }
3659
3660 func BenchmarkLog1p(b *testing.B) {
3661 x := 0.0
3662 for i := 0; i < b.N; i++ {
3663 x = Log1p(.5)
3664 }
3665 GlobalF = x
3666 }
3667
3668 func BenchmarkLog10(b *testing.B) {
3669 x := 0.0
3670 for i := 0; i < b.N; i++ {
3671 x = Log10(.5)
3672 }
3673 GlobalF = x
3674 }
3675
3676 func BenchmarkLog2(b *testing.B) {
3677 x := 0.0
3678 for i := 0; i < b.N; i++ {
3679 x = Log2(.5)
3680 }
3681 GlobalF += x
3682 }
3683
3684 func BenchmarkModf(b *testing.B) {
3685 x := 0.0
3686 y := 0.0
3687 for i := 0; i < b.N; i++ {
3688 x, y = Modf(1.5)
3689 }
3690 GlobalF += x
3691 GlobalF += y
3692 }
3693
3694 func BenchmarkNextafter32(b *testing.B) {
3695 x := float32(0.0)
3696 for i := 0; i < b.N; i++ {
3697 x = Nextafter32(.5, 1)
3698 }
3699 GlobalF = float64(x)
3700 }
3701
3702 func BenchmarkNextafter64(b *testing.B) {
3703 x := 0.0
3704 for i := 0; i < b.N; i++ {
3705 x = Nextafter(.5, 1)
3706 }
3707 GlobalF = x
3708 }
3709
3710 func BenchmarkPowInt(b *testing.B) {
3711 x := 0.0
3712 for i := 0; i < b.N; i++ {
3713 x = Pow(2, 2)
3714 }
3715 GlobalF = x
3716 }
3717
3718 func BenchmarkPowFrac(b *testing.B) {
3719 x := 0.0
3720 for i := 0; i < b.N; i++ {
3721 x = Pow(2.5, 1.5)
3722 }
3723 GlobalF = x
3724 }
3725
3726 var pow10pos = int(300)
3727
3728 func BenchmarkPow10Pos(b *testing.B) {
3729 x := 0.0
3730 for i := 0; i < b.N; i++ {
3731 x = Pow10(pow10pos)
3732 }
3733 GlobalF = x
3734 }
3735
3736 var pow10neg = int(-300)
3737
3738 func BenchmarkPow10Neg(b *testing.B) {
3739 x := 0.0
3740 for i := 0; i < b.N; i++ {
3741 x = Pow10(pow10neg)
3742 }
3743 GlobalF = x
3744 }
3745
3746 var roundNeg = float64(-2.5)
3747
3748 func BenchmarkRound(b *testing.B) {
3749 x := 0.0
3750 for i := 0; i < b.N; i++ {
3751 x = Round(roundNeg)
3752 }
3753 GlobalF = x
3754 }
3755
3756 func BenchmarkRoundToEven(b *testing.B) {
3757 x := 0.0
3758 for i := 0; i < b.N; i++ {
3759 x = RoundToEven(roundNeg)
3760 }
3761 GlobalF = x
3762 }
3763
3764 func BenchmarkRemainder(b *testing.B) {
3765 x := 0.0
3766 for i := 0; i < b.N; i++ {
3767 x = Remainder(10, 3)
3768 }
3769 GlobalF = x
3770 }
3771
3772 var signbitPos = 2.5
3773
3774 func BenchmarkSignbit(b *testing.B) {
3775 x := false
3776 for i := 0; i < b.N; i++ {
3777 x = Signbit(signbitPos)
3778 }
3779 GlobalB = x
3780 }
3781
3782 func BenchmarkSin(b *testing.B) {
3783 x := 0.0
3784 for i := 0; i < b.N; i++ {
3785 x = Sin(.5)
3786 }
3787 GlobalF = x
3788 }
3789
3790 func BenchmarkSincos(b *testing.B) {
3791 x := 0.0
3792 y := 0.0
3793 for i := 0; i < b.N; i++ {
3794 x, y = Sincos(.5)
3795 }
3796 GlobalF += x
3797 GlobalF += y
3798 }
3799
3800 func BenchmarkSinh(b *testing.B) {
3801 x := 0.0
3802 for i := 0; i < b.N; i++ {
3803 x = Sinh(2.5)
3804 }
3805 GlobalF = x
3806 }
3807
3808 func BenchmarkSqrtIndirect(b *testing.B) {
3809 x, y := 0.0, 10.0
3810 f := Sqrt
3811 for i := 0; i < b.N; i++ {
3812 x += f(y)
3813 }
3814 GlobalF = x
3815 }
3816
3817 func BenchmarkSqrtLatency(b *testing.B) {
3818 x := 10.0
3819 for i := 0; i < b.N; i++ {
3820 x = Sqrt(x)
3821 }
3822 GlobalF = x
3823 }
3824
3825 func BenchmarkSqrtIndirectLatency(b *testing.B) {
3826 x := 10.0
3827 f := Sqrt
3828 for i := 0; i < b.N; i++ {
3829 x = f(x)
3830 }
3831 GlobalF = x
3832 }
3833
3834 func BenchmarkSqrtGoLatency(b *testing.B) {
3835 x := 10.0
3836 for i := 0; i < b.N; i++ {
3837 x = SqrtGo(x)
3838 }
3839 GlobalF = x
3840 }
3841
3842 func isPrime(i int) bool {
3843
3844
3845
3846
3847
3848 for j := 2; float64(j) <= Sqrt(float64(i)); j++ {
3849 if i%j == 0 {
3850 return false
3851 }
3852 }
3853 return true
3854 }
3855
3856 func BenchmarkSqrtPrime(b *testing.B) {
3857 x := false
3858 for i := 0; i < b.N; i++ {
3859 x = isPrime(100003)
3860 }
3861 GlobalB = x
3862 }
3863
3864 func BenchmarkTan(b *testing.B) {
3865 x := 0.0
3866 for i := 0; i < b.N; i++ {
3867 x = Tan(.5)
3868 }
3869 GlobalF = x
3870 }
3871
3872 func BenchmarkTanh(b *testing.B) {
3873 x := 0.0
3874 for i := 0; i < b.N; i++ {
3875 x = Tanh(2.5)
3876 }
3877 GlobalF = x
3878 }
3879 func BenchmarkTrunc(b *testing.B) {
3880 x := 0.0
3881 for i := 0; i < b.N; i++ {
3882 x = Trunc(.5)
3883 }
3884 GlobalF = x
3885 }
3886
3887 func BenchmarkY0(b *testing.B) {
3888 x := 0.0
3889 for i := 0; i < b.N; i++ {
3890 x = Y0(2.5)
3891 }
3892 GlobalF = x
3893 }
3894
3895 func BenchmarkY1(b *testing.B) {
3896 x := 0.0
3897 for i := 0; i < b.N; i++ {
3898 x = Y1(2.5)
3899 }
3900 GlobalF = x
3901 }
3902
3903 func BenchmarkYn(b *testing.B) {
3904 x := 0.0
3905 for i := 0; i < b.N; i++ {
3906 x = Yn(2, 2.5)
3907 }
3908 GlobalF = x
3909 }
3910
3911 func BenchmarkFloat64bits(b *testing.B) {
3912 y := uint64(0)
3913 for i := 0; i < b.N; i++ {
3914 y = Float64bits(roundNeg)
3915 }
3916 GlobalI = int(y)
3917 }
3918
3919 var roundUint64 = uint64(5)
3920
3921 func BenchmarkFloat64frombits(b *testing.B) {
3922 x := 0.0
3923 for i := 0; i < b.N; i++ {
3924 x = Float64frombits(roundUint64)
3925 }
3926 GlobalF = x
3927 }
3928
3929 var roundFloat32 = float32(-2.5)
3930
3931 func BenchmarkFloat32bits(b *testing.B) {
3932 y := uint32(0)
3933 for i := 0; i < b.N; i++ {
3934 y = Float32bits(roundFloat32)
3935 }
3936 GlobalI = int(y)
3937 }
3938
3939 var roundUint32 = uint32(5)
3940
3941 func BenchmarkFloat32frombits(b *testing.B) {
3942 x := float32(0.0)
3943 for i := 0; i < b.N; i++ {
3944 x = Float32frombits(roundUint32)
3945 }
3946 GlobalF = float64(x)
3947 }
3948
3949 func BenchmarkFMA(b *testing.B) {
3950 x := 0.0
3951 for i := 0; i < b.N; i++ {
3952 x = FMA(E, Pi, x)
3953 }
3954 GlobalF = x
3955 }
3956
View as plain text