1// Copyright 2009 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package math_test
6
7import (
8	"fmt"
9	. "math"
10	"testing"
11	"unsafe"
12)
13
14var 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// The expected results below were computed by the high precision calculators
28// at http://keisan.casio.com/.  More exact input values (array vf[], above)
29// were obtained by printing them with "%.26f".  The answers were calculated
30// to 26 digits (by using the "Digit number" drop-down control of each
31// calculator).
32var 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}
44var 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}
56var 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}
68var 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}
80var 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}
92var 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}
104var 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}
116var 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}
128var 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}
140var 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}
152var 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// Results for 100000 * Pi + vf[i]
166var 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}
178var cosh = []float64{
179	7.2668796942212842775517446e+01,
180	1.1479413465659254502011135e+03,
181	1.0385767908766418550935495e+00,
182	7.5000957789658051428857788e+01,
183	7.655246669605357888468613e+03,
184	9.3567491758321272072888257e+00,
185	9.331351599270605471131735e+01,
186	7.6833430994624643209296404e+00,
187	3.1829371625150718153881164e+00,
188	2.9595059261916188501640911e+03,
189}
190var erf = []float64{
191	5.1865354817738701906913566e-01,
192	7.2623875834137295116929844e-01,
193	-3.123458688281309990629839e-02,
194	-5.2143121110253302920437013e-01,
195	8.2704742671312902508629582e-01,
196	3.2101767558376376743993945e-01,
197	5.403990312223245516066252e-01,
198	3.0034702916738588551174831e-01,
199	2.0369924417882241241559589e-01,
200	-7.8069386968009226729944677e-01,
201}
202var erfc = []float64{
203	4.8134645182261298093086434e-01,
204	2.7376124165862704883070156e-01,
205	1.0312345868828130999062984e+00,
206	1.5214312111025330292043701e+00,
207	1.7295257328687097491370418e-01,
208	6.7898232441623623256006055e-01,
209	4.596009687776754483933748e-01,
210	6.9965297083261411448825169e-01,
211	7.9630075582117758758440411e-01,
212	1.7806938696800922672994468e+00,
213}
214var erfinv = []float64{
215	4.746037673358033586786350696e-01,
216	8.559054432692110956388764172e-01,
217	-2.45427830571707336251331946e-02,
218	-4.78116683518973366268905506e-01,
219	1.479804430319470983648120853e+00,
220	2.654485787128896161882650211e-01,
221	5.027444534221520197823192493e-01,
222	2.466703532707627818954585670e-01,
223	1.632011465103005426240343116e-01,
224	-1.06672334642196900710000389e+00,
225}
226var exp = []float64{
227	1.4533071302642137507696589e+02,
228	2.2958822575694449002537581e+03,
229	7.5814542574851666582042306e-01,
230	6.6668778421791005061482264e-03,
231	1.5310493273896033740861206e+04,
232	1.8659907517999328638667732e+01,
233	1.8662167355098714543942057e+02,
234	1.5301332413189378961665788e+01,
235	6.2047063430646876349125085e+00,
236	1.6894712385826521111610438e-04,
237}
238var expm1 = []float64{
239	5.105047796122957327384770212e-02,
240	8.046199708567344080562675439e-02,
241	-2.764970978891639815187418703e-03,
242	-4.8871434888875355394330300273e-02,
243	1.0115864277221467777117227494e-01,
244	2.969616407795910726014621657e-02,
245	5.368214487944892300914037972e-02,
246	2.765488851131274068067445335e-02,
247	1.842068661871398836913874273e-02,
248	-8.3193870863553801814961137573e-02,
249}
250var expm1Large = []float64{
251	4.2031418113550844e+21,
252	4.0690789717473863e+33,
253	-0.9372627915981363e+00,
254	-1.0,
255	7.077694784145933e+41,
256	5.117936223839153e+12,
257	5.124137759001189e+22,
258	7.03546003972584e+11,
259	8.456921800389698e+07,
260	-1.0,
261}
262var exp2 = []float64{
263	3.1537839463286288034313104e+01,
264	2.1361549283756232296144849e+02,
265	8.2537402562185562902577219e-01,
266	3.1021158628740294833424229e-02,
267	7.9581744110252191462569661e+02,
268	7.6019905892596359262696423e+00,
269	3.7506882048388096973183084e+01,
270	6.6250893439173561733216375e+00,
271	3.5438267900243941544605339e+00,
272	2.4281533133513300984289196e-03,
273}
274var fabs = []float64{
275	4.9790119248836735e+00,
276	7.7388724745781045e+00,
277	2.7688005719200159e-01,
278	5.0106036182710749e+00,
279	9.6362937071984173e+00,
280	2.9263772392439646e+00,
281	5.2290834314593066e+00,
282	2.7279399104360102e+00,
283	1.8253080916808550e+00,
284	8.6859247685756013e+00,
285}
286var fdim = []float64{
287	4.9790119248836735e+00,
288	7.7388724745781045e+00,
289	0.0000000000000000e+00,
290	0.0000000000000000e+00,
291	9.6362937071984173e+00,
292	2.9263772392439646e+00,
293	5.2290834314593066e+00,
294	2.7279399104360102e+00,
295	1.8253080916808550e+00,
296	0.0000000000000000e+00,
297}
298var floor = []float64{
299	4.0000000000000000e+00,
300	7.0000000000000000e+00,
301	-1.0000000000000000e+00,
302	-6.0000000000000000e+00,
303	9.0000000000000000e+00,
304	2.0000000000000000e+00,
305	5.0000000000000000e+00,
306	2.0000000000000000e+00,
307	1.0000000000000000e+00,
308	-9.0000000000000000e+00,
309}
310var fmod = []float64{
311	4.197615023265299782906368e-02,
312	2.261127525421895434476482e+00,
313	3.231794108794261433104108e-02,
314	4.989396381728925078391512e+00,
315	3.637062928015826201999516e-01,
316	1.220868282268106064236690e+00,
317	4.770916568540693347699744e+00,
318	1.816180268691969246219742e+00,
319	8.734595415957246977711748e-01,
320	1.314075231424398637614104e+00,
321}
322
323type fi struct {
324	f float64
325	i int
326}
327
328var frexp = []fi{
329	{6.2237649061045918750e-01, 3},
330	{9.6735905932226306250e-01, 3},
331	{-5.5376011438400318000e-01, -1},
332	{-6.2632545228388436250e-01, 3},
333	{6.02268356699901081250e-01, 4},
334	{7.3159430981099115000e-01, 2},
335	{6.5363542893241332500e-01, 3},
336	{6.8198497760900255000e-01, 2},
337	{9.1265404584042750000e-01, 1},
338	{-5.4287029803597508250e-01, 4},
339}
340var gamma = []float64{
341	2.3254348370739963835386613898e+01,
342	2.991153837155317076427529816e+03,
343	-4.561154336726758060575129109e+00,
344	7.719403468842639065959210984e-01,
345	1.6111876618855418534325755566e+05,
346	1.8706575145216421164173224946e+00,
347	3.4082787447257502836734201635e+01,
348	1.579733951448952054898583387e+00,
349	9.3834586598354592860187267089e-01,
350	-2.093995902923148389186189429e-05,
351}
352var j0 = []float64{
353	-1.8444682230601672018219338e-01,
354	2.27353668906331975435892e-01,
355	9.809259936157051116270273e-01,
356	-1.741170131426226587841181e-01,
357	-2.1389448451144143352039069e-01,
358	-2.340905848928038763337414e-01,
359	-1.0029099691890912094586326e-01,
360	-1.5466726714884328135358907e-01,
361	3.252650187653420388714693e-01,
362	-8.72218484409407250005360235e-03,
363}
364var j1 = []float64{
365	-3.251526395295203422162967e-01,
366	1.893581711430515718062564e-01,
367	-1.3711761352467242914491514e-01,
368	3.287486536269617297529617e-01,
369	1.3133899188830978473849215e-01,
370	3.660243417832986825301766e-01,
371	-3.4436769271848174665420672e-01,
372	4.329481396640773768835036e-01,
373	5.8181350531954794639333955e-01,
374	-2.7030574577733036112996607e-01,
375}
376var j2 = []float64{
377	5.3837518920137802565192769e-02,
378	-1.7841678003393207281244667e-01,
379	9.521746934916464142495821e-03,
380	4.28958355470987397983072e-02,
381	2.4115371837854494725492872e-01,
382	4.842458532394520316844449e-01,
383	-3.142145220618633390125946e-02,
384	4.720849184745124761189957e-01,
385	3.122312022520957042957497e-01,
386	7.096213118930231185707277e-02,
387}
388var jM3 = []float64{
389	-3.684042080996403091021151e-01,
390	2.8157665936340887268092661e-01,
391	4.401005480841948348343589e-04,
392	3.629926999056814081597135e-01,
393	3.123672198825455192489266e-02,
394	-2.958805510589623607540455e-01,
395	-3.2033177696533233403289416e-01,
396	-2.592737332129663376736604e-01,
397	-1.0241334641061485092351251e-01,
398	-2.3762660886100206491674503e-01,
399}
400var lgamma = []fi{
401	{3.146492141244545774319734e+00, 1},
402	{8.003414490659126375852113e+00, 1},
403	{1.517575735509779707488106e+00, -1},
404	{-2.588480028182145853558748e-01, 1},
405	{1.1989897050205555002007985e+01, 1},
406	{6.262899811091257519386906e-01, 1},
407	{3.5287924899091566764846037e+00, 1},
408	{4.5725644770161182299423372e-01, 1},
409	{-6.363667087767961257654854e-02, 1},
410	{-1.077385130910300066425564e+01, -1},
411}
412var log = []float64{
413	1.605231462693062999102599e+00,
414	2.0462560018708770653153909e+00,
415	-1.2841708730962657801275038e+00,
416	1.6115563905281545116286206e+00,
417	2.2655365644872016636317461e+00,
418	1.0737652208918379856272735e+00,
419	1.6542360106073546632707956e+00,
420	1.0035467127723465801264487e+00,
421	6.0174879014578057187016475e-01,
422	2.161703872847352815363655e+00,
423}
424var logb = []float64{
425	2.0000000000000000e+00,
426	2.0000000000000000e+00,
427	-2.0000000000000000e+00,
428	2.0000000000000000e+00,
429	3.0000000000000000e+00,
430	1.0000000000000000e+00,
431	2.0000000000000000e+00,
432	1.0000000000000000e+00,
433	0.0000000000000000e+00,
434	3.0000000000000000e+00,
435}
436var log10 = []float64{
437	6.9714316642508290997617083e-01,
438	8.886776901739320576279124e-01,
439	-5.5770832400658929815908236e-01,
440	6.998900476822994346229723e-01,
441	9.8391002850684232013281033e-01,
442	4.6633031029295153334285302e-01,
443	7.1842557117242328821552533e-01,
444	4.3583479968917773161304553e-01,
445	2.6133617905227038228626834e-01,
446	9.3881606348649405716214241e-01,
447}
448var log1p = []float64{
449	4.8590257759797794104158205e-02,
450	7.4540265965225865330849141e-02,
451	-2.7726407903942672823234024e-03,
452	-5.1404917651627649094953380e-02,
453	9.1998280672258624681335010e-02,
454	2.8843762576593352865894824e-02,
455	5.0969534581863707268992645e-02,
456	2.6913947602193238458458594e-02,
457	1.8088493239630770262045333e-02,
458	-9.0865245631588989681559268e-02,
459}
460var log2 = []float64{
461	2.3158594707062190618898251e+00,
462	2.9521233862883917703341018e+00,
463	-1.8526669502700329984917062e+00,
464	2.3249844127278861543568029e+00,
465	3.268478366538305087466309e+00,
466	1.5491157592596970278166492e+00,
467	2.3865580889631732407886495e+00,
468	1.447811865817085365540347e+00,
469	8.6813999540425116282815557e-01,
470	3.118679457227342224364709e+00,
471}
472var modf = [][2]float64{
473	{4.0000000000000000e+00, 9.7901192488367350108546816e-01},
474	{7.0000000000000000e+00, 7.3887247457810456552351752e-01},
475	{Copysign(0, -1), -2.7688005719200159404635997e-01},
476	{-5.0000000000000000e+00, -1.060361827107492160848778e-02},
477	{9.0000000000000000e+00, 6.3629370719841737980004837e-01},
478	{2.0000000000000000e+00, 9.2637723924396464525443662e-01},
479	{5.0000000000000000e+00, 2.2908343145930665230025625e-01},
480	{2.0000000000000000e+00, 7.2793991043601025126008608e-01},
481	{1.0000000000000000e+00, 8.2530809168085506044576505e-01},
482	{-8.0000000000000000e+00, -6.8592476857560136238589621e-01},
483}
484var nextafter32 = []float32{
485	4.979012489318848e+00,
486	7.738873004913330e+00,
487	-2.768800258636475e-01,
488	-5.010602951049805e+00,
489	9.636294364929199e+00,
490	2.926377534866333e+00,
491	5.229084014892578e+00,
492	2.727940082550049e+00,
493	1.825308203697205e+00,
494	-8.685923576354980e+00,
495}
496var nextafter64 = []float64{
497	4.97901192488367438926388786e+00,
498	7.73887247457810545370193722e+00,
499	-2.7688005719200153853520874e-01,
500	-5.01060361827107403343006808e+00,
501	9.63629370719841915615688777e+00,
502	2.92637723924396508934364647e+00,
503	5.22908343145930754047867595e+00,
504	2.72793991043601069534929593e+00,
505	1.82530809168085528249036997e+00,
506	-8.68592476857559958602905681e+00,
507}
508var pow = []float64{
509	9.5282232631648411840742957e+04,
510	5.4811599352999901232411871e+07,
511	5.2859121715894396531132279e-01,
512	9.7587991957286474464259698e-06,
513	4.328064329346044846740467e+09,
514	8.4406761805034547437659092e+02,
515	1.6946633276191194947742146e+05,
516	5.3449040147551939075312879e+02,
517	6.688182138451414936380374e+01,
518	2.0609869004248742886827439e-09,
519}
520var remainder = []float64{
521	4.197615023265299782906368e-02,
522	2.261127525421895434476482e+00,
523	3.231794108794261433104108e-02,
524	-2.120723654214984321697556e-02,
525	3.637062928015826201999516e-01,
526	1.220868282268106064236690e+00,
527	-4.581668629186133046005125e-01,
528	-9.117596417440410050403443e-01,
529	8.734595415957246977711748e-01,
530	1.314075231424398637614104e+00,
531}
532var round = []float64{
533	5,
534	8,
535	Copysign(0, -1),
536	-5,
537	10,
538	3,
539	5,
540	3,
541	2,
542	-9,
543}
544var signbit = []bool{
545	false,
546	false,
547	true,
548	true,
549	false,
550	false,
551	false,
552	false,
553	false,
554	true,
555}
556var sin = []float64{
557	-9.6466616586009283766724726e-01,
558	9.9338225271646545763467022e-01,
559	-2.7335587039794393342449301e-01,
560	9.5586257685042792878173752e-01,
561	-2.099421066779969164496634e-01,
562	2.135578780799860532750616e-01,
563	-8.694568971167362743327708e-01,
564	4.019566681155577786649878e-01,
565	9.6778633541687993721617774e-01,
566	-6.734405869050344734943028e-01,
567}
568
569// Results for 100000 * Pi + vf[i]
570var sinLarge = []float64{
571	-9.646661658548936063912e-01,
572	9.933822527198506903752e-01,
573	-2.7335587036246899796e-01,
574	9.55862576853689321268e-01,
575	-2.099421066862688873691e-01,
576	2.13557878070308981163e-01,
577	-8.694568970959221300497e-01,
578	4.01956668098863248917e-01,
579	9.67786335404528727927e-01,
580	-6.7344058693131973066e-01,
581}
582var sinh = []float64{
583	7.2661916084208532301448439e+01,
584	1.1479409110035194500526446e+03,
585	-2.8043136512812518927312641e-01,
586	-7.499429091181587232835164e+01,
587	7.6552466042906758523925934e+03,
588	9.3031583421672014313789064e+00,
589	9.330815755828109072810322e+01,
590	7.6179893137269146407361477e+00,
591	3.021769180549615819524392e+00,
592	-2.95950575724449499189888e+03,
593}
594var sqrt = []float64{
595	2.2313699659365484748756904e+00,
596	2.7818829009464263511285458e+00,
597	5.2619393496314796848143251e-01,
598	2.2384377628763938724244104e+00,
599	3.1042380236055381099288487e+00,
600	1.7106657298385224403917771e+00,
601	2.286718922705479046148059e+00,
602	1.6516476350711159636222979e+00,
603	1.3510396336454586262419247e+00,
604	2.9471892997524949215723329e+00,
605}
606var tan = []float64{
607	-3.661316565040227801781974e+00,
608	8.64900232648597589369854e+00,
609	-2.8417941955033612725238097e-01,
610	3.253290185974728640827156e+00,
611	2.147275640380293804770778e-01,
612	-2.18600910711067004921551e-01,
613	-1.760002817872367935518928e+00,
614	-4.389808914752818126249079e-01,
615	-3.843885560201130679995041e+00,
616	9.10988793377685105753416e-01,
617}
618
619// Results for 100000 * Pi + vf[i]
620var tanLarge = []float64{
621	-3.66131656475596512705e+00,
622	8.6490023287202547927e+00,
623	-2.841794195104782406e-01,
624	3.2532901861033120983e+00,
625	2.14727564046880001365e-01,
626	-2.18600910700688062874e-01,
627	-1.760002817699722747043e+00,
628	-4.38980891453536115952e-01,
629	-3.84388555942723509071e+00,
630	9.1098879344275101051e-01,
631}
632var tanh = []float64{
633	9.9990531206936338549262119e-01,
634	9.9999962057085294197613294e-01,
635	-2.7001505097318677233756845e-01,
636	-9.9991110943061718603541401e-01,
637	9.9999999146798465745022007e-01,
638	9.9427249436125236705001048e-01,
639	9.9994257600983138572705076e-01,
640	9.9149409509772875982054701e-01,
641	9.4936501296239685514466577e-01,
642	-9.9999994291374030946055701e-01,
643}
644var trunc = []float64{
645	4.0000000000000000e+00,
646	7.0000000000000000e+00,
647	Copysign(0, -1),
648	-5.0000000000000000e+00,
649	9.0000000000000000e+00,
650	2.0000000000000000e+00,
651	5.0000000000000000e+00,
652	2.0000000000000000e+00,
653	1.0000000000000000e+00,
654	-8.0000000000000000e+00,
655}
656var y0 = []float64{
657	-3.053399153780788357534855e-01,
658	1.7437227649515231515503649e-01,
659	-8.6221781263678836910392572e-01,
660	-3.100664880987498407872839e-01,
661	1.422200649300982280645377e-01,
662	4.000004067997901144239363e-01,
663	-3.3340749753099352392332536e-01,
664	4.5399790746668954555205502e-01,
665	4.8290004112497761007536522e-01,
666	2.7036697826604756229601611e-01,
667}
668var y1 = []float64{
669	0.15494213737457922210218611,
670	-0.2165955142081145245075746,
671	-2.4644949631241895201032829,
672	0.1442740489541836405154505,
673	0.2215379960518984777080163,
674	0.3038800915160754150565448,
675	0.0691107642452362383808547,
676	0.2380116417809914424860165,
677	-0.20849492979459761009678934,
678	0.0242503179793232308250804,
679}
680var y2 = []float64{
681	0.3675780219390303613394936,
682	-0.23034826393250119879267257,
683	-16.939677983817727205631397,
684	0.367653980523052152867791,
685	-0.0962401471767804440353136,
686	-0.1923169356184851105200523,
687	0.35984072054267882391843766,
688	-0.2794987252299739821654982,
689	-0.7113490692587462579757954,
690	-0.2647831587821263302087457,
691}
692var yM3 = []float64{
693	-0.14035984421094849100895341,
694	-0.097535139617792072703973,
695	242.25775994555580176377379,
696	-0.1492267014802818619511046,
697	0.26148702629155918694500469,
698	0.56675383593895176530394248,
699	-0.206150264009006981070575,
700	0.64784284687568332737963658,
701	1.3503631555901938037008443,
702	0.1461869756579956803341844,
703}
704
705// arguments and expected results for special cases
706var vfacosSC = []float64{
707	-Pi,
708	1,
709	Pi,
710	NaN(),
711}
712var acosSC = []float64{
713	NaN(),
714	0,
715	NaN(),
716	NaN(),
717}
718
719var vfacoshSC = []float64{
720	Inf(-1),
721	0.5,
722	1,
723	Inf(1),
724	NaN(),
725}
726var acoshSC = []float64{
727	NaN(),
728	NaN(),
729	0,
730	Inf(1),
731	NaN(),
732}
733
734var vfasinSC = []float64{
735	-Pi,
736	Copysign(0, -1),
737	0,
738	Pi,
739	NaN(),
740}
741var asinSC = []float64{
742	NaN(),
743	Copysign(0, -1),
744	0,
745	NaN(),
746	NaN(),
747}
748
749var vfasinhSC = []float64{
750	Inf(-1),
751	Copysign(0, -1),
752	0,
753	Inf(1),
754	NaN(),
755}
756var asinhSC = []float64{
757	Inf(-1),
758	Copysign(0, -1),
759	0,
760	Inf(1),
761	NaN(),
762}
763
764var vfatanSC = []float64{
765	Inf(-1),
766	Copysign(0, -1),
767	0,
768	Inf(1),
769	NaN(),
770}
771var atanSC = []float64{
772	-Pi / 2,
773	Copysign(0, -1),
774	0,
775	Pi / 2,
776	NaN(),
777}
778
779var vfatanhSC = []float64{
780	Inf(-1),
781	-Pi,
782	-1,
783	Copysign(0, -1),
784	0,
785	1,
786	Pi,
787	Inf(1),
788	NaN(),
789}
790var atanhSC = []float64{
791	NaN(),
792	NaN(),
793	Inf(-1),
794	Copysign(0, -1),
795	0,
796	Inf(1),
797	NaN(),
798	NaN(),
799	NaN(),
800}
801var vfatan2SC = [][2]float64{
802	{Inf(-1), Inf(-1)},
803	{Inf(-1), -Pi},
804	{Inf(-1), 0},
805	{Inf(-1), +Pi},
806	{Inf(-1), Inf(1)},
807	{Inf(-1), NaN()},
808	{-Pi, Inf(-1)},
809	{-Pi, 0},
810	{-Pi, Inf(1)},
811	{-Pi, NaN()},
812	{Copysign(0, -1), Inf(-1)},
813	{Copysign(0, -1), -Pi},
814	{Copysign(0, -1), Copysign(0, -1)},
815	{Copysign(0, -1), 0},
816	{Copysign(0, -1), +Pi},
817	{Copysign(0, -1), Inf(1)},
818	{Copysign(0, -1), NaN()},
819	{0, Inf(-1)},
820	{0, -Pi},
821	{0, Copysign(0, -1)},
822	{0, 0},
823	{0, +Pi},
824	{0, Inf(1)},
825	{0, NaN()},
826	{+Pi, Inf(-1)},
827	{+Pi, 0},
828	{+Pi, Inf(1)},
829	{+Pi, NaN()},
830	{Inf(1), Inf(-1)},
831	{Inf(1), -Pi},
832	{Inf(1), 0},
833	{Inf(1), +Pi},
834	{Inf(1), Inf(1)},
835	{Inf(1), NaN()},
836	{NaN(), NaN()},
837}
838var atan2SC = []float64{
839	-3 * Pi / 4,     // atan2(-Inf, -Inf)
840	-Pi / 2,         // atan2(-Inf, -Pi)
841	-Pi / 2,         // atan2(-Inf, +0)
842	-Pi / 2,         // atan2(-Inf, +Pi)
843	-Pi / 4,         // atan2(-Inf, +Inf)
844	NaN(),           // atan2(-Inf, NaN)
845	-Pi,             // atan2(-Pi, -Inf)
846	-Pi / 2,         // atan2(-Pi, +0)
847	Copysign(0, -1), // atan2(-Pi, Inf)
848	NaN(),           // atan2(-Pi, NaN)
849	-Pi,             // atan2(-0, -Inf)
850	-Pi,             // atan2(-0, -Pi)
851	-Pi,             // atan2(-0, -0)
852	Copysign(0, -1), // atan2(-0, +0)
853	Copysign(0, -1), // atan2(-0, +Pi)
854	Copysign(0, -1), // atan2(-0, +Inf)
855	NaN(),           // atan2(-0, NaN)
856	Pi,              // atan2(+0, -Inf)
857	Pi,              // atan2(+0, -Pi)
858	Pi,              // atan2(+0, -0)
859	0,               // atan2(+0, +0)
860	0,               // atan2(+0, +Pi)
861	0,               // atan2(+0, +Inf)
862	NaN(),           // atan2(+0, NaN)
863	Pi,              // atan2(+Pi, -Inf)
864	Pi / 2,          // atan2(+Pi, +0)
865	0,               // atan2(+Pi, +Inf)
866	NaN(),           // atan2(+Pi, NaN)
867	3 * Pi / 4,      // atan2(+Inf, -Inf)
868	Pi / 2,          // atan2(+Inf, -Pi)
869	Pi / 2,          // atan2(+Inf, +0)
870	Pi / 2,          // atan2(+Inf, +Pi)
871	Pi / 4,          // atan2(+Inf, +Inf)
872	NaN(),           // atan2(+Inf, NaN)
873	NaN(),           // atan2(NaN, NaN)
874}
875
876var vfcbrtSC = []float64{
877	Inf(-1),
878	Copysign(0, -1),
879	0,
880	Inf(1),
881	NaN(),
882}
883var cbrtSC = []float64{
884	Inf(-1),
885	Copysign(0, -1),
886	0,
887	Inf(1),
888	NaN(),
889}
890
891var vfceilSC = []float64{
892	Inf(-1),
893	Copysign(0, -1),
894	0,
895	Inf(1),
896	NaN(),
897}
898var ceilSC = []float64{
899	Inf(-1),
900	Copysign(0, -1),
901	0,
902	Inf(1),
903	NaN(),
904}
905
906var vfcopysignSC = []float64{
907	Inf(-1),
908	Inf(1),
909	NaN(),
910}
911var copysignSC = []float64{
912	Inf(-1),
913	Inf(-1),
914	NaN(),
915}
916
917var vfcosSC = []float64{
918	Inf(-1),
919	Inf(1),
920	NaN(),
921}
922var cosSC = []float64{
923	NaN(),
924	NaN(),
925	NaN(),
926}
927
928var vfcoshSC = []float64{
929	Inf(-1),
930	Copysign(0, -1),
931	0,
932	Inf(1),
933	NaN(),
934}
935var coshSC = []float64{
936	Inf(1),
937	1,
938	1,
939	Inf(1),
940	NaN(),
941}
942
943var vferfSC = []float64{
944	Inf(-1),
945	Copysign(0, -1),
946	0,
947	Inf(1),
948	NaN(),
949}
950var erfSC = []float64{
951	-1,
952	Copysign(0, -1),
953	0,
954	1,
955	NaN(),
956}
957
958var vferfcSC = []float64{
959	Inf(-1),
960	Inf(1),
961	NaN(),
962}
963var erfcSC = []float64{
964	2,
965	0,
966	NaN(),
967}
968
969var vferfinvSC = []float64{
970	1,
971	-1,
972	0,
973	Inf(-1),
974	Inf(1),
975	NaN(),
976}
977var erfinvSC = []float64{
978	Inf(+1),
979	Inf(-1),
980	0,
981	NaN(),
982	NaN(),
983	NaN(),
984}
985
986var vferfcinvSC = []float64{
987	0,
988	2,
989	1,
990	Inf(1),
991	Inf(-1),
992	NaN(),
993}
994var erfcinvSC = []float64{
995	Inf(+1),
996	Inf(-1),
997	0,
998	NaN(),
999	NaN(),
1000	NaN(),
1001}
1002
1003var vfexpSC = []float64{
1004	Inf(-1),
1005	-2000,
1006	2000,
1007	Inf(1),
1008	NaN(),
1009	// smallest float64 that overflows Exp(x)
1010	7.097827128933841e+02,
1011	// Issue 18912
1012	1.48852223e+09,
1013	1.4885222e+09,
1014	1,
1015}
1016var expSC = []float64{
1017	0,
1018	0,
1019	Inf(1),
1020	Inf(1),
1021	NaN(),
1022	Inf(1),
1023	Inf(1),
1024	Inf(1),
1025	2.718281828459045,
1026}
1027
1028var vfexp2SC = []float64{
1029	Inf(-1),
1030	-2000,
1031	2000,
1032	Inf(1),
1033	NaN(),
1034	// smallest float64 that overflows Exp2(x)
1035	1024,
1036}
1037var exp2SC = []float64{
1038	0,
1039	0,
1040	Inf(1),
1041	Inf(1),
1042	NaN(),
1043	Inf(1),
1044}
1045
1046var vfexpm1SC = []float64{
1047	Inf(-1),
1048	-710,
1049	Copysign(0, -1),
1050	0,
1051	710,
1052	Inf(1),
1053	NaN(),
1054}
1055var expm1SC = []float64{
1056	-1,
1057	-1,
1058	Copysign(0, -1),
1059	0,
1060	Inf(1),
1061	Inf(1),
1062	NaN(),
1063}
1064
1065var vffabsSC = []float64{
1066	Inf(-1),
1067	Copysign(0, -1),
1068	0,
1069	Inf(1),
1070	NaN(),
1071}
1072var fabsSC = []float64{
1073	Inf(1),
1074	0,
1075	0,
1076	Inf(1),
1077	NaN(),
1078}
1079
1080var vffdimSC = [][2]float64{
1081	{Inf(-1), Inf(-1)},
1082	{Inf(-1), Inf(1)},
1083	{Inf(-1), NaN()},
1084	{Copysign(0, -1), Copysign(0, -1)},
1085	{Copysign(0, -1), 0},
1086	{0, Copysign(0, -1)},
1087	{0, 0},
1088	{Inf(1), Inf(-1)},
1089	{Inf(1), Inf(1)},
1090	{Inf(1), NaN()},
1091	{NaN(), Inf(-1)},
1092	{NaN(), Copysign(0, -1)},
1093	{NaN(), 0},
1094	{NaN(), Inf(1)},
1095	{NaN(), NaN()},
1096}
1097var nan = Float64frombits(0xFFF8000000000000) // SSE2 DIVSD 0/0
1098var vffdim2SC = [][2]float64{
1099	{Inf(-1), Inf(-1)},
1100	{Inf(-1), Inf(1)},
1101	{Inf(-1), nan},
1102	{Copysign(0, -1), Copysign(0, -1)},
1103	{Copysign(0, -1), 0},
1104	{0, Copysign(0, -1)},
1105	{0, 0},
1106	{Inf(1), Inf(-1)},
1107	{Inf(1), Inf(1)},
1108	{Inf(1), nan},
1109	{nan, Inf(-1)},
1110	{nan, Copysign(0, -1)},
1111	{nan, 0},
1112	{nan, Inf(1)},
1113	{nan, nan},
1114}
1115var fdimSC = []float64{
1116	NaN(),
1117	0,
1118	NaN(),
1119	0,
1120	0,
1121	0,
1122	0,
1123	Inf(1),
1124	NaN(),
1125	NaN(),
1126	NaN(),
1127	NaN(),
1128	NaN(),
1129	NaN(),
1130	NaN(),
1131}
1132var fmaxSC = []float64{
1133	Inf(-1),
1134	Inf(1),
1135	NaN(),
1136	Copysign(0, -1),
1137	0,
1138	0,
1139	0,
1140	Inf(1),
1141	Inf(1),
1142	Inf(1),
1143	NaN(),
1144	NaN(),
1145	NaN(),
1146	Inf(1),
1147	NaN(),
1148}
1149var fminSC = []float64{
1150	Inf(-1),
1151	Inf(-1),
1152	Inf(-1),
1153	Copysign(0, -1),
1154	Copysign(0, -1),
1155	Copysign(0, -1),
1156	0,
1157	Inf(-1),
1158	Inf(1),
1159	NaN(),
1160	Inf(-1),
1161	NaN(),
1162	NaN(),
1163	NaN(),
1164	NaN(),
1165}
1166
1167var vffmodSC = [][2]float64{
1168	{Inf(-1), Inf(-1)},
1169	{Inf(-1), -Pi},
1170	{Inf(-1), 0},
1171	{Inf(-1), Pi},
1172	{Inf(-1), Inf(1)},
1173	{Inf(-1), NaN()},
1174	{-Pi, Inf(-1)},
1175	{-Pi, 0},
1176	{-Pi, Inf(1)},
1177	{-Pi, NaN()},
1178	{Copysign(0, -1), Inf(-1)},
1179	{Copysign(0, -1), 0},
1180	{Copysign(0, -1), Inf(1)},
1181	{Copysign(0, -1), NaN()},
1182	{0, Inf(-1)},
1183	{0, 0},
1184	{0, Inf(1)},
1185	{0, NaN()},
1186	{Pi, Inf(-1)},
1187	{Pi, 0},
1188	{Pi, Inf(1)},
1189	{Pi, NaN()},
1190	{Inf(1), Inf(-1)},
1191	{Inf(1), -Pi},
1192	{Inf(1), 0},
1193	{Inf(1), Pi},
1194	{Inf(1), Inf(1)},
1195	{Inf(1), NaN()},
1196	{NaN(), Inf(-1)},
1197	{NaN(), -Pi},
1198	{NaN(), 0},
1199	{NaN(), Pi},
1200	{NaN(), Inf(1)},
1201	{NaN(), NaN()},
1202}
1203var fmodSC = []float64{
1204	NaN(),           // fmod(-Inf, -Inf)
1205	NaN(),           // fmod(-Inf, -Pi)
1206	NaN(),           // fmod(-Inf, 0)
1207	NaN(),           // fmod(-Inf, Pi)
1208	NaN(),           // fmod(-Inf, +Inf)
1209	NaN(),           // fmod(-Inf, NaN)
1210	-Pi,             // fmod(-Pi, -Inf)
1211	NaN(),           // fmod(-Pi, 0)
1212	-Pi,             // fmod(-Pi, +Inf)
1213	NaN(),           // fmod(-Pi, NaN)
1214	Copysign(0, -1), // fmod(-0, -Inf)
1215	NaN(),           // fmod(-0, 0)
1216	Copysign(0, -1), // fmod(-0, Inf)
1217	NaN(),           // fmod(-0, NaN)
1218	0,               // fmod(0, -Inf)
1219	NaN(),           // fmod(0, 0)
1220	0,               // fmod(0, +Inf)
1221	NaN(),           // fmod(0, NaN)
1222	Pi,              // fmod(Pi, -Inf)
1223	NaN(),           // fmod(Pi, 0)
1224	Pi,              // fmod(Pi, +Inf)
1225	NaN(),           // fmod(Pi, NaN)
1226	NaN(),           // fmod(+Inf, -Inf)
1227	NaN(),           // fmod(+Inf, -Pi)
1228	NaN(),           // fmod(+Inf, 0)
1229	NaN(),           // fmod(+Inf, Pi)
1230	NaN(),           // fmod(+Inf, +Inf)
1231	NaN(),           // fmod(+Inf, NaN)
1232	NaN(),           // fmod(NaN, -Inf)
1233	NaN(),           // fmod(NaN, -Pi)
1234	NaN(),           // fmod(NaN, 0)
1235	NaN(),           // fmod(NaN, Pi)
1236	NaN(),           // fmod(NaN, +Inf)
1237	NaN(),           // fmod(NaN, NaN)
1238}
1239
1240var vffrexpSC = []float64{
1241	Inf(-1),
1242	Copysign(0, -1),
1243	0,
1244	Inf(1),
1245	NaN(),
1246}
1247var frexpSC = []fi{
1248	{Inf(-1), 0},
1249	{Copysign(0, -1), 0},
1250	{0, 0},
1251	{Inf(1), 0},
1252	{NaN(), 0},
1253}
1254
1255var vfgamma = [][2]float64{
1256	{Inf(1), Inf(1)},
1257	{Inf(-1), NaN()},
1258	{0, Inf(1)},
1259	{Copysign(0, -1), Inf(-1)},
1260	{NaN(), NaN()},
1261	{-1, NaN()},
1262	{-2, NaN()},
1263	{-3, NaN()},
1264	{-1e16, NaN()},
1265	{-1e300, NaN()},
1266	{1.7e308, Inf(1)},
1267
1268	// Test inputs inspired by Python test suite.
1269	// Outputs computed at high precision by PARI/GP.
1270	// If recomputing table entries, be careful to use
1271	// high-precision (%.1000g) formatting of the float64 inputs.
1272	// For example, -2.0000000000000004 is the float64 with exact value
1273	// -2.00000000000000044408920985626161695, and
1274	// gamma(-2.0000000000000004) = -1249999999999999.5386078562728167651513, while
1275	// gamma(-2.00000000000000044408920985626161695) = -1125899906826907.2044875028130093136826.
1276	// Thus the table lists -1.1258999068426235e+15 as the answer.
1277	{0.5, 1.772453850905516},
1278	{1.5, 0.886226925452758},
1279	{2.5, 1.329340388179137},
1280	{3.5, 3.3233509704478426},
1281	{-0.5, -3.544907701811032},
1282	{-1.5, 2.363271801207355},
1283	{-2.5, -0.9453087204829419},
1284	{-3.5, 0.2700882058522691},
1285	{0.1, 9.51350769866873},
1286	{0.01, 99.4325851191506},
1287	{1e-08, 9.999999942278434e+07},
1288	{1e-16, 1e+16},
1289	{0.001, 999.4237724845955},
1290	{1e-16, 1e+16},
1291	{1e-308, 1e+308},
1292	{5.6e-309, 1.7857142857142864e+308},
1293	{5.5e-309, Inf(1)},
1294	{1e-309, Inf(1)},
1295	{1e-323, Inf(1)},
1296	{5e-324, Inf(1)},
1297	{-0.1, -10.686287021193193},
1298	{-0.01, -100.58719796441078},
1299	{-1e-08, -1.0000000057721567e+08},
1300	{-1e-16, -1e+16},
1301	{-0.001, -1000.5782056293586},
1302	{-1e-16, -1e+16},
1303	{-1e-308, -1e+308},
1304	{-5.6e-309, -1.7857142857142864e+308},
1305	{-5.5e-309, Inf(-1)},
1306	{-1e-309, Inf(-1)},
1307	{-1e-323, Inf(-1)},
1308	{-5e-324, Inf(-1)},
1309	{-0.9999999999999999, -9.007199254740992e+15},
1310	{-1.0000000000000002, 4.5035996273704955e+15},
1311	{-1.9999999999999998, 2.2517998136852485e+15},
1312	{-2.0000000000000004, -1.1258999068426235e+15},
1313	{-100.00000000000001, -7.540083334883109e-145},
1314	{-99.99999999999999, 7.540083334884096e-145},
1315	{17, 2.0922789888e+13},
1316	{171, 7.257415615307999e+306},
1317	{171.6, 1.5858969096672565e+308},
1318	{171.624, 1.7942117599248104e+308},
1319	{171.625, Inf(1)},
1320	{172, Inf(1)},
1321	{2000, Inf(1)},
1322	{-100.5, -3.3536908198076787e-159},
1323	{-160.5, -5.255546447007829e-286},
1324	{-170.5, -3.3127395215386074e-308},
1325	{-171.5, 1.9316265431712e-310},
1326	{-176.5, -1.196e-321},
1327	{-177.5, 5e-324},
1328	{-178.5, Copysign(0, -1)},
1329	{-179.5, 0},
1330	{-201.0001, 0},
1331	{-202.9999, Copysign(0, -1)},
1332	{-1000.5, Copysign(0, -1)},
1333	{-1.0000000003e+09, Copysign(0, -1)},
1334	{-4.5035996273704955e+15, 0},
1335	{-63.349078729022985, 4.177797167776188e-88},
1336	{-127.45117632943295, 1.183111089623681e-214},
1337}
1338
1339var vfhypotSC = [][2]float64{
1340	{Inf(-1), Inf(-1)},
1341	{Inf(-1), 0},
1342	{Inf(-1), Inf(1)},
1343	{Inf(-1), NaN()},
1344	{Copysign(0, -1), Copysign(0, -1)},
1345	{Copysign(0, -1), 0},
1346	{0, Copysign(0, -1)},
1347	{0, 0}, // +0, +0
1348	{0, Inf(-1)},
1349	{0, Inf(1)},
1350	{0, NaN()},
1351	{Inf(1), Inf(-1)},
1352	{Inf(1), 0},
1353	{Inf(1), Inf(1)},
1354	{Inf(1), NaN()},
1355	{NaN(), Inf(-1)},
1356	{NaN(), 0},
1357	{NaN(), Inf(1)},
1358	{NaN(), NaN()},
1359}
1360var hypotSC = []float64{
1361	Inf(1),
1362	Inf(1),
1363	Inf(1),
1364	Inf(1),
1365	0,
1366	0,
1367	0,
1368	0,
1369	Inf(1),
1370	Inf(1),
1371	NaN(),
1372	Inf(1),
1373	Inf(1),
1374	Inf(1),
1375	Inf(1),
1376	Inf(1),
1377	NaN(),
1378	Inf(1),
1379	NaN(),
1380}
1381
1382var ilogbSC = []int{
1383	MaxInt32,
1384	MinInt32,
1385	MaxInt32,
1386	MaxInt32,
1387}
1388
1389var vfj0SC = []float64{
1390	Inf(-1),
1391	0,
1392	Inf(1),
1393	NaN(),
1394}
1395var j0SC = []float64{
1396	0,
1397	1,
1398	0,
1399	NaN(),
1400}
1401var j1SC = []float64{
1402	0,
1403	0,
1404	0,
1405	NaN(),
1406}
1407var j2SC = []float64{
1408	0,
1409	0,
1410	0,
1411	NaN(),
1412}
1413var jM3SC = []float64{
1414	0,
1415	0,
1416	0,
1417	NaN(),
1418}
1419
1420var vfldexpSC = []fi{
1421	{0, 0},
1422	{0, -1075},
1423	{0, 1024},
1424	{Copysign(0, -1), 0},
1425	{Copysign(0, -1), -1075},
1426	{Copysign(0, -1), 1024},
1427	{Inf(1), 0},
1428	{Inf(1), -1024},
1429	{Inf(-1), 0},
1430	{Inf(-1), -1024},
1431	{NaN(), -1024},
1432	{10, int(1) << (uint64(unsafe.Sizeof(0)-1) * 8)},
1433	{10, -(int(1) << (uint64(unsafe.Sizeof(0)-1) * 8))},
1434}
1435var ldexpSC = []float64{
1436	0,
1437	0,
1438	0,
1439	Copysign(0, -1),
1440	Copysign(0, -1),
1441	Copysign(0, -1),
1442	Inf(1),
1443	Inf(1),
1444	Inf(-1),
1445	Inf(-1),
1446	NaN(),
1447	Inf(1),
1448	0,
1449}
1450
1451var vflgammaSC = []float64{
1452	Inf(-1),
1453	-3,
1454	0,
1455	1,
1456	2,
1457	Inf(1),
1458	NaN(),
1459}
1460var lgammaSC = []fi{
1461	{Inf(-1), 1},
1462	{Inf(1), 1},
1463	{Inf(1), 1},
1464	{0, 1},
1465	{0, 1},
1466	{Inf(1), 1},
1467	{NaN(), 1},
1468}
1469
1470var vflogSC = []float64{
1471	Inf(-1),
1472	-Pi,
1473	Copysign(0, -1),
1474	0,
1475	1,
1476	Inf(1),
1477	NaN(),
1478}
1479var logSC = []float64{
1480	NaN(),
1481	NaN(),
1482	Inf(-1),
1483	Inf(-1),
1484	0,
1485	Inf(1),
1486	NaN(),
1487}
1488
1489var vflogbSC = []float64{
1490	Inf(-1),
1491	0,
1492	Inf(1),
1493	NaN(),
1494}
1495var logbSC = []float64{
1496	Inf(1),
1497	Inf(-1),
1498	Inf(1),
1499	NaN(),
1500}
1501
1502var vflog1pSC = []float64{
1503	Inf(-1),
1504	-Pi,
1505	-1,
1506	Copysign(0, -1),
1507	0,
1508	Inf(1),
1509	NaN(),
1510}
1511var log1pSC = []float64{
1512	NaN(),
1513	NaN(),
1514	Inf(-1),
1515	Copysign(0, -1),
1516	0,
1517	Inf(1),
1518	NaN(),
1519}
1520
1521var vfmodfSC = []float64{
1522	Inf(-1),
1523	Copysign(0, -1),
1524	Inf(1),
1525	NaN(),
1526}
1527var modfSC = [][2]float64{
1528	{Inf(-1), NaN()}, // [2]float64{Copysign(0, -1), Inf(-1)},
1529	{Copysign(0, -1), Copysign(0, -1)},
1530	{Inf(1), NaN()}, // [2]float64{0, Inf(1)},
1531	{NaN(), NaN()},
1532}
1533
1534var vfnextafter32SC = [][2]float32{
1535	{0, 0},
1536	{0, float32(Copysign(0, -1))},
1537	{0, -1},
1538	{0, float32(NaN())},
1539	{float32(Copysign(0, -1)), 1},
1540	{float32(Copysign(0, -1)), 0},
1541	{float32(Copysign(0, -1)), float32(Copysign(0, -1))},
1542	{float32(Copysign(0, -1)), -1},
1543	{float32(NaN()), 0},
1544	{float32(NaN()), float32(NaN())},
1545}
1546var nextafter32SC = []float32{
1547	0,
1548	0,
1549	-1.401298464e-45, // Float32frombits(0x80000001)
1550	float32(NaN()),
1551	1.401298464e-45, // Float32frombits(0x00000001)
1552	float32(Copysign(0, -1)),
1553	float32(Copysign(0, -1)),
1554	-1.401298464e-45, // Float32frombits(0x80000001)
1555	float32(NaN()),
1556	float32(NaN()),
1557}
1558
1559var vfnextafter64SC = [][2]float64{
1560	{0, 0},
1561	{0, Copysign(0, -1)},
1562	{0, -1},
1563	{0, NaN()},
1564	{Copysign(0, -1), 1},
1565	{Copysign(0, -1), 0},
1566	{Copysign(0, -1), Copysign(0, -1)},
1567	{Copysign(0, -1), -1},
1568	{NaN(), 0},
1569	{NaN(), NaN()},
1570}
1571var nextafter64SC = []float64{
1572	0,
1573	0,
1574	-4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1575	NaN(),
1576	4.9406564584124654418e-324, // Float64frombits(0x0000000000000001)
1577	Copysign(0, -1),
1578	Copysign(0, -1),
1579	-4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1580	NaN(),
1581	NaN(),
1582}
1583
1584var vfpowSC = [][2]float64{
1585	{Inf(-1), -Pi},
1586	{Inf(-1), -3},
1587	{Inf(-1), Copysign(0, -1)},
1588	{Inf(-1), 0},
1589	{Inf(-1), 1},
1590	{Inf(-1), 3},
1591	{Inf(-1), Pi},
1592	{Inf(-1), 0.5},
1593	{Inf(-1), NaN()},
1594
1595	{-Pi, Inf(-1)},
1596	{-Pi, -Pi},
1597	{-Pi, Copysign(0, -1)},
1598	{-Pi, 0},
1599	{-Pi, 1},
1600	{-Pi, Pi},
1601	{-Pi, Inf(1)},
1602	{-Pi, NaN()},
1603
1604	{-1, Inf(-1)},
1605	{-1, Inf(1)},
1606	{-1, NaN()},
1607	{-1 / 2, Inf(-1)},
1608	{-1 / 2, Inf(1)},
1609	{Copysign(0, -1), Inf(-1)},
1610	{Copysign(0, -1), -Pi},
1611	{Copysign(0, -1), -0.5},
1612	{Copysign(0, -1), -3},
1613	{Copysign(0, -1), 3},
1614	{Copysign(0, -1), Pi},
1615	{Copysign(0, -1), 0.5},
1616	{Copysign(0, -1), Inf(1)},
1617
1618	{0, Inf(-1)},
1619	{0, -Pi},
1620	{0, -3},
1621	{0, Copysign(0, -1)},
1622	{0, 0},
1623	{0, 3},
1624	{0, Pi},
1625	{0, Inf(1)},
1626	{0, NaN()},
1627
1628	{1 / 2, Inf(-1)},
1629	{1 / 2, Inf(1)},
1630	{1, Inf(-1)},
1631	{1, Inf(1)},
1632	{1, NaN()},
1633
1634	{Pi, Inf(-1)},
1635	{Pi, Copysign(0, -1)},
1636	{Pi, 0},
1637	{Pi, 1},
1638	{Pi, Inf(1)},
1639	{Pi, NaN()},
1640	{Inf(1), -Pi},
1641	{Inf(1), Copysign(0, -1)},
1642	{Inf(1), 0},
1643	{Inf(1), 1},
1644	{Inf(1), Pi},
1645	{Inf(1), NaN()},
1646	{NaN(), -Pi},
1647	{NaN(), Copysign(0, -1)},
1648	{NaN(), 0},
1649	{NaN(), 1},
1650	{NaN(), Pi},
1651	{NaN(), NaN()},
1652
1653	// Issue #7394 overflow checks
1654	{2, float64(1 << 32)},
1655	{2, -float64(1 << 32)},
1656	{-2, float64(1<<32 + 1)},
1657	{1 / 2, float64(1 << 45)},
1658	{1 / 2, -float64(1 << 45)},
1659	{Nextafter(1, 2), float64(1 << 63)},
1660	{Nextafter(1, -2), float64(1 << 63)},
1661	{Nextafter(-1, 2), float64(1 << 63)},
1662	{Nextafter(-1, -2), float64(1 << 63)},
1663}
1664var powSC = []float64{
1665	0,               // pow(-Inf, -Pi)
1666	Copysign(0, -1), // pow(-Inf, -3)
1667	1,               // pow(-Inf, -0)
1668	1,               // pow(-Inf, +0)
1669	Inf(-1),         // pow(-Inf, 1)
1670	Inf(-1),         // pow(-Inf, 3)
1671	Inf(1),          // pow(-Inf, Pi)
1672	Inf(1),          // pow(-Inf, 0.5)
1673	NaN(),           // pow(-Inf, NaN)
1674	0,               // pow(-Pi, -Inf)
1675	NaN(),           // pow(-Pi, -Pi)
1676	1,               // pow(-Pi, -0)
1677	1,               // pow(-Pi, +0)
1678	-Pi,             // pow(-Pi, 1)
1679	NaN(),           // pow(-Pi, Pi)
1680	Inf(1),          // pow(-Pi, +Inf)
1681	NaN(),           // pow(-Pi, NaN)
1682	1,               // pow(-1, -Inf) IEEE 754-2008
1683	1,               // pow(-1, +Inf) IEEE 754-2008
1684	NaN(),           // pow(-1, NaN)
1685	Inf(1),          // pow(-1/2, -Inf)
1686	0,               // pow(-1/2, +Inf)
1687	Inf(1),          // pow(-0, -Inf)
1688	Inf(1),          // pow(-0, -Pi)
1689	Inf(1),          // pow(-0, -0.5)
1690	Inf(-1),         // pow(-0, -3) IEEE 754-2008
1691	Copysign(0, -1), // pow(-0, 3) IEEE 754-2008
1692	0,               // pow(-0, +Pi)
1693	0,               // pow(-0, 0.5)
1694	0,               // pow(-0, +Inf)
1695	Inf(1),          // pow(+0, -Inf)
1696	Inf(1),          // pow(+0, -Pi)
1697	Inf(1),          // pow(+0, -3)
1698	1,               // pow(+0, -0)
1699	1,               // pow(+0, +0)
1700	0,               // pow(+0, 3)
1701	0,               // pow(+0, +Pi)
1702	0,               // pow(+0, +Inf)
1703	NaN(),           // pow(+0, NaN)
1704	Inf(1),          // pow(1/2, -Inf)
1705	0,               // pow(1/2, +Inf)
1706	1,               // pow(1, -Inf) IEEE 754-2008
1707	1,               // pow(1, +Inf) IEEE 754-2008
1708	1,               // pow(1, NaN) IEEE 754-2008
1709	0,               // pow(+Pi, -Inf)
1710	1,               // pow(+Pi, -0)
1711	1,               // pow(+Pi, +0)
1712	Pi,              // pow(+Pi, 1)
1713	Inf(1),          // pow(+Pi, +Inf)
1714	NaN(),           // pow(+Pi, NaN)
1715	0,               // pow(+Inf, -Pi)
1716	1,               // pow(+Inf, -0)
1717	1,               // pow(+Inf, +0)
1718	Inf(1),          // pow(+Inf, 1)
1719	Inf(1),          // pow(+Inf, Pi)
1720	NaN(),           // pow(+Inf, NaN)
1721	NaN(),           // pow(NaN, -Pi)
1722	1,               // pow(NaN, -0)
1723	1,               // pow(NaN, +0)
1724	NaN(),           // pow(NaN, 1)
1725	NaN(),           // pow(NaN, +Pi)
1726	NaN(),           // pow(NaN, NaN)
1727
1728	// Issue #7394 overflow checks
1729	Inf(1),  // pow(2, float64(1 << 32))
1730	0,       // pow(2, -float64(1 << 32))
1731	Inf(-1), // pow(-2, float64(1<<32 + 1))
1732	0,       // pow(1/2, float64(1 << 45))
1733	Inf(1),  // pow(1/2, -float64(1 << 45))
1734	Inf(1),  // pow(Nextafter(1, 2), float64(1 << 63))
1735	0,       // pow(Nextafter(1, -2), float64(1 << 63))
1736	0,       // pow(Nextafter(-1, 2), float64(1 << 63))
1737	Inf(1),  // pow(Nextafter(-1, -2), float64(1 << 63))
1738}
1739
1740var vfpow10SC = []int{
1741	MinInt32,
1742	-324,
1743	-323,
1744	-50,
1745	-22,
1746	-1,
1747	0,
1748	1,
1749	22,
1750	50,
1751	100,
1752	200,
1753	308,
1754	309,
1755	MaxInt32,
1756}
1757
1758var pow10SC = []float64{
1759	0,        // pow10(MinInt32)
1760	0,        // pow10(-324)
1761	1.0e-323, // pow10(-323)
1762	1.0e-50,  // pow10(-50)
1763	1.0e-22,  // pow10(-22)
1764	1.0e-1,   // pow10(-1)
1765	1.0e0,    // pow10(0)
1766	1.0e1,    // pow10(1)
1767	1.0e22,   // pow10(22)
1768	1.0e50,   // pow10(50)
1769	1.0e100,  // pow10(100)
1770	1.0e200,  // pow10(200)
1771	1.0e308,  // pow10(308)
1772	Inf(1),   // pow10(309)
1773	Inf(1),   // pow10(MaxInt32)
1774}
1775
1776var vfroundSC = [][2]float64{
1777	{0, 0},
1778	{1.390671161567e-309, 0}, // denormal
1779	{0.49999999999999994, 0}, // 0.5-epsilon
1780	{0.5, 1},
1781	{0.5000000000000001, 1}, // 0.5+epsilon
1782	{-1.5, -2},
1783	{-2.5, -3},
1784	{NaN(), NaN()},
1785	{Inf(1), Inf(1)},
1786	{2251799813685249.5, 2251799813685250}, // 1 bit fraction
1787	{2251799813685250.5, 2251799813685251},
1788	{4503599627370495.5, 4503599627370496}, // 1 bit fraction, rounding to 0 bit fraction
1789	{4503599627370497, 4503599627370497},   // large integer
1790}
1791var vfroundEvenSC = [][2]float64{
1792	{0, 0},
1793	{1.390671161567e-309, 0}, // denormal
1794	{0.49999999999999994, 0}, // 0.5-epsilon
1795	{0.5, 0},
1796	{0.5000000000000001, 1}, // 0.5+epsilon
1797	{-1.5, -2},
1798	{-2.5, -2},
1799	{NaN(), NaN()},
1800	{Inf(1), Inf(1)},
1801	{2251799813685249.5, 2251799813685250}, // 1 bit fraction
1802	{2251799813685250.5, 2251799813685250},
1803	{4503599627370495.5, 4503599627370496}, // 1 bit fraction, rounding to 0 bit fraction
1804	{4503599627370497, 4503599627370497},   // large integer
1805}
1806
1807var vfsignbitSC = []float64{
1808	Inf(-1),
1809	Copysign(0, -1),
1810	0,
1811	Inf(1),
1812	NaN(),
1813}
1814var signbitSC = []bool{
1815	true,
1816	true,
1817	false,
1818	false,
1819	false,
1820}
1821
1822var vfsinSC = []float64{
1823	Inf(-1),
1824	Copysign(0, -1),
1825	0,
1826	Inf(1),
1827	NaN(),
1828}
1829var sinSC = []float64{
1830	NaN(),
1831	Copysign(0, -1),
1832	0,
1833	NaN(),
1834	NaN(),
1835}
1836
1837var vfsinhSC = []float64{
1838	Inf(-1),
1839	Copysign(0, -1),
1840	0,
1841	Inf(1),
1842	NaN(),
1843}
1844var sinhSC = []float64{
1845	Inf(-1),
1846	Copysign(0, -1),
1847	0,
1848	Inf(1),
1849	NaN(),
1850}
1851
1852var vfsqrtSC = []float64{
1853	Inf(-1),
1854	-Pi,
1855	Copysign(0, -1),
1856	0,
1857	Inf(1),
1858	NaN(),
1859	Float64frombits(2), // subnormal; see https://golang.org/issue/13013
1860}
1861var sqrtSC = []float64{
1862	NaN(),
1863	NaN(),
1864	Copysign(0, -1),
1865	0,
1866	Inf(1),
1867	NaN(),
1868	3.1434555694052576e-162,
1869}
1870
1871var vftanhSC = []float64{
1872	Inf(-1),
1873	Copysign(0, -1),
1874	0,
1875	Inf(1),
1876	NaN(),
1877}
1878var tanhSC = []float64{
1879	-1,
1880	Copysign(0, -1),
1881	0,
1882	1,
1883	NaN(),
1884}
1885
1886var vfy0SC = []float64{
1887	Inf(-1),
1888	0,
1889	Inf(1),
1890	NaN(),
1891	-1,
1892}
1893var y0SC = []float64{
1894	NaN(),
1895	Inf(-1),
1896	0,
1897	NaN(),
1898	NaN(),
1899}
1900var y1SC = []float64{
1901	NaN(),
1902	Inf(-1),
1903	0,
1904	NaN(),
1905	NaN(),
1906}
1907var y2SC = []float64{
1908	NaN(),
1909	Inf(-1),
1910	0,
1911	NaN(),
1912	NaN(),
1913}
1914var yM3SC = []float64{
1915	NaN(),
1916	Inf(1),
1917	0,
1918	NaN(),
1919	NaN(),
1920}
1921
1922// arguments and expected results for boundary cases
1923const (
1924	SmallestNormalFloat64   = 2.2250738585072014e-308 // 2**-1022
1925	LargestSubnormalFloat64 = SmallestNormalFloat64 - SmallestNonzeroFloat64
1926)
1927
1928var vffrexpBC = []float64{
1929	SmallestNormalFloat64,
1930	LargestSubnormalFloat64,
1931	SmallestNonzeroFloat64,
1932	MaxFloat64,
1933	-SmallestNormalFloat64,
1934	-LargestSubnormalFloat64,
1935	-SmallestNonzeroFloat64,
1936	-MaxFloat64,
1937}
1938var frexpBC = []fi{
1939	{0.5, -1021},
1940	{0.99999999999999978, -1022},
1941	{0.5, -1073},
1942	{0.99999999999999989, 1024},
1943	{-0.5, -1021},
1944	{-0.99999999999999978, -1022},
1945	{-0.5, -1073},
1946	{-0.99999999999999989, 1024},
1947}
1948
1949var vfldexpBC = []fi{
1950	{SmallestNormalFloat64, -52},
1951	{LargestSubnormalFloat64, -51},
1952	{SmallestNonzeroFloat64, 1074},
1953	{MaxFloat64, -(1023 + 1074)},
1954	{1, -1075},
1955	{-1, -1075},
1956	{1, 1024},
1957	{-1, 1024},
1958}
1959var ldexpBC = []float64{
1960	SmallestNonzeroFloat64,
1961	1e-323, // 2**-1073
1962	1,
1963	1e-323, // 2**-1073
1964	0,
1965	Copysign(0, -1),
1966	Inf(1),
1967	Inf(-1),
1968}
1969
1970var logbBC = []float64{
1971	-1022,
1972	-1023,
1973	-1074,
1974	1023,
1975	-1022,
1976	-1023,
1977	-1074,
1978	1023,
1979}
1980
1981func tolerance(a, b, e float64) bool {
1982	// Multiplying by e here can underflow denormal values to zero.
1983	// Check a==b so that at least if a and b are small and identical
1984	// we say they match.
1985	if a == b {
1986		return true
1987	}
1988	d := a - b
1989	if d < 0 {
1990		d = -d
1991	}
1992
1993	// note: b is correct (expected) value, a is actual value.
1994	// make error tolerance a fraction of b, not a.
1995	if b != 0 {
1996		e = e * b
1997		if e < 0 {
1998			e = -e
1999		}
2000	}
2001	return d < e
2002}
2003func close(a, b float64) bool      { return tolerance(a, b, 1e-14) }
2004func veryclose(a, b float64) bool  { return tolerance(a, b, 4e-16) }
2005func soclose(a, b, e float64) bool { return tolerance(a, b, e) }
2006func alike(a, b float64) bool {
2007	switch {
2008	case IsNaN(a) && IsNaN(b):
2009		return true
2010	case a == b:
2011		return Signbit(a) == Signbit(b)
2012	}
2013	return false
2014}
2015
2016func TestNaN(t *testing.T) {
2017	f64 := NaN()
2018	if f64 == f64 {
2019		t.Fatalf("NaN() returns %g, expected NaN", f64)
2020	}
2021	f32 := float32(f64)
2022	if f32 == f32 {
2023		t.Fatalf("float32(NaN()) is %g, expected NaN", f32)
2024	}
2025}
2026
2027func TestAcos(t *testing.T) {
2028	for i := 0; i < len(vf); i++ {
2029		a := vf[i] / 10
2030		if f := Acos(a); !close(acos[i], f) {
2031			t.Errorf("Acos(%g) = %g, want %g", a, f, acos[i])
2032		}
2033	}
2034	for i := 0; i < len(vfacosSC); i++ {
2035		if f := Acos(vfacosSC[i]); !alike(acosSC[i], f) {
2036			t.Errorf("Acos(%g) = %g, want %g", vfacosSC[i], f, acosSC[i])
2037		}
2038	}
2039}
2040
2041func TestAcosh(t *testing.T) {
2042	for i := 0; i < len(vf); i++ {
2043		a := 1 + Abs(vf[i])
2044		if f := Acosh(a); !veryclose(acosh[i], f) {
2045			t.Errorf("Acosh(%g) = %g, want %g", a, f, acosh[i])
2046		}
2047	}
2048	for i := 0; i < len(vfacoshSC); i++ {
2049		if f := Acosh(vfacoshSC[i]); !alike(acoshSC[i], f) {
2050			t.Errorf("Acosh(%g) = %g, want %g", vfacoshSC[i], f, acoshSC[i])
2051		}
2052	}
2053}
2054
2055func TestAsin(t *testing.T) {
2056	for i := 0; i < len(vf); i++ {
2057		a := vf[i] / 10
2058		if f := Asin(a); !veryclose(asin[i], f) {
2059			t.Errorf("Asin(%g) = %g, want %g", a, f, asin[i])
2060		}
2061	}
2062	for i := 0; i < len(vfasinSC); i++ {
2063		if f := Asin(vfasinSC[i]); !alike(asinSC[i], f) {
2064			t.Errorf("Asin(%g) = %g, want %g", vfasinSC[i], f, asinSC[i])
2065		}
2066	}
2067}
2068
2069func TestAsinh(t *testing.T) {
2070	for i := 0; i < len(vf); i++ {
2071		if f := Asinh(vf[i]); !veryclose(asinh[i], f) {
2072			t.Errorf("Asinh(%g) = %g, want %g", vf[i], f, asinh[i])
2073		}
2074	}
2075	for i := 0; i < len(vfasinhSC); i++ {
2076		if f := Asinh(vfasinhSC[i]); !alike(asinhSC[i], f) {
2077			t.Errorf("Asinh(%g) = %g, want %g", vfasinhSC[i], f, asinhSC[i])
2078		}
2079	}
2080}
2081
2082func TestAtan(t *testing.T) {
2083	for i := 0; i < len(vf); i++ {
2084		if f := Atan(vf[i]); !veryclose(atan[i], f) {
2085			t.Errorf("Atan(%g) = %g, want %g", vf[i], f, atan[i])
2086		}
2087	}
2088	for i := 0; i < len(vfatanSC); i++ {
2089		if f := Atan(vfatanSC[i]); !alike(atanSC[i], f) {
2090			t.Errorf("Atan(%g) = %g, want %g", vfatanSC[i], f, atanSC[i])
2091		}
2092	}
2093}
2094
2095func TestAtanh(t *testing.T) {
2096	for i := 0; i < len(vf); i++ {
2097		a := vf[i] / 10
2098		if f := Atanh(a); !veryclose(atanh[i], f) {
2099			t.Errorf("Atanh(%g) = %g, want %g", a, f, atanh[i])
2100		}
2101	}
2102	for i := 0; i < len(vfatanhSC); i++ {
2103		if f := Atanh(vfatanhSC[i]); !alike(atanhSC[i], f) {
2104			t.Errorf("Atanh(%g) = %g, want %g", vfatanhSC[i], f, atanhSC[i])
2105		}
2106	}
2107}
2108
2109func TestAtan2(t *testing.T) {
2110	for i := 0; i < len(vf); i++ {
2111		if f := Atan2(10, vf[i]); !veryclose(atan2[i], f) {
2112			t.Errorf("Atan2(10, %g) = %g, want %g", vf[i], f, atan2[i])
2113		}
2114	}
2115	for i := 0; i < len(vfatan2SC); i++ {
2116		if f := Atan2(vfatan2SC[i][0], vfatan2SC[i][1]); !alike(atan2SC[i], f) {
2117			t.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC[i][0], vfatan2SC[i][1], f, atan2SC[i])
2118		}
2119	}
2120}
2121
2122func TestCbrt(t *testing.T) {
2123	for i := 0; i < len(vf); i++ {
2124		if f := Cbrt(vf[i]); !veryclose(cbrt[i], f) {
2125			t.Errorf("Cbrt(%g) = %g, want %g", vf[i], f, cbrt[i])
2126		}
2127	}
2128	for i := 0; i < len(vfcbrtSC); i++ {
2129		if f := Cbrt(vfcbrtSC[i]); !alike(cbrtSC[i], f) {
2130			t.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC[i], f, cbrtSC[i])
2131		}
2132	}
2133}
2134
2135func TestCeil(t *testing.T) {
2136	for i := 0; i < len(vf); i++ {
2137		if f := Ceil(vf[i]); !alike(ceil[i], f) {
2138			t.Errorf("Ceil(%g) = %g, want %g", vf[i], f, ceil[i])
2139		}
2140	}
2141	for i := 0; i < len(vfceilSC); i++ {
2142		if f := Ceil(vfceilSC[i]); !alike(ceilSC[i], f) {
2143			t.Errorf("Ceil(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2144		}
2145	}
2146}
2147
2148func TestCopysign(t *testing.T) {
2149	for i := 0; i < len(vf); i++ {
2150		if f := Copysign(vf[i], -1); copysign[i] != f {
2151			t.Errorf("Copysign(%g, -1) = %g, want %g", vf[i], f, copysign[i])
2152		}
2153	}
2154	for i := 0; i < len(vf); i++ {
2155		if f := Copysign(vf[i], 1); -copysign[i] != f {
2156			t.Errorf("Copysign(%g, 1) = %g, want %g", vf[i], f, -copysign[i])
2157		}
2158	}
2159	for i := 0; i < len(vfcopysignSC); i++ {
2160		if f := Copysign(vfcopysignSC[i], -1); !alike(copysignSC[i], f) {
2161			t.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC[i], f, copysignSC[i])
2162		}
2163	}
2164}
2165
2166func TestCos(t *testing.T) {
2167	for i := 0; i < len(vf); i++ {
2168		if f := Cos(vf[i]); !veryclose(cos[i], f) {
2169			t.Errorf("Cos(%g) = %g, want %g", vf[i], f, cos[i])
2170		}
2171	}
2172	for i := 0; i < len(vfcosSC); i++ {
2173		if f := Cos(vfcosSC[i]); !alike(cosSC[i], f) {
2174			t.Errorf("Cos(%g) = %g, want %g", vfcosSC[i], f, cosSC[i])
2175		}
2176	}
2177}
2178
2179func TestCosh(t *testing.T) {
2180	for i := 0; i < len(vf); i++ {
2181		if f := Cosh(vf[i]); !close(cosh[i], f) {
2182			t.Errorf("Cosh(%g) = %g, want %g", vf[i], f, cosh[i])
2183		}
2184	}
2185	for i := 0; i < len(vfcoshSC); i++ {
2186		if f := Cosh(vfcoshSC[i]); !alike(coshSC[i], f) {
2187			t.Errorf("Cosh(%g) = %g, want %g", vfcoshSC[i], f, coshSC[i])
2188		}
2189	}
2190}
2191
2192func TestErf(t *testing.T) {
2193	for i := 0; i < len(vf); i++ {
2194		a := vf[i] / 10
2195		if f := Erf(a); !veryclose(erf[i], f) {
2196			t.Errorf("Erf(%g) = %g, want %g", a, f, erf[i])
2197		}
2198	}
2199	for i := 0; i < len(vferfSC); i++ {
2200		if f := Erf(vferfSC[i]); !alike(erfSC[i], f) {
2201			t.Errorf("Erf(%g) = %g, want %g", vferfSC[i], f, erfSC[i])
2202		}
2203	}
2204}
2205
2206func TestErfc(t *testing.T) {
2207	for i := 0; i < len(vf); i++ {
2208		a := vf[i] / 10
2209		if f := Erfc(a); !veryclose(erfc[i], f) {
2210			t.Errorf("Erfc(%g) = %g, want %g", a, f, erfc[i])
2211		}
2212	}
2213	for i := 0; i < len(vferfcSC); i++ {
2214		if f := Erfc(vferfcSC[i]); !alike(erfcSC[i], f) {
2215			t.Errorf("Erfc(%g) = %g, want %g", vferfcSC[i], f, erfcSC[i])
2216		}
2217	}
2218}
2219
2220func TestErfinv(t *testing.T) {
2221	for i := 0; i < len(vf); i++ {
2222		a := vf[i] / 10
2223		if f := Erfinv(a); !veryclose(erfinv[i], f) {
2224			t.Errorf("Erfinv(%g) = %g, want %g", a, f, erfinv[i])
2225		}
2226	}
2227	for i := 0; i < len(vferfinvSC); i++ {
2228		if f := Erfinv(vferfinvSC[i]); !alike(erfinvSC[i], f) {
2229			t.Errorf("Erfinv(%g) = %g, want %g", vferfinvSC[i], f, erfinvSC[i])
2230		}
2231	}
2232	for x := -0.9; x <= 0.90; x += 1e-2 {
2233		if f := Erf(Erfinv(x)); !close(x, f) {
2234			t.Errorf("Erf(Erfinv(%g)) = %g, want %g", x, f, x)
2235		}
2236	}
2237	for x := -0.9; x <= 0.90; x += 1e-2 {
2238		if f := Erfinv(Erf(x)); !close(x, f) {
2239			t.Errorf("Erfinv(Erf(%g)) = %g, want %g", x, f, x)
2240		}
2241	}
2242}
2243
2244func TestErfcinv(t *testing.T) {
2245	for i := 0; i < len(vf); i++ {
2246		a := 1.0 - (vf[i] / 10)
2247		if f := Erfcinv(a); !veryclose(erfinv[i], f) {
2248			t.Errorf("Erfcinv(%g) = %g, want %g", a, f, erfinv[i])
2249		}
2250	}
2251	for i := 0; i < len(vferfcinvSC); i++ {
2252		if f := Erfcinv(vferfcinvSC[i]); !alike(erfcinvSC[i], f) {
2253			t.Errorf("Erfcinv(%g) = %g, want %g", vferfcinvSC[i], f, erfcinvSC[i])
2254		}
2255	}
2256	for x := 0.1; x <= 1.9; x += 1e-2 {
2257		if f := Erfc(Erfcinv(x)); !close(x, f) {
2258			t.Errorf("Erfc(Erfcinv(%g)) = %g, want %g", x, f, x)
2259		}
2260	}
2261	for x := 0.1; x <= 1.9; x += 1e-2 {
2262		if f := Erfcinv(Erfc(x)); !close(x, f) {
2263			t.Errorf("Erfcinv(Erfc(%g)) = %g, want %g", x, f, x)
2264		}
2265	}
2266}
2267
2268func TestExp(t *testing.T) {
2269	testExp(t, Exp, "Exp")
2270	testExp(t, ExpGo, "ExpGo")
2271}
2272
2273func testExp(t *testing.T, Exp func(float64) float64, name string) {
2274	for i := 0; i < len(vf); i++ {
2275		if f := Exp(vf[i]); !veryclose(exp[i], f) {
2276			t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp[i])
2277		}
2278	}
2279	for i := 0; i < len(vfexpSC); i++ {
2280		if f := Exp(vfexpSC[i]); !alike(expSC[i], f) {
2281			t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
2282		}
2283	}
2284}
2285
2286func TestExpm1(t *testing.T) {
2287	for i := 0; i < len(vf); i++ {
2288		a := vf[i] / 100
2289		if f := Expm1(a); !veryclose(expm1[i], f) {
2290			t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1[i])
2291		}
2292	}
2293	for i := 0; i < len(vf); i++ {
2294		a := vf[i] * 10
2295		if f := Expm1(a); !close(expm1Large[i], f) {
2296			t.Errorf("Expm1(%g) = %g, want %g", a, f, expm1Large[i])
2297		}
2298	}
2299	for i := 0; i < len(vfexpm1SC); i++ {
2300		if f := Expm1(vfexpm1SC[i]); !alike(expm1SC[i], f) {
2301			t.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC[i], f, expm1SC[i])
2302		}
2303	}
2304}
2305
2306func TestExp2(t *testing.T) {
2307	testExp2(t, Exp2, "Exp2")
2308	testExp2(t, Exp2Go, "Exp2Go")
2309}
2310
2311func testExp2(t *testing.T, Exp2 func(float64) float64, name string) {
2312	for i := 0; i < len(vf); i++ {
2313		if f := Exp2(vf[i]); !close(exp2[i], f) {
2314			t.Errorf("%s(%g) = %g, want %g", name, vf[i], f, exp2[i])
2315		}
2316	}
2317	for i := 0; i < len(vfexp2SC); i++ {
2318		if f := Exp2(vfexp2SC[i]); !alike(exp2SC[i], f) {
2319			t.Errorf("%s(%g) = %g, want %g", name, vfexpSC[i], f, expSC[i])
2320		}
2321	}
2322	for n := -1074; n < 1024; n++ {
2323		f := Exp2(float64(n))
2324		vf := Ldexp(1, n)
2325		if f != vf {
2326			t.Errorf("%s(%d) = %g, want %g", name, n, f, vf)
2327		}
2328	}
2329}
2330
2331func TestAbs(t *testing.T) {
2332	for i := 0; i < len(vf); i++ {
2333		if f := Abs(vf[i]); fabs[i] != f {
2334			t.Errorf("Abs(%g) = %g, want %g", vf[i], f, fabs[i])
2335		}
2336	}
2337	for i := 0; i < len(vffabsSC); i++ {
2338		if f := Abs(vffabsSC[i]); !alike(fabsSC[i], f) {
2339			t.Errorf("Abs(%g) = %g, want %g", vffabsSC[i], f, fabsSC[i])
2340		}
2341	}
2342}
2343
2344func TestDim(t *testing.T) {
2345	for i := 0; i < len(vf); i++ {
2346		if f := Dim(vf[i], 0); fdim[i] != f {
2347			t.Errorf("Dim(%g, %g) = %g, want %g", vf[i], 0.0, f, fdim[i])
2348		}
2349	}
2350	for i := 0; i < len(vffdimSC); i++ {
2351		if f := Dim(vffdimSC[i][0], vffdimSC[i][1]); !alike(fdimSC[i], f) {
2352			t.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fdimSC[i])
2353		}
2354	}
2355	for i := 0; i < len(vffdim2SC); i++ {
2356		if f := Dim(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fdimSC[i], f) {
2357			t.Errorf("Dim(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fdimSC[i])
2358		}
2359	}
2360}
2361
2362func TestFloor(t *testing.T) {
2363	for i := 0; i < len(vf); i++ {
2364		if f := Floor(vf[i]); !alike(floor[i], f) {
2365			t.Errorf("Floor(%g) = %g, want %g", vf[i], f, floor[i])
2366		}
2367	}
2368	for i := 0; i < len(vfceilSC); i++ {
2369		if f := Floor(vfceilSC[i]); !alike(ceilSC[i], f) {
2370			t.Errorf("Floor(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2371		}
2372	}
2373}
2374
2375func TestMax(t *testing.T) {
2376	for i := 0; i < len(vf); i++ {
2377		if f := Max(vf[i], ceil[i]); ceil[i] != f {
2378			t.Errorf("Max(%g, %g) = %g, want %g", vf[i], ceil[i], f, ceil[i])
2379		}
2380	}
2381	for i := 0; i < len(vffdimSC); i++ {
2382		if f := Max(vffdimSC[i][0], vffdimSC[i][1]); !alike(fmaxSC[i], f) {
2383			t.Errorf("Max(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fmaxSC[i])
2384		}
2385	}
2386	for i := 0; i < len(vffdim2SC); i++ {
2387		if f := Max(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fmaxSC[i], f) {
2388			t.Errorf("Max(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fmaxSC[i])
2389		}
2390	}
2391}
2392
2393func TestMin(t *testing.T) {
2394	for i := 0; i < len(vf); i++ {
2395		if f := Min(vf[i], floor[i]); floor[i] != f {
2396			t.Errorf("Min(%g, %g) = %g, want %g", vf[i], floor[i], f, floor[i])
2397		}
2398	}
2399	for i := 0; i < len(vffdimSC); i++ {
2400		if f := Min(vffdimSC[i][0], vffdimSC[i][1]); !alike(fminSC[i], f) {
2401			t.Errorf("Min(%g, %g) = %g, want %g", vffdimSC[i][0], vffdimSC[i][1], f, fminSC[i])
2402		}
2403	}
2404	for i := 0; i < len(vffdim2SC); i++ {
2405		if f := Min(vffdim2SC[i][0], vffdim2SC[i][1]); !alike(fminSC[i], f) {
2406			t.Errorf("Min(%g, %g) = %g, want %g", vffdim2SC[i][0], vffdim2SC[i][1], f, fminSC[i])
2407		}
2408	}
2409}
2410
2411func TestMod(t *testing.T) {
2412	for i := 0; i < len(vf); i++ {
2413		if f := Mod(10, vf[i]); fmod[i] != f {
2414			t.Errorf("Mod(10, %g) = %g, want %g", vf[i], f, fmod[i])
2415		}
2416	}
2417	for i := 0; i < len(vffmodSC); i++ {
2418		if f := Mod(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2419			t.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2420		}
2421	}
2422}
2423
2424func TestFrexp(t *testing.T) {
2425	for i := 0; i < len(vf); i++ {
2426		if f, j := Frexp(vf[i]); !veryclose(frexp[i].f, f) || frexp[i].i != j {
2427			t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf[i], f, j, frexp[i].f, frexp[i].i)
2428		}
2429	}
2430	for i := 0; i < len(vffrexpSC); i++ {
2431		if f, j := Frexp(vffrexpSC[i]); !alike(frexpSC[i].f, f) || frexpSC[i].i != j {
2432			t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC[i], f, j, frexpSC[i].f, frexpSC[i].i)
2433		}
2434	}
2435	for i := 0; i < len(vffrexpBC); i++ {
2436		if f, j := Frexp(vffrexpBC[i]); !alike(frexpBC[i].f, f) || frexpBC[i].i != j {
2437			t.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC[i], f, j, frexpBC[i].f, frexpBC[i].i)
2438		}
2439	}
2440}
2441
2442func TestGamma(t *testing.T) {
2443	for i := 0; i < len(vf); i++ {
2444		if f := Gamma(vf[i]); !close(gamma[i], f) {
2445			t.Errorf("Gamma(%g) = %g, want %g", vf[i], f, gamma[i])
2446		}
2447	}
2448	for _, g := range vfgamma {
2449		f := Gamma(g[0])
2450		var ok bool
2451		if IsNaN(g[1]) || IsInf(g[1], 0) || g[1] == 0 || f == 0 {
2452			ok = alike(g[1], f)
2453		} else if g[0] > -50 && g[0] <= 171 {
2454			ok = veryclose(g[1], f)
2455		} else {
2456			ok = close(g[1], f)
2457		}
2458		if !ok {
2459			t.Errorf("Gamma(%g) = %g, want %g", g[0], f, g[1])
2460		}
2461	}
2462}
2463
2464func TestHypot(t *testing.T) {
2465	for i := 0; i < len(vf); i++ {
2466		a := Abs(1e200 * tanh[i] * Sqrt(2))
2467		if f := Hypot(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2468			t.Errorf("Hypot(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2469		}
2470	}
2471	for i := 0; i < len(vfhypotSC); i++ {
2472		if f := Hypot(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2473			t.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2474		}
2475	}
2476}
2477
2478func TestHypotGo(t *testing.T) {
2479	for i := 0; i < len(vf); i++ {
2480		a := Abs(1e200 * tanh[i] * Sqrt(2))
2481		if f := HypotGo(1e200*tanh[i], 1e200*tanh[i]); !veryclose(a, f) {
2482			t.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200*tanh[i], 1e200*tanh[i], f, a)
2483		}
2484	}
2485	for i := 0; i < len(vfhypotSC); i++ {
2486		if f := HypotGo(vfhypotSC[i][0], vfhypotSC[i][1]); !alike(hypotSC[i], f) {
2487			t.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC[i][0], vfhypotSC[i][1], f, hypotSC[i])
2488		}
2489	}
2490}
2491
2492func TestIlogb(t *testing.T) {
2493	for i := 0; i < len(vf); i++ {
2494		a := frexp[i].i - 1 // adjust because fr in the interval [½, 1)
2495		if e := Ilogb(vf[i]); a != e {
2496			t.Errorf("Ilogb(%g) = %d, want %d", vf[i], e, a)
2497		}
2498	}
2499	for i := 0; i < len(vflogbSC); i++ {
2500		if e := Ilogb(vflogbSC[i]); ilogbSC[i] != e {
2501			t.Errorf("Ilogb(%g) = %d, want %d", vflogbSC[i], e, ilogbSC[i])
2502		}
2503	}
2504	for i := 0; i < len(vffrexpBC); i++ {
2505		if e := Ilogb(vffrexpBC[i]); int(logbBC[i]) != e {
2506			t.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC[i], e, int(logbBC[i]))
2507		}
2508	}
2509}
2510
2511func TestJ0(t *testing.T) {
2512	for i := 0; i < len(vf); i++ {
2513		if f := J0(vf[i]); !soclose(j0[i], f, 4e-14) {
2514			t.Errorf("J0(%g) = %g, want %g", vf[i], f, j0[i])
2515		}
2516	}
2517	for i := 0; i < len(vfj0SC); i++ {
2518		if f := J0(vfj0SC[i]); !alike(j0SC[i], f) {
2519			t.Errorf("J0(%g) = %g, want %g", vfj0SC[i], f, j0SC[i])
2520		}
2521	}
2522}
2523
2524func TestJ1(t *testing.T) {
2525	for i := 0; i < len(vf); i++ {
2526		if f := J1(vf[i]); !close(j1[i], f) {
2527			t.Errorf("J1(%g) = %g, want %g", vf[i], f, j1[i])
2528		}
2529	}
2530	for i := 0; i < len(vfj0SC); i++ {
2531		if f := J1(vfj0SC[i]); !alike(j1SC[i], f) {
2532			t.Errorf("J1(%g) = %g, want %g", vfj0SC[i], f, j1SC[i])
2533		}
2534	}
2535}
2536
2537func TestJn(t *testing.T) {
2538	for i := 0; i < len(vf); i++ {
2539		if f := Jn(2, vf[i]); !close(j2[i], f) {
2540			t.Errorf("Jn(2, %g) = %g, want %g", vf[i], f, j2[i])
2541		}
2542		if f := Jn(-3, vf[i]); !close(jM3[i], f) {
2543			t.Errorf("Jn(-3, %g) = %g, want %g", vf[i], f, jM3[i])
2544		}
2545	}
2546	for i := 0; i < len(vfj0SC); i++ {
2547		if f := Jn(2, vfj0SC[i]); !alike(j2SC[i], f) {
2548			t.Errorf("Jn(2, %g) = %g, want %g", vfj0SC[i], f, j2SC[i])
2549		}
2550		if f := Jn(-3, vfj0SC[i]); !alike(jM3SC[i], f) {
2551			t.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC[i], f, jM3SC[i])
2552		}
2553	}
2554}
2555
2556func TestLdexp(t *testing.T) {
2557	for i := 0; i < len(vf); i++ {
2558		if f := Ldexp(frexp[i].f, frexp[i].i); !veryclose(vf[i], f) {
2559			t.Errorf("Ldexp(%g, %d) = %g, want %g", frexp[i].f, frexp[i].i, f, vf[i])
2560		}
2561	}
2562	for i := 0; i < len(vffrexpSC); i++ {
2563		if f := Ldexp(frexpSC[i].f, frexpSC[i].i); !alike(vffrexpSC[i], f) {
2564			t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC[i].f, frexpSC[i].i, f, vffrexpSC[i])
2565		}
2566	}
2567	for i := 0; i < len(vfldexpSC); i++ {
2568		if f := Ldexp(vfldexpSC[i].f, vfldexpSC[i].i); !alike(ldexpSC[i], f) {
2569			t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC[i].f, vfldexpSC[i].i, f, ldexpSC[i])
2570		}
2571	}
2572	for i := 0; i < len(vffrexpBC); i++ {
2573		if f := Ldexp(frexpBC[i].f, frexpBC[i].i); !alike(vffrexpBC[i], f) {
2574			t.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC[i].f, frexpBC[i].i, f, vffrexpBC[i])
2575		}
2576	}
2577	for i := 0; i < len(vfldexpBC); i++ {
2578		if f := Ldexp(vfldexpBC[i].f, vfldexpBC[i].i); !alike(ldexpBC[i], f) {
2579			t.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC[i].f, vfldexpBC[i].i, f, ldexpBC[i])
2580		}
2581	}
2582}
2583
2584func TestLgamma(t *testing.T) {
2585	for i := 0; i < len(vf); i++ {
2586		if f, s := Lgamma(vf[i]); !close(lgamma[i].f, f) || lgamma[i].i != s {
2587			t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf[i], f, s, lgamma[i].f, lgamma[i].i)
2588		}
2589	}
2590	for i := 0; i < len(vflgammaSC); i++ {
2591		if f, s := Lgamma(vflgammaSC[i]); !alike(lgammaSC[i].f, f) || lgammaSC[i].i != s {
2592			t.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC[i], f, s, lgammaSC[i].f, lgammaSC[i].i)
2593		}
2594	}
2595}
2596
2597func TestLog(t *testing.T) {
2598	for i := 0; i < len(vf); i++ {
2599		a := Abs(vf[i])
2600		if f := Log(a); log[i] != f {
2601			t.Errorf("Log(%g) = %g, want %g", a, f, log[i])
2602		}
2603	}
2604	if f := Log(10); f != Ln10 {
2605		t.Errorf("Log(%g) = %g, want %g", 10.0, f, Ln10)
2606	}
2607	for i := 0; i < len(vflogSC); i++ {
2608		if f := Log(vflogSC[i]); !alike(logSC[i], f) {
2609			t.Errorf("Log(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2610		}
2611	}
2612}
2613
2614func TestLogb(t *testing.T) {
2615	for i := 0; i < len(vf); i++ {
2616		if f := Logb(vf[i]); logb[i] != f {
2617			t.Errorf("Logb(%g) = %g, want %g", vf[i], f, logb[i])
2618		}
2619	}
2620	for i := 0; i < len(vflogbSC); i++ {
2621		if f := Logb(vflogbSC[i]); !alike(logbSC[i], f) {
2622			t.Errorf("Logb(%g) = %g, want %g", vflogbSC[i], f, logbSC[i])
2623		}
2624	}
2625	for i := 0; i < len(vffrexpBC); i++ {
2626		if f := Logb(vffrexpBC[i]); !alike(logbBC[i], f) {
2627			t.Errorf("Logb(%g) = %g, want %g", vffrexpBC[i], f, logbBC[i])
2628		}
2629	}
2630}
2631
2632func TestLog10(t *testing.T) {
2633	for i := 0; i < len(vf); i++ {
2634		a := Abs(vf[i])
2635		if f := Log10(a); !veryclose(log10[i], f) {
2636			t.Errorf("Log10(%g) = %g, want %g", a, f, log10[i])
2637		}
2638	}
2639	if f := Log10(E); f != Log10E {
2640		t.Errorf("Log10(%g) = %g, want %g", E, f, Log10E)
2641	}
2642	for i := 0; i < len(vflogSC); i++ {
2643		if f := Log10(vflogSC[i]); !alike(logSC[i], f) {
2644			t.Errorf("Log10(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2645		}
2646	}
2647}
2648
2649func TestLog1p(t *testing.T) {
2650	for i := 0; i < len(vf); i++ {
2651		a := vf[i] / 100
2652		if f := Log1p(a); !veryclose(log1p[i], f) {
2653			t.Errorf("Log1p(%g) = %g, want %g", a, f, log1p[i])
2654		}
2655	}
2656	a := 9.0
2657	if f := Log1p(a); f != Ln10 {
2658		t.Errorf("Log1p(%g) = %g, want %g", a, f, Ln10)
2659	}
2660	for i := 0; i < len(vflogSC); i++ {
2661		if f := Log1p(vflog1pSC[i]); !alike(log1pSC[i], f) {
2662			t.Errorf("Log1p(%g) = %g, want %g", vflog1pSC[i], f, log1pSC[i])
2663		}
2664	}
2665}
2666
2667func TestLog2(t *testing.T) {
2668	for i := 0; i < len(vf); i++ {
2669		a := Abs(vf[i])
2670		if f := Log2(a); !veryclose(log2[i], f) {
2671			t.Errorf("Log2(%g) = %g, want %g", a, f, log2[i])
2672		}
2673	}
2674	if f := Log2(E); f != Log2E {
2675		t.Errorf("Log2(%g) = %g, want %g", E, f, Log2E)
2676	}
2677	for i := 0; i < len(vflogSC); i++ {
2678		if f := Log2(vflogSC[i]); !alike(logSC[i], f) {
2679			t.Errorf("Log2(%g) = %g, want %g", vflogSC[i], f, logSC[i])
2680		}
2681	}
2682	for i := -1074; i <= 1023; i++ {
2683		f := Ldexp(1, i)
2684		l := Log2(f)
2685		if l != float64(i) {
2686			t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
2687		}
2688	}
2689}
2690
2691func TestModf(t *testing.T) {
2692	for i := 0; i < len(vf); i++ {
2693		if f, g := Modf(vf[i]); !veryclose(modf[i][0], f) || !veryclose(modf[i][1], g) {
2694			t.Errorf("Modf(%g) = %g, %g, want %g, %g", vf[i], f, g, modf[i][0], modf[i][1])
2695		}
2696	}
2697	for i := 0; i < len(vfmodfSC); i++ {
2698		if f, g := Modf(vfmodfSC[i]); !alike(modfSC[i][0], f) || !alike(modfSC[i][1], g) {
2699			t.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC[i], f, g, modfSC[i][0], modfSC[i][1])
2700		}
2701	}
2702}
2703
2704func TestNextafter32(t *testing.T) {
2705	for i := 0; i < len(vf); i++ {
2706		vfi := float32(vf[i])
2707		if f := Nextafter32(vfi, 10); nextafter32[i] != f {
2708			t.Errorf("Nextafter32(%g, %g) = %g want %g", vfi, 10.0, f, nextafter32[i])
2709		}
2710	}
2711	for i := 0; i < len(vfnextafter32SC); i++ {
2712		if f := Nextafter32(vfnextafter32SC[i][0], vfnextafter32SC[i][1]); !alike(float64(nextafter32SC[i]), float64(f)) {
2713			t.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC[i][0], vfnextafter32SC[i][1], f, nextafter32SC[i])
2714		}
2715	}
2716}
2717
2718func TestNextafter64(t *testing.T) {
2719	for i := 0; i < len(vf); i++ {
2720		if f := Nextafter(vf[i], 10); nextafter64[i] != f {
2721			t.Errorf("Nextafter64(%g, %g) = %g want %g", vf[i], 10.0, f, nextafter64[i])
2722		}
2723	}
2724	for i := 0; i < len(vfnextafter64SC); i++ {
2725		if f := Nextafter(vfnextafter64SC[i][0], vfnextafter64SC[i][1]); !alike(nextafter64SC[i], f) {
2726			t.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC[i][0], vfnextafter64SC[i][1], f, nextafter64SC[i])
2727		}
2728	}
2729}
2730
2731func TestPow(t *testing.T) {
2732	for i := 0; i < len(vf); i++ {
2733		if f := Pow(10, vf[i]); !close(pow[i], f) {
2734			t.Errorf("Pow(10, %g) = %g, want %g", vf[i], f, pow[i])
2735		}
2736	}
2737	for i := 0; i < len(vfpowSC); i++ {
2738		if f := Pow(vfpowSC[i][0], vfpowSC[i][1]); !alike(powSC[i], f) {
2739			t.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC[i][0], vfpowSC[i][1], f, powSC[i])
2740		}
2741	}
2742}
2743
2744func TestPow10(t *testing.T) {
2745	for i := 0; i < len(vfpow10SC); i++ {
2746		if f := Pow10(vfpow10SC[i]); !alike(pow10SC[i], f) {
2747			t.Errorf("Pow10(%d) = %g, want %g", vfpow10SC[i], f, pow10SC[i])
2748		}
2749	}
2750}
2751
2752func TestRemainder(t *testing.T) {
2753	for i := 0; i < len(vf); i++ {
2754		if f := Remainder(10, vf[i]); remainder[i] != f {
2755			t.Errorf("Remainder(10, %g) = %g, want %g", vf[i], f, remainder[i])
2756		}
2757	}
2758	for i := 0; i < len(vffmodSC); i++ {
2759		if f := Remainder(vffmodSC[i][0], vffmodSC[i][1]); !alike(fmodSC[i], f) {
2760			t.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC[i][0], vffmodSC[i][1], f, fmodSC[i])
2761		}
2762	}
2763}
2764
2765func TestRound(t *testing.T) {
2766	for i := 0; i < len(vf); i++ {
2767		if f := Round(vf[i]); !alike(round[i], f) {
2768			t.Errorf("Round(%g) = %g, want %g", vf[i], f, round[i])
2769		}
2770	}
2771	for i := 0; i < len(vfroundSC); i++ {
2772		if f := Round(vfroundSC[i][0]); !alike(vfroundSC[i][1], f) {
2773			t.Errorf("Round(%g) = %g, want %g", vfroundSC[i][0], f, vfroundSC[i][1])
2774		}
2775	}
2776}
2777
2778func TestRoundToEven(t *testing.T) {
2779	for i := 0; i < len(vf); i++ {
2780		if f := RoundToEven(vf[i]); !alike(round[i], f) {
2781			t.Errorf("RoundToEven(%g) = %g, want %g", vf[i], f, round[i])
2782		}
2783	}
2784	for i := 0; i < len(vfroundEvenSC); i++ {
2785		if f := RoundToEven(vfroundEvenSC[i][0]); !alike(vfroundEvenSC[i][1], f) {
2786			t.Errorf("RoundToEven(%g) = %g, want %g", vfroundEvenSC[i][0], f, vfroundEvenSC[i][1])
2787		}
2788	}
2789}
2790
2791func TestSignbit(t *testing.T) {
2792	for i := 0; i < len(vf); i++ {
2793		if f := Signbit(vf[i]); signbit[i] != f {
2794			t.Errorf("Signbit(%g) = %t, want %t", vf[i], f, signbit[i])
2795		}
2796	}
2797	for i := 0; i < len(vfsignbitSC); i++ {
2798		if f := Signbit(vfsignbitSC[i]); signbitSC[i] != f {
2799			t.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC[i], f, signbitSC[i])
2800		}
2801	}
2802}
2803func TestSin(t *testing.T) {
2804	for i := 0; i < len(vf); i++ {
2805		if f := Sin(vf[i]); !veryclose(sin[i], f) {
2806			t.Errorf("Sin(%g) = %g, want %g", vf[i], f, sin[i])
2807		}
2808	}
2809	for i := 0; i < len(vfsinSC); i++ {
2810		if f := Sin(vfsinSC[i]); !alike(sinSC[i], f) {
2811			t.Errorf("Sin(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
2812		}
2813	}
2814}
2815
2816func TestSincos(t *testing.T) {
2817	for i := 0; i < len(vf); i++ {
2818		if s, c := Sincos(vf[i]); !veryclose(sin[i], s) || !veryclose(cos[i], c) {
2819			t.Errorf("Sincos(%g) = %g, %g want %g, %g", vf[i], s, c, sin[i], cos[i])
2820		}
2821	}
2822}
2823
2824func TestSinh(t *testing.T) {
2825	for i := 0; i < len(vf); i++ {
2826		if f := Sinh(vf[i]); !close(sinh[i], f) {
2827			t.Errorf("Sinh(%g) = %g, want %g", vf[i], f, sinh[i])
2828		}
2829	}
2830	for i := 0; i < len(vfsinhSC); i++ {
2831		if f := Sinh(vfsinhSC[i]); !alike(sinhSC[i], f) {
2832			t.Errorf("Sinh(%g) = %g, want %g", vfsinhSC[i], f, sinhSC[i])
2833		}
2834	}
2835}
2836
2837func TestSqrt(t *testing.T) {
2838	for i := 0; i < len(vf); i++ {
2839		a := Abs(vf[i])
2840		if f := SqrtGo(a); sqrt[i] != f {
2841			t.Errorf("SqrtGo(%g) = %g, want %g", a, f, sqrt[i])
2842		}
2843		a = Abs(vf[i])
2844		if f := Sqrt(a); sqrt[i] != f {
2845			t.Errorf("Sqrt(%g) = %g, want %g", a, f, sqrt[i])
2846		}
2847	}
2848	for i := 0; i < len(vfsqrtSC); i++ {
2849		if f := SqrtGo(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
2850			t.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
2851		}
2852		if f := Sqrt(vfsqrtSC[i]); !alike(sqrtSC[i], f) {
2853			t.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC[i], f, sqrtSC[i])
2854		}
2855	}
2856}
2857
2858func TestTan(t *testing.T) {
2859	for i := 0; i < len(vf); i++ {
2860		if f := Tan(vf[i]); !veryclose(tan[i], f) {
2861			t.Errorf("Tan(%g) = %g, want %g", vf[i], f, tan[i])
2862		}
2863	}
2864	// same special cases as Sin
2865	for i := 0; i < len(vfsinSC); i++ {
2866		if f := Tan(vfsinSC[i]); !alike(sinSC[i], f) {
2867			t.Errorf("Tan(%g) = %g, want %g", vfsinSC[i], f, sinSC[i])
2868		}
2869	}
2870}
2871
2872func TestTanh(t *testing.T) {
2873	for i := 0; i < len(vf); i++ {
2874		if f := Tanh(vf[i]); !veryclose(tanh[i], f) {
2875			t.Errorf("Tanh(%g) = %g, want %g", vf[i], f, tanh[i])
2876		}
2877	}
2878	for i := 0; i < len(vftanhSC); i++ {
2879		if f := Tanh(vftanhSC[i]); !alike(tanhSC[i], f) {
2880			t.Errorf("Tanh(%g) = %g, want %g", vftanhSC[i], f, tanhSC[i])
2881		}
2882	}
2883}
2884
2885func TestTrunc(t *testing.T) {
2886	for i := 0; i < len(vf); i++ {
2887		if f := Trunc(vf[i]); !alike(trunc[i], f) {
2888			t.Errorf("Trunc(%g) = %g, want %g", vf[i], f, trunc[i])
2889		}
2890	}
2891	for i := 0; i < len(vfceilSC); i++ {
2892		if f := Trunc(vfceilSC[i]); !alike(ceilSC[i], f) {
2893			t.Errorf("Trunc(%g) = %g, want %g", vfceilSC[i], f, ceilSC[i])
2894		}
2895	}
2896}
2897
2898func TestY0(t *testing.T) {
2899	for i := 0; i < len(vf); i++ {
2900		a := Abs(vf[i])
2901		if f := Y0(a); !close(y0[i], f) {
2902			t.Errorf("Y0(%g) = %g, want %g", a, f, y0[i])
2903		}
2904	}
2905	for i := 0; i < len(vfy0SC); i++ {
2906		if f := Y0(vfy0SC[i]); !alike(y0SC[i], f) {
2907			t.Errorf("Y0(%g) = %g, want %g", vfy0SC[i], f, y0SC[i])
2908		}
2909	}
2910}
2911
2912func TestY1(t *testing.T) {
2913	for i := 0; i < len(vf); i++ {
2914		a := Abs(vf[i])
2915		if f := Y1(a); !soclose(y1[i], f, 2e-14) {
2916			t.Errorf("Y1(%g) = %g, want %g", a, f, y1[i])
2917		}
2918	}
2919	for i := 0; i < len(vfy0SC); i++ {
2920		if f := Y1(vfy0SC[i]); !alike(y1SC[i], f) {
2921			t.Errorf("Y1(%g) = %g, want %g", vfy0SC[i], f, y1SC[i])
2922		}
2923	}
2924}
2925
2926func TestYn(t *testing.T) {
2927	for i := 0; i < len(vf); i++ {
2928		a := Abs(vf[i])
2929		if f := Yn(2, a); !close(y2[i], f) {
2930			t.Errorf("Yn(2, %g) = %g, want %g", a, f, y2[i])
2931		}
2932		if f := Yn(-3, a); !close(yM3[i], f) {
2933			t.Errorf("Yn(-3, %g) = %g, want %g", a, f, yM3[i])
2934		}
2935	}
2936	for i := 0; i < len(vfy0SC); i++ {
2937		if f := Yn(2, vfy0SC[i]); !alike(y2SC[i], f) {
2938			t.Errorf("Yn(2, %g) = %g, want %g", vfy0SC[i], f, y2SC[i])
2939		}
2940		if f := Yn(-3, vfy0SC[i]); !alike(yM3SC[i], f) {
2941			t.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC[i], f, yM3SC[i])
2942		}
2943	}
2944	if f := Yn(0, 0); !alike(Inf(-1), f) {
2945		t.Errorf("Yn(0, 0) = %g, want %g", f, Inf(-1))
2946	}
2947}
2948
2949// Check that math functions of high angle values
2950// return accurate results. [Since (vf[i] + large) - large != vf[i],
2951// testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
2952// a multiple of 2*Pi, is misleading.]
2953func TestLargeCos(t *testing.T) {
2954	large := float64(100000 * Pi)
2955	for i := 0; i < len(vf); i++ {
2956		f1 := cosLarge[i]
2957		f2 := Cos(vf[i] + large)
2958		if !close(f1, f2) {
2959			t.Errorf("Cos(%g) = %g, want %g", vf[i]+large, f2, f1)
2960		}
2961	}
2962}
2963
2964func TestLargeSin(t *testing.T) {
2965	large := float64(100000 * Pi)
2966	for i := 0; i < len(vf); i++ {
2967		f1 := sinLarge[i]
2968		f2 := Sin(vf[i] + large)
2969		if !close(f1, f2) {
2970			t.Errorf("Sin(%g) = %g, want %g", vf[i]+large, f2, f1)
2971		}
2972	}
2973}
2974
2975func TestLargeSincos(t *testing.T) {
2976	large := float64(100000 * Pi)
2977	for i := 0; i < len(vf); i++ {
2978		f1, g1 := sinLarge[i], cosLarge[i]
2979		f2, g2 := Sincos(vf[i] + large)
2980		if !close(f1, f2) || !close(g1, g2) {
2981			t.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf[i]+large, f2, g2, f1, g1)
2982		}
2983	}
2984}
2985
2986func TestLargeTan(t *testing.T) {
2987	large := float64(100000 * Pi)
2988	for i := 0; i < len(vf); i++ {
2989		f1 := tanLarge[i]
2990		f2 := Tan(vf[i] + large)
2991		if !close(f1, f2) {
2992			t.Errorf("Tan(%g) = %g, want %g", vf[i]+large, f2, f1)
2993		}
2994	}
2995}
2996
2997// Check that math constants are accepted by compiler
2998// and have right value (assumes strconv.ParseFloat works).
2999// https://golang.org/issue/201
3000
3001type floatTest struct {
3002	val  interface{}
3003	name string
3004	str  string
3005}
3006
3007var floatTests = []floatTest{
3008	{float64(MaxFloat64), "MaxFloat64", "1.7976931348623157e+308"},
3009	{float64(SmallestNonzeroFloat64), "SmallestNonzeroFloat64", "5e-324"},
3010	{float32(MaxFloat32), "MaxFloat32", "3.4028235e+38"},
3011	{float32(SmallestNonzeroFloat32), "SmallestNonzeroFloat32", "1e-45"},
3012}
3013
3014func TestFloatMinMax(t *testing.T) {
3015	for _, tt := range floatTests {
3016		s := fmt.Sprint(tt.val)
3017		if s != tt.str {
3018			t.Errorf("Sprint(%v) = %s, want %s", tt.name, s, tt.str)
3019		}
3020	}
3021}
3022
3023// Benchmarks
3024
3025// Global exported variables are used to store the
3026// return values of functions measured in the benchmarks.
3027// Storing the results in these variables prevents the compiler
3028// from completely optimizing the benchmarked functions away.
3029var (
3030	GlobalI int
3031	GlobalB bool
3032	GlobalF float64
3033)
3034
3035func BenchmarkAcos(b *testing.B) {
3036	x := 0.0
3037	for i := 0; i < b.N; i++ {
3038		x = Acos(.5)
3039	}
3040	GlobalF = x
3041}
3042
3043func BenchmarkAcosh(b *testing.B) {
3044	x := 0.0
3045	for i := 0; i < b.N; i++ {
3046		x = Acosh(1.5)
3047	}
3048	GlobalF = x
3049}
3050
3051func BenchmarkAsin(b *testing.B) {
3052	x := 0.0
3053	for i := 0; i < b.N; i++ {
3054		x = Asin(.5)
3055	}
3056	GlobalF = x
3057}
3058
3059func BenchmarkAsinh(b *testing.B) {
3060	x := 0.0
3061	for i := 0; i < b.N; i++ {
3062		x = Asinh(.5)
3063	}
3064	GlobalF = x
3065}
3066
3067func BenchmarkAtan(b *testing.B) {
3068	x := 0.0
3069	for i := 0; i < b.N; i++ {
3070		x = Atan(.5)
3071	}
3072	GlobalF = x
3073}
3074
3075func BenchmarkAtanh(b *testing.B) {
3076	x := 0.0
3077	for i := 0; i < b.N; i++ {
3078		x = Atanh(.5)
3079	}
3080	GlobalF = x
3081}
3082
3083func BenchmarkAtan2(b *testing.B) {
3084	x := 0.0
3085	for i := 0; i < b.N; i++ {
3086		x = Atan2(.5, 1)
3087	}
3088	GlobalF = x
3089}
3090
3091func BenchmarkCbrt(b *testing.B) {
3092	x := 0.0
3093	for i := 0; i < b.N; i++ {
3094		x = Cbrt(10)
3095	}
3096	GlobalF = x
3097}
3098
3099func BenchmarkCeil(b *testing.B) {
3100	x := 0.0
3101	for i := 0; i < b.N; i++ {
3102		x = Ceil(.5)
3103	}
3104	GlobalF = x
3105}
3106
3107var copysignNeg = -1.0
3108
3109func BenchmarkCopysign(b *testing.B) {
3110	x := 0.0
3111	for i := 0; i < b.N; i++ {
3112		x = Copysign(.5, copysignNeg)
3113	}
3114	GlobalF = x
3115}
3116
3117func BenchmarkCos(b *testing.B) {
3118	x := 0.0
3119	for i := 0; i < b.N; i++ {
3120		x = Cos(.5)
3121	}
3122	GlobalF = x
3123}
3124
3125func BenchmarkCosh(b *testing.B) {
3126	x := 0.0
3127	for i := 0; i < b.N; i++ {
3128		x = Cosh(2.5)
3129	}
3130	GlobalF = x
3131}
3132
3133func BenchmarkErf(b *testing.B) {
3134	x := 0.0
3135	for i := 0; i < b.N; i++ {
3136		x = Erf(.5)
3137	}
3138	GlobalF = x
3139}
3140
3141func BenchmarkErfc(b *testing.B) {
3142	x := 0.0
3143	for i := 0; i < b.N; i++ {
3144		x = Erfc(.5)
3145	}
3146	GlobalF = x
3147}
3148
3149func BenchmarkErfinv(b *testing.B) {
3150	x := 0.0
3151	for i := 0; i < b.N; i++ {
3152		x = Erfinv(.5)
3153	}
3154	GlobalF = x
3155}
3156
3157func BenchmarkErfcinv(b *testing.B) {
3158	x := 0.0
3159	for i := 0; i < b.N; i++ {
3160		x = Erfcinv(.5)
3161	}
3162	GlobalF = x
3163}
3164
3165func BenchmarkExp(b *testing.B) {
3166	x := 0.0
3167	for i := 0; i < b.N; i++ {
3168		x = Exp(.5)
3169	}
3170	GlobalF = x
3171}
3172
3173func BenchmarkExpGo(b *testing.B) {
3174	x := 0.0
3175	for i := 0; i < b.N; i++ {
3176		x = ExpGo(.5)
3177	}
3178	GlobalF = x
3179}
3180
3181func BenchmarkExpm1(b *testing.B) {
3182	x := 0.0
3183	for i := 0; i < b.N; i++ {
3184		x = Expm1(.5)
3185	}
3186	GlobalF = x
3187}
3188
3189func BenchmarkExp2(b *testing.B) {
3190	x := 0.0
3191	for i := 0; i < b.N; i++ {
3192		x = Exp2(.5)
3193	}
3194	GlobalF = x
3195}
3196
3197func BenchmarkExp2Go(b *testing.B) {
3198	x := 0.0
3199	for i := 0; i < b.N; i++ {
3200		x = Exp2Go(.5)
3201	}
3202	GlobalF = x
3203}
3204
3205var absPos = .5
3206
3207func BenchmarkAbs(b *testing.B) {
3208	x := 0.0
3209	for i := 0; i < b.N; i++ {
3210		x = Abs(absPos)
3211	}
3212	GlobalF = x
3213
3214}
3215
3216func BenchmarkDim(b *testing.B) {
3217	x := 0.0
3218	for i := 0; i < b.N; i++ {
3219		x = Dim(GlobalF, x)
3220	}
3221	GlobalF = x
3222}
3223
3224func BenchmarkFloor(b *testing.B) {
3225	x := 0.0
3226	for i := 0; i < b.N; i++ {
3227		x = Floor(.5)
3228	}
3229	GlobalF = x
3230}
3231
3232func BenchmarkMax(b *testing.B) {
3233	x := 0.0
3234	for i := 0; i < b.N; i++ {
3235		x = Max(10, 3)
3236	}
3237	GlobalF = x
3238}
3239
3240func BenchmarkMin(b *testing.B) {
3241	x := 0.0
3242	for i := 0; i < b.N; i++ {
3243		x = Min(10, 3)
3244	}
3245	GlobalF = x
3246}
3247
3248func BenchmarkMod(b *testing.B) {
3249	x := 0.0
3250	for i := 0; i < b.N; i++ {
3251		x = Mod(10, 3)
3252	}
3253	GlobalF = x
3254}
3255
3256func BenchmarkFrexp(b *testing.B) {
3257	x := 0.0
3258	y := 0
3259	for i := 0; i < b.N; i++ {
3260		x, y = Frexp(8)
3261	}
3262	GlobalF = x
3263	GlobalI = y
3264}
3265
3266func BenchmarkGamma(b *testing.B) {
3267	x := 0.0
3268	for i := 0; i < b.N; i++ {
3269		x = Gamma(2.5)
3270	}
3271	GlobalF = x
3272}
3273
3274func BenchmarkHypot(b *testing.B) {
3275	x := 0.0
3276	for i := 0; i < b.N; i++ {
3277		x = Hypot(3, 4)
3278	}
3279	GlobalF = x
3280}
3281
3282func BenchmarkHypotGo(b *testing.B) {
3283	x := 0.0
3284	for i := 0; i < b.N; i++ {
3285		x = HypotGo(3, 4)
3286	}
3287	GlobalF = x
3288}
3289
3290func BenchmarkIlogb(b *testing.B) {
3291	x := 0
3292	for i := 0; i < b.N; i++ {
3293		x = Ilogb(.5)
3294	}
3295	GlobalI = x
3296}
3297
3298func BenchmarkJ0(b *testing.B) {
3299	x := 0.0
3300	for i := 0; i < b.N; i++ {
3301		x = J0(2.5)
3302	}
3303	GlobalF = x
3304}
3305
3306func BenchmarkJ1(b *testing.B) {
3307	x := 0.0
3308	for i := 0; i < b.N; i++ {
3309		x = J1(2.5)
3310	}
3311	GlobalF = x
3312}
3313
3314func BenchmarkJn(b *testing.B) {
3315	x := 0.0
3316	for i := 0; i < b.N; i++ {
3317		x = Jn(2, 2.5)
3318	}
3319	GlobalF = x
3320}
3321
3322func BenchmarkLdexp(b *testing.B) {
3323	x := 0.0
3324	for i := 0; i < b.N; i++ {
3325		x = Ldexp(.5, 2)
3326	}
3327	GlobalF = x
3328}
3329
3330func BenchmarkLgamma(b *testing.B) {
3331	x := 0.0
3332	y := 0
3333	for i := 0; i < b.N; i++ {
3334		x, y = Lgamma(2.5)
3335	}
3336	GlobalF = x
3337	GlobalI = y
3338}
3339
3340func BenchmarkLog(b *testing.B) {
3341	x := 0.0
3342	for i := 0; i < b.N; i++ {
3343		x = Log(.5)
3344	}
3345	GlobalF = x
3346}
3347
3348func BenchmarkLogb(b *testing.B) {
3349	x := 0.0
3350	for i := 0; i < b.N; i++ {
3351		x = Logb(.5)
3352	}
3353	GlobalF = x
3354}
3355
3356func BenchmarkLog1p(b *testing.B) {
3357	x := 0.0
3358	for i := 0; i < b.N; i++ {
3359		x = Log1p(.5)
3360	}
3361	GlobalF = x
3362}
3363
3364func BenchmarkLog10(b *testing.B) {
3365	x := 0.0
3366	for i := 0; i < b.N; i++ {
3367		x = Log10(.5)
3368	}
3369	GlobalF = x
3370}
3371
3372func BenchmarkLog2(b *testing.B) {
3373	x := 0.0
3374	for i := 0; i < b.N; i++ {
3375		x = Log2(.5)
3376	}
3377	GlobalF += x
3378}
3379
3380func BenchmarkModf(b *testing.B) {
3381	x := 0.0
3382	y := 0.0
3383	for i := 0; i < b.N; i++ {
3384		x, y = Modf(1.5)
3385	}
3386	GlobalF += x
3387	GlobalF += y
3388}
3389
3390func BenchmarkNextafter32(b *testing.B) {
3391	x := float32(0.0)
3392	for i := 0; i < b.N; i++ {
3393		x = Nextafter32(.5, 1)
3394	}
3395	GlobalF = float64(x)
3396}
3397
3398func BenchmarkNextafter64(b *testing.B) {
3399	x := 0.0
3400	for i := 0; i < b.N; i++ {
3401		x = Nextafter(.5, 1)
3402	}
3403	GlobalF = x
3404}
3405
3406func BenchmarkPowInt(b *testing.B) {
3407	x := 0.0
3408	for i := 0; i < b.N; i++ {
3409		x = Pow(2, 2)
3410	}
3411	GlobalF = x
3412}
3413
3414func BenchmarkPowFrac(b *testing.B) {
3415	x := 0.0
3416	for i := 0; i < b.N; i++ {
3417		x = Pow(2.5, 1.5)
3418	}
3419	GlobalF = x
3420}
3421
3422var pow10pos = int(300)
3423
3424func BenchmarkPow10Pos(b *testing.B) {
3425	x := 0.0
3426	for i := 0; i < b.N; i++ {
3427		x = Pow10(pow10pos)
3428	}
3429	GlobalF = x
3430}
3431
3432var pow10neg = int(-300)
3433
3434func BenchmarkPow10Neg(b *testing.B) {
3435	x := 0.0
3436	for i := 0; i < b.N; i++ {
3437		x = Pow10(pow10neg)
3438	}
3439	GlobalF = x
3440}
3441
3442var roundNeg = float64(-2.5)
3443
3444func BenchmarkRound(b *testing.B) {
3445	x := 0.0
3446	for i := 0; i < b.N; i++ {
3447		x = Round(roundNeg)
3448	}
3449	GlobalF = x
3450}
3451
3452func BenchmarkRoundToEven(b *testing.B) {
3453	x := 0.0
3454	for i := 0; i < b.N; i++ {
3455		x = RoundToEven(roundNeg)
3456	}
3457	GlobalF = x
3458}
3459
3460func BenchmarkRemainder(b *testing.B) {
3461	x := 0.0
3462	for i := 0; i < b.N; i++ {
3463		x = Remainder(10, 3)
3464	}
3465	GlobalF = x
3466}
3467
3468var signbitPos = 2.5
3469
3470func BenchmarkSignbit(b *testing.B) {
3471	x := false
3472	for i := 0; i < b.N; i++ {
3473		x = Signbit(signbitPos)
3474	}
3475	GlobalB = x
3476}
3477
3478func BenchmarkSin(b *testing.B) {
3479	x := 0.0
3480	for i := 0; i < b.N; i++ {
3481		x = Sin(.5)
3482	}
3483	GlobalF = x
3484}
3485
3486func BenchmarkSincos(b *testing.B) {
3487	x := 0.0
3488	y := 0.0
3489	for i := 0; i < b.N; i++ {
3490		x, y = Sincos(.5)
3491	}
3492	GlobalF += x
3493	GlobalF += y
3494}
3495
3496func BenchmarkSinh(b *testing.B) {
3497	x := 0.0
3498	for i := 0; i < b.N; i++ {
3499		x = Sinh(2.5)
3500	}
3501	GlobalF = x
3502}
3503
3504func BenchmarkSqrtIndirect(b *testing.B) {
3505	x, y := 0.0, 10.0
3506	f := Sqrt
3507	for i := 0; i < b.N; i++ {
3508		x += f(y)
3509	}
3510	GlobalF = x
3511}
3512
3513func BenchmarkSqrtLatency(b *testing.B) {
3514	x := 10.0
3515	for i := 0; i < b.N; i++ {
3516		x = Sqrt(x)
3517	}
3518	GlobalF = x
3519}
3520
3521func BenchmarkSqrtIndirectLatency(b *testing.B) {
3522	x := 10.0
3523	f := Sqrt
3524	for i := 0; i < b.N; i++ {
3525		x = f(x)
3526	}
3527	GlobalF = x
3528}
3529
3530func BenchmarkSqrtGoLatency(b *testing.B) {
3531	x := 10.0
3532	for i := 0; i < b.N; i++ {
3533		x = SqrtGo(x)
3534	}
3535	GlobalF = x
3536}
3537
3538func isPrime(i int) bool {
3539	// Yes, this is a dumb way to write this code,
3540	// but calling Sqrt repeatedly in this way demonstrates
3541	// the benefit of using a direct SQRT instruction on systems
3542	// that have one, whereas the obvious loop seems not to
3543	// demonstrate such a benefit.
3544	for j := 2; float64(j) <= Sqrt(float64(i)); j++ {
3545		if i%j == 0 {
3546			return false
3547		}
3548	}
3549	return true
3550}
3551
3552func BenchmarkSqrtPrime(b *testing.B) {
3553	x := false
3554	for i := 0; i < b.N; i++ {
3555		x = isPrime(100003)
3556	}
3557	GlobalB = x
3558}
3559
3560func BenchmarkTan(b *testing.B) {
3561	x := 0.0
3562	for i := 0; i < b.N; i++ {
3563		x = Tan(.5)
3564	}
3565	GlobalF = x
3566}
3567
3568func BenchmarkTanh(b *testing.B) {
3569	x := 0.0
3570	for i := 0; i < b.N; i++ {
3571		x = Tanh(2.5)
3572	}
3573	GlobalF = x
3574}
3575func BenchmarkTrunc(b *testing.B) {
3576	x := 0.0
3577	for i := 0; i < b.N; i++ {
3578		x = Trunc(.5)
3579	}
3580	GlobalF = x
3581}
3582
3583func BenchmarkY0(b *testing.B) {
3584	x := 0.0
3585	for i := 0; i < b.N; i++ {
3586		x = Y0(2.5)
3587	}
3588	GlobalF = x
3589}
3590
3591func BenchmarkY1(b *testing.B) {
3592	x := 0.0
3593	for i := 0; i < b.N; i++ {
3594		x = Y1(2.5)
3595	}
3596	GlobalF = x
3597}
3598
3599func BenchmarkYn(b *testing.B) {
3600	x := 0.0
3601	for i := 0; i < b.N; i++ {
3602		x = Yn(2, 2.5)
3603	}
3604	GlobalF = x
3605}
3606