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