github.com/twelsh-aw/go/src@v0.0.0-20230516233729-a56fe86a7c81/math/all_test.go (about)

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