Source file
src/math/all_test.go
Documentation: math
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 {-0.5, Inf(-1)},
1635 {-0.5, 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 {0.5, Inf(-1)},
1656 {0.5, 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 {0.5, float64(1 << 45)},
1685 {0.5, -float64(1 << 45)},
1686 {Nextafter(1, 2), float64(1 << 63)},
1687 {Nextafter(1, -2), float64(1 << 63)},
1688 {Nextafter(-1, 2), float64(1 << 63)},
1689 {Nextafter(-1, -2), float64(1 << 63)},
1690
1691
1692 {Copysign(0, -1), 1e19},
1693 {Copysign(0, -1), -1e19},
1694 {Copysign(0, -1), 1<<53 - 1},
1695 {Copysign(0, -1), -(1<<53 - 1)},
1696 }
1697 var powSC = []float64{
1698 0,
1699 Copysign(0, -1),
1700 1,
1701 1,
1702 Inf(-1),
1703 Inf(-1),
1704 Inf(1),
1705 Inf(1),
1706 NaN(),
1707 0,
1708 NaN(),
1709 1,
1710 1,
1711 -Pi,
1712 NaN(),
1713 Inf(1),
1714 NaN(),
1715 1,
1716 1,
1717 NaN(),
1718 Inf(1),
1719 0,
1720 Inf(1),
1721 Inf(1),
1722 Inf(1),
1723 Inf(-1),
1724 Copysign(0, -1),
1725 0,
1726 0,
1727 0,
1728 Inf(1),
1729 Inf(1),
1730 Inf(1),
1731 1,
1732 1,
1733 0,
1734 0,
1735 0,
1736 NaN(),
1737 Inf(1),
1738 0,
1739 1,
1740 1,
1741 1,
1742 0,
1743 1,
1744 1,
1745 Pi,
1746 Inf(1),
1747 NaN(),
1748 0,
1749 1,
1750 1,
1751 Inf(1),
1752 Inf(1),
1753 NaN(),
1754 NaN(),
1755 1,
1756 1,
1757 NaN(),
1758 NaN(),
1759 NaN(),
1760
1761
1762 Inf(1),
1763 0,
1764 Inf(-1),
1765 0,
1766 Inf(1),
1767 Inf(1),
1768 0,
1769 0,
1770 Inf(1),
1771
1772
1773 0,
1774 Inf(1),
1775 Copysign(0, -1),
1776 Inf(-1),
1777 }
1778
1779 var vfpow10SC = []int{
1780 MinInt32,
1781 -324,
1782 -323,
1783 -50,
1784 -22,
1785 -1,
1786 0,
1787 1,
1788 22,
1789 50,
1790 100,
1791 200,
1792 308,
1793 309,
1794 MaxInt32,
1795 }
1796
1797 var pow10SC = []float64{
1798 0,
1799 0,
1800 1.0e-323,
1801 1.0e-50,
1802 1.0e-22,
1803 1.0e-1,
1804 1.0e0,
1805 1.0e1,
1806 1.0e22,
1807 1.0e50,
1808 1.0e100,
1809 1.0e200,
1810 1.0e308,
1811 Inf(1),
1812 Inf(1),
1813 }
1814
1815 var vfroundSC = [][2]float64{
1816 {0, 0},
1817 {1.390671161567e-309, 0},
1818 {0.49999999999999994, 0},
1819 {0.5, 1},
1820 {0.5000000000000001, 1},
1821 {-1.5, -2},
1822 {-2.5, -3},
1823 {NaN(), NaN()},
1824 {Inf(1), Inf(1)},
1825 {2251799813685249.5, 2251799813685250},
1826 {2251799813685250.5, 2251799813685251},
1827 {4503599627370495.5, 4503599627370496},
1828 {4503599627370497, 4503599627370497},
1829 }
1830 var vfroundEvenSC = [][2]float64{
1831 {0, 0},
1832 {1.390671161567e-309, 0},
1833 {0.49999999999999994, 0},
1834 {0.5, 0},
1835 {0.5000000000000001, 1},
1836 {-1.5, -2},
1837 {-2.5, -2},
1838 {NaN(), NaN()},
1839 {Inf(1), Inf(1)},
1840 {2251799813685249.5, 2251799813685250},
1841 {2251799813685250.5, 2251799813685250},
1842 {4503599627370495.5, 4503599627370496},
1843 {4503599627370497, 4503599627370497},
1844 }
1845
1846 var vfsignbitSC = []float64{
1847 Inf(-1),
1848 Copysign(0, -1),
1849 0,
1850 Inf(1),
1851 NaN(),
1852 }
1853 var signbitSC = []bool{
1854 true,
1855 true,
1856 false,
1857 false,
1858 false,
1859 }
1860
1861 var vfsinSC = []float64{
1862 Inf(-1),
1863 Copysign(0, -1),
1864 0,
1865 Inf(1),
1866 NaN(),
1867 }
1868 var sinSC = []float64{
1869 NaN(),
1870 Copysign(0, -1),
1871 0,
1872 NaN(),
1873 NaN(),
1874 }
1875
1876 var vfsinhSC = []float64{
1877 Inf(-1),
1878 Copysign(0, -1),
1879 0,
1880 Inf(1),
1881 NaN(),
1882 }
1883 var sinhSC = []float64{
1884 Inf(-1),
1885 Copysign(0, -1),
1886 0,
1887 Inf(1),
1888 NaN(),
1889 }
1890
1891 var vfsqrtSC = []float64{
1892 Inf(-1),
1893 -Pi,
1894 Copysign(0, -1),
1895 0,
1896 Inf(1),
1897 NaN(),
1898 Float64frombits(2),
1899 }
1900 var sqrtSC = []float64{
1901 NaN(),
1902 NaN(),
1903 Copysign(0, -1),
1904 0,
1905 Inf(1),
1906 NaN(),
1907 3.1434555694052576e-162,
1908 }
1909
1910 var vftanhSC = []float64{
1911 Inf(-1),
1912 Copysign(0, -1),
1913 0,
1914 Inf(1),
1915 NaN(),
1916 }
1917 var tanhSC = []float64{
1918 -1,
1919 Copysign(0, -1),
1920 0,
1921 1,
1922 NaN(),
1923 }
1924
1925 var vfy0SC = []float64{
1926 Inf(-1),
1927 0,
1928 Inf(1),
1929 NaN(),
1930 -1,
1931 }
1932 var y0SC = []float64{
1933 NaN(),
1934 Inf(-1),
1935 0,
1936 NaN(),
1937 NaN(),
1938 }
1939 var y1SC = []float64{
1940 NaN(),
1941 Inf(-1),
1942 0,
1943 NaN(),
1944 NaN(),
1945 }
1946 var y2SC = []float64{
1947 NaN(),
1948 Inf(-1),
1949 0,
1950 NaN(),
1951 NaN(),
1952 }
1953 var yM3SC = []float64{
1954 NaN(),
1955 Inf(1),
1956 0,
1957 NaN(),
1958 NaN(),
1959 }
1960
1961
1962 const (
1963 SmallestNormalFloat64 = 2.2250738585072014e-308
1964 LargestSubnormalFloat64 = SmallestNormalFloat64 - SmallestNonzeroFloat64
1965 )
1966
1967 var vffrexpBC = []float64{
1968 SmallestNormalFloat64,
1969 LargestSubnormalFloat64,
1970 SmallestNonzeroFloat64,
1971 MaxFloat64,
1972 -SmallestNormalFloat64,
1973 -LargestSubnormalFloat64,
1974 -SmallestNonzeroFloat64,
1975 -MaxFloat64,
1976 }
1977 var frexpBC = []fi{
1978 {0.5, -1021},
1979 {0.99999999999999978, -1022},
1980 {0.5, -1073},
1981 {0.99999999999999989, 1024},
1982 {-0.5, -1021},
1983 {-0.99999999999999978, -1022},
1984 {-0.5, -1073},
1985 {-0.99999999999999989, 1024},
1986 }
1987
1988 var vfldexpBC = []fi{
1989 {SmallestNormalFloat64, -52},
1990 {LargestSubnormalFloat64, -51},
1991 {SmallestNonzeroFloat64, 1074},
1992 {MaxFloat64, -(1023 + 1074)},
1993 {1, -1075},
1994 {-1, -1075},
1995 {1, 1024},
1996 {-1, 1024},
1997 {1.0000000000000002, -1075},
1998 {1, -1075},
1999 }
2000 var ldexpBC = []float64{
2001 SmallestNonzeroFloat64,
2002 1e-323,
2003 1,
2004 1e-323,
2005 0,
2006 Copysign(0, -1),
2007 Inf(1),
2008 Inf(-1),
2009 SmallestNonzeroFloat64,
2010 0,
2011 }
2012
2013 var logbBC = []float64{
2014 -1022,
2015 -1023,
2016 -1074,
2017 1023,
2018 -1022,
2019 -1023,
2020 -1074,
2021 1023,
2022 }
2023
2024
2025
2026
2027 var fmaC = []struct{ x, y, z, want float64 }{
2028
2029 {-3.999999999999087, -1.1123914289620494e-16, -7.999877929687506, -7.999877929687505},
2030 {-262112.0000004768, -0.06251525855623184, 1.1102230248837136e-16, 16385.99945072085},
2031 {-6.462348523533467e-27, -2.3763644720331857e-211, 4.000000000931324, 4.000000000931324},
2032
2033
2034 {-2.0000000037252907, 6.7904383376e-313, -3.3951933161e-313, -1.697607001654e-312},
2035 {-0.12499999999999999, 512.007568359375, -1.4193627164960366e-16, -64.00094604492188},
2036 {-2.7550648847397148e-39, -3.4028301595800694e+38, 0.9960937495343386, 1.9335955376735676},
2037 {5.723369164769208e+24, 3.8149300927159385e-06, 1.84489958778182e+19, 4.028324913621874e+19},
2038 {-0.4843749999990904, -3.6893487872543293e+19, 9.223653786709391e+18, 2.7093936974938993e+19},
2039 {-3.8146972665201165e-06, 4.2949672959999385e+09, -2.2204460489938386e-16, -16384.000003844263},
2040 {6.98156394130982e-309, -1.1072962560000002e+09, -4.4414561548793455e-308, -7.73065965765153e-300},
2041
2042
2043 {5e-324, 4.5, -2e-323, 0},
2044 {5e-324, 7, -3.5e-323, 0},
2045 {5e-324, 0.5000000000000001, -5e-324, Copysign(0, -1)},
2046 {-2.1240680525e-314, -1.233647078189316e+308, -0.25781249999954525, -0.25780987964919844},
2047 {8.579992955364441e-308, 0.6037391876780558, -4.4501307410480706e-308, 7.29947236107098e-309},
2048 {-4.450143471986689e-308, -0.9960937499927239, -4.450419332475649e-308, -1.7659233458788e-310},
2049 {1.4932076393918112, -2.2248022430460833e-308, 4.449875571054211e-308, 1.127783865601762e-308},
2050
2051
2052 {-2.288020632214759e+38, -8.98846570988901e+307, 1.7696041796300924e+308, Inf(0)},
2053 {1.4888652783208255e+308, -9.007199254742012e+15, -6.807282911929205e+38, Inf(-1)},
2054 {9.142703268902826e+192, -1.3504889569802838e+296, -1.9082200803806996e-89, Inf(-1)},
2055
2056
2057 {31.99218749627471, -1.7976930544991702e+308, Inf(0), Inf(0)},
2058 {-1.7976931281784667e+308, -2.0009765625002265, Inf(-1), Inf(-1)},
2059
2060
2061 {0, 0, 0, 0},
2062 {Copysign(0, -1), 0, 0, 0},
2063 {0, 0, Copysign(0, -1), 0},
2064 {Copysign(0, -1), 0, Copysign(0, -1), Copysign(0, -1)},
2065 {-1.1754226043408471e-38, NaN(), Inf(0), NaN()},
2066 {0, 0, 2.22507385643494e-308, 2.22507385643494e-308},
2067 {-8.65697792e+09, NaN(), -7.516192799999999e+09, NaN()},
2068 {-0.00012207403779029757, 3.221225471996093e+09, NaN(), NaN()},
2069 {Inf(-1), 0.1252441407414153, -1.387184532981584e-76, Inf(-1)},
2070 {Inf(0), 1.525878907671432e-05, -9.214364835452549e+18, Inf(0)},
2071
2072
2073 {0.1777916152213626, -32.000015266239636, -2.2204459148334633e-16, -5.689334401293007},
2074 {-2.0816681711722314e-16, -0.4997558592585846, -0.9465627129124969, -0.9465627129124968},
2075 {-1.9999997615814211, 1.8518819259933516e+19, 16.874999999999996, -3.703763410463646e+19},
2076 {-0.12499994039717421, 32767.99999976135, -2.0752587082923246e+19, -2.075258708292325e+19},
2077 {7.705600568510257e-34, -1.801432979000528e+16, -0.17224197722973714, -0.17224197722973716},
2078 {3.8988133103758913e-308, -0.9848632812499999, 3.893879244098556e-308, 5.40811742605814e-310},
2079 {-0.012651981190687427, 6.911985574912436e+38, 6.669240527007144e+18, -8.745031148409496e+36},
2080 {4.612811918325842e+18, 1.4901161193847641e-08, 2.6077032311277997e-08, 6.873625395187494e+10},
2081 {-9.094947033611148e-13, 4.450691014249257e-308, 2.086006742350485e-308, 2.086006742346437e-308},
2082 {-7.751454006381804e-05, 5.588653777189071e-308, -2.2207280111272877e-308, -2.2211612130544025e-308},
2083
2084
2085 {-1, 1, 1, 0},
2086 {1, 1, -1, 0},
2087 }
2088
2089 var sqrt32 = []float32{
2090 0,
2091 float32(Copysign(0, -1)),
2092 float32(NaN()),
2093 float32(Inf(1)),
2094 float32(Inf(-1)),
2095 1,
2096 2,
2097 -2,
2098 4.9790119248836735e+00,
2099 7.7388724745781045e+00,
2100 -2.7688005719200159e-01,
2101 -5.0106036182710749e+00,
2102 }
2103
2104 func tolerance(a, b, e float64) bool {
2105
2106
2107
2108 if a == b {
2109 return true
2110 }
2111 d := a - b
2112 if d < 0 {
2113 d = -d
2114 }
2115
2116
2117
2118 if b != 0 {
2119 e = e * b
2120 if e < 0 {
2121 e = -e
2122 }
2123 }
2124 return d < e
2125 }
2126 func close(a, b float64) bool { return tolerance(a, b, 1e-14) }
2127 func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
2128 func soclose(a, b, e float64) bool { return tolerance(a, b, e) }
2129 func alike(a, b float64) bool {
2130 switch {
2131 case IsNaN(a) && IsNaN(b):
2132 return true
2133 case a == b:
2134 return Signbit(a) == Signbit(b)
2135 }
2136 return false
2137 }
2138
2139 func TestNaN(t *testing.T) {
2140 f64 := NaN()
2141 if f64 == f64 {
2142 t.Fatalf("NaN() returns %g, expected NaN", f64)
2143 }
2144 f32 := float32(f64)
2145 if f32 == f32 {
2146 t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
2147 }
2148 }
2149
2150 func TestAcos(t *testing.T) {
2151 for i := 0; i < len(vf); i++ {
2152 a := vf[i] / 10
2153 if f := Acos(a); !close(acos[i], f) {
2154 t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
2155 }
2156 }
2157 for i := 0; i < len(vfacosSC); i++ {
2158 if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
2159 t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosSC[i])
2160 }
2161 }
2162 }
2163
2164 func TestAcosh(t *testing.T) {
2165 for i := 0; i < len(vf); i++ {
2166 a := 1 + Abs(vf[i])
2167 if f := Acosh(a); !veryclose(acosh[i], f) {
2168 t.Errorf("Acosh(%g) = %g, want %g", a, f, acosh[i])
2169 }
2170 }
2171 for i := 0; i < len(vfacoshSC); i++ {
2172 if f := Acosh(vfacoshSC[i]); !alike(acoshSC[i], f) {
2173 t.Errorf("Acosh(%g) = %g, want %g", vfacoshSC[i], f, acoshSC[i])
2174 }
2175 }
2176 }
2177
2178 func TestAsin(t *testing.T) {
2179 for i := 0; i < len(vf); i++ {
2180 a := vf[i] / 10
2181 if f := Asin(a); !veryclose(asin[i], f) {
2182 t.Errorf("Asin(%g) = %g, want %g", a, f, asin[i])
2183 }
2184 }
2185 for i := 0; i < len(vfasinSC); i++ {
2186 if f := Asin(vfasinSC[i]); !alike(asinSC[i], f) {
2187 t.Errorf("Asin(%g) = %g, want %g", vfasinSC[i], f, asinSC[i])
2188 }
2189 }
2190 }
2191
2192 func TestAsinh(t *testing.T) {
2193 for i := 0; i < len(vf); i++ {
2194 if f := Asinh(vf[i]); !veryclose(asinh[i], f) {
2195 t.Errorf("Asinh(%g) = %g, want %g", vf[i], f, asinh[i])
2196 }
2197 }
2198 for i := 0; i < len(vfasinhSC); i++ {
2199 if f := Asinh(vfasinhSC[i]); !alike(asinhSC[i], f) {
2200 t.Errorf("Asinh(%g) = %g, want %g", vfasinhSC[i], f, asinhSC[i])
2201 }
2202 }
2203 }
2204
2205 func TestAtan(t *testing.T) {
2206 for i := 0; i < len(vf); i++ {
2207 if f := Atan(vf[i]); !veryclose(atan[i], f) {
2208 t.Errorf("Atan(%g) = %g, want %g", vf[i], f, atan[i])
2209 }
2210 }
2211 for i := 0; i < len(vfatanSC); i++ {
2212 if f := Atan(vfatanSC[i]); !alike(atanSC[i], f) {
2213 t.Errorf("Atan(%g) = %g, want %g", vfatanSC[i], f, atanSC[i])
2214 }
2215 }
2216 }
2217
2218 func TestAtanh(t *testing.T) {
2219 for i := 0; i < len(vf); i++ {
2220 a := vf[i] / 10
2221 if f := Atanh(a); !veryclose(atanh[i], f) {
2222 t.Errorf("Atanh(%g) = %g, want %g", a, f, atanh[i])
2223 }
2224 }
2225 for i := 0; i < len(vfatanhSC); i++ {
2226 if f := Atanh(vfatanhSC[i]); !alike(atanhSC[i], f) {
2227 t.Errorf("Atanh(%g) = %g, want %g", vfatanhSC[i], f, atanhSC[i])
2228 }
2229 }
2230 }
2231
2232 func TestAtan2(t *testing.T) {
2233 for i := 0; i < len(vf); i++ {
2234 if f := Atan2(10, vf[i]); !veryclose(atan2[i], f) {
2235 t.Errorf("Atan2(10, %g) = %g, want %g", vf[i], f, atan2[i])
2236 }
2237 }
2238 for i := 0; i < len(vfatan2SC); i++ {
2239 if f := Atan2(vfatan2SC[i][0], vfatan2SC[i][1]); !alike(atan2SC[i], f) {
2240 t.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC[i][0], vfatan2SC[i][1], f, atan2SC[i])
2241 }
2242 }
2243 }
2244
2245 func TestCbrt(t *testing.T) {
2246 for i := 0; i < len(vf); i++ {
2247 if f := Cbrt(vf[i]); !veryclose(cbrt[i], f) {
2248 t.Errorf("Cbrt(%g) = %g, want %g", vf[i], f, cbrt[i])
2249 }
2250 }
2251 for i := 0; i < len(vfcbrtSC); i++ {
2252 if f := Cbrt(vfcbrtSC[i]); !alike(cbrtSC[i], f) {
2253 t.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC[i], f, cbrtSC[i])
2254 }
2255 }
2256 }
2257
2258 func TestCeil(t *testing.T) {
2259 for i := 0; i < len(vf); i++ {
2260 if f := Ceil(vf[i]); !alike(ceil[i], f) {
2261 t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
2262 }
2263 }
2264 for i := 0; i < len(vfceilSC); i++ {
2265 if f := Ceil(vfceilSC[i]); !alike(ceilSC[i], f) {
2266 t.Errorf("Ceil(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2267 }
2268 }
2269 }
2270
2271 func TestCopysign(t *testing.T) {
2272 for i := 0; i < len(vf); i++ {
2273 if f := Copysign(vf[i], -1); copysign[i] != f {
2274 t.Errorf("Copysign(%g, -1) = %g, want %g", vf[i], f, copysign[i])
2275 }
2276 }
2277 for i := 0; i < len(vf); i++ {
2278 if f := Copysign(vf[i], 1); -copysign[i] != f {
2279 t.Errorf("Copysign(%g, 1) = %g, want %g", vf[i], f, -copysign[i])
2280 }
2281 }
2282 for i := 0; i < len(vfcopysignSC); i++ {
2283 if f := Copysign(vfcopysignSC[i], -1); !alike(copysignSC[i], f) {
2284 t.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC[i], f, copysignSC[i])
2285 }
2286 }
2287 }
2288
2289 func TestCos(t *testing.T) {
2290 for i := 0; i < len(vf); i++ {
2291 if f := Cos(vf[i]); !veryclose(cos[i], f) {
2292 t.Errorf("Cos(%g) = %g, want %g", vf[i], f, cos[i])
2293 }
2294 }
2295 for i := 0; i < len(vfcosSC); i++ {
2296 if f := Cos(vfcosSC[i]); !alike(cosSC[i], f) {
2297 t.Errorf("Cos(%g) = %g, want %g", vfcosSC[i], f, cosSC[i])
2298 }
2299 }
2300 }
2301
2302 func TestCosh(t *testing.T) {
2303 for i := 0; i < len(vf); i++ {
2304 if f := Cosh(vf[i]); !close(cosh[i], f) {
2305 t.Errorf("Cosh(%g) = %g, want %g", vf[i], f, cosh[i])
2306 }
2307 }
2308 for i := 0; i < len(vfcoshSC); i++ {
2309 if f := Cosh(vfcoshSC[i]); !alike(coshSC[i], f) {
2310 t.Errorf("Cosh(%g) = %g, want %g", vfcoshSC[i], f, coshSC[i])
2311 }
2312 }
2313 }
2314
2315 func TestErf(t *testing.T) {
2316 for i := 0; i < len(vf); i++ {
2317 a := vf[i] / 10
2318 if f := Erf(a); !veryclose(erf[i], f) {
2319 t.Errorf("Erf(%g) = %g, want %g", a, f, erf[i])
2320 }
2321 }
2322 for i := 0; i < len(vferfSC); i++ {
2323 if f := Erf(vferfSC[i]); !alike(erfSC[i], f) {
2324 t.Errorf("Erf(%g) = %g, want %g", vferfSC[i], f, erfSC[i])
2325 }
2326 }
2327 }
2328
2329 func TestErfc(t *testing.T) {
2330 for i := 0; i < len(vf); i++ {
2331 a := vf[i] / 10
2332 if f := Erfc(a); !veryclose(erfc[i], f) {
2333 t.Errorf("Erfc(%g) = %g, want %g", a, f, erfc[i])
2334 }
2335 }
2336 for i := 0; i < len(vferfcSC); i++ {
2337 if f := Erfc(vferfcSC[i]); !alike(erfcSC[i], f) {
2338 t.Errorf("Erfc(%g) = %g, want %g", vferfcSC[i], f, erfcSC[i])
2339 }
2340 }
2341 }
2342
2343 func TestErfinv(t *testing.T) {
2344 for i := 0; i < len(vf); i++ {
2345 a := vf[i] / 10
2346 if f := Erfinv(a); !veryclose(erfinv[i], f) {
2347 t.Errorf("Erfinv(%g) = %g, want %g", a, f, erfinv[i])
2348 }
2349 }
2350 for i := 0; i < len(vferfinvSC); i++ {
2351 if f := Erfinv(vferfinvSC[i]); !alike(erfinvSC[i], f) {
2352 t.Errorf("Erfinv(%g) = %g, want %g", vferfinvSC[i], f, erfinvSC[i])
2353 }
2354 }
2355 for x := -0.9; x <= 0.90; x += 1e-2 {
2356 if f := Erf(Erfinv(x)); !close(x, f) {
2357 t.Errorf("Erf(Erfinv(%g)) = %g, want %g", x, f, x)
2358 }
2359 }
2360 for x := -0.9; x <= 0.90; x += 1e-2 {
2361 if f := Erfinv(Erf(x)); !close(x, f) {
2362 t.Errorf("Erfinv(Erf(%g)) = %g, want %g", x, f, x)
2363 }
2364 }
2365 }
2366
2367 func TestErfcinv(t *testing.T) {
2368 for i := 0; i < len(vf); i++ {
2369 a := 1.0 - (vf[i] / 10)
2370 if f := Erfcinv(a); !veryclose(erfinv[i], f) {
2371 t.Errorf("Erfcinv(%g) = %g, want %g", a, f, erfinv[i])
2372 }
2373 }
2374 for i := 0; i < len(vferfcinvSC); i++ {
2375 if f := Erfcinv(vferfcinvSC[i]); !alike(erfcinvSC[i], f) {
2376 t.Errorf("Erfcinv(%g) = %g, want %g", vferfcinvSC[i], f, erfcinvSC[i])
2377 }
2378 }
2379 for x := 0.1; x <= 1.9; x += 1e-2 {
2380 if f := Erfc(Erfcinv(x)); !close(x, f) {
2381 t.Errorf("Erfc(Erfcinv(%g)) = %g, want %g", x, f, x)
2382 }
2383 }
2384 for x := 0.1; x <= 1.9; x += 1e-2 {
2385 if f := Erfcinv(Erfc(x)); !close(x, f) {
2386 t.Errorf("Erfcinv(Erfc(%g)) = %g, want %g", x, f, x)
2387 }
2388 }
2389 }
2390
2391 func TestExp(t *testing.T) {
2392 testExp(t, Exp, "Exp")
2393 testExp(t, ExpGo, "ExpGo")
2394 }
2395
2396 func testExp(t *testing.T, Exp func(float64) float64, name string) {
2397 for i := 0; i < len(vf); i++ {
2398 if f := Exp(vf[i]); !veryclose(exp[i], f) {
2399 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp[i])
2400 }
2401 }
2402 for i := 0; i < len(vfexpSC); i++ {
2403 if f := Exp(vfexpSC[i]); !alike(expSC[i], f) {
2404 t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
2405 }
2406 }
2407 }
2408
2409 func TestExpm1(t *testing.T) {
2410 for i := 0; i < len(vf); i++ {
2411 a := vf[i] / 100
2412 if f := Expm1(a); !veryclose(expm1[i], f) {
2413 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1[i])
2414 }
2415 }
2416 for i := 0; i < len(vf); i++ {
2417 a := vf[i] * 10
2418 if f := Expm1(a); !close(expm1Large[i], f) {
2419 t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1Large[i])
2420 }
2421 }
2422 for i := 0; i < len(vfexpm1SC); i++ {
2423 if f := Expm1(vfexpm1SC[i]); !alike(expm1SC[i], f) {
2424 t.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC[i], f, expm1SC[i])
2425 }
2426 }
2427 }
2428
2429 func TestExp2(t *testing.T) {
2430 testExp2(t, Exp2, "Exp2")
2431 testExp2(t, Exp2Go, "Exp2Go")
2432 }
2433
2434 func testExp2(t *testing.T, Exp2 func(float64) float64, name string) {
2435 for i := 0; i < len(vf); i++ {
2436 if f := Exp2(vf[i]); !close(exp2[i], f) {
2437 t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp2[i])
2438 }
2439 }
2440 for i := 0; i < len(vfexp2SC); i++ {
2441 if f := Exp2(vfexp2SC[i]); !alike(exp2SC[i], f) {
2442 t.Errorf("%s(%g) = %g, want %g", name, vfexp2SC[i], f, exp2SC[i])
2443 }
2444 }
2445 for n := -1074; n < 1024; n++ {
2446 f := Exp2(float64(n))
2447 vf := Ldexp(1, n)
2448 if f != vf {
2449 t.Errorf("%s(%d) = %g, want %g", name, n, f, vf)
2450 }
2451 }
2452 }
2453
2454 func TestAbs(t *testing.T) {
2455 for i := 0; i < len(vf); i++ {
2456 if f := Abs(vf[i]); fabs[i] != f {
2457 t.Errorf("Abs(%g) = %g, want %g", vf[i], f, fabs[i])
2458 }
2459 }
2460 for i := 0; i < len(vffabsSC); i++ {
2461 if f := Abs(vffabsSC[i]); !alike(fabsSC[i], f) {
2462 t.Errorf("Abs(%g) = %g, want %g", vffabsSC[i], f, fabsSC[i])
2463 }
2464 }
2465 }
2466
2467 func TestDim(t *testing.T) {
2468 for i := 0; i < len(vf); i++ {
2469 if f := Dim(vf[i], 0); fdim[i] != f {
2470 t.Errorf("Dim(%g, %g) = %g, want %g", vf[i], 0.0, f, fdim[i])
2471 }
2472 }
2473 for i := 0; i < len(vffdimSC); i++ {
2474 if f := Dim(vffdimSC[i][0], vffdimSC[i][1]); !alike(fdimSC[i], f) {
2475 t.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fdimSC[i])
2476 }
2477 }
2478 for i := 0; i < len(vffdim2SC); i++ {
2479 if f := Dim(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fdimSC[i], f) {
2480 t.Errorf("Dim(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fdimSC[i])
2481 }
2482 }
2483 }
2484
2485 func TestFloor(t *testing.T) {
2486 for i := 0; i < len(vf); i++ {
2487 if f := Floor(vf[i]); !alike(floor[i], f) {
2488 t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
2489 }
2490 }
2491 for i := 0; i < len(vfceilSC); i++ {
2492 if f := Floor(vfceilSC[i]); !alike(ceilSC[i], f) {
2493 t.Errorf("Floor(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2494 }
2495 }
2496 }
2497
2498 func TestMax(t *testing.T) {
2499 for i := 0; i < len(vf); i++ {
2500 if f := Max(vf[i], ceil[i]); ceil[i] != f {
2501 t.Errorf("Max(%g, %g) = %g, want %g", vf[i], ceil[i], f, ceil[i])
2502 }
2503 }
2504 for i := 0; i < len(vffdimSC); i++ {
2505 if f := Max(vffdimSC[i][0], vffdimSC[i][1]); !alike(fmaxSC[i], f) {
2506 t.Errorf("Max(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fmaxSC[i])
2507 }
2508 }
2509 for i := 0; i < len(vffdim2SC); i++ {
2510 if f := Max(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fmaxSC[i], f) {
2511 t.Errorf("Max(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fmaxSC[i])
2512 }
2513 }
2514 }
2515
2516 func TestMin(t *testing.T) {
2517 for i := 0; i < len(vf); i++ {
2518 if f := Min(vf[i], floor[i]); floor[i] != f {
2519 t.Errorf("Min(%g, %g) = %g, want %g", vf[i], floor[i], f, floor[i])
2520 }
2521 }
2522 for i := 0; i < len(vffdimSC); i++ {
2523 if f := Min(vffdimSC[i][0], vffdimSC[i][1]); !alike(fminSC[i], f) {
2524 t.Errorf("Min(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fminSC[i])
2525 }
2526 }
2527 for i := 0; i < len(vffdim2SC); i++ {
2528 if f := Min(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fminSC[i], f) {
2529 t.Errorf("Min(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fminSC[i])
2530 }
2531 }
2532 }
2533
2534 func TestMod(t *testing.T) {
2535 for i := 0; i < len(vf); i++ {
2536 if f := Mod(10, vf[i]); fmod[i] != f {
2537 t.Errorf("Mod(10, %g) = %g, want %g", vf[i], f, fmod[i])
2538 }
2539 }
2540 for i := 0; i < len(vffmodSC); i++ {
2541 if f := Mod(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2542 t.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2543 }
2544 }
2545
2546 if f := Mod(5.9790119248836734e+200, 1.1258465975523544); 0.6447968302508578 != f {
2547 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want 0.6447968302508578", f)
2548 }
2549 }
2550
2551 func TestFrexp(t *testing.T) {
2552 for i := 0; i < len(vf); i++ {
2553 if f, j := Frexp(vf[i]); !veryclose(frexp[i].f, f) || frexp[i].i != j {
2554 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf[i], f, j, frexp[i].f, frexp[i].i)
2555 }
2556 }
2557 for i := 0; i < len(vffrexpSC); i++ {
2558 if f, j := Frexp(vffrexpSC[i]); !alike(frexpSC[i].f, f) || frexpSC[i].i != j {
2559 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC[i], f, j, frexpSC[i].f, frexpSC[i].i)
2560 }
2561 }
2562 for i := 0; i < len(vffrexpBC); i++ {
2563 if f, j := Frexp(vffrexpBC[i]); !alike(frexpBC[i].f, f) || frexpBC[i].i != j {
2564 t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC[i], f, j, frexpBC[i].f, frexpBC[i].i)
2565 }
2566 }
2567 }
2568
2569 func TestGamma(t *testing.T) {
2570 for i := 0; i < len(vf); i++ {
2571 if f := Gamma(vf[i]); !close(gamma[i], f) {
2572 t.Errorf("Gamma(%g) = %g, want %g", vf[i], f, gamma[i])
2573 }
2574 }
2575 for _, g := range vfgamma {
2576 f := Gamma(g[0])
2577 var ok bool
2578 if IsNaN(g[1]) || IsInf(g[1], 0) || g[1] == 0 || f == 0 {
2579 ok = alike(g[1], f)
2580 } else if g[0] > -50 && g[0] <= 171 {
2581 ok = veryclose(g[1], f)
2582 } else {
2583 ok = close(g[1], f)
2584 }
2585 if !ok {
2586 t.Errorf("Gamma(%g) = %g, want %g", g[0], f, g[1])
2587 }
2588 }
2589 }
2590
2591 func TestHypot(t *testing.T) {
2592 for i := 0; i < len(vf); i++ {
2593 a := Abs(1e200 * tanh[i] * Sqrt(2))
2594 if f := Hypot(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2595 t.Errorf("Hypot(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2596 }
2597 }
2598 for i := 0; i < len(vfhypotSC); i++ {
2599 if f := Hypot(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2600 t.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2601 }
2602 }
2603 }
2604
2605 func TestHypotGo(t *testing.T) {
2606 for i := 0; i < len(vf); i++ {
2607 a := Abs(1e200 * tanh[i] * Sqrt(2))
2608 if f := HypotGo(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2609 t.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2610 }
2611 }
2612 for i := 0; i < len(vfhypotSC); i++ {
2613 if f := HypotGo(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2614 t.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2615 }
2616 }
2617 }
2618
2619 func TestIlogb(t *testing.T) {
2620 for i := 0; i < len(vf); i++ {
2621 a := frexp[i].i - 1
2622 if e := Ilogb(vf[i]); a != e {
2623 t.Errorf("Ilogb(%g) = %d, want %d", vf[i], e, a)
2624 }
2625 }
2626 for i := 0; i < len(vflogbSC); i++ {
2627 if e := Ilogb(vflogbSC[i]); ilogbSC[i] != e {
2628 t.Errorf("Ilogb(%g) = %d, want %d", vflogbSC[i], e, ilogbSC[i])
2629 }
2630 }
2631 for i := 0; i < len(vffrexpBC); i++ {
2632 if e := Ilogb(vffrexpBC[i]); int(logbBC[i]) != e {
2633 t.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC[i], e, int(logbBC[i]))
2634 }
2635 }
2636 }
2637
2638 func TestJ0(t *testing.T) {
2639 for i := 0; i < len(vf); i++ {
2640 if f := J0(vf[i]); !soclose(j0[i], f, 4e-14) {
2641 t.Errorf("J0(%g) = %g, want %g", vf[i], f, j0[i])
2642 }
2643 }
2644 for i := 0; i < len(vfj0SC); i++ {
2645 if f := J0(vfj0SC[i]); !alike(j0SC[i], f) {
2646 t.Errorf("J0(%g) = %g, want %g", vfj0SC[i], f, j0SC[i])
2647 }
2648 }
2649 }
2650
2651 func TestJ1(t *testing.T) {
2652 for i := 0; i < len(vf); i++ {
2653 if f := J1(vf[i]); !close(j1[i], f) {
2654 t.Errorf("J1(%g) = %g, want %g", vf[i], f, j1[i])
2655 }
2656 }
2657 for i := 0; i < len(vfj0SC); i++ {
2658 if f := J1(vfj0SC[i]); !alike(j1SC[i], f) {
2659 t.Errorf("J1(%g) = %g, want %g", vfj0SC[i], f, j1SC[i])
2660 }
2661 }
2662 }
2663
2664 func TestJn(t *testing.T) {
2665 for i := 0; i < len(vf); i++ {
2666 if f := Jn(2, vf[i]); !close(j2[i], f) {
2667 t.Errorf("Jn(2, %g) = %g, want %g", vf[i], f, j2[i])
2668 }
2669 if f := Jn(-3, vf[i]); !close(jM3[i], f) {
2670 t.Errorf("Jn(-3, %g) = %g, want %g", vf[i], f, jM3[i])
2671 }
2672 }
2673 for i := 0; i < len(vfj0SC); i++ {
2674 if f := Jn(2, vfj0SC[i]); !alike(j2SC[i], f) {
2675 t.Errorf("Jn(2, %g) = %g, want %g", vfj0SC[i], f, j2SC[i])
2676 }
2677 if f := Jn(-3, vfj0SC[i]); !alike(jM3SC[i], f) {
2678 t.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC[i], f, jM3SC[i])
2679 }
2680 }
2681 }
2682
2683 func TestLdexp(t *testing.T) {
2684 for i := 0; i < len(vf); i++ {
2685 if f := Ldexp(frexp[i].f, frexp[i].i); !veryclose(vf[i], f) {
2686 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexp[i].f, frexp[i].i, f, vf[i])
2687 }
2688 }
2689 for i := 0; i < len(vffrexpSC); i++ {
2690 if f := Ldexp(frexpSC[i].f, frexpSC[i].i); !alike(vffrexpSC[i], f) {
2691 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC[i].f, frexpSC[i].i, f, vffrexpSC[i])
2692 }
2693 }
2694 for i := 0; i < len(vfldexpSC); i++ {
2695 if f := Ldexp(vfldexpSC[i].f, vfldexpSC[i].i); !alike(ldexpSC[i], f) {
2696 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC[i].f, vfldexpSC[i].i, f, ldexpSC[i])
2697 }
2698 }
2699 for i := 0; i < len(vffrexpBC); i++ {
2700 if f := Ldexp(frexpBC[i].f, frexpBC[i].i); !alike(vffrexpBC[i], f) {
2701 t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC[i].f, frexpBC[i].i, f, vffrexpBC[i])
2702 }
2703 }
2704 for i := 0; i < len(vfldexpBC); i++ {
2705 if f := Ldexp(vfldexpBC[i].f, vfldexpBC[i].i); !alike(ldexpBC[i], f) {
2706 t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC[i].f, vfldexpBC[i].i, f, ldexpBC[i])
2707 }
2708 }
2709 }
2710
2711 func TestLgamma(t *testing.T) {
2712 for i := 0; i < len(vf); i++ {
2713 if f, s := Lgamma(vf[i]); !close(lgamma[i].f, f) || lgamma[i].i != s {
2714 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf[i], f, s, lgamma[i].f, lgamma[i].i)
2715 }
2716 }
2717 for i := 0; i < len(vflgammaSC); i++ {
2718 if f, s := Lgamma(vflgammaSC[i]); !alike(lgammaSC[i].f, f) || lgammaSC[i].i != s {
2719 t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC[i], f, s, lgammaSC[i].f, lgammaSC[i].i)
2720 }
2721 }
2722 }
2723
2724 func TestLog(t *testing.T) {
2725 for i := 0; i < len(vf); i++ {
2726 a := Abs(vf[i])
2727 if f := Log(a); log[i] != f {
2728 t.Errorf("Log(%g) = %g, want %g", a, f, log[i])
2729 }
2730 }
2731 if f := Log(10); f != Ln10 {
2732 t.Errorf("Log(%g) = %g, want %g", 10.0, f, Ln10)
2733 }
2734 for i := 0; i < len(vflogSC); i++ {
2735 if f := Log(vflogSC[i]); !alike(logSC[i], f) {
2736 t.Errorf("Log(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2737 }
2738 }
2739 }
2740
2741 func TestLogb(t *testing.T) {
2742 for i := 0; i < len(vf); i++ {
2743 if f := Logb(vf[i]); logb[i] != f {
2744 t.Errorf("Logb(%g) = %g, want %g", vf[i], f, logb[i])
2745 }
2746 }
2747 for i := 0; i < len(vflogbSC); i++ {
2748 if f := Logb(vflogbSC[i]); !alike(logbSC[i], f) {
2749 t.Errorf("Logb(%g) = %g, want %g", vflogbSC[i], f, logbSC[i])
2750 }
2751 }
2752 for i := 0; i < len(vffrexpBC); i++ {
2753 if f := Logb(vffrexpBC[i]); !alike(logbBC[i], f) {
2754 t.Errorf("Logb(%g) = %g, want %g", vffrexpBC[i], f, logbBC[i])
2755 }
2756 }
2757 }
2758
2759 func TestLog10(t *testing.T) {
2760 for i := 0; i < len(vf); i++ {
2761 a := Abs(vf[i])
2762 if f := Log10(a); !veryclose(log10[i], f) {
2763 t.Errorf("Log10(%g) = %g, want %g", a, f, log10[i])
2764 }
2765 }
2766 if f := Log10(E); f != Log10E {
2767 t.Errorf("Log10(%g) = %g, want %g", E, f, Log10E)
2768 }
2769 for i := 0; i < len(vflogSC); i++ {
2770 if f := Log10(vflogSC[i]); !alike(logSC[i], f) {
2771 t.Errorf("Log10(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2772 }
2773 }
2774 }
2775
2776 func TestLog1p(t *testing.T) {
2777 for i := 0; i < len(vf); i++ {
2778 a := vf[i] / 100
2779 if f := Log1p(a); !veryclose(log1p[i], f) {
2780 t.Errorf("Log1p(%g) = %g, want %g", a, f, log1p[i])
2781 }
2782 }
2783 a := 9.0
2784 if f := Log1p(a); f != Ln10 {
2785 t.Errorf("Log1p(%g) = %g, want %g", a, f, Ln10)
2786 }
2787 for i := 0; i < len(vflogSC); i++ {
2788 if f := Log1p(vflog1pSC[i]); !alike(log1pSC[i], f) {
2789 t.Errorf("Log1p(%g) = %g, want %g", vflog1pSC[i], f, log1pSC[i])
2790 }
2791 }
2792 }
2793
2794 func TestLog2(t *testing.T) {
2795 for i := 0; i < len(vf); i++ {
2796 a := Abs(vf[i])
2797 if f := Log2(a); !veryclose(log2[i], f) {
2798 t.Errorf("Log2(%g) = %g, want %g", a, f, log2[i])
2799 }
2800 }
2801 if f := Log2(E); f != Log2E {
2802 t.Errorf("Log2(%g) = %g, want %g", E, f, Log2E)
2803 }
2804 for i := 0; i < len(vflogSC); i++ {
2805 if f := Log2(vflogSC[i]); !alike(logSC[i], f) {
2806 t.Errorf("Log2(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2807 }
2808 }
2809 for i := -1074; i <= 1023; i++ {
2810 f := Ldexp(1, i)
2811 l := Log2(f)
2812 if l != float64(i) {
2813 t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
2814 }
2815 }
2816 }
2817
2818 func TestModf(t *testing.T) {
2819 for i := 0; i < len(vf); i++ {
2820 if f, g := Modf(vf[i]); !veryclose(modf[i][0], f) || !veryclose(modf[i][1], g) {
2821 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vf[i], f, g, modf[i][0], modf[i][1])
2822 }
2823 }
2824 for i := 0; i < len(vfmodfSC); i++ {
2825 if f, g := Modf(vfmodfSC[i]); !alike(modfSC[i][0], f) || !alike(modfSC[i][1], g) {
2826 t.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC[i], f, g, modfSC[i][0], modfSC[i][1])
2827 }
2828 }
2829 }
2830
2831 func TestNextafter32(t *testing.T) {
2832 for i := 0; i < len(vf); i++ {
2833 vfi := float32(vf[i])
2834 if f := Nextafter32(vfi, 10); nextafter32[i] != f {
2835 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfi, 10.0, f, nextafter32[i])
2836 }
2837 }
2838 for i := 0; i < len(vfnextafter32SC); i++ {
2839 if f := Nextafter32(vfnextafter32SC[i][0], vfnextafter32SC[i][1]); !alike(float64(nextafter32SC[i]), float64(f)) {
2840 t.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC[i][0], vfnextafter32SC[i][1], f, nextafter32SC[i])
2841 }
2842 }
2843 }
2844
2845 func TestNextafter64(t *testing.T) {
2846 for i := 0; i < len(vf); i++ {
2847 if f := Nextafter(vf[i], 10); nextafter64[i] != f {
2848 t.Errorf("Nextafter64(%g, %g) = %g want %g", vf[i], 10.0, f, nextafter64[i])
2849 }
2850 }
2851 for i := 0; i < len(vfnextafter64SC); i++ {
2852 if f := Nextafter(vfnextafter64SC[i][0], vfnextafter64SC[i][1]); !alike(nextafter64SC[i], f) {
2853 t.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC[i][0], vfnextafter64SC[i][1], f, nextafter64SC[i])
2854 }
2855 }
2856 }
2857
2858 func TestPow(t *testing.T) {
2859 for i := 0; i < len(vf); i++ {
2860 if f := Pow(10, vf[i]); !close(pow[i], f) {
2861 t.Errorf("Pow(10, %g) = %g, want %g", vf[i], f, pow[i])
2862 }
2863 }
2864 for i := 0; i < len(vfpowSC); i++ {
2865 if f := Pow(vfpowSC[i][0], vfpowSC[i][1]); !alike(powSC[i], f) {
2866 t.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC[i][0], vfpowSC[i][1], f, powSC[i])
2867 }
2868 }
2869 }
2870
2871 func TestPow10(t *testing.T) {
2872 for i := 0; i < len(vfpow10SC); i++ {
2873 if f := Pow10(vfpow10SC[i]); !alike(pow10SC[i], f) {
2874 t.Errorf("Pow10(%d) = %g, want %g", vfpow10SC[i], f, pow10SC[i])
2875 }
2876 }
2877 }
2878
2879 func TestRemainder(t *testing.T) {
2880 for i := 0; i < len(vf); i++ {
2881 if f := Remainder(10, vf[i]); remainder[i] != f {
2882 t.Errorf("Remainder(10, %g) = %g, want %g", vf[i], f, remainder[i])
2883 }
2884 }
2885 for i := 0; i < len(vffmodSC); i++ {
2886 if f := Remainder(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2887 t.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2888 }
2889 }
2890
2891 if f := Remainder(5.9790119248836734e+200, 1.1258465975523544); -0.4810497673014966 != f {
2892 t.Errorf("Remainder(5.9790119248836734e+200, 1.1258465975523544) = %g, want -0.4810497673014966", f)
2893 }
2894
2895 test := func(x, y float64) {
2896 if r := Remainder(x, y); r == 0 && Signbit(r) != Signbit(x) {
2897 t.Errorf("Remainder(x=%f, y=%f) = %f, sign of (zero) result should agree with sign of x", x, y, r)
2898 }
2899 }
2900 for x := 0.0; x <= 3.0; x += 1 {
2901 for y := 1.0; y <= 3.0; y += 1 {
2902 test(x, y)
2903 test(x, -y)
2904 test(-x, y)
2905 test(-x, -y)
2906 }
2907 }
2908 }
2909
2910 func TestRound(t *testing.T) {
2911 for i := 0; i < len(vf); i++ {
2912 if f := Round(vf[i]); !alike(round[i], f) {
2913 t.Errorf("Round(%g) = %g, want %g", vf[i], f, round[i])
2914 }
2915 }
2916 for i := 0; i < len(vfroundSC); i++ {
2917 if f := Round(vfroundSC[i][0]); !alike(vfroundSC[i][1], f) {
2918 t.Errorf("Round(%g) = %g, want %g", vfroundSC[i][0], f, vfroundSC[i][1])
2919 }
2920 }
2921 }
2922
2923 func TestRoundToEven(t *testing.T) {
2924 for i := 0; i < len(vf); i++ {
2925 if f := RoundToEven(vf[i]); !alike(round[i], f) {
2926 t.Errorf("RoundToEven(%g) = %g, want %g", vf[i], f, round[i])
2927 }
2928 }
2929 for i := 0; i < len(vfroundEvenSC); i++ {
2930 if f := RoundToEven(vfroundEvenSC[i][0]); !alike(vfroundEvenSC[i][1], f) {
2931 t.Errorf("RoundToEven(%g) = %g, want %g", vfroundEvenSC[i][0], f, vfroundEvenSC[i][1])
2932 }
2933 }
2934 }
2935
2936 func TestSignbit(t *testing.T) {
2937 for i := 0; i < len(vf); i++ {
2938 if f := Signbit(vf[i]); signbit[i] != f {
2939 t.Errorf("Signbit(%g) = %t, want %t", vf[i], f, signbit[i])
2940 }
2941 }
2942 for i := 0; i < len(vfsignbitSC); i++ {
2943 if f := Signbit(vfsignbitSC[i]); signbitSC[i] != f {
2944 t.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC[i], f, signbitSC[i])
2945 }
2946 }
2947 }
2948 func TestSin(t *testing.T) {
2949 for i := 0; i < len(vf); i++ {
2950 if f := Sin(vf[i]); !veryclose(sin[i], f) {
2951 t.Errorf("Sin(%g) = %g, want %g", vf[i], f, sin[i])
2952 }
2953 }
2954 for i := 0; i < len(vfsinSC); i++ {
2955 if f := Sin(vfsinSC[i]); !alike(sinSC[i], f) {
2956 t.Errorf("Sin(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
2957 }
2958 }
2959 }
2960
2961 func TestSincos(t *testing.T) {
2962 for i := 0; i < len(vf); i++ {
2963 if s, c := Sincos(vf[i]); !veryclose(sin[i], s) || !veryclose(cos[i], c) {
2964 t.Errorf("Sincos(%g) = %g, %g want %g, %g", vf[i], s, c, sin[i], cos[i])
2965 }
2966 }
2967 }
2968
2969 func TestSinh(t *testing.T) {
2970 for i := 0; i < len(vf); i++ {
2971 if f := Sinh(vf[i]); !close(sinh[i], f) {
2972 t.Errorf("Sinh(%g) = %g, want %g", vf[i], f, sinh[i])
2973 }
2974 }
2975 for i := 0; i < len(vfsinhSC); i++ {
2976 if f := Sinh(vfsinhSC[i]); !alike(sinhSC[i], f) {
2977 t.Errorf("Sinh(%g) = %g, want %g", vfsinhSC[i], f, sinhSC[i])
2978 }
2979 }
2980 }
2981
2982 func TestSqrt(t *testing.T) {
2983 for i := 0; i < len(vf); i++ {
2984 a := Abs(vf[i])
2985 if f := SqrtGo(a); sqrt[i] != f {
2986 t.Errorf("SqrtGo(%g) = %g, want %g", a, f, sqrt[i])
2987 }
2988 a = Abs(vf[i])
2989 if f := Sqrt(a); sqrt[i] != f {
2990 t.Errorf("Sqrt(%g) = %g, want %g", a, f, sqrt[i])
2991 }
2992 }
2993 for i := 0; i < len(vfsqrtSC); i++ {
2994 if f := SqrtGo(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
2995 t.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
2996 }
2997 if f := Sqrt(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
2998 t.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
2999 }
3000 }
3001 }
3002
3003 func TestTan(t *testing.T) {
3004 for i := 0; i < len(vf); i++ {
3005 if f := Tan(vf[i]); !veryclose(tan[i], f) {
3006 t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
3007 }
3008 }
3009
3010 for i := 0; i < len(vfsinSC); i++ {
3011 if f := Tan(vfsinSC[i]); !alike(sinSC[i], f) {
3012 t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
3013 }
3014 }
3015 }
3016
3017 func TestTanh(t *testing.T) {
3018 for i := 0; i < len(vf); i++ {
3019 if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
3020 t.Errorf("Tanh(%g) = %g, want %g", vf[i], f, tanh[i])
3021 }
3022 }
3023 for i := 0; i < len(vftanhSC); i++ {
3024 if f := Tanh(vftanhSC[i]); !alike(tanhSC[i], f) {
3025 t.Errorf("Tanh(%g) = %g, want %g", vftanhSC[i], f, tanhSC[i])
3026 }
3027 }
3028 }
3029
3030 func TestTrunc(t *testing.T) {
3031 for i := 0; i < len(vf); i++ {
3032 if f := Trunc(vf[i]); !alike(trunc[i], f) {
3033 t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
3034 }
3035 }
3036 for i := 0; i < len(vfceilSC); i++ {
3037 if f := Trunc(vfceilSC[i]); !alike(ceilSC[i], f) {
3038 t.Errorf("Trunc(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
3039 }
3040 }
3041 }
3042
3043 func TestY0(t *testing.T) {
3044 for i := 0; i < len(vf); i++ {
3045 a := Abs(vf[i])
3046 if f := Y0(a); !close(y0[i], f) {
3047 t.Errorf("Y0(%g) = %g, want %g", a, f, y0[i])
3048 }
3049 }
3050 for i := 0; i < len(vfy0SC); i++ {
3051 if f := Y0(vfy0SC[i]); !alike(y0SC[i], f) {
3052 t.Errorf("Y0(%g) = %g, want %g", vfy0SC[i], f, y0SC[i])
3053 }
3054 }
3055 }
3056
3057 func TestY1(t *testing.T) {
3058 for i := 0; i < len(vf); i++ {
3059 a := Abs(vf[i])
3060 if f := Y1(a); !soclose(y1[i], f, 2e-14) {
3061 t.Errorf("Y1(%g) = %g, want %g", a, f, y1[i])
3062 }
3063 }
3064 for i := 0; i < len(vfy0SC); i++ {
3065 if f := Y1(vfy0SC[i]); !alike(y1SC[i], f) {
3066 t.Errorf("Y1(%g) = %g, want %g", vfy0SC[i], f, y1SC[i])
3067 }
3068 }
3069 }
3070
3071 func TestYn(t *testing.T) {
3072 for i := 0; i < len(vf); i++ {
3073 a := Abs(vf[i])
3074 if f := Yn(2, a); !close(y2[i], f) {
3075 t.Errorf("Yn(2, %g) = %g, want %g", a, f, y2[i])
3076 }
3077 if f := Yn(-3, a); !close(yM3[i], f) {
3078 t.Errorf("Yn(-3, %g) = %g, want %g", a, f, yM3[i])
3079 }
3080 }
3081 for i := 0; i < len(vfy0SC); i++ {
3082 if f := Yn(2, vfy0SC[i]); !alike(y2SC[i], f) {
3083 t.Errorf("Yn(2, %g) = %g, want %g", vfy0SC[i], f, y2SC[i])
3084 }
3085 if f := Yn(-3, vfy0SC[i]); !alike(yM3SC[i], f) {
3086 t.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC[i], f, yM3SC[i])
3087 }
3088 }
3089 if f := Yn(0, 0); !alike(Inf(-1), f) {
3090 t.Errorf("Yn(0, 0) = %g, want %g", f, Inf(-1))
3091 }
3092 }
3093
3094 var PortableFMA = FMA
3095
3096 func TestFMA(t *testing.T) {
3097 for _, c := range fmaC {
3098 got := FMA(c.x, c.y, c.z)
3099 if !alike(got, c.want) {
3100 t.Errorf("FMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3101 }
3102 got = PortableFMA(c.x, c.y, c.z)
3103 if !alike(got, c.want) {
3104 t.Errorf("PortableFMA(%g,%g,%g) == %g; want %g", c.x, c.y, c.z, got, c.want)
3105 }
3106 }
3107 }
3108
3109
3110 func fmsub(x, y, z float64) float64 {
3111 return FMA(x, y, -z)
3112 }
3113
3114
3115 func fnmsub(x, y, z float64) float64 {
3116 return FMA(-x, y, z)
3117 }
3118
3119
3120 func fnmadd(x, y, z float64) float64 {
3121 return FMA(-x, y, -z)
3122 }
3123
3124 func TestFMANegativeArgs(t *testing.T) {
3125
3126
3127
3128
3129 for _, c := range fmaC {
3130 want := PortableFMA(c.x, c.y, -c.z)
3131 got := fmsub(c.x, c.y, c.z)
3132 if !alike(got, want) {
3133 t.Errorf("FMA(%g, %g, -(%g)) == %g, want %g", c.x, c.y, c.z, got, want)
3134 }
3135 want = PortableFMA(-c.x, c.y, c.z)
3136 got = fnmsub(c.x, c.y, c.z)
3137 if !alike(got, want) {
3138 t.Errorf("FMA(-(%g), %g, %g) == %g, want %g", c.x, c.y, c.z, got, want)
3139 }
3140 want = PortableFMA(-c.x, c.y, -c.z)
3141 got = fnmadd(c.x, c.y, c.z)
3142 if !alike(got, want) {
3143 t.Errorf("FMA(-(%g), %g, -(%g)) == %g, want %g", c.x, c.y, c.z, got, want)
3144 }
3145 }
3146 }
3147
3148
3149
3150
3151
3152 func TestLargeCos(t *testing.T) {
3153 large := float64(100000 * Pi)
3154 for i := 0; i < len(vf); i++ {
3155 f1 := cosLarge[i]
3156 f2 := Cos(vf[i] + large)
3157 if !close(f1, f2) {
3158 t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
3159 }
3160 }
3161 }
3162
3163 func TestLargeSin(t *testing.T) {
3164 large := float64(100000 * Pi)
3165 for i := 0; i < len(vf); i++ {
3166 f1 := sinLarge[i]
3167 f2 := Sin(vf[i] + large)
3168 if !close(f1, f2) {
3169 t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
3170 }
3171 }
3172 }
3173
3174 func TestLargeSincos(t *testing.T) {
3175 large := float64(100000 * Pi)
3176 for i := 0; i < len(vf); i++ {
3177 f1, g1 := sinLarge[i], cosLarge[i]
3178 f2, g2 := Sincos(vf[i] + large)
3179 if !close(f1, f2) || !close(g1, g2) {
3180 t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
3181 }
3182 }
3183 }
3184
3185 func TestLargeTan(t *testing.T) {
3186 large := float64(100000 * Pi)
3187 for i := 0; i < len(vf); i++ {
3188 f1 := tanLarge[i]
3189 f2 := Tan(vf[i] + large)
3190 if !close(f1, f2) {
3191 t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
3192 }
3193 }
3194 }
3195
3196
3197
3198 func TestTrigReduce(t *testing.T) {
3199 inputs := make([]float64, len(vf))
3200
3201 copy(inputs, vf)
3202
3203 large := float64(100000 * Pi)
3204 for _, v := range vf {
3205 inputs = append(inputs, v+large)
3206 }
3207
3208 inputs = append(inputs, Pi, Nextafter(ReduceThreshold, 0))
3209 for _, x := range inputs {
3210
3211 j, z := TrigReduce(x)
3212 xred := float64(j)*(Pi/4) + z
3213
3214 if f, fred := Sin(x), Sin(xred); !close(f, fred) {
3215 t.Errorf("Sin(trigReduce(%g)) != Sin(%g), got %g, want %g", x, x, fred, f)
3216 }
3217 if f, fred := Cos(x), Cos(xred); !close(f, fred) {
3218 t.Errorf("Cos(trigReduce(%g)) != Cos(%g), got %g, want %g", x, x, fred, f)
3219 }
3220 if f, fred := Tan(x), Tan(xred); !close(f, fred) {
3221 t.Errorf(" Tan(trigReduce(%g)) != Tan(%g), got %g, want %g", x, x, fred, f)
3222 }
3223 f, g := Sincos(x)
3224 fred, gred := Sincos(xred)
3225 if !close(f, fred) || !close(g, gred) {
3226 t.Errorf(" Sincos(trigReduce(%g)) != Sincos(%g), got %g, %g, want %g, %g", x, x, fred, gred, f, g)
3227 }
3228 }
3229 }
3230
3231
3232
3233
3234
3235 type floatTest struct {
3236 val any
3237 name string
3238 str string
3239 }
3240
3241 var floatTests = []floatTest{
3242 {float64(MaxFloat64), "MaxFloat64", "1.7976931348623157e+308"},
3243 {float64(SmallestNonzeroFloat64), "SmallestNonzeroFloat64", "5e-324"},
3244 {float32(MaxFloat32), "MaxFloat32", "3.4028235e+38"},
3245 {float32(SmallestNonzeroFloat32), "SmallestNonzeroFloat32", "1e-45"},
3246 }
3247
3248 func TestFloatMinMax(t *testing.T) {
3249 for _, tt := range floatTests {
3250 s := fmt.Sprint(tt.val)
3251 if s != tt.str {
3252 t.Errorf("Sprint(%v) = %s, want %s", tt.name, s, tt.str)
3253 }
3254 }
3255 }
3256
3257 func TestFloatMinima(t *testing.T) {
3258 if q := float32(SmallestNonzeroFloat32 / 2); q != 0 {
3259 t.Errorf("float32(SmallestNonzeroFloat32 / 2) = %g, want 0", q)
3260 }
3261 if q := float64(SmallestNonzeroFloat64 / 2); q != 0 {
3262 t.Errorf("float64(SmallestNonzeroFloat64 / 2) = %g, want 0", q)
3263 }
3264 }
3265
3266 var indirectSqrt = Sqrt
3267
3268
3269 func TestFloat32Sqrt(t *testing.T) {
3270 for _, v := range sqrt32 {
3271 want := float32(indirectSqrt(float64(v)))
3272 got := float32(Sqrt(float64(v)))
3273 if IsNaN(float64(want)) {
3274 if !IsNaN(float64(got)) {
3275 t.Errorf("got=%#v want=NaN, v=%#v", got, v)
3276 }
3277 continue
3278 }
3279 if got != want {
3280 t.Errorf("got=%#v want=%#v, v=%#v", got, want, v)
3281 }
3282 }
3283 }
3284
3285
3286
3287
3288
3289
3290
3291 var (
3292 GlobalI int
3293 GlobalB bool
3294 GlobalF float64
3295 )
3296
3297 func BenchmarkAcos(b *testing.B) {
3298 x := 0.0
3299 for i := 0; i < b.N; i++ {
3300 x = Acos(.5)
3301 }
3302 GlobalF = x
3303 }
3304
3305 func BenchmarkAcosh(b *testing.B) {
3306 x := 0.0
3307 for i := 0; i < b.N; i++ {
3308 x = Acosh(1.5)
3309 }
3310 GlobalF = x
3311 }
3312
3313 func BenchmarkAsin(b *testing.B) {
3314 x := 0.0
3315 for i := 0; i < b.N; i++ {
3316 x = Asin(.5)
3317 }
3318 GlobalF = x
3319 }
3320
3321 func BenchmarkAsinh(b *testing.B) {
3322 x := 0.0
3323 for i := 0; i < b.N; i++ {
3324 x = Asinh(.5)
3325 }
3326 GlobalF = x
3327 }
3328
3329 func BenchmarkAtan(b *testing.B) {
3330 x := 0.0
3331 for i := 0; i < b.N; i++ {
3332 x = Atan(.5)
3333 }
3334 GlobalF = x
3335 }
3336
3337 func BenchmarkAtanh(b *testing.B) {
3338 x := 0.0
3339 for i := 0; i < b.N; i++ {
3340 x = Atanh(.5)
3341 }
3342 GlobalF = x
3343 }
3344
3345 func BenchmarkAtan2(b *testing.B) {
3346 x := 0.0
3347 for i := 0; i < b.N; i++ {
3348 x = Atan2(.5, 1)
3349 }
3350 GlobalF = x
3351 }
3352
3353 func BenchmarkCbrt(b *testing.B) {
3354 x := 0.0
3355 for i := 0; i < b.N; i++ {
3356 x = Cbrt(10)
3357 }
3358 GlobalF = x
3359 }
3360
3361 func BenchmarkCeil(b *testing.B) {
3362 x := 0.0
3363 for i := 0; i < b.N; i++ {
3364 x = Ceil(.5)
3365 }
3366 GlobalF = x
3367 }
3368
3369 var copysignNeg = -1.0
3370
3371 func BenchmarkCopysign(b *testing.B) {
3372 x := 0.0
3373 for i := 0; i < b.N; i++ {
3374 x = Copysign(.5, copysignNeg)
3375 }
3376 GlobalF = x
3377 }
3378
3379 func BenchmarkCos(b *testing.B) {
3380 x := 0.0
3381 for i := 0; i < b.N; i++ {
3382 x = Cos(.5)
3383 }
3384 GlobalF = x
3385 }
3386
3387 func BenchmarkCosh(b *testing.B) {
3388 x := 0.0
3389 for i := 0; i < b.N; i++ {
3390 x = Cosh(2.5)
3391 }
3392 GlobalF = x
3393 }
3394
3395 func BenchmarkErf(b *testing.B) {
3396 x := 0.0
3397 for i := 0; i < b.N; i++ {
3398 x = Erf(.5)
3399 }
3400 GlobalF = x
3401 }
3402
3403 func BenchmarkErfc(b *testing.B) {
3404 x := 0.0
3405 for i := 0; i < b.N; i++ {
3406 x = Erfc(.5)
3407 }
3408 GlobalF = x
3409 }
3410
3411 func BenchmarkErfinv(b *testing.B) {
3412 x := 0.0
3413 for i := 0; i < b.N; i++ {
3414 x = Erfinv(.5)
3415 }
3416 GlobalF = x
3417 }
3418
3419 func BenchmarkErfcinv(b *testing.B) {
3420 x := 0.0
3421 for i := 0; i < b.N; i++ {
3422 x = Erfcinv(.5)
3423 }
3424 GlobalF = x
3425 }
3426
3427 func BenchmarkExp(b *testing.B) {
3428 x := 0.0
3429 for i := 0; i < b.N; i++ {
3430 x = Exp(.5)
3431 }
3432 GlobalF = x
3433 }
3434
3435 func BenchmarkExpGo(b *testing.B) {
3436 x := 0.0
3437 for i := 0; i < b.N; i++ {
3438 x = ExpGo(.5)
3439 }
3440 GlobalF = x
3441 }
3442
3443 func BenchmarkExpm1(b *testing.B) {
3444 x := 0.0
3445 for i := 0; i < b.N; i++ {
3446 x = Expm1(.5)
3447 }
3448 GlobalF = x
3449 }
3450
3451 func BenchmarkExp2(b *testing.B) {
3452 x := 0.0
3453 for i := 0; i < b.N; i++ {
3454 x = Exp2(.5)
3455 }
3456 GlobalF = x
3457 }
3458
3459 func BenchmarkExp2Go(b *testing.B) {
3460 x := 0.0
3461 for i := 0; i < b.N; i++ {
3462 x = Exp2Go(.5)
3463 }
3464 GlobalF = x
3465 }
3466
3467 var absPos = .5
3468
3469 func BenchmarkAbs(b *testing.B) {
3470 x := 0.0
3471 for i := 0; i < b.N; i++ {
3472 x = Abs(absPos)
3473 }
3474 GlobalF = x
3475
3476 }
3477
3478 func BenchmarkDim(b *testing.B) {
3479 x := 0.0
3480 for i := 0; i < b.N; i++ {
3481 x = Dim(GlobalF, x)
3482 }
3483 GlobalF = x
3484 }
3485
3486 func BenchmarkFloor(b *testing.B) {
3487 x := 0.0
3488 for i := 0; i < b.N; i++ {
3489 x = Floor(.5)
3490 }
3491 GlobalF = x
3492 }
3493
3494 func BenchmarkMax(b *testing.B) {
3495 x := 0.0
3496 for i := 0; i < b.N; i++ {
3497 x = Max(10, 3)
3498 }
3499 GlobalF = x
3500 }
3501
3502 func BenchmarkMin(b *testing.B) {
3503 x := 0.0
3504 for i := 0; i < b.N; i++ {
3505 x = Min(10, 3)
3506 }
3507 GlobalF = x
3508 }
3509
3510 func BenchmarkMod(b *testing.B) {
3511 x := 0.0
3512 for i := 0; i < b.N; i++ {
3513 x = Mod(10, 3)
3514 }
3515 GlobalF = x
3516 }
3517
3518 func BenchmarkFrexp(b *testing.B) {
3519 x := 0.0
3520 y := 0
3521 for i := 0; i < b.N; i++ {
3522 x, y = Frexp(8)
3523 }
3524 GlobalF = x
3525 GlobalI = y
3526 }
3527
3528 func BenchmarkGamma(b *testing.B) {
3529 x := 0.0
3530 for i := 0; i < b.N; i++ {
3531 x = Gamma(2.5)
3532 }
3533 GlobalF = x
3534 }
3535
3536 func BenchmarkHypot(b *testing.B) {
3537 x := 0.0
3538 for i := 0; i < b.N; i++ {
3539 x = Hypot(3, 4)
3540 }
3541 GlobalF = x
3542 }
3543
3544 func BenchmarkHypotGo(b *testing.B) {
3545 x := 0.0
3546 for i := 0; i < b.N; i++ {
3547 x = HypotGo(3, 4)
3548 }
3549 GlobalF = x
3550 }
3551
3552 func BenchmarkIlogb(b *testing.B) {
3553 x := 0
3554 for i := 0; i < b.N; i++ {
3555 x = Ilogb(.5)
3556 }
3557 GlobalI = x
3558 }
3559
3560 func BenchmarkJ0(b *testing.B) {
3561 x := 0.0
3562 for i := 0; i < b.N; i++ {
3563 x = J0(2.5)
3564 }
3565 GlobalF = x
3566 }
3567
3568 func BenchmarkJ1(b *testing.B) {
3569 x := 0.0
3570 for i := 0; i < b.N; i++ {
3571 x = J1(2.5)
3572 }
3573 GlobalF = x
3574 }
3575
3576 func BenchmarkJn(b *testing.B) {
3577 x := 0.0
3578 for i := 0; i < b.N; i++ {
3579 x = Jn(2, 2.5)
3580 }
3581 GlobalF = x
3582 }
3583
3584 func BenchmarkLdexp(b *testing.B) {
3585 x := 0.0
3586 for i := 0; i < b.N; i++ {
3587 x = Ldexp(.5, 2)
3588 }
3589 GlobalF = x
3590 }
3591
3592 func BenchmarkLgamma(b *testing.B) {
3593 x := 0.0
3594 y := 0
3595 for i := 0; i < b.N; i++ {
3596 x, y = Lgamma(2.5)
3597 }
3598 GlobalF = x
3599 GlobalI = y
3600 }
3601
3602 func BenchmarkLog(b *testing.B) {
3603 x := 0.0
3604 for i := 0; i < b.N; i++ {
3605 x = Log(.5)
3606 }
3607 GlobalF = x
3608 }
3609
3610 func BenchmarkLogb(b *testing.B) {
3611 x := 0.0
3612 for i := 0; i < b.N; i++ {
3613 x = Logb(.5)
3614 }
3615 GlobalF = x
3616 }
3617
3618 func BenchmarkLog1p(b *testing.B) {
3619 x := 0.0
3620 for i := 0; i < b.N; i++ {
3621 x = Log1p(.5)
3622 }
3623 GlobalF = x
3624 }
3625
3626 func BenchmarkLog10(b *testing.B) {
3627 x := 0.0
3628 for i := 0; i < b.N; i++ {
3629 x = Log10(.5)
3630 }
3631 GlobalF = x
3632 }
3633
3634 func BenchmarkLog2(b *testing.B) {
3635 x := 0.0
3636 for i := 0; i < b.N; i++ {
3637 x = Log2(.5)
3638 }
3639 GlobalF += x
3640 }
3641
3642 func BenchmarkModf(b *testing.B) {
3643 x := 0.0
3644 y := 0.0
3645 for i := 0; i < b.N; i++ {
3646 x, y = Modf(1.5)
3647 }
3648 GlobalF += x
3649 GlobalF += y
3650 }
3651
3652 func BenchmarkNextafter32(b *testing.B) {
3653 x := float32(0.0)
3654 for i := 0; i < b.N; i++ {
3655 x = Nextafter32(.5, 1)
3656 }
3657 GlobalF = float64(x)
3658 }
3659
3660 func BenchmarkNextafter64(b *testing.B) {
3661 x := 0.0
3662 for i := 0; i < b.N; i++ {
3663 x = Nextafter(.5, 1)
3664 }
3665 GlobalF = x
3666 }
3667
3668 func BenchmarkPowInt(b *testing.B) {
3669 x := 0.0
3670 for i := 0; i < b.N; i++ {
3671 x = Pow(2, 2)
3672 }
3673 GlobalF = x
3674 }
3675
3676 func BenchmarkPowFrac(b *testing.B) {
3677 x := 0.0
3678 for i := 0; i < b.N; i++ {
3679 x = Pow(2.5, 1.5)
3680 }
3681 GlobalF = x
3682 }
3683
3684 var pow10pos = int(300)
3685
3686 func BenchmarkPow10Pos(b *testing.B) {
3687 x := 0.0
3688 for i := 0; i < b.N; i++ {
3689 x = Pow10(pow10pos)
3690 }
3691 GlobalF = x
3692 }
3693
3694 var pow10neg = int(-300)
3695
3696 func BenchmarkPow10Neg(b *testing.B) {
3697 x := 0.0
3698 for i := 0; i < b.N; i++ {
3699 x = Pow10(pow10neg)
3700 }
3701 GlobalF = x
3702 }
3703
3704 var roundNeg = float64(-2.5)
3705
3706 func BenchmarkRound(b *testing.B) {
3707 x := 0.0
3708 for i := 0; i < b.N; i++ {
3709 x = Round(roundNeg)
3710 }
3711 GlobalF = x
3712 }
3713
3714 func BenchmarkRoundToEven(b *testing.B) {
3715 x := 0.0
3716 for i := 0; i < b.N; i++ {
3717 x = RoundToEven(roundNeg)
3718 }
3719 GlobalF = x
3720 }
3721
3722 func BenchmarkRemainder(b *testing.B) {
3723 x := 0.0
3724 for i := 0; i < b.N; i++ {
3725 x = Remainder(10, 3)
3726 }
3727 GlobalF = x
3728 }
3729
3730 var signbitPos = 2.5
3731
3732 func BenchmarkSignbit(b *testing.B) {
3733 x := false
3734 for i := 0; i < b.N; i++ {
3735 x = Signbit(signbitPos)
3736 }
3737 GlobalB = x
3738 }
3739
3740 func BenchmarkSin(b *testing.B) {
3741 x := 0.0
3742 for i := 0; i < b.N; i++ {
3743 x = Sin(.5)
3744 }
3745 GlobalF = x
3746 }
3747
3748 func BenchmarkSincos(b *testing.B) {
3749 x := 0.0
3750 y := 0.0
3751 for i := 0; i < b.N; i++ {
3752 x, y = Sincos(.5)
3753 }
3754 GlobalF += x
3755 GlobalF += y
3756 }
3757
3758 func BenchmarkSinh(b *testing.B) {
3759 x := 0.0
3760 for i := 0; i < b.N; i++ {
3761 x = Sinh(2.5)
3762 }
3763 GlobalF = x
3764 }
3765
3766 func BenchmarkSqrtIndirect(b *testing.B) {
3767 x, y := 0.0, 10.0
3768 f := Sqrt
3769 for i := 0; i < b.N; i++ {
3770 x += f(y)
3771 }
3772 GlobalF = x
3773 }
3774
3775 func BenchmarkSqrtLatency(b *testing.B) {
3776 x := 10.0
3777 for i := 0; i < b.N; i++ {
3778 x = Sqrt(x)
3779 }
3780 GlobalF = x
3781 }
3782
3783 func BenchmarkSqrtIndirectLatency(b *testing.B) {
3784 x := 10.0
3785 f := Sqrt
3786 for i := 0; i < b.N; i++ {
3787 x = f(x)
3788 }
3789 GlobalF = x
3790 }
3791
3792 func BenchmarkSqrtGoLatency(b *testing.B) {
3793 x := 10.0
3794 for i := 0; i < b.N; i++ {
3795 x = SqrtGo(x)
3796 }
3797 GlobalF = x
3798 }
3799
3800 func isPrime(i int) bool {
3801
3802
3803
3804
3805
3806 for j := 2; float64(j) <= Sqrt(float64(i)); j++ {
3807 if i%j == 0 {
3808 return false
3809 }
3810 }
3811 return true
3812 }
3813
3814 func BenchmarkSqrtPrime(b *testing.B) {
3815 x := false
3816 for i := 0; i < b.N; i++ {
3817 x = isPrime(100003)
3818 }
3819 GlobalB = x
3820 }
3821
3822 func BenchmarkTan(b *testing.B) {
3823 x := 0.0
3824 for i := 0; i < b.N; i++ {
3825 x = Tan(.5)
3826 }
3827 GlobalF = x
3828 }
3829
3830 func BenchmarkTanh(b *testing.B) {
3831 x := 0.0
3832 for i := 0; i < b.N; i++ {
3833 x = Tanh(2.5)
3834 }
3835 GlobalF = x
3836 }
3837 func BenchmarkTrunc(b *testing.B) {
3838 x := 0.0
3839 for i := 0; i < b.N; i++ {
3840 x = Trunc(.5)
3841 }
3842 GlobalF = x
3843 }
3844
3845 func BenchmarkY0(b *testing.B) {
3846 x := 0.0
3847 for i := 0; i < b.N; i++ {
3848 x = Y0(2.5)
3849 }
3850 GlobalF = x
3851 }
3852
3853 func BenchmarkY1(b *testing.B) {
3854 x := 0.0
3855 for i := 0; i < b.N; i++ {
3856 x = Y1(2.5)
3857 }
3858 GlobalF = x
3859 }
3860
3861 func BenchmarkYn(b *testing.B) {
3862 x := 0.0
3863 for i := 0; i < b.N; i++ {
3864 x = Yn(2, 2.5)
3865 }
3866 GlobalF = x
3867 }
3868
3869 func BenchmarkFloat64bits(b *testing.B) {
3870 y := uint64(0)
3871 for i := 0; i < b.N; i++ {
3872 y = Float64bits(roundNeg)
3873 }
3874 GlobalI = int(y)
3875 }
3876
3877 var roundUint64 = uint64(5)
3878
3879 func BenchmarkFloat64frombits(b *testing.B) {
3880 x := 0.0
3881 for i := 0; i < b.N; i++ {
3882 x = Float64frombits(roundUint64)
3883 }
3884 GlobalF = x
3885 }
3886
3887 var roundFloat32 = float32(-2.5)
3888
3889 func BenchmarkFloat32bits(b *testing.B) {
3890 y := uint32(0)
3891 for i := 0; i < b.N; i++ {
3892 y = Float32bits(roundFloat32)
3893 }
3894 GlobalI = int(y)
3895 }
3896
3897 var roundUint32 = uint32(5)
3898
3899 func BenchmarkFloat32frombits(b *testing.B) {
3900 x := float32(0.0)
3901 for i := 0; i < b.N; i++ {
3902 x = Float32frombits(roundUint32)
3903 }
3904 GlobalF = float64(x)
3905 }
3906
3907 func BenchmarkFMA(b *testing.B) {
3908 x := 0.0
3909 for i := 0; i < b.N; i++ {
3910 x = FMA(E, Pi, x)
3911 }
3912 GlobalF = x
3913 }
3914
View as plain text