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.
14 4.9790119248836735e+00,
15 7.7388724745781045e+00,
16 -2.7688005719200159e-01,
17 -5.0106036182710749e+00,
18 9.6362937071984173e+00,
19 2.9263772392439646e+00,
20 5.2290834314593066e+00,
21 2.7279399104360102e+00,
22 1.8253080916808550e+00,
23 -8.6859247685756013e+00,
26 // The expected results below were computed by the high precision calculators
27 // at http://keisan.casio.com/. More exact input values (array vf[], above)
28 // were obtained by printing them with "%.26f". The answers were calculated
29 // to 26 digits (by using the "Digit number" drop-down control of each
32 1.0496193546107222142571536e+00,
33 6.8584012813664425171660692e-01,
34 1.5984878714577160325521819e+00,
35 2.0956199361475859327461799e+00,
36 2.7053008467824138592616927e-01,
37 1.2738121680361776018155625e+00,
38 1.0205369421140629186287407e+00,
39 1.2945003481781246062157835e+00,
40 1.3872364345374451433846657e+00,
41 2.6231510803970463967294145e+00,
43 var acosh
= []float64{
44 2.4743347004159012494457618e+00,
45 2.8576385344292769649802701e+00,
46 7.2796961502981066190593175e-01,
47 2.4796794418831451156471977e+00,
48 3.0552020742306061857212962e+00,
49 2.044238592688586588942468e+00,
50 2.5158701513104513595766636e+00,
51 1.99050839282411638174299e+00,
52 1.6988625798424034227205445e+00,
53 2.9611454842470387925531875e+00,
56 5.2117697218417440497416805e-01,
57 8.8495619865825236751471477e-01,
58 -02.769154466281941332086016e-02,
59 -5.2482360935268931351485822e-01,
60 1.3002662421166552333051524e+00,
61 2.9698415875871901741575922e-01,
62 5.5025938468083370060258102e-01,
63 2.7629597861677201301553823e-01,
64 1.83559892257451475846656e-01,
65 -1.0523547536021497774980928e+00,
67 var asinh
= []float64{
68 2.3083139124923523427628243e+00,
69 2.743551594301593620039021e+00,
70 -2.7345908534880091229413487e-01,
71 -2.3145157644718338650499085e+00,
72 2.9613652154015058521951083e+00,
73 1.7949041616585821933067568e+00,
74 2.3564032905983506405561554e+00,
75 1.7287118790768438878045346e+00,
76 1.3626658083714826013073193e+00,
77 -2.8581483626513914445234004e+00,
80 1.372590262129621651920085e+00,
81 1.442290609645298083020664e+00,
82 -2.7011324359471758245192595e-01,
83 -1.3738077684543379452781531e+00,
84 1.4673921193587666049154681e+00,
85 1.2415173565870168649117764e+00,
86 1.3818396865615168979966498e+00,
87 1.2194305844639670701091426e+00,
88 1.0696031952318783760193244e+00,
89 -1.4561721938838084990898679e+00,
91 var atanh
= []float64{
92 5.4651163712251938116878204e-01,
93 1.0299474112843111224914709e+00,
94 -2.7695084420740135145234906e-02,
95 -5.5072096119207195480202529e-01,
96 1.9943940993171843235906642e+00,
97 3.01448604578089708203017e-01,
98 5.8033427206942188834370595e-01,
99 2.7987997499441511013958297e-01,
100 1.8459947964298794318714228e-01,
101 -1.3273186910532645867272502e+00,
103 var atan2
= []float64{
104 1.1088291730037004444527075e+00,
105 9.1218183188715804018797795e-01,
106 1.5984772603216203736068915e+00,
107 2.0352918654092086637227327e+00,
108 8.0391819139044720267356014e-01,
109 1.2861075249894661588866752e+00,
110 1.0889904479131695712182587e+00,
111 1.3044821793397925293797357e+00,
112 1.3902530903455392306872261e+00,
113 2.2859857424479142655411058e+00,
115 var cbrt
= []float64{
116 1.7075799841925094446722675e+00,
117 1.9779982212970353936691498e+00,
118 -6.5177429017779910853339447e-01,
119 -1.7111838886544019873338113e+00,
120 2.1279920909827937423960472e+00,
121 1.4303536770460741452312367e+00,
122 1.7357021059106154902341052e+00,
123 1.3972633462554328350552916e+00,
124 1.2221149580905388454977636e+00,
125 -2.0556003730500069110343596e+00,
127 var ceil
= []float64{
128 5.0000000000000000e+00,
129 8.0000000000000000e+00,
130 0.0000000000000000e+00,
131 -5.0000000000000000e+00,
132 1.0000000000000000e+01,
133 3.0000000000000000e+00,
134 6.0000000000000000e+00,
135 3.0000000000000000e+00,
136 2.0000000000000000e+00,
137 -8.0000000000000000e+00,
139 var copysign
= []float64{
140 -4.9790119248836735e+00,
141 -7.7388724745781045e+00,
142 -2.7688005719200159e-01,
143 -5.0106036182710749e+00,
144 -9.6362937071984173e+00,
145 -2.9263772392439646e+00,
146 -5.2290834314593066e+00,
147 -2.7279399104360102e+00,
148 -1.8253080916808550e+00,
149 -8.6859247685756013e+00,
152 2.634752140995199110787593e-01,
153 1.148551260848219865642039e-01,
154 9.6191297325640768154550453e-01,
155 2.938141150061714816890637e-01,
156 -9.777138189897924126294461e-01,
157 -9.7693041344303219127199518e-01,
158 4.940088096948647263961162e-01,
159 -9.1565869021018925545016502e-01,
160 -2.517729313893103197176091e-01,
161 -7.39241351595676573201918e-01,
164 // Results for 100000 * Pi + vf[i]
165 var cosLarge
= []float64{
166 2.634752141185559426744e-01,
167 1.14855126055543100712e-01,
168 9.61912973266488928113e-01,
169 2.9381411499556122552e-01,
170 -9.777138189880161924641e-01,
171 -9.76930413445147608049e-01,
172 4.940088097314976789841e-01,
173 -9.15658690217517835002e-01,
174 -2.51772931436786954751e-01,
175 -7.3924135157173099849e-01,
177 var cosh
= []float64{
178 7.2668796942212842775517446e+01,
179 1.1479413465659254502011135e+03,
180 1.0385767908766418550935495e+00,
181 7.5000957789658051428857788e+01,
182 7.655246669605357888468613e+03,
183 9.3567491758321272072888257e+00,
184 9.331351599270605471131735e+01,
185 7.6833430994624643209296404e+00,
186 3.1829371625150718153881164e+00,
187 2.9595059261916188501640911e+03,
190 5.1865354817738701906913566e-01,
191 7.2623875834137295116929844e-01,
192 -3.123458688281309990629839e-02,
193 -5.2143121110253302920437013e-01,
194 8.2704742671312902508629582e-01,
195 3.2101767558376376743993945e-01,
196 5.403990312223245516066252e-01,
197 3.0034702916738588551174831e-01,
198 2.0369924417882241241559589e-01,
199 -7.8069386968009226729944677e-01,
201 var erfc
= []float64{
202 4.8134645182261298093086434e-01,
203 2.7376124165862704883070156e-01,
204 1.0312345868828130999062984e+00,
205 1.5214312111025330292043701e+00,
206 1.7295257328687097491370418e-01,
207 6.7898232441623623256006055e-01,
208 4.596009687776754483933748e-01,
209 6.9965297083261411448825169e-01,
210 7.9630075582117758758440411e-01,
211 1.7806938696800922672994468e+00,
214 1.4533071302642137507696589e+02,
215 2.2958822575694449002537581e+03,
216 7.5814542574851666582042306e-01,
217 6.6668778421791005061482264e-03,
218 1.5310493273896033740861206e+04,
219 1.8659907517999328638667732e+01,
220 1.8662167355098714543942057e+02,
221 1.5301332413189378961665788e+01,
222 6.2047063430646876349125085e+00,
223 1.6894712385826521111610438e-04,
225 var expm1
= []float64{
226 5.105047796122957327384770212e-02,
227 8.046199708567344080562675439e-02,
228 -2.764970978891639815187418703e-03,
229 -4.8871434888875355394330300273e-02,
230 1.0115864277221467777117227494e-01,
231 2.969616407795910726014621657e-02,
232 5.368214487944892300914037972e-02,
233 2.765488851131274068067445335e-02,
234 1.842068661871398836913874273e-02,
235 -8.3193870863553801814961137573e-02,
237 var exp2
= []float64{
238 3.1537839463286288034313104e+01,
239 2.1361549283756232296144849e+02,
240 8.2537402562185562902577219e-01,
241 3.1021158628740294833424229e-02,
242 7.9581744110252191462569661e+02,
243 7.6019905892596359262696423e+00,
244 3.7506882048388096973183084e+01,
245 6.6250893439173561733216375e+00,
246 3.5438267900243941544605339e+00,
247 2.4281533133513300984289196e-03,
249 var fabs
= []float64{
250 4.9790119248836735e+00,
251 7.7388724745781045e+00,
252 2.7688005719200159e-01,
253 5.0106036182710749e+00,
254 9.6362937071984173e+00,
255 2.9263772392439646e+00,
256 5.2290834314593066e+00,
257 2.7279399104360102e+00,
258 1.8253080916808550e+00,
259 8.6859247685756013e+00,
261 var fdim
= []float64{
262 4.9790119248836735e+00,
263 7.7388724745781045e+00,
264 0.0000000000000000e+00,
265 0.0000000000000000e+00,
266 9.6362937071984173e+00,
267 2.9263772392439646e+00,
268 5.2290834314593066e+00,
269 2.7279399104360102e+00,
270 1.8253080916808550e+00,
271 0.0000000000000000e+00,
273 var floor
= []float64{
274 4.0000000000000000e+00,
275 7.0000000000000000e+00,
276 -1.0000000000000000e+00,
277 -6.0000000000000000e+00,
278 9.0000000000000000e+00,
279 2.0000000000000000e+00,
280 5.0000000000000000e+00,
281 2.0000000000000000e+00,
282 1.0000000000000000e+00,
283 -9.0000000000000000e+00,
285 var fmod
= []float64{
286 4.197615023265299782906368e-02,
287 2.261127525421895434476482e+00,
288 3.231794108794261433104108e-02,
289 4.989396381728925078391512e+00,
290 3.637062928015826201999516e-01,
291 1.220868282268106064236690e+00,
292 4.770916568540693347699744e+00,
293 1.816180268691969246219742e+00,
294 8.734595415957246977711748e-01,
295 1.314075231424398637614104e+00,
304 {6.2237649061045918750e-01, 3},
305 {9.6735905932226306250e-01, 3},
306 {-5.5376011438400318000e-01, -1},
307 {-6.2632545228388436250e-01, 3},
308 {6.02268356699901081250e-01, 4},
309 {7.3159430981099115000e-01, 2},
310 {6.5363542893241332500e-01, 3},
311 {6.8198497760900255000e-01, 2},
312 {9.1265404584042750000e-01, 1},
313 {-5.4287029803597508250e-01, 4},
315 var gamma
= []float64{
316 2.3254348370739963835386613898e+01,
317 2.991153837155317076427529816e+03,
318 -4.561154336726758060575129109e+00,
319 7.719403468842639065959210984e-01,
320 1.6111876618855418534325755566e+05,
321 1.8706575145216421164173224946e+00,
322 3.4082787447257502836734201635e+01,
323 1.579733951448952054898583387e+00,
324 9.3834586598354592860187267089e-01,
325 -2.093995902923148389186189429e-05,
328 -1.8444682230601672018219338e-01,
329 2.27353668906331975435892e-01,
330 9.809259936157051116270273e-01,
331 -1.741170131426226587841181e-01,
332 -2.1389448451144143352039069e-01,
333 -2.340905848928038763337414e-01,
334 -1.0029099691890912094586326e-01,
335 -1.5466726714884328135358907e-01,
336 3.252650187653420388714693e-01,
337 -8.72218484409407250005360235e-03,
340 -3.251526395295203422162967e-01,
341 1.893581711430515718062564e-01,
342 -1.3711761352467242914491514e-01,
343 3.287486536269617297529617e-01,
344 1.3133899188830978473849215e-01,
345 3.660243417832986825301766e-01,
346 -3.4436769271848174665420672e-01,
347 4.329481396640773768835036e-01,
348 5.8181350531954794639333955e-01,
349 -2.7030574577733036112996607e-01,
352 5.3837518920137802565192769e-02,
353 -1.7841678003393207281244667e-01,
354 9.521746934916464142495821e-03,
355 4.28958355470987397983072e-02,
356 2.4115371837854494725492872e-01,
357 4.842458532394520316844449e-01,
358 -3.142145220618633390125946e-02,
359 4.720849184745124761189957e-01,
360 3.122312022520957042957497e-01,
361 7.096213118930231185707277e-02,
364 -3.684042080996403091021151e-01,
365 2.8157665936340887268092661e-01,
366 4.401005480841948348343589e-04,
367 3.629926999056814081597135e-01,
368 3.123672198825455192489266e-02,
369 -2.958805510589623607540455e-01,
370 -3.2033177696533233403289416e-01,
371 -2.592737332129663376736604e-01,
372 -1.0241334641061485092351251e-01,
373 -2.3762660886100206491674503e-01,
376 {3.146492141244545774319734e+00, 1},
377 {8.003414490659126375852113e+00, 1},
378 {1.517575735509779707488106e+00, -1},
379 {-2.588480028182145853558748e-01, 1},
380 {1.1989897050205555002007985e+01, 1},
381 {6.262899811091257519386906e-01, 1},
382 {3.5287924899091566764846037e+00, 1},
383 {4.5725644770161182299423372e-01, 1},
384 {-6.363667087767961257654854e-02, 1},
385 {-1.077385130910300066425564e+01, -1},
388 1.605231462693062999102599e+00,
389 2.0462560018708770653153909e+00,
390 -1.2841708730962657801275038e+00,
391 1.6115563905281545116286206e+00,
392 2.2655365644872016636317461e+00,
393 1.0737652208918379856272735e+00,
394 1.6542360106073546632707956e+00,
395 1.0035467127723465801264487e+00,
396 6.0174879014578057187016475e-01,
397 2.161703872847352815363655e+00,
399 var logb
= []float64{
400 2.0000000000000000e+00,
401 2.0000000000000000e+00,
402 -2.0000000000000000e+00,
403 2.0000000000000000e+00,
404 3.0000000000000000e+00,
405 1.0000000000000000e+00,
406 2.0000000000000000e+00,
407 1.0000000000000000e+00,
408 0.0000000000000000e+00,
409 3.0000000000000000e+00,
411 var log10
= []float64{
412 6.9714316642508290997617083e-01,
413 8.886776901739320576279124e-01,
414 -5.5770832400658929815908236e-01,
415 6.998900476822994346229723e-01,
416 9.8391002850684232013281033e-01,
417 4.6633031029295153334285302e-01,
418 7.1842557117242328821552533e-01,
419 4.3583479968917773161304553e-01,
420 2.6133617905227038228626834e-01,
421 9.3881606348649405716214241e-01,
423 var log1p
= []float64{
424 4.8590257759797794104158205e-02,
425 7.4540265965225865330849141e-02,
426 -2.7726407903942672823234024e-03,
427 -5.1404917651627649094953380e-02,
428 9.1998280672258624681335010e-02,
429 2.8843762576593352865894824e-02,
430 5.0969534581863707268992645e-02,
431 2.6913947602193238458458594e-02,
432 1.8088493239630770262045333e-02,
433 -9.0865245631588989681559268e-02,
435 var log2
= []float64{
436 2.3158594707062190618898251e+00,
437 2.9521233862883917703341018e+00,
438 -1.8526669502700329984917062e+00,
439 2.3249844127278861543568029e+00,
440 3.268478366538305087466309e+00,
441 1.5491157592596970278166492e+00,
442 2.3865580889631732407886495e+00,
443 1.447811865817085365540347e+00,
444 8.6813999540425116282815557e-01,
445 3.118679457227342224364709e+00,
447 var modf
= [][2]float64{
448 {4.0000000000000000e+00, 9.7901192488367350108546816e-01},
449 {7.0000000000000000e+00, 7.3887247457810456552351752e-01},
450 {0.0000000000000000e+00, -2.7688005719200159404635997e-01},
451 {-5.0000000000000000e+00, -1.060361827107492160848778e-02},
452 {9.0000000000000000e+00, 6.3629370719841737980004837e-01},
453 {2.0000000000000000e+00, 9.2637723924396464525443662e-01},
454 {5.0000000000000000e+00, 2.2908343145930665230025625e-01},
455 {2.0000000000000000e+00, 7.2793991043601025126008608e-01},
456 {1.0000000000000000e+00, 8.2530809168085506044576505e-01},
457 {-8.0000000000000000e+00, -6.8592476857560136238589621e-01},
459 var nextafter32
= []float32{
460 4.979012489318848e+00,
461 7.738873004913330e+00,
462 -2.768800258636475e-01,
463 -5.010602951049805e+00,
464 9.636294364929199e+00,
465 2.926377534866333e+00,
466 5.229084014892578e+00,
467 2.727940082550049e+00,
468 1.825308203697205e+00,
469 -8.685923576354980e+00,
471 var nextafter64
= []float64{
472 4.97901192488367438926388786e+00,
473 7.73887247457810545370193722e+00,
474 -2.7688005719200153853520874e-01,
475 -5.01060361827107403343006808e+00,
476 9.63629370719841915615688777e+00,
477 2.92637723924396508934364647e+00,
478 5.22908343145930754047867595e+00,
479 2.72793991043601069534929593e+00,
480 1.82530809168085528249036997e+00,
481 -8.68592476857559958602905681e+00,
484 9.5282232631648411840742957e+04,
485 5.4811599352999901232411871e+07,
486 5.2859121715894396531132279e-01,
487 9.7587991957286474464259698e-06,
488 4.328064329346044846740467e+09,
489 8.4406761805034547437659092e+02,
490 1.6946633276191194947742146e+05,
491 5.3449040147551939075312879e+02,
492 6.688182138451414936380374e+01,
493 2.0609869004248742886827439e-09,
495 var remainder
= []float64{
496 4.197615023265299782906368e-02,
497 2.261127525421895434476482e+00,
498 3.231794108794261433104108e-02,
499 -2.120723654214984321697556e-02,
500 3.637062928015826201999516e-01,
501 1.220868282268106064236690e+00,
502 -4.581668629186133046005125e-01,
503 -9.117596417440410050403443e-01,
504 8.734595415957246977711748e-01,
505 1.314075231424398637614104e+00,
507 var signbit
= []bool{
520 -9.6466616586009283766724726e-01,
521 9.9338225271646545763467022e-01,
522 -2.7335587039794393342449301e-01,
523 9.5586257685042792878173752e-01,
524 -2.099421066779969164496634e-01,
525 2.135578780799860532750616e-01,
526 -8.694568971167362743327708e-01,
527 4.019566681155577786649878e-01,
528 9.6778633541687993721617774e-01,
529 -6.734405869050344734943028e-01,
532 // Results for 100000 * Pi + vf[i]
533 var sinLarge
= []float64{
534 -9.646661658548936063912e-01,
535 9.933822527198506903752e-01,
536 -2.7335587036246899796e-01,
537 9.55862576853689321268e-01,
538 -2.099421066862688873691e-01,
539 2.13557878070308981163e-01,
540 -8.694568970959221300497e-01,
541 4.01956668098863248917e-01,
542 9.67786335404528727927e-01,
543 -6.7344058693131973066e-01,
545 var sinh
= []float64{
546 7.2661916084208532301448439e+01,
547 1.1479409110035194500526446e+03,
548 -2.8043136512812518927312641e-01,
549 -7.499429091181587232835164e+01,
550 7.6552466042906758523925934e+03,
551 9.3031583421672014313789064e+00,
552 9.330815755828109072810322e+01,
553 7.6179893137269146407361477e+00,
554 3.021769180549615819524392e+00,
555 -2.95950575724449499189888e+03,
557 var sqrt
= []float64{
558 2.2313699659365484748756904e+00,
559 2.7818829009464263511285458e+00,
560 5.2619393496314796848143251e-01,
561 2.2384377628763938724244104e+00,
562 3.1042380236055381099288487e+00,
563 1.7106657298385224403917771e+00,
564 2.286718922705479046148059e+00,
565 1.6516476350711159636222979e+00,
566 1.3510396336454586262419247e+00,
567 2.9471892997524949215723329e+00,
570 -3.661316565040227801781974e+00,
571 8.64900232648597589369854e+00,
572 -2.8417941955033612725238097e-01,
573 3.253290185974728640827156e+00,
574 2.147275640380293804770778e-01,
575 -2.18600910711067004921551e-01,
576 -1.760002817872367935518928e+00,
577 -4.389808914752818126249079e-01,
578 -3.843885560201130679995041e+00,
579 9.10988793377685105753416e-01,
582 // Results for 100000 * Pi + vf[i]
583 var tanLarge
= []float64{
584 -3.66131656475596512705e+00,
585 8.6490023287202547927e+00,
586 -2.841794195104782406e-01,
587 3.2532901861033120983e+00,
588 2.14727564046880001365e-01,
589 -2.18600910700688062874e-01,
590 -1.760002817699722747043e+00,
591 -4.38980891453536115952e-01,
592 -3.84388555942723509071e+00,
593 9.1098879344275101051e-01,
595 var tanh
= []float64{
596 9.9990531206936338549262119e-01,
597 9.9999962057085294197613294e-01,
598 -2.7001505097318677233756845e-01,
599 -9.9991110943061718603541401e-01,
600 9.9999999146798465745022007e-01,
601 9.9427249436125236705001048e-01,
602 9.9994257600983138572705076e-01,
603 9.9149409509772875982054701e-01,
604 9.4936501296239685514466577e-01,
605 -9.9999994291374030946055701e-01,
607 var trunc
= []float64{
608 4.0000000000000000e+00,
609 7.0000000000000000e+00,
610 -0.0000000000000000e+00,
611 -5.0000000000000000e+00,
612 9.0000000000000000e+00,
613 2.0000000000000000e+00,
614 5.0000000000000000e+00,
615 2.0000000000000000e+00,
616 1.0000000000000000e+00,
617 -8.0000000000000000e+00,
620 -3.053399153780788357534855e-01,
621 1.7437227649515231515503649e-01,
622 -8.6221781263678836910392572e-01,
623 -3.100664880987498407872839e-01,
624 1.422200649300982280645377e-01,
625 4.000004067997901144239363e-01,
626 -3.3340749753099352392332536e-01,
627 4.5399790746668954555205502e-01,
628 4.8290004112497761007536522e-01,
629 2.7036697826604756229601611e-01,
632 0.15494213737457922210218611,
633 -0.2165955142081145245075746,
634 -2.4644949631241895201032829,
635 0.1442740489541836405154505,
636 0.2215379960518984777080163,
637 0.3038800915160754150565448,
638 0.0691107642452362383808547,
639 0.2380116417809914424860165,
640 -0.20849492979459761009678934,
641 0.0242503179793232308250804,
644 0.3675780219390303613394936,
645 -0.23034826393250119879267257,
646 -16.939677983817727205631397,
647 0.367653980523052152867791,
648 -0.0962401471767804440353136,
649 -0.1923169356184851105200523,
650 0.35984072054267882391843766,
651 -0.2794987252299739821654982,
652 -0.7113490692587462579757954,
653 -0.2647831587821263302087457,
656 -0.14035984421094849100895341,
657 -0.097535139617792072703973,
658 242.25775994555580176377379,
659 -0.1492267014802818619511046,
660 0.26148702629155918694500469,
661 0.56675383593895176530394248,
662 -0.206150264009006981070575,
663 0.64784284687568332737963658,
664 1.3503631555901938037008443,
665 0.1461869756579956803341844,
668 // arguments and expected results for special cases
669 var vfacosSC
= []float64{
675 var acosSC
= []float64{
682 var vfacoshSC
= []float64{
689 var acoshSC
= []float64{
697 var vfasinSC
= []float64{
704 var asinSC
= []float64{
712 var vfasinhSC
= []float64{
719 var asinhSC
= []float64{
727 var vfatanSC
= []float64{
734 var atanSC
= []float64{
742 var vfatanhSC
= []float64{
753 var atanhSC
= []float64{
764 var vfatan2SC
= [][2]float64{
775 {Copysign(0, -1), Inf(-1)},
776 {Copysign(0, -1), -Pi
},
777 {Copysign(0, -1), Copysign(0, -1)},
778 {Copysign(0, -1), 0},
779 {Copysign(0, -1), +Pi
},
780 {Copysign(0, -1), Inf(1)},
781 {Copysign(0, -1), NaN()},
784 {0, Copysign(0, -1)},
801 var atan2SC
= []float64{
802 -3 * Pi
/ 4, // atan2(-Inf, -Inf)
803 -Pi
/ 2, // atan2(-Inf, -Pi)
804 -Pi
/ 2, // atan2(-Inf, +0)
805 -Pi
/ 2, // atan2(-Inf, +Pi)
806 -Pi
/ 4, // atan2(-Inf, +Inf)
807 NaN(), // atan2(-Inf, NaN)
808 -Pi
, // atan2(-Pi, -Inf)
809 -Pi
/ 2, // atan2(-Pi, +0)
810 Copysign(0, -1), // atan2(-Pi, Inf)
811 NaN(), // atan2(-Pi, NaN)
812 -Pi
, // atan2(-0, -Inf)
813 -Pi
, // atan2(-0, -Pi)
814 -Pi
, // atan2(-0, -0)
815 Copysign(0, -1), // atan2(-0, +0)
816 Copysign(0, -1), // atan2(-0, +Pi)
817 Copysign(0, -1), // atan2(-0, +Inf)
818 NaN(), // atan2(-0, NaN)
819 Pi
, // atan2(+0, -Inf)
820 Pi
, // atan2(+0, -Pi)
824 0, // atan2(+0, +Inf)
825 NaN(), // atan2(+0, NaN)
826 Pi
, // atan2(+Pi, -Inf)
827 Pi
/ 2, // atan2(+Pi, +0)
828 0, // atan2(+Pi, +Inf)
829 NaN(), // atan2(+Pi, NaN)
830 3 * Pi
/ 4, // atan2(+Inf, -Inf)
831 Pi
/ 2, // atan2(+Inf, -Pi)
832 Pi
/ 2, // atan2(+Inf, +0)
833 Pi
/ 2, // atan2(+Inf, +Pi)
834 Pi
/ 4, // atan2(+Inf, +Inf)
835 NaN(), // atan2(+Inf, NaN)
836 NaN(), // atan2(NaN, NaN)
839 var vfcbrtSC
= []float64{
846 var cbrtSC
= []float64{
854 var vfceilSC
= []float64{
861 var ceilSC
= []float64{
869 var vfcopysignSC
= []float64{
874 var copysignSC
= []float64{
880 var vfcosSC
= []float64{
885 var cosSC
= []float64{
891 var vfcoshSC
= []float64{
898 var coshSC
= []float64{
906 var vferfSC
= []float64{
913 var erfSC
= []float64{
921 var vferfcSC
= []float64{
926 var erfcSC
= []float64{
932 var vfexpSC
= []float64{
939 var expSC
= []float64{
947 var vfexpm1SC
= []float64{
954 var expm1SC
= []float64{
962 var vffabsSC
= []float64{
969 var fabsSC
= []float64{
977 var vffdimSC
= [][2]float64{
981 {Copysign(0, -1), Copysign(0, -1)},
982 {Copysign(0, -1), 0},
983 {0, Copysign(0, -1)},
989 {NaN(), Copysign(0, -1)},
994 var fdimSC
= []float64{
1011 var fmaxSC
= []float64{
1028 var fminSC
= []float64{
1046 var vffmodSC
= [][2]float64{
1057 {Copysign(0, -1), Inf(-1)},
1058 {Copysign(0, -1), 0},
1059 {Copysign(0, -1), Inf(1)},
1060 {Copysign(0, -1), NaN()},
1082 var fmodSC
= []float64{
1083 NaN(), // fmod(-Inf, -Inf)
1084 NaN(), // fmod(-Inf, -Pi)
1085 NaN(), // fmod(-Inf, 0)
1086 NaN(), // fmod(-Inf, Pi)
1087 NaN(), // fmod(-Inf, +Inf)
1088 NaN(), // fmod(-Inf, NaN)
1089 -Pi
, // fmod(-Pi, -Inf)
1090 NaN(), // fmod(-Pi, 0)
1091 -Pi
, // fmod(-Pi, +Inf)
1092 NaN(), // fmod(-Pi, NaN)
1093 Copysign(0, -1), // fmod(-0, -Inf)
1094 NaN(), // fmod(-0, 0)
1095 Copysign(0, -1), // fmod(-0, Inf)
1096 NaN(), // fmod(-0, NaN)
1098 NaN(), // fmod(0, 0)
1100 NaN(), // fmod(0, NaN)
1101 Pi
, // fmod(Pi, -Inf)
1102 NaN(), // fmod(Pi, 0)
1103 Pi
, // fmod(Pi, +Inf)
1104 NaN(), // fmod(Pi, NaN)
1105 NaN(), // fmod(+Inf, -Inf)
1106 NaN(), // fmod(+Inf, -Pi)
1107 NaN(), // fmod(+Inf, 0)
1108 NaN(), // fmod(+Inf, Pi)
1109 NaN(), // fmod(+Inf, +Inf)
1110 NaN(), // fmod(+Inf, NaN)
1111 NaN(), // fmod(NaN, -Inf)
1112 NaN(), // fmod(NaN, -Pi)
1113 NaN(), // fmod(NaN, 0)
1114 NaN(), // fmod(NaN, Pi)
1115 NaN(), // fmod(NaN, +Inf)
1116 NaN(), // fmod(NaN, NaN)
1119 var vffrexpSC
= []float64{
1128 {Copysign(0, -1), 0},
1134 var vfgammaSC
= []float64{
1142 var gammaSC
= []float64{
1151 var vfhypotSC
= [][2]float64{
1156 {Copysign(0, -1), Copysign(0, -1)},
1157 {Copysign(0, -1), 0},
1158 {0, Copysign(0, -1)},
1172 var hypotSC
= []float64{
1194 var vfilogbSC
= []float64{
1200 var ilogbSC
= []int{
1207 var vfj0SC
= []float64{
1213 var j0SC
= []float64{
1219 var j1SC
= []float64{
1225 var j2SC
= []float64{
1231 var jM3SC
= []float64{
1238 var vfldexpSC
= []fi
{
1242 {Copysign(0, -1), 0},
1243 {Copysign(0, -1), -1075},
1244 {Copysign(0, -1), 1024},
1251 var ldexpSC
= []float64{
1265 var vflgammaSC
= []float64{
1274 var lgammaSC
= []fi
{
1284 var vflogSC
= []float64{
1293 var logSC
= []float64{
1303 var vflogbSC
= []float64{
1309 var logbSC
= []float64{
1316 var vflog1pSC
= []float64{
1325 var log1pSC
= []float64{
1335 var vfmodfSC
= []float64{
1340 var modfSC
= [][2]float64{
1341 {Inf(-1), NaN()}, // [2]float64{Copysign(0, -1), Inf(-1)},
1342 {Inf(1), NaN()}, // [2]float64{0, Inf(1)},
1346 var vfnextafter32SC
= [][2]float32{
1348 {0, float32(Copysign(0, -1))},
1350 {0, float32(NaN())},
1351 {float32(Copysign(0, -1)), 1},
1352 {float32(Copysign(0, -1)), 0},
1353 {float32(Copysign(0, -1)), float32(Copysign(0, -1))},
1354 {float32(Copysign(0, -1)), -1},
1355 {float32(NaN()), 0},
1356 {float32(NaN()), float32(NaN())},
1358 var nextafter32SC
= []float32{
1361 -1.401298464e-45, // Float32frombits(0x80000001)
1363 1.401298464e-45, // Float32frombits(0x00000001)
1364 float32(Copysign(0, -1)),
1365 float32(Copysign(0, -1)),
1366 -1.401298464e-45, // Float32frombits(0x80000001)
1371 var vfnextafter64SC
= [][2]float64{
1373 {0, Copysign(0, -1)},
1376 {Copysign(0, -1), 1},
1377 {Copysign(0, -1), 0},
1378 {Copysign(0, -1), Copysign(0, -1)},
1379 {Copysign(0, -1), -1},
1383 var nextafter64SC
= []float64{
1386 -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1388 4.9406564584124654418e-324, // Float64frombits(0x0000000000000001)
1391 -4.9406564584124654418e-324, // Float64frombits(0x8000000000000001)
1396 var vfpowSC
= [][2]float64{
1399 {Inf(-1), Copysign(0, -1)},
1408 {-Pi
, Copysign(0, -1)},
1420 {Copysign(0, -1), Inf(-1)},
1421 {Copysign(0, -1), -Pi
},
1422 {Copysign(0, -1), -3},
1423 {Copysign(0, -1), 3},
1424 {Copysign(0, -1), Pi
},
1425 {Copysign(0, -1), Inf(1)},
1430 {0, Copysign(0, -1)},
1444 {Pi
, Copysign(0, -1)},
1450 {Inf(1), Copysign(0, -1)},
1456 {NaN(), Copysign(0, -1)},
1462 var powSC
= []float64{
1463 0, // pow(-Inf, -Pi)
1464 Copysign(0, -1), // pow(-Inf, -3)
1467 Inf(-1), // pow(-Inf, 1)
1468 Inf(-1), // pow(-Inf, 3)
1469 Inf(1), // pow(-Inf, Pi)
1470 NaN(), // pow(-Inf, NaN)
1471 0, // pow(-Pi, -Inf)
1472 NaN(), // pow(-Pi, -Pi)
1476 NaN(), // pow(-Pi, Pi)
1477 Inf(1), // pow(-Pi, +Inf)
1478 NaN(), // pow(-Pi, NaN)
1479 1, // pow(-1, -Inf) IEEE 754-2008
1480 1, // pow(-1, +Inf) IEEE 754-2008
1481 NaN(), // pow(-1, NaN)
1482 Inf(1), // pow(-1/2, -Inf)
1483 0, // pow(-1/2, +Inf)
1484 Inf(1), // pow(-0, -Inf)
1485 Inf(1), // pow(-0, -Pi)
1486 Inf(-1), // pow(-0, -3) IEEE 754-2008
1487 Copysign(0, -1), // pow(-0, 3) IEEE 754-2008
1490 Inf(1), // pow(+0, -Inf)
1491 Inf(1), // pow(+0, -Pi)
1492 Inf(1), // pow(+0, -3)
1498 NaN(), // pow(+0, NaN)
1499 Inf(1), // pow(1/2, -Inf)
1500 0, // pow(1/2, +Inf)
1501 1, // pow(1, -Inf) IEEE 754-2008
1502 1, // pow(1, +Inf) IEEE 754-2008
1503 1, // pow(1, NaN) IEEE 754-2008
1504 0, // pow(+Pi, -Inf)
1508 Inf(1), // pow(+Pi, +Inf)
1509 NaN(), // pow(+Pi, NaN)
1510 0, // pow(+Inf, -Pi)
1513 Inf(1), // pow(+Inf, 1)
1514 Inf(1), // pow(+Inf, Pi)
1515 NaN(), // pow(+Inf, NaN)
1516 NaN(), // pow(NaN, -Pi)
1519 NaN(), // pow(NaN, 1)
1520 NaN(), // pow(NaN, +Pi)
1521 NaN(), // pow(NaN, NaN)
1524 var vfpow10SC
= []int{
1531 var pow10SC
= []float64{
1532 0, // pow10(MinInt32)
1533 Inf(1), // pow10(MaxInt32)
1535 Inf(1), // pow10(309)
1538 var vfsignbitSC
= []float64{
1545 var signbitSC
= []bool{
1553 var vfsinSC
= []float64{
1560 var sinSC
= []float64{
1568 var vfsinhSC
= []float64{
1575 var sinhSC
= []float64{
1583 var vfsqrtSC
= []float64{
1591 var sqrtSC
= []float64{
1600 var vftanhSC
= []float64{
1607 var tanhSC
= []float64{
1615 var vfy0SC
= []float64{
1621 var y0SC
= []float64{
1627 var y1SC
= []float64{
1633 var y2SC
= []float64{
1639 var yM3SC
= []float64{
1646 // arguments and expected results for boundary cases
1648 SmallestNormalFloat64
= 2.2250738585072014e-308 // 2**-1022
1649 LargestSubnormalFloat64
= SmallestNormalFloat64
- SmallestNonzeroFloat64
1652 var vffrexpBC
= []float64{
1653 SmallestNormalFloat64
,
1654 LargestSubnormalFloat64
,
1655 SmallestNonzeroFloat64
,
1657 -SmallestNormalFloat64
,
1658 -LargestSubnormalFloat64
,
1659 -SmallestNonzeroFloat64
,
1664 {0.99999999999999978, -1022},
1666 {0.99999999999999989, 1024},
1668 {-0.99999999999999978, -1022},
1670 {-0.99999999999999989, 1024},
1673 var vfldexpBC
= []fi
{
1674 {SmallestNormalFloat64
, -52},
1675 {LargestSubnormalFloat64
, -51},
1676 {SmallestNonzeroFloat64
, 1074},
1677 {MaxFloat64
, -(1023 + 1074)},
1683 var ldexpBC
= []float64{
1684 SmallestNonzeroFloat64
,
1694 var logbBC
= []float64{
1705 func tolerance(a
, b
, e
float64) bool {
1719 func kindaclose(a
, b
float64) bool { return tolerance(a
, b
, 1e-8) }
1720 func close(a
, b
float64) bool { return tolerance(a
, b
, 1e-14) }
1721 func veryclose(a
, b
float64) bool { return tolerance(a
, b
, 4e-16) }
1722 func soclose(a
, b
, e
float64) bool { return tolerance(a
, b
, e
) }
1723 func alike(a
, b
float64) bool {
1725 case IsNaN(a
) && IsNaN(b
):
1728 return Signbit(a
) == Signbit(b
)
1733 func TestNaN(t
*testing
.T
) {
1736 t
.Fatalf("NaN() returns %g, expected NaN", f64
)
1740 t
.Fatalf("float32(NaN()) is %g, expected NaN", f32
)
1744 func TestAcos(t
*testing
.T
) {
1745 for i
:= 0; i
< len(vf
); i
++ {
1747 if f
:= Acos(a
); !close(acos
[i
], f
) {
1748 t
.Errorf("Acos(%g) = %g, want %g", a
, f
, acos
[i
])
1751 for i
:= 0; i
< len(vfacosSC
); i
++ {
1752 if f
:= Acos(vfacosSC
[i
]); !alike(acosSC
[i
], f
) {
1753 t
.Errorf("Acos(%g) = %g, want %g", vfacosSC
[i
], f
, acosSC
[i
])
1758 func TestAcosh(t
*testing
.T
) {
1759 for i
:= 0; i
< len(vf
); i
++ {
1761 if f
:= Acosh(a
); !veryclose(acosh
[i
], f
) {
1762 t
.Errorf("Acosh(%g) = %g, want %g", a
, f
, acosh
[i
])
1765 for i
:= 0; i
< len(vfacoshSC
); i
++ {
1766 if f
:= Acosh(vfacoshSC
[i
]); !alike(acoshSC
[i
], f
) {
1767 t
.Errorf("Acosh(%g) = %g, want %g", vfacoshSC
[i
], f
, acoshSC
[i
])
1772 func TestAsin(t
*testing
.T
) {
1773 for i
:= 0; i
< len(vf
); i
++ {
1775 if f
:= Asin(a
); !veryclose(asin
[i
], f
) {
1776 t
.Errorf("Asin(%g) = %g, want %g", a
, f
, asin
[i
])
1779 for i
:= 0; i
< len(vfasinSC
); i
++ {
1780 if f
:= Asin(vfasinSC
[i
]); !alike(asinSC
[i
], f
) {
1781 t
.Errorf("Asin(%g) = %g, want %g", vfasinSC
[i
], f
, asinSC
[i
])
1786 func TestAsinh(t
*testing
.T
) {
1787 for i
:= 0; i
< len(vf
); i
++ {
1788 if f
:= Asinh(vf
[i
]); !veryclose(asinh
[i
], f
) {
1789 t
.Errorf("Asinh(%g) = %g, want %g", vf
[i
], f
, asinh
[i
])
1792 for i
:= 0; i
< len(vfasinhSC
); i
++ {
1793 if f
:= Asinh(vfasinhSC
[i
]); !alike(asinhSC
[i
], f
) {
1794 t
.Errorf("Asinh(%g) = %g, want %g", vfasinhSC
[i
], f
, asinhSC
[i
])
1799 func TestAtan(t
*testing
.T
) {
1800 for i
:= 0; i
< len(vf
); i
++ {
1801 if f
:= Atan(vf
[i
]); !veryclose(atan
[i
], f
) {
1802 t
.Errorf("Atan(%g) = %g, want %g", vf
[i
], f
, atan
[i
])
1805 for i
:= 0; i
< len(vfatanSC
); i
++ {
1806 if f
:= Atan(vfatanSC
[i
]); !alike(atanSC
[i
], f
) {
1807 t
.Errorf("Atan(%g) = %g, want %g", vfatanSC
[i
], f
, atanSC
[i
])
1812 func TestAtanh(t
*testing
.T
) {
1813 for i
:= 0; i
< len(vf
); i
++ {
1815 if f
:= Atanh(a
); !veryclose(atanh
[i
], f
) {
1816 t
.Errorf("Atanh(%g) = %g, want %g", a
, f
, atanh
[i
])
1819 for i
:= 0; i
< len(vfatanhSC
); i
++ {
1820 if f
:= Atanh(vfatanhSC
[i
]); !alike(atanhSC
[i
], f
) {
1821 t
.Errorf("Atanh(%g) = %g, want %g", vfatanhSC
[i
], f
, atanhSC
[i
])
1826 func TestAtan2(t
*testing
.T
) {
1827 for i
:= 0; i
< len(vf
); i
++ {
1828 if f
:= Atan2(10, vf
[i
]); !veryclose(atan2
[i
], f
) {
1829 t
.Errorf("Atan2(10, %g) = %g, want %g", vf
[i
], f
, atan2
[i
])
1832 for i
:= 0; i
< len(vfatan2SC
); i
++ {
1833 if f
:= Atan2(vfatan2SC
[i
][0], vfatan2SC
[i
][1]); !alike(atan2SC
[i
], f
) {
1834 t
.Errorf("Atan2(%g, %g) = %g, want %g", vfatan2SC
[i
][0], vfatan2SC
[i
][1], f
, atan2SC
[i
])
1839 func TestCbrt(t
*testing
.T
) {
1840 for i
:= 0; i
< len(vf
); i
++ {
1841 if f
:= Cbrt(vf
[i
]); !veryclose(cbrt
[i
], f
) {
1842 t
.Errorf("Cbrt(%g) = %g, want %g", vf
[i
], f
, cbrt
[i
])
1845 for i
:= 0; i
< len(vfcbrtSC
); i
++ {
1846 if f
:= Cbrt(vfcbrtSC
[i
]); !alike(cbrtSC
[i
], f
) {
1847 t
.Errorf("Cbrt(%g) = %g, want %g", vfcbrtSC
[i
], f
, cbrtSC
[i
])
1852 func TestCeil(t
*testing
.T
) {
1853 for i
:= 0; i
< len(vf
); i
++ {
1854 if f
:= Ceil(vf
[i
]); ceil
[i
] != f
{
1855 t
.Errorf("Ceil(%g) = %g, want %g", vf
[i
], f
, ceil
[i
])
1858 for i
:= 0; i
< len(vfceilSC
); i
++ {
1859 if f
:= Ceil(vfceilSC
[i
]); !alike(ceilSC
[i
], f
) {
1860 t
.Errorf("Ceil(%g) = %g, want %g", vfceilSC
[i
], f
, ceilSC
[i
])
1865 func TestCopysign(t
*testing
.T
) {
1866 for i
:= 0; i
< len(vf
); i
++ {
1867 if f
:= Copysign(vf
[i
], -1); copysign
[i
] != f
{
1868 t
.Errorf("Copysign(%g, -1) = %g, want %g", vf
[i
], f
, copysign
[i
])
1871 for i
:= 0; i
< len(vf
); i
++ {
1872 if f
:= Copysign(vf
[i
], 1); -copysign
[i
] != f
{
1873 t
.Errorf("Copysign(%g, 1) = %g, want %g", vf
[i
], f
, -copysign
[i
])
1876 for i
:= 0; i
< len(vfcopysignSC
); i
++ {
1877 if f
:= Copysign(vfcopysignSC
[i
], -1); !alike(copysignSC
[i
], f
) {
1878 t
.Errorf("Copysign(%g, -1) = %g, want %g", vfcopysignSC
[i
], f
, copysignSC
[i
])
1883 func TestCos(t
*testing
.T
) {
1884 for i
:= 0; i
< len(vf
); i
++ {
1885 if f
:= Cos(vf
[i
]); !veryclose(cos
[i
], f
) {
1886 t
.Errorf("Cos(%g) = %g, want %g", vf
[i
], f
, cos
[i
])
1889 for i
:= 0; i
< len(vfcosSC
); i
++ {
1890 if f
:= Cos(vfcosSC
[i
]); !alike(cosSC
[i
], f
) {
1891 t
.Errorf("Cos(%g) = %g, want %g", vfcosSC
[i
], f
, cosSC
[i
])
1896 func TestCosh(t
*testing
.T
) {
1897 for i
:= 0; i
< len(vf
); i
++ {
1898 if f
:= Cosh(vf
[i
]); !close(cosh
[i
], f
) {
1899 t
.Errorf("Cosh(%g) = %g, want %g", vf
[i
], f
, cosh
[i
])
1902 for i
:= 0; i
< len(vfcoshSC
); i
++ {
1903 if f
:= Cosh(vfcoshSC
[i
]); !alike(coshSC
[i
], f
) {
1904 t
.Errorf("Cosh(%g) = %g, want %g", vfcoshSC
[i
], f
, coshSC
[i
])
1909 func TestErf(t
*testing
.T
) {
1910 for i
:= 0; i
< len(vf
); i
++ {
1912 if f
:= Erf(a
); !veryclose(erf
[i
], f
) {
1913 t
.Errorf("Erf(%g) = %g, want %g", a
, f
, erf
[i
])
1916 for i
:= 0; i
< len(vferfSC
); i
++ {
1917 if f
:= Erf(vferfSC
[i
]); !alike(erfSC
[i
], f
) {
1918 t
.Errorf("Erf(%g) = %g, want %g", vferfSC
[i
], f
, erfSC
[i
])
1923 func TestErfc(t
*testing
.T
) {
1924 for i
:= 0; i
< len(vf
); i
++ {
1926 if f
:= Erfc(a
); !veryclose(erfc
[i
], f
) {
1927 t
.Errorf("Erfc(%g) = %g, want %g", a
, f
, erfc
[i
])
1930 for i
:= 0; i
< len(vferfcSC
); i
++ {
1931 if f
:= Erfc(vferfcSC
[i
]); !alike(erfcSC
[i
], f
) {
1932 t
.Errorf("Erfc(%g) = %g, want %g", vferfcSC
[i
], f
, erfcSC
[i
])
1937 func TestExp(t
*testing
.T
) {
1938 testExp(t
, Exp
, "Exp")
1939 testExp(t
, ExpGo
, "ExpGo")
1942 func testExp(t
*testing
.T
, Exp
func(float64) float64, name
string) {
1943 for i
:= 0; i
< len(vf
); i
++ {
1944 if f
:= Exp(vf
[i
]); !close(exp
[i
], f
) {
1945 t
.Errorf("%s(%g) = %g, want %g", name
, vf
[i
], f
, exp
[i
])
1948 for i
:= 0; i
< len(vfexpSC
); i
++ {
1949 if f
:= Exp(vfexpSC
[i
]); !alike(expSC
[i
], f
) {
1950 t
.Errorf("%s(%g) = %g, want %g", name
, vfexpSC
[i
], f
, expSC
[i
])
1955 func TestExpm1(t
*testing
.T
) {
1956 for i
:= 0; i
< len(vf
); i
++ {
1958 if f
:= Expm1(a
); !veryclose(expm1
[i
], f
) {
1959 t
.Errorf("Expm1(%g) = %g, want %g", a
, f
, expm1
[i
])
1962 for i
:= 0; i
< len(vfexpm1SC
); i
++ {
1963 if f
:= Expm1(vfexpm1SC
[i
]); !alike(expm1SC
[i
], f
) {
1964 t
.Errorf("Expm1(%g) = %g, want %g", vfexpm1SC
[i
], f
, expm1SC
[i
])
1969 func TestExp2(t
*testing
.T
) {
1970 testExp2(t
, Exp2
, "Exp2")
1971 testExp2(t
, Exp2Go
, "Exp2Go")
1974 func testExp2(t
*testing
.T
, Exp2
func(float64) float64, name
string) {
1975 for i
:= 0; i
< len(vf
); i
++ {
1976 if f
:= Exp2(vf
[i
]); !close(exp2
[i
], f
) {
1977 t
.Errorf("%s(%g) = %g, want %g", name
, vf
[i
], f
, exp2
[i
])
1980 for i
:= 0; i
< len(vfexpSC
); i
++ {
1981 if f
:= Exp2(vfexpSC
[i
]); !alike(expSC
[i
], f
) {
1982 t
.Errorf("%s(%g) = %g, want %g", name
, vfexpSC
[i
], f
, expSC
[i
])
1985 for n
:= -1074; n
< 1024; n
++ {
1986 f
:= Exp2(float64(n
))
1989 t
.Errorf("%s(%d) = %g, want %g", name
, n
, f
, vf
)
1994 func TestAbs(t
*testing
.T
) {
1995 for i
:= 0; i
< len(vf
); i
++ {
1996 if f
:= Abs(vf
[i
]); fabs
[i
] != f
{
1997 t
.Errorf("Abs(%g) = %g, want %g", vf
[i
], f
, fabs
[i
])
2000 for i
:= 0; i
< len(vffabsSC
); i
++ {
2001 if f
:= Abs(vffabsSC
[i
]); !alike(fabsSC
[i
], f
) {
2002 t
.Errorf("Abs(%g) = %g, want %g", vffabsSC
[i
], f
, fabsSC
[i
])
2007 func TestDim(t
*testing
.T
) {
2008 for i
:= 0; i
< len(vf
); i
++ {
2009 if f
:= Dim(vf
[i
], 0); fdim
[i
] != f
{
2010 t
.Errorf("Dim(%g, %g) = %g, want %g", vf
[i
], 0.0, f
, fdim
[i
])
2013 for i
:= 0; i
< len(vffdimSC
); i
++ {
2014 if f
:= Dim(vffdimSC
[i
][0], vffdimSC
[i
][1]); !alike(fdimSC
[i
], f
) {
2015 t
.Errorf("Dim(%g, %g) = %g, want %g", vffdimSC
[i
][0], vffdimSC
[i
][1], f
, fdimSC
[i
])
2020 func TestFloor(t
*testing
.T
) {
2021 for i
:= 0; i
< len(vf
); i
++ {
2022 if f
:= Floor(vf
[i
]); floor
[i
] != f
{
2023 t
.Errorf("Floor(%g) = %g, want %g", vf
[i
], f
, floor
[i
])
2026 for i
:= 0; i
< len(vfceilSC
); i
++ {
2027 if f
:= Floor(vfceilSC
[i
]); !alike(ceilSC
[i
], f
) {
2028 t
.Errorf("Floor(%g) = %g, want %g", vfceilSC
[i
], f
, ceilSC
[i
])
2033 func TestMax(t
*testing
.T
) {
2034 for i
:= 0; i
< len(vf
); i
++ {
2035 if f
:= Max(vf
[i
], ceil
[i
]); ceil
[i
] != f
{
2036 t
.Errorf("Max(%g, %g) = %g, want %g", vf
[i
], ceil
[i
], f
, ceil
[i
])
2039 for i
:= 0; i
< len(vffdimSC
); i
++ {
2040 if f
:= Max(vffdimSC
[i
][0], vffdimSC
[i
][1]); !alike(fmaxSC
[i
], f
) {
2041 t
.Errorf("Max(%g, %g) = %g, want %g", vffdimSC
[i
][0], vffdimSC
[i
][1], f
, fmaxSC
[i
])
2046 func TestMin(t
*testing
.T
) {
2047 for i
:= 0; i
< len(vf
); i
++ {
2048 if f
:= Min(vf
[i
], floor
[i
]); floor
[i
] != f
{
2049 t
.Errorf("Min(%g, %g) = %g, want %g", vf
[i
], floor
[i
], f
, floor
[i
])
2052 for i
:= 0; i
< len(vffdimSC
); i
++ {
2053 if f
:= Min(vffdimSC
[i
][0], vffdimSC
[i
][1]); !alike(fminSC
[i
], f
) {
2054 t
.Errorf("Min(%g, %g) = %g, want %g", vffdimSC
[i
][0], vffdimSC
[i
][1], f
, fminSC
[i
])
2059 func TestMod(t
*testing
.T
) {
2060 for i
:= 0; i
< len(vf
); i
++ {
2061 if f
:= Mod(10, vf
[i
]); fmod
[i
] != f
{
2062 t
.Errorf("Mod(10, %g) = %g, want %g", vf
[i
], f
, fmod
[i
])
2065 for i
:= 0; i
< len(vffmodSC
); i
++ {
2066 if f
:= Mod(vffmodSC
[i
][0], vffmodSC
[i
][1]); !alike(fmodSC
[i
], f
) {
2067 t
.Errorf("Mod(%g, %g) = %g, want %g", vffmodSC
[i
][0], vffmodSC
[i
][1], f
, fmodSC
[i
])
2072 func TestFrexp(t
*testing
.T
) {
2073 for i
:= 0; i
< len(vf
); i
++ {
2074 if f
, j
:= Frexp(vf
[i
]); !veryclose(frexp
[i
].f
, f
) || frexp
[i
].i
!= j
{
2075 t
.Errorf("Frexp(%g) = %g, %d, want %g, %d", vf
[i
], f
, j
, frexp
[i
].f
, frexp
[i
].i
)
2078 for i
:= 0; i
< len(vffrexpSC
); i
++ {
2079 if f
, j
:= Frexp(vffrexpSC
[i
]); !alike(frexpSC
[i
].f
, f
) || frexpSC
[i
].i
!= j
{
2080 t
.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpSC
[i
], f
, j
, frexpSC
[i
].f
, frexpSC
[i
].i
)
2083 for i
:= 0; i
< len(vffrexpBC
); i
++ {
2084 if f
, j
:= Frexp(vffrexpBC
[i
]); !alike(frexpBC
[i
].f
, f
) || frexpBC
[i
].i
!= j
{
2085 t
.Errorf("Frexp(%g) = %g, %d, want %g, %d", vffrexpBC
[i
], f
, j
, frexpBC
[i
].f
, frexpBC
[i
].i
)
2090 func TestGamma(t
*testing
.T
) {
2091 for i
:= 0; i
< len(vf
); i
++ {
2092 if f
:= Gamma(vf
[i
]); !close(gamma
[i
], f
) {
2093 t
.Errorf("Gamma(%g) = %g, want %g", vf
[i
], f
, gamma
[i
])
2096 for i
:= 0; i
< len(vfgammaSC
); i
++ {
2097 if f
:= Gamma(vfgammaSC
[i
]); !alike(gammaSC
[i
], f
) {
2098 t
.Errorf("Gamma(%g) = %g, want %g", vfgammaSC
[i
], f
, gammaSC
[i
])
2103 func TestHypot(t
*testing
.T
) {
2104 for i
:= 0; i
< len(vf
); i
++ {
2105 a
:= Abs(1e200
* tanh
[i
] * Sqrt(2))
2106 if f
:= Hypot(1e200
*tanh
[i
], 1e200
*tanh
[i
]); !veryclose(a
, f
) {
2107 t
.Errorf("Hypot(%g, %g) = %g, want %g", 1e200
*tanh
[i
], 1e200
*tanh
[i
], f
, a
)
2110 for i
:= 0; i
< len(vfhypotSC
); i
++ {
2111 if f
:= Hypot(vfhypotSC
[i
][0], vfhypotSC
[i
][1]); !alike(hypotSC
[i
], f
) {
2112 t
.Errorf("Hypot(%g, %g) = %g, want %g", vfhypotSC
[i
][0], vfhypotSC
[i
][1], f
, hypotSC
[i
])
2117 func TestHypotGo(t
*testing
.T
) {
2118 for i
:= 0; i
< len(vf
); i
++ {
2119 a
:= Abs(1e200
* tanh
[i
] * Sqrt(2))
2120 if f
:= HypotGo(1e200
*tanh
[i
], 1e200
*tanh
[i
]); !veryclose(a
, f
) {
2121 t
.Errorf("HypotGo(%g, %g) = %g, want %g", 1e200
*tanh
[i
], 1e200
*tanh
[i
], f
, a
)
2124 for i
:= 0; i
< len(vfhypotSC
); i
++ {
2125 if f
:= HypotGo(vfhypotSC
[i
][0], vfhypotSC
[i
][1]); !alike(hypotSC
[i
], f
) {
2126 t
.Errorf("HypotGo(%g, %g) = %g, want %g", vfhypotSC
[i
][0], vfhypotSC
[i
][1], f
, hypotSC
[i
])
2131 func TestIlogb(t
*testing
.T
) {
2132 for i
:= 0; i
< len(vf
); i
++ {
2133 a
:= frexp
[i
].i
- 1 // adjust because fr in the interval [½, 1)
2134 if e
:= Ilogb(vf
[i
]); a
!= e
{
2135 t
.Errorf("Ilogb(%g) = %d, want %d", vf
[i
], e
, a
)
2138 for i
:= 0; i
< len(vflogbSC
); i
++ {
2139 if e
:= Ilogb(vflogbSC
[i
]); ilogbSC
[i
] != e
{
2140 t
.Errorf("Ilogb(%g) = %d, want %d", vflogbSC
[i
], e
, ilogbSC
[i
])
2143 for i
:= 0; i
< len(vffrexpBC
); i
++ {
2144 if e
:= Ilogb(vffrexpBC
[i
]); int(logbBC
[i
]) != e
{
2145 t
.Errorf("Ilogb(%g) = %d, want %d", vffrexpBC
[i
], e
, int(logbBC
[i
]))
2150 func TestJ0(t
*testing
.T
) {
2151 for i
:= 0; i
< len(vf
); i
++ {
2152 if f
:= J0(vf
[i
]); !soclose(j0
[i
], f
, 4e-14) {
2153 t
.Errorf("J0(%g) = %g, want %g", vf
[i
], f
, j0
[i
])
2156 for i
:= 0; i
< len(vfj0SC
); i
++ {
2157 if f
:= J0(vfj0SC
[i
]); !alike(j0SC
[i
], f
) {
2158 t
.Errorf("J0(%g) = %g, want %g", vfj0SC
[i
], f
, j0SC
[i
])
2163 func TestJ1(t
*testing
.T
) {
2164 for i
:= 0; i
< len(vf
); i
++ {
2165 if f
:= J1(vf
[i
]); !close(j1
[i
], f
) {
2166 t
.Errorf("J1(%g) = %g, want %g", vf
[i
], f
, j1
[i
])
2169 for i
:= 0; i
< len(vfj0SC
); i
++ {
2170 if f
:= J1(vfj0SC
[i
]); !alike(j1SC
[i
], f
) {
2171 t
.Errorf("J1(%g) = %g, want %g", vfj0SC
[i
], f
, j1SC
[i
])
2176 func TestJn(t
*testing
.T
) {
2177 for i
:= 0; i
< len(vf
); i
++ {
2178 if f
:= Jn(2, vf
[i
]); !close(j2
[i
], f
) {
2179 t
.Errorf("Jn(2, %g) = %g, want %g", vf
[i
], f
, j2
[i
])
2181 if f
:= Jn(-3, vf
[i
]); !close(jM3
[i
], f
) {
2182 t
.Errorf("Jn(-3, %g) = %g, want %g", vf
[i
], f
, jM3
[i
])
2185 for i
:= 0; i
< len(vfj0SC
); i
++ {
2186 if f
:= Jn(2, vfj0SC
[i
]); !alike(j2SC
[i
], f
) {
2187 t
.Errorf("Jn(2, %g) = %g, want %g", vfj0SC
[i
], f
, j2SC
[i
])
2189 if f
:= Jn(-3, vfj0SC
[i
]); !alike(jM3SC
[i
], f
) {
2190 t
.Errorf("Jn(-3, %g) = %g, want %g", vfj0SC
[i
], f
, jM3SC
[i
])
2195 func TestLdexp(t
*testing
.T
) {
2196 for i
:= 0; i
< len(vf
); i
++ {
2197 if f
:= Ldexp(frexp
[i
].f
, frexp
[i
].i
); !veryclose(vf
[i
], f
) {
2198 t
.Errorf("Ldexp(%g, %d) = %g, want %g", frexp
[i
].f
, frexp
[i
].i
, f
, vf
[i
])
2201 for i
:= 0; i
< len(vffrexpSC
); i
++ {
2202 if f
:= Ldexp(frexpSC
[i
].f
, frexpSC
[i
].i
); !alike(vffrexpSC
[i
], f
) {
2203 t
.Errorf("Ldexp(%g, %d) = %g, want %g", frexpSC
[i
].f
, frexpSC
[i
].i
, f
, vffrexpSC
[i
])
2206 for i
:= 0; i
< len(vfldexpSC
); i
++ {
2207 if f
:= Ldexp(vfldexpSC
[i
].f
, vfldexpSC
[i
].i
); !alike(ldexpSC
[i
], f
) {
2208 t
.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpSC
[i
].f
, vfldexpSC
[i
].i
, f
, ldexpSC
[i
])
2211 for i
:= 0; i
< len(vffrexpBC
); i
++ {
2212 if f
:= Ldexp(frexpBC
[i
].f
, frexpBC
[i
].i
); !alike(vffrexpBC
[i
], f
) {
2213 t
.Errorf("Ldexp(%g, %d) = %g, want %g", frexpBC
[i
].f
, frexpBC
[i
].i
, f
, vffrexpBC
[i
])
2216 for i
:= 0; i
< len(vfldexpBC
); i
++ {
2217 if f
:= Ldexp(vfldexpBC
[i
].f
, vfldexpBC
[i
].i
); !alike(ldexpBC
[i
], f
) {
2218 t
.Errorf("Ldexp(%g, %d) = %g, want %g", vfldexpBC
[i
].f
, vfldexpBC
[i
].i
, f
, ldexpBC
[i
])
2223 func TestLgamma(t
*testing
.T
) {
2224 for i
:= 0; i
< len(vf
); i
++ {
2225 if f
, s
:= Lgamma(vf
[i
]); !close(lgamma
[i
].f
, f
) || lgamma
[i
].i
!= s
{
2226 t
.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vf
[i
], f
, s
, lgamma
[i
].f
, lgamma
[i
].i
)
2229 for i
:= 0; i
< len(vflgammaSC
); i
++ {
2230 if f
, s
:= Lgamma(vflgammaSC
[i
]); !alike(lgammaSC
[i
].f
, f
) || lgammaSC
[i
].i
!= s
{
2231 t
.Errorf("Lgamma(%g) = %g, %d, want %g, %d", vflgammaSC
[i
], f
, s
, lgammaSC
[i
].f
, lgammaSC
[i
].i
)
2236 func TestLog(t
*testing
.T
) {
2237 for i
:= 0; i
< len(vf
); i
++ {
2239 if f
:= Log(a
); log
[i
] != f
{
2240 t
.Errorf("Log(%g) = %g, want %g", a
, f
, log
[i
])
2243 if f
:= Log(10); f
!= Ln10
{
2244 t
.Errorf("Log(%g) = %g, want %g", 10.0, f
, Ln10
)
2246 for i
:= 0; i
< len(vflogSC
); i
++ {
2247 if f
:= Log(vflogSC
[i
]); !alike(logSC
[i
], f
) {
2248 t
.Errorf("Log(%g) = %g, want %g", vflogSC
[i
], f
, logSC
[i
])
2253 func TestLogb(t
*testing
.T
) {
2254 for i
:= 0; i
< len(vf
); i
++ {
2255 if f
:= Logb(vf
[i
]); logb
[i
] != f
{
2256 t
.Errorf("Logb(%g) = %g, want %g", vf
[i
], f
, logb
[i
])
2259 for i
:= 0; i
< len(vflogbSC
); i
++ {
2260 if f
:= Logb(vflogbSC
[i
]); !alike(logbSC
[i
], f
) {
2261 t
.Errorf("Logb(%g) = %g, want %g", vflogbSC
[i
], f
, logbSC
[i
])
2264 for i
:= 0; i
< len(vffrexpBC
); i
++ {
2265 if f
:= Logb(vffrexpBC
[i
]); !alike(logbBC
[i
], f
) {
2266 t
.Errorf("Logb(%g) = %g, want %g", vffrexpBC
[i
], f
, logbBC
[i
])
2271 func TestLog10(t
*testing
.T
) {
2272 for i
:= 0; i
< len(vf
); i
++ {
2274 if f
:= Log10(a
); !veryclose(log10
[i
], f
) {
2275 t
.Errorf("Log10(%g) = %g, want %g", a
, f
, log10
[i
])
2278 if f
:= Log10(E
); f
!= Log10E
{
2279 t
.Errorf("Log10(%g) = %g, want %g", E
, f
, Log10E
)
2281 for i
:= 0; i
< len(vflogSC
); i
++ {
2282 if f
:= Log10(vflogSC
[i
]); !alike(logSC
[i
], f
) {
2283 t
.Errorf("Log10(%g) = %g, want %g", vflogSC
[i
], f
, logSC
[i
])
2288 func TestLog1p(t
*testing
.T
) {
2289 for i
:= 0; i
< len(vf
); i
++ {
2291 if f
:= Log1p(a
); !veryclose(log1p
[i
], f
) {
2292 t
.Errorf("Log1p(%g) = %g, want %g", a
, f
, log1p
[i
])
2296 if f
:= Log1p(a
); f
!= Ln10
{
2297 t
.Errorf("Log1p(%g) = %g, want %g", a
, f
, Ln10
)
2299 for i
:= 0; i
< len(vflogSC
); i
++ {
2300 if f
:= Log1p(vflog1pSC
[i
]); !alike(log1pSC
[i
], f
) {
2301 t
.Errorf("Log1p(%g) = %g, want %g", vflog1pSC
[i
], f
, log1pSC
[i
])
2306 func TestLog2(t
*testing
.T
) {
2307 for i
:= 0; i
< len(vf
); i
++ {
2309 if f
:= Log2(a
); !veryclose(log2
[i
], f
) {
2310 t
.Errorf("Log2(%g) = %g, want %g", a
, f
, log2
[i
])
2313 if f
:= Log2(E
); f
!= Log2E
{
2314 t
.Errorf("Log2(%g) = %g, want %g", E
, f
, Log2E
)
2316 for i
:= 0; i
< len(vflogSC
); i
++ {
2317 if f
:= Log2(vflogSC
[i
]); !alike(logSC
[i
], f
) {
2318 t
.Errorf("Log2(%g) = %g, want %g", vflogSC
[i
], f
, logSC
[i
])
2321 for i
:= -1074; i
<= 1023; i
++ {
2324 if l
!= float64(i
) {
2325 t
.Errorf("Log2(2**%d) = %g, want %d", i
, l
, i
)
2330 func TestModf(t
*testing
.T
) {
2331 for i
:= 0; i
< len(vf
); i
++ {
2332 if f
, g
:= Modf(vf
[i
]); !veryclose(modf
[i
][0], f
) ||
!veryclose(modf
[i
][1], g
) {
2333 t
.Errorf("Modf(%g) = %g, %g, want %g, %g", vf
[i
], f
, g
, modf
[i
][0], modf
[i
][1])
2336 for i
:= 0; i
< len(vfmodfSC
); i
++ {
2337 if f
, g
:= Modf(vfmodfSC
[i
]); !alike(modfSC
[i
][0], f
) ||
!alike(modfSC
[i
][1], g
) {
2338 t
.Errorf("Modf(%g) = %g, %g, want %g, %g", vfmodfSC
[i
], f
, g
, modfSC
[i
][0], modfSC
[i
][1])
2343 func TestNextafter32(t
*testing
.T
) {
2344 for i
:= 0; i
< len(vf
); i
++ {
2345 vfi
:= float32(vf
[i
])
2346 if f
:= Nextafter32(vfi
, 10); nextafter32
[i
] != f
{
2347 t
.Errorf("Nextafter32(%g, %g) = %g want %g", vfi
, 10.0, f
, nextafter32
[i
])
2350 for i
:= 0; i
< len(vfnextafter32SC
); i
++ {
2351 if f
:= Nextafter32(vfnextafter32SC
[i
][0], vfnextafter32SC
[i
][1]); !alike(float64(nextafter32SC
[i
]), float64(f
)) {
2352 t
.Errorf("Nextafter32(%g, %g) = %g want %g", vfnextafter32SC
[i
][0], vfnextafter32SC
[i
][1], f
, nextafter32SC
[i
])
2357 func TestNextafter64(t
*testing
.T
) {
2358 for i
:= 0; i
< len(vf
); i
++ {
2359 if f
:= Nextafter(vf
[i
], 10); nextafter64
[i
] != f
{
2360 t
.Errorf("Nextafter64(%g, %g) = %g want %g", vf
[i
], 10.0, f
, nextafter64
[i
])
2363 for i
:= 0; i
< len(vfnextafter64SC
); i
++ {
2364 if f
:= Nextafter(vfnextafter64SC
[i
][0], vfnextafter64SC
[i
][1]); !alike(nextafter64SC
[i
], f
) {
2365 t
.Errorf("Nextafter64(%g, %g) = %g want %g", vfnextafter64SC
[i
][0], vfnextafter64SC
[i
][1], f
, nextafter64SC
[i
])
2370 func TestPow(t
*testing
.T
) {
2371 for i
:= 0; i
< len(vf
); i
++ {
2372 if f
:= Pow(10, vf
[i
]); !close(pow
[i
], f
) {
2373 t
.Errorf("Pow(10, %g) = %g, want %g", vf
[i
], f
, pow
[i
])
2376 for i
:= 0; i
< len(vfpowSC
); i
++ {
2377 if f
:= Pow(vfpowSC
[i
][0], vfpowSC
[i
][1]); !alike(powSC
[i
], f
) {
2378 t
.Errorf("Pow(%g, %g) = %g, want %g", vfpowSC
[i
][0], vfpowSC
[i
][1], f
, powSC
[i
])
2383 func TestPow10(t
*testing
.T
) {
2384 for i
:= 0; i
< len(vfpow10SC
); i
++ {
2385 if f
:= Pow10(vfpow10SC
[i
]); !alike(pow10SC
[i
], f
) {
2386 t
.Errorf("Pow10(%d) = %g, want %g", vfpow10SC
[i
], f
, pow10SC
[i
])
2391 func TestRemainder(t
*testing
.T
) {
2392 for i
:= 0; i
< len(vf
); i
++ {
2393 if f
:= Remainder(10, vf
[i
]); remainder
[i
] != f
{
2394 t
.Errorf("Remainder(10, %g) = %g, want %g", vf
[i
], f
, remainder
[i
])
2397 for i
:= 0; i
< len(vffmodSC
); i
++ {
2398 if f
:= Remainder(vffmodSC
[i
][0], vffmodSC
[i
][1]); !alike(fmodSC
[i
], f
) {
2399 t
.Errorf("Remainder(%g, %g) = %g, want %g", vffmodSC
[i
][0], vffmodSC
[i
][1], f
, fmodSC
[i
])
2404 func TestSignbit(t
*testing
.T
) {
2405 for i
:= 0; i
< len(vf
); i
++ {
2406 if f
:= Signbit(vf
[i
]); signbit
[i
] != f
{
2407 t
.Errorf("Signbit(%g) = %t, want %t", vf
[i
], f
, signbit
[i
])
2410 for i
:= 0; i
< len(vfsignbitSC
); i
++ {
2411 if f
:= Signbit(vfsignbitSC
[i
]); signbitSC
[i
] != f
{
2412 t
.Errorf("Signbit(%g) = %t, want %t", vfsignbitSC
[i
], f
, signbitSC
[i
])
2416 func TestSin(t
*testing
.T
) {
2417 for i
:= 0; i
< len(vf
); i
++ {
2418 if f
:= Sin(vf
[i
]); !veryclose(sin
[i
], f
) {
2419 t
.Errorf("Sin(%g) = %g, want %g", vf
[i
], f
, sin
[i
])
2422 for i
:= 0; i
< len(vfsinSC
); i
++ {
2423 if f
:= Sin(vfsinSC
[i
]); !alike(sinSC
[i
], f
) {
2424 t
.Errorf("Sin(%g) = %g, want %g", vfsinSC
[i
], f
, sinSC
[i
])
2429 func TestSincos(t
*testing
.T
) {
2430 for i
:= 0; i
< len(vf
); i
++ {
2431 if s
, c
:= Sincos(vf
[i
]); !veryclose(sin
[i
], s
) ||
!veryclose(cos
[i
], c
) {
2432 t
.Errorf("Sincos(%g) = %g, %g want %g, %g", vf
[i
], s
, c
, sin
[i
], cos
[i
])
2437 func TestSinh(t
*testing
.T
) {
2438 for i
:= 0; i
< len(vf
); i
++ {
2439 if f
:= Sinh(vf
[i
]); !close(sinh
[i
], f
) {
2440 t
.Errorf("Sinh(%g) = %g, want %g", vf
[i
], f
, sinh
[i
])
2443 for i
:= 0; i
< len(vfsinhSC
); i
++ {
2444 if f
:= Sinh(vfsinhSC
[i
]); !alike(sinhSC
[i
], f
) {
2445 t
.Errorf("Sinh(%g) = %g, want %g", vfsinhSC
[i
], f
, sinhSC
[i
])
2450 func TestSqrt(t
*testing
.T
) {
2451 for i
:= 0; i
< len(vf
); i
++ {
2453 if f
:= SqrtGo(a
); sqrt
[i
] != f
{
2454 t
.Errorf("SqrtGo(%g) = %g, want %g", a
, f
, sqrt
[i
])
2457 if f
:= Sqrt(a
); sqrt
[i
] != f
{
2458 t
.Errorf("Sqrt(%g) = %g, want %g", a
, f
, sqrt
[i
])
2461 for i
:= 0; i
< len(vfsqrtSC
); i
++ {
2462 if f
:= SqrtGo(vfsqrtSC
[i
]); !alike(sqrtSC
[i
], f
) {
2463 t
.Errorf("SqrtGo(%g) = %g, want %g", vfsqrtSC
[i
], f
, sqrtSC
[i
])
2465 if f
:= Sqrt(vfsqrtSC
[i
]); !alike(sqrtSC
[i
], f
) {
2466 t
.Errorf("Sqrt(%g) = %g, want %g", vfsqrtSC
[i
], f
, sqrtSC
[i
])
2471 func TestTan(t
*testing
.T
) {
2472 for i
:= 0; i
< len(vf
); i
++ {
2473 if f
:= Tan(vf
[i
]); !veryclose(tan
[i
], f
) {
2474 t
.Errorf("Tan(%g) = %g, want %g", vf
[i
], f
, tan
[i
])
2477 // same special cases as Sin
2478 for i
:= 0; i
< len(vfsinSC
); i
++ {
2479 if f
:= Tan(vfsinSC
[i
]); !alike(sinSC
[i
], f
) {
2480 t
.Errorf("Tan(%g) = %g, want %g", vfsinSC
[i
], f
, sinSC
[i
])
2485 func TestTanh(t
*testing
.T
) {
2486 for i
:= 0; i
< len(vf
); i
++ {
2487 if f
:= Tanh(vf
[i
]); !veryclose(tanh
[i
], f
) {
2488 t
.Errorf("Tanh(%g) = %g, want %g", vf
[i
], f
, tanh
[i
])
2491 for i
:= 0; i
< len(vftanhSC
); i
++ {
2492 if f
:= Tanh(vftanhSC
[i
]); !alike(tanhSC
[i
], f
) {
2493 t
.Errorf("Tanh(%g) = %g, want %g", vftanhSC
[i
], f
, tanhSC
[i
])
2498 func TestTrunc(t
*testing
.T
) {
2499 for i
:= 0; i
< len(vf
); i
++ {
2500 if f
:= Trunc(vf
[i
]); trunc
[i
] != f
{
2501 t
.Errorf("Trunc(%g) = %g, want %g", vf
[i
], f
, trunc
[i
])
2504 for i
:= 0; i
< len(vfceilSC
); i
++ {
2505 if f
:= Trunc(vfceilSC
[i
]); !alike(ceilSC
[i
], f
) {
2506 t
.Errorf("Trunc(%g) = %g, want %g", vfceilSC
[i
], f
, ceilSC
[i
])
2511 func TestY0(t
*testing
.T
) {
2512 for i
:= 0; i
< len(vf
); i
++ {
2514 if f
:= Y0(a
); !close(y0
[i
], f
) {
2515 t
.Errorf("Y0(%g) = %g, want %g", a
, f
, y0
[i
])
2518 for i
:= 0; i
< len(vfy0SC
); i
++ {
2519 if f
:= Y0(vfy0SC
[i
]); !alike(y0SC
[i
], f
) {
2520 t
.Errorf("Y0(%g) = %g, want %g", vfy0SC
[i
], f
, y0SC
[i
])
2525 func TestY1(t
*testing
.T
) {
2526 for i
:= 0; i
< len(vf
); i
++ {
2528 if f
:= Y1(a
); !soclose(y1
[i
], f
, 2e-14) {
2529 t
.Errorf("Y1(%g) = %g, want %g", a
, f
, y1
[i
])
2532 for i
:= 0; i
< len(vfy0SC
); i
++ {
2533 if f
:= Y1(vfy0SC
[i
]); !alike(y1SC
[i
], f
) {
2534 t
.Errorf("Y1(%g) = %g, want %g", vfy0SC
[i
], f
, y1SC
[i
])
2539 func TestYn(t
*testing
.T
) {
2540 for i
:= 0; i
< len(vf
); i
++ {
2542 if f
:= Yn(2, a
); !close(y2
[i
], f
) {
2543 t
.Errorf("Yn(2, %g) = %g, want %g", a
, f
, y2
[i
])
2545 if f
:= Yn(-3, a
); !close(yM3
[i
], f
) {
2546 t
.Errorf("Yn(-3, %g) = %g, want %g", a
, f
, yM3
[i
])
2549 for i
:= 0; i
< len(vfy0SC
); i
++ {
2550 if f
:= Yn(2, vfy0SC
[i
]); !alike(y2SC
[i
], f
) {
2551 t
.Errorf("Yn(2, %g) = %g, want %g", vfy0SC
[i
], f
, y2SC
[i
])
2553 if f
:= Yn(-3, vfy0SC
[i
]); !alike(yM3SC
[i
], f
) {
2554 t
.Errorf("Yn(-3, %g) = %g, want %g", vfy0SC
[i
], f
, yM3SC
[i
])
2559 // Check that math functions of high angle values
2560 // return accurate results. [Since (vf[i] + large) - large != vf[i],
2561 // testing for Trig(vf[i] + large) == Trig(vf[i]), where large is
2562 // a multiple of 2*Pi, is misleading.]
2563 func TestLargeCos(t
*testing
.T
) {
2564 large
:= float64(100000 * Pi
)
2565 for i
:= 0; i
< len(vf
); i
++ {
2567 f2
:= Cos(vf
[i
] + large
)
2569 t
.Errorf("Cos(%g) = %g, want %g", vf
[i
]+large
, f2
, f1
)
2574 func TestLargeSin(t
*testing
.T
) {
2575 large
:= float64(100000 * Pi
)
2576 for i
:= 0; i
< len(vf
); i
++ {
2578 f2
:= Sin(vf
[i
] + large
)
2580 t
.Errorf("Sin(%g) = %g, want %g", vf
[i
]+large
, f2
, f1
)
2585 func TestLargeSincos(t
*testing
.T
) {
2586 large
:= float64(100000 * Pi
)
2587 for i
:= 0; i
< len(vf
); i
++ {
2588 f1
, g1
:= sinLarge
[i
], cosLarge
[i
]
2589 f2
, g2
:= Sincos(vf
[i
] + large
)
2590 if !close(f1
, f2
) ||
!close(g1
, g2
) {
2591 t
.Errorf("Sincos(%g) = %g, %g, want %g, %g", vf
[i
]+large
, f2
, g2
, f1
, g1
)
2596 func TestLargeTan(t
*testing
.T
) {
2597 large
:= float64(100000 * Pi
)
2598 for i
:= 0; i
< len(vf
); i
++ {
2600 f2
:= Tan(vf
[i
] + large
)
2602 t
.Errorf("Tan(%g) = %g, want %g", vf
[i
]+large
, f2
, f1
)
2607 // Check that math constants are accepted by compiler
2608 // and have right value (assumes strconv.ParseFloat works).
2609 // http://code.google.com/p/go/issues/detail?id=201
2611 type floatTest
struct {
2617 var floatTests
= []floatTest
{
2618 {float64(MaxFloat64
), "MaxFloat64", "1.7976931348623157e+308"},
2619 {float64(SmallestNonzeroFloat64
), "SmallestNonzeroFloat64", "5e-324"},
2620 {float32(MaxFloat32
), "MaxFloat32", "3.4028235e+38"},
2621 {float32(SmallestNonzeroFloat32
), "SmallestNonzeroFloat32", "1e-45"},
2624 func TestFloatMinMax(t
*testing
.T
) {
2625 for _
, tt
:= range floatTests
{
2626 s
:= fmt
.Sprint(tt
.val
)
2628 t
.Errorf("Sprint(%v) = %s, want %s", tt
.name
, s
, tt
.str
)
2635 func BenchmarkAcos(b
*testing
.B
) {
2636 for i
:= 0; i
< b
.N
; i
++ {
2641 func BenchmarkAcosh(b
*testing
.B
) {
2642 for i
:= 0; i
< b
.N
; i
++ {
2647 func BenchmarkAsin(b
*testing
.B
) {
2648 for i
:= 0; i
< b
.N
; i
++ {
2653 func BenchmarkAsinh(b
*testing
.B
) {
2654 for i
:= 0; i
< b
.N
; i
++ {
2659 func BenchmarkAtan(b
*testing
.B
) {
2660 for i
:= 0; i
< b
.N
; i
++ {
2665 func BenchmarkAtanh(b
*testing
.B
) {
2666 for i
:= 0; i
< b
.N
; i
++ {
2671 func BenchmarkAtan2(b
*testing
.B
) {
2672 for i
:= 0; i
< b
.N
; i
++ {
2677 func BenchmarkCbrt(b
*testing
.B
) {
2678 for i
:= 0; i
< b
.N
; i
++ {
2683 func BenchmarkCeil(b
*testing
.B
) {
2684 for i
:= 0; i
< b
.N
; i
++ {
2689 func BenchmarkCopysign(b
*testing
.B
) {
2690 for i
:= 0; i
< b
.N
; i
++ {
2695 func BenchmarkCos(b
*testing
.B
) {
2696 for i
:= 0; i
< b
.N
; i
++ {
2701 func BenchmarkCosh(b
*testing
.B
) {
2702 for i
:= 0; i
< b
.N
; i
++ {
2707 func BenchmarkErf(b
*testing
.B
) {
2708 for i
:= 0; i
< b
.N
; i
++ {
2713 func BenchmarkErfc(b
*testing
.B
) {
2714 for i
:= 0; i
< b
.N
; i
++ {
2719 func BenchmarkExp(b
*testing
.B
) {
2720 for i
:= 0; i
< b
.N
; i
++ {
2725 func BenchmarkExpGo(b
*testing
.B
) {
2726 for i
:= 0; i
< b
.N
; i
++ {
2731 func BenchmarkExpm1(b
*testing
.B
) {
2732 for i
:= 0; i
< b
.N
; i
++ {
2737 func BenchmarkExp2(b
*testing
.B
) {
2738 for i
:= 0; i
< b
.N
; i
++ {
2743 func BenchmarkExp2Go(b
*testing
.B
) {
2744 for i
:= 0; i
< b
.N
; i
++ {
2749 func BenchmarkAbs(b
*testing
.B
) {
2750 for i
:= 0; i
< b
.N
; i
++ {
2755 func BenchmarkDim(b
*testing
.B
) {
2756 for i
:= 0; i
< b
.N
; i
++ {
2761 func BenchmarkFloor(b
*testing
.B
) {
2762 for i
:= 0; i
< b
.N
; i
++ {
2767 func BenchmarkMax(b
*testing
.B
) {
2768 for i
:= 0; i
< b
.N
; i
++ {
2773 func BenchmarkMin(b
*testing
.B
) {
2774 for i
:= 0; i
< b
.N
; i
++ {
2779 func BenchmarkMod(b
*testing
.B
) {
2780 for i
:= 0; i
< b
.N
; i
++ {
2785 func BenchmarkFrexp(b
*testing
.B
) {
2786 for i
:= 0; i
< b
.N
; i
++ {
2791 func BenchmarkGamma(b
*testing
.B
) {
2792 for i
:= 0; i
< b
.N
; i
++ {
2797 func BenchmarkHypot(b
*testing
.B
) {
2798 for i
:= 0; i
< b
.N
; i
++ {
2803 func BenchmarkHypotGo(b
*testing
.B
) {
2804 for i
:= 0; i
< b
.N
; i
++ {
2809 func BenchmarkIlogb(b
*testing
.B
) {
2810 for i
:= 0; i
< b
.N
; i
++ {
2815 func BenchmarkJ0(b
*testing
.B
) {
2816 for i
:= 0; i
< b
.N
; i
++ {
2821 func BenchmarkJ1(b
*testing
.B
) {
2822 for i
:= 0; i
< b
.N
; i
++ {
2827 func BenchmarkJn(b
*testing
.B
) {
2828 for i
:= 0; i
< b
.N
; i
++ {
2833 func BenchmarkLdexp(b
*testing
.B
) {
2834 for i
:= 0; i
< b
.N
; i
++ {
2839 func BenchmarkLgamma(b
*testing
.B
) {
2840 for i
:= 0; i
< b
.N
; i
++ {
2845 func BenchmarkLog(b
*testing
.B
) {
2846 for i
:= 0; i
< b
.N
; i
++ {
2851 func BenchmarkLogb(b
*testing
.B
) {
2852 for i
:= 0; i
< b
.N
; i
++ {
2857 func BenchmarkLog1p(b
*testing
.B
) {
2858 for i
:= 0; i
< b
.N
; i
++ {
2863 func BenchmarkLog10(b
*testing
.B
) {
2864 for i
:= 0; i
< b
.N
; i
++ {
2869 func BenchmarkLog2(b
*testing
.B
) {
2870 for i
:= 0; i
< b
.N
; i
++ {
2875 func BenchmarkModf(b
*testing
.B
) {
2876 for i
:= 0; i
< b
.N
; i
++ {
2881 func BenchmarkNextafter32(b
*testing
.B
) {
2882 for i
:= 0; i
< b
.N
; i
++ {
2887 func BenchmarkNextafter64(b
*testing
.B
) {
2888 for i
:= 0; i
< b
.N
; i
++ {
2893 func BenchmarkPowInt(b
*testing
.B
) {
2894 for i
:= 0; i
< b
.N
; i
++ {
2899 func BenchmarkPowFrac(b
*testing
.B
) {
2900 for i
:= 0; i
< b
.N
; i
++ {
2905 func BenchmarkPow10Pos(b
*testing
.B
) {
2906 for i
:= 0; i
< b
.N
; i
++ {
2911 func BenchmarkPow10Neg(b
*testing
.B
) {
2912 for i
:= 0; i
< b
.N
; i
++ {
2917 func BenchmarkRemainder(b
*testing
.B
) {
2918 for i
:= 0; i
< b
.N
; i
++ {
2923 func BenchmarkSignbit(b
*testing
.B
) {
2924 for i
:= 0; i
< b
.N
; i
++ {
2929 func BenchmarkSin(b
*testing
.B
) {
2930 for i
:= 0; i
< b
.N
; i
++ {
2935 func BenchmarkSincos(b
*testing
.B
) {
2936 for i
:= 0; i
< b
.N
; i
++ {
2941 func BenchmarkSinh(b
*testing
.B
) {
2942 for i
:= 0; i
< b
.N
; i
++ {
2947 func BenchmarkSqrt(b
*testing
.B
) {
2948 for i
:= 0; i
< b
.N
; i
++ {
2953 func BenchmarkSqrtGo(b
*testing
.B
) {
2954 for i
:= 0; i
< b
.N
; i
++ {
2959 func BenchmarkTan(b
*testing
.B
) {
2960 for i
:= 0; i
< b
.N
; i
++ {
2965 func BenchmarkTanh(b
*testing
.B
) {
2966 for i
:= 0; i
< b
.N
; i
++ {
2970 func BenchmarkTrunc(b
*testing
.B
) {
2971 for i
:= 0; i
< b
.N
; i
++ {
2976 func BenchmarkY0(b
*testing
.B
) {
2977 for i
:= 0; i
< b
.N
; i
++ {
2982 func BenchmarkY1(b
*testing
.B
) {
2983 for i
:= 0; i
< b
.N
; i
++ {
2988 func BenchmarkYn(b
*testing
.B
) {
2989 for i
:= 0; i
< b
.N
; i
++ {