...

Source file src/math/cmplx/cmath_test.go

Documentation: math/cmplx

		 1  // Copyright 2010 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 cmplx
		 6  
		 7  import (
		 8  	"math"
		 9  	"testing"
		10  )
		11  
		12  // The higher-precision values in vc26 were used to derive the
		13  // input arguments vc (see also comment below). For reference
		14  // only (do not delete).
		15  var vc26 = []complex128{
		16  	(4.97901192488367350108546816 + 7.73887247457810456552351752i),
		17  	(7.73887247457810456552351752 - 0.27688005719200159404635997i),
		18  	(-0.27688005719200159404635997 - 5.01060361827107492160848778i),
		19  	(-5.01060361827107492160848778 + 9.63629370719841737980004837i),
		20  	(9.63629370719841737980004837 + 2.92637723924396464525443662i),
		21  	(2.92637723924396464525443662 + 5.22908343145930665230025625i),
		22  	(5.22908343145930665230025625 + 2.72793991043601025126008608i),
		23  	(2.72793991043601025126008608 + 1.82530809168085506044576505i),
		24  	(1.82530809168085506044576505 - 8.68592476857560136238589621i),
		25  	(-8.68592476857560136238589621 + 4.97901192488367350108546816i),
		26  }
		27  
		28  var vc = []complex128{
		29  	(4.9790119248836735e+00 + 7.7388724745781045e+00i),
		30  	(7.7388724745781045e+00 - 2.7688005719200159e-01i),
		31  	(-2.7688005719200159e-01 - 5.0106036182710749e+00i),
		32  	(-5.0106036182710749e+00 + 9.6362937071984173e+00i),
		33  	(9.6362937071984173e+00 + 2.9263772392439646e+00i),
		34  	(2.9263772392439646e+00 + 5.2290834314593066e+00i),
		35  	(5.2290834314593066e+00 + 2.7279399104360102e+00i),
		36  	(2.7279399104360102e+00 + 1.8253080916808550e+00i),
		37  	(1.8253080916808550e+00 - 8.6859247685756013e+00i),
		38  	(-8.6859247685756013e+00 + 4.9790119248836735e+00i),
		39  }
		40  
		41  // The expected results below were computed by the high precision calculators
		42  // at https://keisan.casio.com/.	More exact input values (array vc[], above)
		43  // were obtained by printing them with "%.26f".	The answers were calculated
		44  // to 26 digits (by using the "Digit number" drop-down control of each
		45  // calculator).
		46  
		47  var abs = []float64{
		48  	9.2022120669932650313380972e+00,
		49  	7.7438239742296106616261394e+00,
		50  	5.0182478202557746902556648e+00,
		51  	1.0861137372799545160704002e+01,
		52  	1.0070841084922199607011905e+01,
		53  	5.9922447613166942183705192e+00,
		54  	5.8978784056736762299945176e+00,
		55  	3.2822866700678709020367184e+00,
		56  	8.8756430028990417290744307e+00,
		57  	1.0011785496777731986390856e+01,
		58  }
		59  
		60  var acos = []complex128{
		61  	(1.0017679804707456328694569 - 2.9138232718554953784519807i),
		62  	(0.03606427612041407369636057 + 2.7358584434576260925091256i),
		63  	(1.6249365462333796703711823 + 2.3159537454335901187730929i),
		64  	(2.0485650849650740120660391 - 3.0795576791204117911123886i),
		65  	(0.29621132089073067282488147 - 3.0007392508200622519398814i),
		66  	(1.0664555914934156601503632 - 2.4872865024796011364747111i),
		67  	(0.48681307452231387690013905 - 2.463655912283054555225301i),
		68  	(0.6116977071277574248407752 - 1.8734458851737055262693056i),
		69  	(1.3649311280370181331184214 + 2.8793528632328795424123832i),
		70  	(2.6189310485682988308904501 - 2.9956543302898767795858704i),
		71  }
		72  var acosh = []complex128{
		73  	(2.9138232718554953784519807 + 1.0017679804707456328694569i),
		74  	(2.7358584434576260925091256 - 0.03606427612041407369636057i),
		75  	(2.3159537454335901187730929 - 1.6249365462333796703711823i),
		76  	(3.0795576791204117911123886 + 2.0485650849650740120660391i),
		77  	(3.0007392508200622519398814 + 0.29621132089073067282488147i),
		78  	(2.4872865024796011364747111 + 1.0664555914934156601503632i),
		79  	(2.463655912283054555225301 + 0.48681307452231387690013905i),
		80  	(1.8734458851737055262693056 + 0.6116977071277574248407752i),
		81  	(2.8793528632328795424123832 - 1.3649311280370181331184214i),
		82  	(2.9956543302898767795858704 + 2.6189310485682988308904501i),
		83  }
		84  var asin = []complex128{
		85  	(0.56902834632415098636186476 + 2.9138232718554953784519807i),
		86  	(1.5347320506744825455349611 - 2.7358584434576260925091256i),
		87  	(-0.054140219438483051139860579 - 2.3159537454335901187730929i),
		88  	(-0.47776875817017739283471738 + 3.0795576791204117911123886i),
		89  	(1.2745850059041659464064402 + 3.0007392508200622519398814i),
		90  	(0.50434073530148095908095852 + 2.4872865024796011364747111i),
		91  	(1.0839832522725827423311826 + 2.463655912283054555225301i),
		92  	(0.9590986196671391943905465 + 1.8734458851737055262693056i),
		93  	(0.20586519875787848611290031 - 2.8793528632328795424123832i),
		94  	(-1.0481347217734022116591284 + 2.9956543302898767795858704i),
		95  }
		96  var asinh = []complex128{
		97  	(2.9113760469415295679342185 + 0.99639459545704326759805893i),
		98  	(2.7441755423994259061579029 - 0.035468308789000500601119392i),
		99  	(-2.2962136462520690506126678 - 1.5144663565690151885726707i),
	 100  	(-3.0771233459295725965402455 + 1.0895577967194013849422294i),
	 101  	(3.0048366100923647417557027 + 0.29346979169819220036454168i),
	 102  	(2.4800059370795363157364643 + 1.0545868606049165710424232i),
	 103  	(2.4718773838309585611141821 + 0.47502344364250803363708842i),
	 104  	(1.8910743588080159144378396 + 0.56882925572563602341139174i),
	 105  	(2.8735426423367341878069406 - 1.362376149648891420997548i),
	 106  	(-2.9981750586172477217567878 + 0.5183571985225367505624207i),
	 107  }
	 108  var atan = []complex128{
	 109  	(1.5115747079332741358607654 + 0.091324403603954494382276776i),
	 110  	(1.4424504323482602560806727 - 0.0045416132642803911503770933i),
	 111  	(-1.5593488703630532674484026 - 0.20163295409248362456446431i),
	 112  	(-1.5280619472445889867794105 + 0.081721556230672003746956324i),
	 113  	(1.4759909163240799678221039 + 0.028602969320691644358773586i),
	 114  	(1.4877353772046548932715555 + 0.14566877153207281663773599i),
	 115  	(1.4206983927779191889826 + 0.076830486127880702249439993i),
	 116  	(1.3162236060498933364869556 + 0.16031313000467530644933363i),
	 117  	(1.5473450684303703578810093 - 0.11064907507939082484935782i),
	 118  	(-1.4841462340185253987375812 + 0.049341850305024399493142411i),
	 119  }
	 120  var atanh = []complex128{
	 121  	(0.058375027938968509064640438 + 1.4793488495105334458167782i),
	 122  	(0.12977343497790381229915667 - 1.5661009410463561327262499i),
	 123  	(-0.010576456067347252072200088 - 1.3743698658402284549750563i),
	 124  	(-0.042218595678688358882784918 + 1.4891433968166405606692604i),
	 125  	(0.095218997991316722061828397 + 1.5416884098777110330499698i),
	 126  	(0.079965459366890323857556487 + 1.4252510353873192700350435i),
	 127  	(0.15051245471980726221708301 + 1.4907432533016303804884461i),
	 128  	(0.25082072933993987714470373 + 1.392057665392187516442986i),
	 129  	(0.022896108815797135846276662 - 1.4609224989282864208963021i),
	 130  	(-0.08665624101841876130537396 + 1.5207902036935093480142159i),
	 131  }
	 132  var conj = []complex128{
	 133  	(4.9790119248836735e+00 - 7.7388724745781045e+00i),
	 134  	(7.7388724745781045e+00 + 2.7688005719200159e-01i),
	 135  	(-2.7688005719200159e-01 + 5.0106036182710749e+00i),
	 136  	(-5.0106036182710749e+00 - 9.6362937071984173e+00i),
	 137  	(9.6362937071984173e+00 - 2.9263772392439646e+00i),
	 138  	(2.9263772392439646e+00 - 5.2290834314593066e+00i),
	 139  	(5.2290834314593066e+00 - 2.7279399104360102e+00i),
	 140  	(2.7279399104360102e+00 - 1.8253080916808550e+00i),
	 141  	(1.8253080916808550e+00 + 8.6859247685756013e+00i),
	 142  	(-8.6859247685756013e+00 - 4.9790119248836735e+00i),
	 143  }
	 144  var cos = []complex128{
	 145  	(3.024540920601483938336569e+02 + 1.1073797572517071650045357e+03i),
	 146  	(1.192858682649064973252758e-01 + 2.7857554122333065540970207e-01i),
	 147  	(7.2144394304528306603857962e+01 - 2.0500129667076044169954205e+01i),
	 148  	(2.24921952538403984190541e+03 - 7.317363745602773587049329e+03i),
	 149  	(-9.148222970032421760015498e+00 + 1.953124661113563541862227e+00i),
	 150  	(-9.116081175857732248227078e+01 - 1.992669213569952232487371e+01i),
	 151  	(3.795639179042704640002918e+00 + 6.623513350981458399309662e+00i),
	 152  	(-2.9144840732498869560679084e+00 - 1.214620271628002917638748e+00i),
	 153  	(-7.45123482501299743872481e+02 + 2.8641692314488080814066734e+03i),
	 154  	(-5.371977967039319076416747e+01 + 4.893348341339375830564624e+01i),
	 155  }
	 156  var cosh = []complex128{
	 157  	(8.34638383523018249366948e+00 + 7.2181057886425846415112064e+01i),
	 158  	(1.10421967379919366952251e+03 - 3.1379638689277575379469861e+02i),
	 159  	(3.051485206773701584738512e-01 - 2.6805384730105297848044485e-01i),
	 160  	(-7.33294728684187933370938e+01 + 1.574445942284918251038144e+01i),
	 161  	(-7.478643293945957535757355e+03 + 1.6348382209913353929473321e+03i),
	 162  	(4.622316522966235701630926e+00 - 8.088695185566375256093098e+00i),
	 163  	(-8.544333183278877406197712e+01 + 3.7505836120128166455231717e+01i),
	 164  	(-1.934457815021493925115198e+00 + 7.3725859611767228178358673e+00i),
	 165  	(-2.352958770061749348353548e+00 - 2.034982010440878358915409e+00i),
	 166  	(7.79756457532134748165069e+02 + 2.8549350716819176560377717e+03i),
	 167  }
	 168  var exp = []complex128{
	 169  	(1.669197736864670815125146e+01 + 1.4436895109507663689174096e+02i),
	 170  	(2.2084389286252583447276212e+03 - 6.2759289284909211238261917e+02i),
	 171  	(2.227538273122775173434327e-01 + 7.2468284028334191250470034e-01i),
	 172  	(-6.5182985958153548997881627e-03 - 1.39965837915193860879044e-03i),
	 173  	(-1.4957286524084015746110777e+04 + 3.269676455931135688988042e+03i),
	 174  	(9.218158701983105935659273e+00 - 1.6223985291084956009304582e+01i),
	 175  	(-1.7088175716853040841444505e+02 + 7.501382609870410713795546e+01i),
	 176  	(-3.852461315830959613132505e+00 + 1.4808420423156073221970892e+01i),
	 177  	(-4.586775503301407379786695e+00 - 4.178501081246873415144744e+00i),
	 178  	(4.451337963005453491095747e-05 - 1.62977574205442915935263e-04i),
	 179  }
	 180  var log = []complex128{
	 181  	(2.2194438972179194425697051e+00 + 9.9909115046919291062461269e-01i),
	 182  	(2.0468956191154167256337289e+00 - 3.5762575021856971295156489e-02i),
	 183  	(1.6130808329853860438751244e+00 - 1.6259990074019058442232221e+00i),
	 184  	(2.3851910394823008710032651e+00 + 2.0502936359659111755031062e+00i),
	 185  	(2.3096442270679923004800651e+00 + 2.9483213155446756211881774e-01i),
	 186  	(1.7904660933974656106951860e+00 + 1.0605860367252556281902109e+00i),
	 187  	(1.7745926939841751666177512e+00 + 4.8084556083358307819310911e-01i),
	 188  	(1.1885403350045342425648780e+00 + 5.8969634164776659423195222e-01i),
	 189  	(2.1833107837679082586772505e+00 - 1.3636647724582455028314573e+00i),
	 190  	(2.3037629487273259170991671e+00 + 2.6210913895386013290915234e+00i),
	 191  }
	 192  var log10 = []complex128{
	 193  	(9.6389223745559042474184943e-01 + 4.338997735671419492599631e-01i),
	 194  	(8.8895547241376579493490892e-01 - 1.5531488990643548254864806e-02i),
	 195  	(7.0055210462945412305244578e-01 - 7.0616239649481243222248404e-01i),
	 196  	(1.0358753067322445311676952e+00 + 8.9043121238134980156490909e-01i),
	 197  	(1.003065742975330237172029e+00 + 1.2804396782187887479857811e-01i),
	 198  	(7.7758954439739162532085157e-01 + 4.6060666333341810869055108e-01i),
	 199  	(7.7069581462315327037689152e-01 + 2.0882857371769952195512475e-01i),
	 200  	(5.1617650901191156135137239e-01 + 2.5610186717615977620363299e-01i),
	 201  	(9.4819982567026639742663212e-01 - 5.9223208584446952284914289e-01i),
	 202  	(1.0005115362454417135973429e+00 + 1.1383255270407412817250921e+00i),
	 203  }
	 204  
	 205  type ff struct {
	 206  	r, theta float64
	 207  }
	 208  
	 209  var polar = []ff{
	 210  	{9.2022120669932650313380972e+00, 9.9909115046919291062461269e-01},
	 211  	{7.7438239742296106616261394e+00, -3.5762575021856971295156489e-02},
	 212  	{5.0182478202557746902556648e+00, -1.6259990074019058442232221e+00},
	 213  	{1.0861137372799545160704002e+01, 2.0502936359659111755031062e+00},
	 214  	{1.0070841084922199607011905e+01, 2.9483213155446756211881774e-01},
	 215  	{5.9922447613166942183705192e+00, 1.0605860367252556281902109e+00},
	 216  	{5.8978784056736762299945176e+00, 4.8084556083358307819310911e-01},
	 217  	{3.2822866700678709020367184e+00, 5.8969634164776659423195222e-01},
	 218  	{8.8756430028990417290744307e+00, -1.3636647724582455028314573e+00},
	 219  	{1.0011785496777731986390856e+01, 2.6210913895386013290915234e+00},
	 220  }
	 221  var pow = []complex128{
	 222  	(-2.499956739197529585028819e+00 + 1.759751724335650228957144e+00i),
	 223  	(7.357094338218116311191939e+04 - 5.089973412479151648145882e+04i),
	 224  	(1.320777296067768517259592e+01 - 3.165621914333901498921986e+01i),
	 225  	(-3.123287828297300934072149e-07 - 1.9849567521490553032502223e-7i),
	 226  	(8.0622651468477229614813e+04 - 7.80028727944573092944363e+04i),
	 227  	(-1.0268824572103165858577141e+00 - 4.716844738244989776610672e-01i),
	 228  	(-4.35953819012244175753187e+01 + 2.2036445974645306917648585e+02i),
	 229  	(8.3556092283250594950239e-01 - 1.2261571947167240272593282e+01i),
	 230  	(1.582292972120769306069625e+03 + 1.273564263524278244782512e+04i),
	 231  	(6.592208301642122149025369e-08 + 2.584887236651661903526389e-08i),
	 232  }
	 233  var sin = []complex128{
	 234  	(-1.1073801774240233539648544e+03 + 3.024539773002502192425231e+02i),
	 235  	(1.0317037521400759359744682e+00 - 3.2208979799929570242818e-02i),
	 236  	(-2.0501952097271429804261058e+01 - 7.2137981348240798841800967e+01i),
	 237  	(7.3173638080346338642193078e+03 + 2.249219506193664342566248e+03i),
	 238  	(-1.964375633631808177565226e+00 - 9.0958264713870404464159683e+00i),
	 239  	(1.992783647158514838337674e+01 - 9.11555769410191350416942e+01i),
	 240  	(-6.680335650741921444300349e+00 + 3.763353833142432513086117e+00i),
	 241  	(1.2794028166657459148245993e+00 - 2.7669092099795781155109602e+00i),
	 242  	(2.8641693949535259594188879e+03 + 7.451234399649871202841615e+02i),
	 243  	(-4.893811726244659135553033e+01 - 5.371469305562194635957655e+01i),
	 244  }
	 245  var sinh = []complex128{
	 246  	(8.34559353341652565758198e+00 + 7.2187893208650790476628899e+01i),
	 247  	(1.1042192548260646752051112e+03 - 3.1379650595631635858792056e+02i),
	 248  	(-8.239469336509264113041849e-02 + 9.9273668758439489098514519e-01i),
	 249  	(7.332295456982297798219401e+01 - 1.574585908122833444899023e+01i),
	 250  	(-7.4786432301380582103534216e+03 + 1.63483823493980029604071e+03i),
	 251  	(4.595842179016870234028347e+00 - 8.135290105518580753211484e+00i),
	 252  	(-8.543842533574163435246793e+01 + 3.750798997857594068272375e+01i),
	 253  	(-1.918003500809465688017307e+00 + 7.4358344619793504041350251e+00i),
	 254  	(-2.233816733239658031433147e+00 - 2.143519070805995056229335e+00i),
	 255  	(-7.797564130187551181105341e+02 - 2.8549352346594918614806877e+03i),
	 256  }
	 257  var sqrt = []complex128{
	 258  	(2.6628203086086130543813948e+00 + 1.4531345674282185229796902e+00i),
	 259  	(2.7823278427251986247149295e+00 - 4.9756907317005224529115567e-02i),
	 260  	(1.5397025302089642757361015e+00 - 1.6271336573016637535695727e+00i),
	 261  	(1.7103411581506875260277898e+00 + 2.8170677122737589676157029e+00i),
	 262  	(3.1390392472953103383607947e+00 + 4.6612625849858653248980849e-01i),
	 263  	(2.1117080764822417640789287e+00 + 1.2381170223514273234967850e+00i),
	 264  	(2.3587032281672256703926939e+00 + 5.7827111903257349935720172e-01i),
	 265  	(1.7335262588873410476661577e+00 + 5.2647258220721269141550382e-01i),
	 266  	(2.3131094974708716531499282e+00 - 1.8775429304303785570775490e+00i),
	 267  	(8.1420535745048086240947359e-01 + 3.0575897587277248522656113e+00i),
	 268  }
	 269  var tan = []complex128{
	 270  	(-1.928757919086441129134525e-07 + 1.0000003267499169073251826e+00i),
	 271  	(1.242412685364183792138948e+00 - 3.17149693883133370106696e+00i),
	 272  	(-4.6745126251587795225571826e-05 - 9.9992439225263959286114298e-01i),
	 273  	(4.792363401193648192887116e-09 + 1.0000000070589333451557723e+00i),
	 274  	(2.345740824080089140287315e-03 + 9.947733046570988661022763e-01i),
	 275  	(-2.396030789494815566088809e-05 + 9.9994781345418591429826779e-01i),
	 276  	(-7.370204836644931340905303e-03 + 1.0043553413417138987717748e+00i),
	 277  	(-3.691803847992048527007457e-02 + 9.6475071993469548066328894e-01i),
	 278  	(-2.781955256713729368401878e-08 - 1.000000049848910609006646e+00i),
	 279  	(9.4281590064030478879791249e-05 + 9.9999119340863718183758545e-01i),
	 280  }
	 281  var tanh = []complex128{
	 282  	(1.0000921981225144748819918e+00 + 2.160986245871518020231507e-05i),
	 283  	(9.9999967727531993209562591e-01 - 1.9953763222959658873657676e-07i),
	 284  	(-1.765485739548037260789686e+00 + 1.7024216325552852445168471e+00i),
	 285  	(-9.999189442732736452807108e-01 + 3.64906070494473701938098e-05i),
	 286  	(9.9999999224622333738729767e-01 - 3.560088949517914774813046e-09i),
	 287  	(1.0029324933367326862499343e+00 - 4.948790309797102353137528e-03i),
	 288  	(9.9996113064788012488693567e-01 - 4.226995742097032481451259e-05i),
	 289  	(1.0074784189316340029873945e+00 - 4.194050814891697808029407e-03i),
	 290  	(9.9385534229718327109131502e-01 + 5.144217985914355502713437e-02i),
	 291  	(-1.0000000491604982429364892e+00 - 2.901873195374433112227349e-08i),
	 292  }
	 293  
	 294  // huge values along the real axis for testing reducePi in Tan
	 295  var hugeIn = []complex128{
	 296  	1 << 28,
	 297  	1 << 29,
	 298  	1 << 30,
	 299  	1 << 35,
	 300  	-1 << 120,
	 301  	1 << 240,
	 302  	1 << 300,
	 303  	-1 << 480,
	 304  	1234567891234567 << 180,
	 305  	-1234567891234567 << 300,
	 306  }
	 307  
	 308  // Results for tanHuge[i] calculated with https://github.com/robpike/ivy
	 309  // using 4096 bits of working precision.
	 310  var tanHuge = []complex128{
	 311  	5.95641897939639421,
	 312  	-0.34551069233430392,
	 313  	-0.78469661331920043,
	 314  	0.84276385870875983,
	 315  	0.40806638884180424,
	 316  	-0.37603456702698076,
	 317  	4.60901287677810962,
	 318  	3.39135965054779932,
	 319  	-6.76813854009065030,
	 320  	-0.76417695016604922,
	 321  }
	 322  
	 323  // special cases conform to C99 standard appendix G.6 Complex arithmetic
	 324  var inf, nan = math.Inf(1), math.NaN()
	 325  
	 326  var vcAbsSC = []complex128{
	 327  	NaN(),
	 328  }
	 329  var absSC = []float64{
	 330  	math.NaN(),
	 331  }
	 332  var acosSC = []struct {
	 333  	in,
	 334  	want complex128
	 335  }{
	 336  	// G.6.1.1
	 337  	{complex(zero, zero),
	 338  		complex(math.Pi/2, -zero)},
	 339  	{complex(-zero, zero),
	 340  		complex(math.Pi/2, -zero)},
	 341  	{complex(zero, nan),
	 342  		complex(math.Pi/2, nan)},
	 343  	{complex(-zero, nan),
	 344  		complex(math.Pi/2, nan)},
	 345  	{complex(1.0, inf),
	 346  		complex(math.Pi/2, -inf)},
	 347  	{complex(1.0, nan),
	 348  		NaN()},
	 349  	{complex(-inf, 1.0),
	 350  		complex(math.Pi, -inf)},
	 351  	{complex(inf, 1.0),
	 352  		complex(0.0, -inf)},
	 353  	{complex(-inf, inf),
	 354  		complex(3*math.Pi/4, -inf)},
	 355  	{complex(inf, inf),
	 356  		complex(math.Pi/4, -inf)},
	 357  	{complex(inf, nan),
	 358  		complex(nan, -inf)}, // imaginary sign unspecified
	 359  	{complex(-inf, nan),
	 360  		complex(nan, inf)}, // imaginary sign unspecified
	 361  	{complex(nan, 1.0),
	 362  		NaN()},
	 363  	{complex(nan, inf),
	 364  		complex(nan, -inf)},
	 365  	{NaN(),
	 366  		NaN()},
	 367  }
	 368  var acoshSC = []struct {
	 369  	in,
	 370  	want complex128
	 371  }{
	 372  	// G.6.2.1
	 373  	{complex(zero, zero),
	 374  		complex(zero, math.Pi/2)},
	 375  	{complex(-zero, zero),
	 376  		complex(zero, math.Pi/2)},
	 377  	{complex(1.0, inf),
	 378  		complex(inf, math.Pi/2)},
	 379  	{complex(1.0, nan),
	 380  		NaN()},
	 381  	{complex(-inf, 1.0),
	 382  		complex(inf, math.Pi)},
	 383  	{complex(inf, 1.0),
	 384  		complex(inf, zero)},
	 385  	{complex(-inf, inf),
	 386  		complex(inf, 3*math.Pi/4)},
	 387  	{complex(inf, inf),
	 388  		complex(inf, math.Pi/4)},
	 389  	{complex(inf, nan),
	 390  		complex(inf, nan)},
	 391  	{complex(-inf, nan),
	 392  		complex(inf, nan)},
	 393  	{complex(nan, 1.0),
	 394  		NaN()},
	 395  	{complex(nan, inf),
	 396  		complex(inf, nan)},
	 397  	{NaN(),
	 398  		NaN()},
	 399  }
	 400  var asinSC = []struct {
	 401  	in,
	 402  	want complex128
	 403  }{
	 404  	// Derived from Asin(z) = -i * Asinh(i * z), G.6 #7
	 405  	{complex(zero, zero),
	 406  		complex(zero, zero)},
	 407  	{complex(1.0, inf),
	 408  		complex(0, inf)},
	 409  	{complex(1.0, nan),
	 410  		NaN()},
	 411  	{complex(inf, 1),
	 412  		complex(math.Pi/2, inf)},
	 413  	{complex(inf, inf),
	 414  		complex(math.Pi/4, inf)},
	 415  	{complex(inf, nan),
	 416  		complex(nan, inf)}, // imaginary sign unspecified
	 417  	{complex(nan, zero),
	 418  		NaN()},
	 419  	{complex(nan, 1),
	 420  		NaN()},
	 421  	{complex(nan, inf),
	 422  		complex(nan, inf)},
	 423  	{NaN(),
	 424  		NaN()},
	 425  }
	 426  var asinhSC = []struct {
	 427  	in,
	 428  	want complex128
	 429  }{
	 430  	// G.6.2.2
	 431  	{complex(zero, zero),
	 432  		complex(zero, zero)},
	 433  	{complex(1.0, inf),
	 434  		complex(inf, math.Pi/2)},
	 435  	{complex(1.0, nan),
	 436  		NaN()},
	 437  	{complex(inf, 1.0),
	 438  		complex(inf, zero)},
	 439  	{complex(inf, inf),
	 440  		complex(inf, math.Pi/4)},
	 441  	{complex(inf, nan),
	 442  		complex(inf, nan)},
	 443  	{complex(nan, zero),
	 444  		complex(nan, zero)},
	 445  	{complex(nan, 1.0),
	 446  		NaN()},
	 447  	{complex(nan, inf),
	 448  		complex(inf, nan)}, // sign of real part unspecified
	 449  	{NaN(),
	 450  		NaN()},
	 451  }
	 452  var atanSC = []struct {
	 453  	in,
	 454  	want complex128
	 455  }{
	 456  	// Derived from Atan(z) = -i * Atanh(i * z), G.6 #7
	 457  	{complex(0, zero),
	 458  		complex(0, zero)},
	 459  	{complex(0, nan),
	 460  		NaN()},
	 461  	{complex(1.0, zero),
	 462  		complex(math.Pi/4, zero)},
	 463  	{complex(1.0, inf),
	 464  		complex(math.Pi/2, zero)},
	 465  	{complex(1.0, nan),
	 466  		NaN()},
	 467  	{complex(inf, 1),
	 468  		complex(math.Pi/2, zero)},
	 469  	{complex(inf, inf),
	 470  		complex(math.Pi/2, zero)},
	 471  	{complex(inf, nan),
	 472  		complex(math.Pi/2, zero)},
	 473  	{complex(nan, 1),
	 474  		NaN()},
	 475  	{complex(nan, inf),
	 476  		complex(nan, zero)},
	 477  	{NaN(),
	 478  		NaN()},
	 479  }
	 480  var atanhSC = []struct {
	 481  	in,
	 482  	want complex128
	 483  }{
	 484  	// G.6.2.3
	 485  	{complex(zero, zero),
	 486  		complex(zero, zero)},
	 487  	{complex(zero, nan),
	 488  		complex(zero, nan)},
	 489  	{complex(1.0, zero),
	 490  		complex(inf, zero)},
	 491  	{complex(1.0, inf),
	 492  		complex(0, math.Pi/2)},
	 493  	{complex(1.0, nan),
	 494  		NaN()},
	 495  	{complex(inf, 1.0),
	 496  		complex(zero, math.Pi/2)},
	 497  	{complex(inf, inf),
	 498  		complex(zero, math.Pi/2)},
	 499  	{complex(inf, nan),
	 500  		complex(0, nan)},
	 501  	{complex(nan, 1.0),
	 502  		NaN()},
	 503  	{complex(nan, inf),
	 504  		complex(zero, math.Pi/2)}, // sign of real part not specified.
	 505  	{NaN(),
	 506  		NaN()},
	 507  }
	 508  var vcConjSC = []complex128{
	 509  	NaN(),
	 510  }
	 511  var conjSC = []complex128{
	 512  	NaN(),
	 513  }
	 514  var cosSC = []struct {
	 515  	in,
	 516  	want complex128
	 517  }{
	 518  	// Derived from Cos(z) = Cosh(i * z), G.6 #7
	 519  	{complex(zero, zero),
	 520  		complex(1.0, -zero)},
	 521  	{complex(zero, inf),
	 522  		complex(inf, -zero)},
	 523  	{complex(zero, nan),
	 524  		complex(nan, zero)}, // imaginary sign unspecified
	 525  	{complex(1.0, inf),
	 526  		complex(inf, -inf)},
	 527  	{complex(1.0, nan),
	 528  		NaN()},
	 529  	{complex(inf, zero),
	 530  		complex(nan, -zero)},
	 531  	{complex(inf, 1.0),
	 532  		NaN()},
	 533  	{complex(inf, inf),
	 534  		complex(inf, nan)}, // real sign unspecified
	 535  	{complex(inf, nan),
	 536  		NaN()},
	 537  	{complex(nan, zero),
	 538  		complex(nan, -zero)}, // imaginary sign unspecified
	 539  	{complex(nan, 1.0),
	 540  		NaN()},
	 541  	{complex(nan, inf),
	 542  		complex(inf, nan)},
	 543  	{NaN(),
	 544  		NaN()},
	 545  }
	 546  var coshSC = []struct {
	 547  	in,
	 548  	want complex128
	 549  }{
	 550  	// G.6.2.4
	 551  	{complex(zero, zero),
	 552  		complex(1.0, zero)},
	 553  	{complex(zero, inf),
	 554  		complex(nan, zero)}, // imaginary sign unspecified
	 555  	{complex(zero, nan),
	 556  		complex(nan, zero)}, // imaginary sign unspecified
	 557  	{complex(1.0, inf),
	 558  		NaN()},
	 559  	{complex(1.0, nan),
	 560  		NaN()},
	 561  	{complex(inf, zero),
	 562  		complex(inf, zero)},
	 563  	{complex(inf, 1.0),
	 564  		complex(inf*math.Cos(1.0), inf*math.Sin(1.0))}, // +inf	cis(y)
	 565  	{complex(inf, inf),
	 566  		complex(inf, nan)}, // real sign unspecified
	 567  	{complex(inf, nan),
	 568  		complex(inf, nan)},
	 569  	{complex(nan, zero),
	 570  		complex(nan, zero)}, // imaginary sign unspecified
	 571  	{complex(nan, 1.0),
	 572  		NaN()},
	 573  	{complex(nan, inf),
	 574  		NaN()},
	 575  	{NaN(),
	 576  		NaN()},
	 577  }
	 578  var expSC = []struct {
	 579  	in,
	 580  	want complex128
	 581  }{
	 582  	// G.6.3.1
	 583  	{complex(zero, zero),
	 584  		complex(1.0, zero)},
	 585  	{complex(-zero, zero),
	 586  		complex(1.0, zero)},
	 587  	{complex(1.0, inf),
	 588  		NaN()},
	 589  	{complex(1.0, nan),
	 590  		NaN()},
	 591  	{complex(inf, zero),
	 592  		complex(inf, zero)},
	 593  	{complex(-inf, 1.0),
	 594  		complex(math.Copysign(0.0, math.Cos(1.0)), math.Copysign(0.0, math.Sin(1.0)))}, // +0 cis(y)
	 595  	{complex(inf, 1.0),
	 596  		complex(inf*math.Cos(1.0), inf*math.Sin(1.0))}, // +inf	cis(y)
	 597  	{complex(-inf, inf),
	 598  		complex(zero, zero)}, // real and imaginary sign unspecified
	 599  	{complex(inf, inf),
	 600  		complex(inf, nan)}, // real sign unspecified
	 601  	{complex(-inf, nan),
	 602  		complex(zero, zero)}, // real and imaginary sign unspecified
	 603  	{complex(inf, nan),
	 604  		complex(inf, nan)}, // real sign unspecified
	 605  	{complex(nan, zero),
	 606  		complex(nan, zero)},
	 607  	{complex(nan, 1.0),
	 608  		NaN()},
	 609  	{complex(nan, inf),
	 610  		NaN()},
	 611  	{NaN(),
	 612  		NaN()},
	 613  }
	 614  var vcIsNaNSC = []complex128{
	 615  	complex(math.Inf(-1), math.Inf(-1)),
	 616  	complex(math.Inf(-1), math.NaN()),
	 617  	complex(math.NaN(), math.Inf(-1)),
	 618  	complex(0, math.NaN()),
	 619  	complex(math.NaN(), 0),
	 620  	complex(math.Inf(1), math.Inf(1)),
	 621  	complex(math.Inf(1), math.NaN()),
	 622  	complex(math.NaN(), math.Inf(1)),
	 623  	complex(math.NaN(), math.NaN()),
	 624  }
	 625  var isNaNSC = []bool{
	 626  	false,
	 627  	false,
	 628  	false,
	 629  	true,
	 630  	true,
	 631  	false,
	 632  	false,
	 633  	false,
	 634  	true,
	 635  }
	 636  
	 637  var logSC = []struct {
	 638  	in,
	 639  	want complex128
	 640  }{
	 641  	// G.6.3.2
	 642  	{complex(zero, zero),
	 643  		complex(-inf, zero)},
	 644  	{complex(-zero, zero),
	 645  		complex(-inf, math.Pi)},
	 646  	{complex(1.0, inf),
	 647  		complex(inf, math.Pi/2)},
	 648  	{complex(1.0, nan),
	 649  		NaN()},
	 650  	{complex(-inf, 1.0),
	 651  		complex(inf, math.Pi)},
	 652  	{complex(inf, 1.0),
	 653  		complex(inf, 0.0)},
	 654  	{complex(-inf, inf),
	 655  		complex(inf, 3*math.Pi/4)},
	 656  	{complex(inf, inf),
	 657  		complex(inf, math.Pi/4)},
	 658  	{complex(-inf, nan),
	 659  		complex(inf, nan)},
	 660  	{complex(inf, nan),
	 661  		complex(inf, nan)},
	 662  	{complex(nan, 1.0),
	 663  		NaN()},
	 664  	{complex(nan, inf),
	 665  		complex(inf, nan)},
	 666  	{NaN(),
	 667  		NaN()},
	 668  }
	 669  var log10SC = []struct {
	 670  	in,
	 671  	want complex128
	 672  }{
	 673  	// derived from Log special cases via Log10(x) = math.Log10E*Log(x)
	 674  	{complex(zero, zero),
	 675  		complex(-inf, zero)},
	 676  	{complex(-zero, zero),
	 677  		complex(-inf, float64(math.Log10E)*float64(math.Pi))},
	 678  	{complex(1.0, inf),
	 679  		complex(inf, float64(math.Log10E)*float64(math.Pi/2))},
	 680  	{complex(1.0, nan),
	 681  		NaN()},
	 682  	{complex(-inf, 1.0),
	 683  		complex(inf, float64(math.Log10E)*float64(math.Pi))},
	 684  	{complex(inf, 1.0),
	 685  		complex(inf, 0.0)},
	 686  	{complex(-inf, inf),
	 687  		complex(inf, float64(math.Log10E)*float64(3*math.Pi/4))},
	 688  	{complex(inf, inf),
	 689  		complex(inf, float64(math.Log10E)*float64(math.Pi/4))},
	 690  	{complex(-inf, nan),
	 691  		complex(inf, nan)},
	 692  	{complex(inf, nan),
	 693  		complex(inf, nan)},
	 694  	{complex(nan, 1.0),
	 695  		NaN()},
	 696  	{complex(nan, inf),
	 697  		complex(inf, nan)},
	 698  	{NaN(),
	 699  		NaN()},
	 700  }
	 701  var vcPolarSC = []complex128{
	 702  	NaN(),
	 703  }
	 704  var polarSC = []ff{
	 705  	{math.NaN(), math.NaN()},
	 706  }
	 707  var vcPowSC = [][2]complex128{
	 708  	{NaN(), NaN()},
	 709  	{0, NaN()},
	 710  }
	 711  var powSC = []complex128{
	 712  	NaN(),
	 713  	NaN(),
	 714  }
	 715  var sinSC = []struct {
	 716  	in,
	 717  	want complex128
	 718  }{
	 719  	// Derived from Sin(z) = -i * Sinh(i * z), G.6 #7
	 720  	{complex(zero, zero),
	 721  		complex(zero, zero)},
	 722  	{complex(zero, inf),
	 723  		complex(zero, inf)},
	 724  	{complex(zero, nan),
	 725  		complex(zero, nan)},
	 726  	{complex(1.0, inf),
	 727  		complex(inf, inf)},
	 728  	{complex(1.0, nan),
	 729  		NaN()},
	 730  	{complex(inf, zero),
	 731  		complex(nan, zero)},
	 732  	{complex(inf, 1.0),
	 733  		NaN()},
	 734  	{complex(inf, inf),
	 735  		complex(nan, inf)},
	 736  	{complex(inf, nan),
	 737  		NaN()},
	 738  	{complex(nan, zero),
	 739  		complex(nan, zero)},
	 740  	{complex(nan, 1.0),
	 741  		NaN()},
	 742  	{complex(nan, inf),
	 743  		complex(nan, inf)},
	 744  	{NaN(),
	 745  		NaN()},
	 746  }
	 747  
	 748  var sinhSC = []struct {
	 749  	in,
	 750  	want complex128
	 751  }{
	 752  	// G.6.2.5
	 753  	{complex(zero, zero),
	 754  		complex(zero, zero)},
	 755  	{complex(zero, inf),
	 756  		complex(zero, nan)}, // real sign unspecified
	 757  	{complex(zero, nan),
	 758  		complex(zero, nan)}, // real sign unspecified
	 759  	{complex(1.0, inf),
	 760  		NaN()},
	 761  	{complex(1.0, nan),
	 762  		NaN()},
	 763  	{complex(inf, zero),
	 764  		complex(inf, zero)},
	 765  	{complex(inf, 1.0),
	 766  		complex(inf*math.Cos(1.0), inf*math.Sin(1.0))}, // +inf	cis(y)
	 767  	{complex(inf, inf),
	 768  		complex(inf, nan)}, // real sign unspecified
	 769  	{complex(inf, nan),
	 770  		complex(inf, nan)}, // real sign unspecified
	 771  	{complex(nan, zero),
	 772  		complex(nan, zero)},
	 773  	{complex(nan, 1.0),
	 774  		NaN()},
	 775  	{complex(nan, inf),
	 776  		NaN()},
	 777  	{NaN(),
	 778  		NaN()},
	 779  }
	 780  
	 781  var sqrtSC = []struct {
	 782  	in,
	 783  	want complex128
	 784  }{
	 785  	// G.6.4.2
	 786  	{complex(zero, zero),
	 787  		complex(zero, zero)},
	 788  	{complex(-zero, zero),
	 789  		complex(zero, zero)},
	 790  	{complex(1.0, inf),
	 791  		complex(inf, inf)},
	 792  	{complex(nan, inf),
	 793  		complex(inf, inf)},
	 794  	{complex(1.0, nan),
	 795  		NaN()},
	 796  	{complex(-inf, 1.0),
	 797  		complex(zero, inf)},
	 798  	{complex(inf, 1.0),
	 799  		complex(inf, zero)},
	 800  	{complex(-inf, nan),
	 801  		complex(nan, inf)}, // imaginary sign unspecified
	 802  	{complex(inf, nan),
	 803  		complex(inf, nan)},
	 804  	{complex(nan, 1.0),
	 805  		NaN()},
	 806  	{NaN(),
	 807  		NaN()},
	 808  }
	 809  var tanSC = []struct {
	 810  	in,
	 811  	want complex128
	 812  }{
	 813  	// Derived from Tan(z) = -i * Tanh(i * z), G.6 #7
	 814  	{complex(zero, zero),
	 815  		complex(zero, zero)},
	 816  	{complex(zero, nan),
	 817  		complex(zero, nan)},
	 818  	{complex(1.0, inf),
	 819  		complex(zero, 1.0)},
	 820  	{complex(1.0, nan),
	 821  		NaN()},
	 822  	{complex(inf, 1.0),
	 823  		NaN()},
	 824  	{complex(inf, inf),
	 825  		complex(zero, 1.0)},
	 826  	{complex(inf, nan),
	 827  		NaN()},
	 828  	{complex(nan, zero),
	 829  		NaN()},
	 830  	{complex(nan, 1.0),
	 831  		NaN()},
	 832  	{complex(nan, inf),
	 833  		complex(zero, 1.0)},
	 834  	{NaN(),
	 835  		NaN()},
	 836  }
	 837  var tanhSC = []struct {
	 838  	in,
	 839  	want complex128
	 840  }{
	 841  	// G.6.2.6
	 842  	{complex(zero, zero),
	 843  		complex(zero, zero)},
	 844  	{complex(1.0, inf),
	 845  		NaN()},
	 846  	{complex(1.0, nan),
	 847  		NaN()},
	 848  	{complex(inf, 1.0),
	 849  		complex(1.0, math.Copysign(0.0, math.Sin(2*1.0)))}, // 1 + i 0 sin(2y)
	 850  	{complex(inf, inf),
	 851  		complex(1.0, zero)}, // imaginary sign unspecified
	 852  	{complex(inf, nan),
	 853  		complex(1.0, zero)}, // imaginary sign unspecified
	 854  	{complex(nan, zero),
	 855  		complex(nan, zero)},
	 856  	{complex(nan, 1.0),
	 857  		NaN()},
	 858  	{complex(nan, inf),
	 859  		NaN()},
	 860  	{NaN(),
	 861  		NaN()},
	 862  }
	 863  
	 864  // branch cut continuity checks
	 865  // points on each axis at |z| > 1 are checked for one-sided continuity from both the positive and negative side
	 866  // all possible branch cuts for the elementary functions are at one of these points
	 867  
	 868  var zero = 0.0
	 869  var eps = 1.0 / (1 << 53)
	 870  
	 871  var branchPoints = [][2]complex128{
	 872  	{complex(2.0, zero), complex(2.0, eps)},
	 873  	{complex(2.0, -zero), complex(2.0, -eps)},
	 874  	{complex(-2.0, zero), complex(-2.0, eps)},
	 875  	{complex(-2.0, -zero), complex(-2.0, -eps)},
	 876  	{complex(zero, 2.0), complex(eps, 2.0)},
	 877  	{complex(-zero, 2.0), complex(-eps, 2.0)},
	 878  	{complex(zero, -2.0), complex(eps, -2.0)},
	 879  	{complex(-zero, -2.0), complex(-eps, -2.0)},
	 880  }
	 881  
	 882  // functions borrowed from pkg/math/all_test.go
	 883  func tolerance(a, b, e float64) bool {
	 884  	d := a - b
	 885  	if d < 0 {
	 886  		d = -d
	 887  	}
	 888  
	 889  	// note: b is correct (expected) value, a is actual value.
	 890  	// make error tolerance a fraction of b, not a.
	 891  	if b != 0 {
	 892  		e = e * b
	 893  		if e < 0 {
	 894  			e = -e
	 895  		}
	 896  	}
	 897  	return d < e
	 898  }
	 899  func veryclose(a, b float64) bool { return tolerance(a, b, 4e-16) }
	 900  func alike(a, b float64) bool {
	 901  	switch {
	 902  	case a != a && b != b: // math.IsNaN(a) && math.IsNaN(b):
	 903  		return true
	 904  	case a == b:
	 905  		return math.Signbit(a) == math.Signbit(b)
	 906  	}
	 907  	return false
	 908  }
	 909  
	 910  func cTolerance(a, b complex128, e float64) bool {
	 911  	d := Abs(a - b)
	 912  	if b != 0 {
	 913  		e = e * Abs(b)
	 914  		if e < 0 {
	 915  			e = -e
	 916  		}
	 917  	}
	 918  	return d < e
	 919  }
	 920  func cSoclose(a, b complex128, e float64) bool { return cTolerance(a, b, e) }
	 921  func cVeryclose(a, b complex128) bool					{ return cTolerance(a, b, 4e-16) }
	 922  func cAlike(a, b complex128) bool {
	 923  	var realAlike, imagAlike bool
	 924  	if isExact(real(b)) {
	 925  		realAlike = alike(real(a), real(b))
	 926  	} else {
	 927  		// Allow non-exact special cases to have errors in ULP.
	 928  		realAlike = veryclose(real(a), real(b))
	 929  	}
	 930  	if isExact(imag(b)) {
	 931  		imagAlike = alike(imag(a), imag(b))
	 932  	} else {
	 933  		// Allow non-exact special cases to have errors in ULP.
	 934  		imagAlike = veryclose(imag(a), imag(b))
	 935  	}
	 936  	return realAlike && imagAlike
	 937  }
	 938  func isExact(x float64) bool {
	 939  	// Special cases that should match exactly.	Other cases are multiples
	 940  	// of Pi that may not be last bit identical on all platforms.
	 941  	return math.IsNaN(x) || math.IsInf(x, 0) || x == 0 || x == 1 || x == -1
	 942  }
	 943  
	 944  func TestAbs(t *testing.T) {
	 945  	for i := 0; i < len(vc); i++ {
	 946  		if f := Abs(vc[i]); !veryclose(abs[i], f) {
	 947  			t.Errorf("Abs(%g) = %g, want %g", vc[i], f, abs[i])
	 948  		}
	 949  	}
	 950  	for i := 0; i < len(vcAbsSC); i++ {
	 951  		if f := Abs(vcAbsSC[i]); !alike(absSC[i], f) {
	 952  			t.Errorf("Abs(%g) = %g, want %g", vcAbsSC[i], f, absSC[i])
	 953  		}
	 954  	}
	 955  }
	 956  func TestAcos(t *testing.T) {
	 957  	for i := 0; i < len(vc); i++ {
	 958  		if f := Acos(vc[i]); !cSoclose(acos[i], f, 1e-14) {
	 959  			t.Errorf("Acos(%g) = %g, want %g", vc[i], f, acos[i])
	 960  		}
	 961  	}
	 962  	for _, v := range acosSC {
	 963  		if f := Acos(v.in); !cAlike(v.want, f) {
	 964  			t.Errorf("Acos(%g) = %g, want %g", v.in, f, v.want)
	 965  		}
	 966  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	 967  			// Negating NaN is undefined with regard to the sign bit produced.
	 968  			continue
	 969  		}
	 970  		// Acos(Conj(z))	== Conj(Acos(z))
	 971  		if f := Acos(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	 972  			t.Errorf("Acos(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	 973  		}
	 974  	}
	 975  	for _, pt := range branchPoints {
	 976  		if f0, f1 := Acos(pt[0]), Acos(pt[1]); !cVeryclose(f0, f1) {
	 977  			t.Errorf("Acos(%g) not continuous, got %g want %g", pt[0], f0, f1)
	 978  		}
	 979  	}
	 980  }
	 981  func TestAcosh(t *testing.T) {
	 982  	for i := 0; i < len(vc); i++ {
	 983  		if f := Acosh(vc[i]); !cSoclose(acosh[i], f, 1e-14) {
	 984  			t.Errorf("Acosh(%g) = %g, want %g", vc[i], f, acosh[i])
	 985  		}
	 986  	}
	 987  	for _, v := range acoshSC {
	 988  		if f := Acosh(v.in); !cAlike(v.want, f) {
	 989  			t.Errorf("Acosh(%g) = %g, want %g", v.in, f, v.want)
	 990  		}
	 991  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	 992  			// Negating NaN is undefined with regard to the sign bit produced.
	 993  			continue
	 994  		}
	 995  		// Acosh(Conj(z))	== Conj(Acosh(z))
	 996  		if f := Acosh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	 997  			t.Errorf("Acosh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	 998  		}
	 999  
	1000  	}
	1001  	for _, pt := range branchPoints {
	1002  		if f0, f1 := Acosh(pt[0]), Acosh(pt[1]); !cVeryclose(f0, f1) {
	1003  			t.Errorf("Acosh(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1004  		}
	1005  	}
	1006  }
	1007  func TestAsin(t *testing.T) {
	1008  	for i := 0; i < len(vc); i++ {
	1009  		if f := Asin(vc[i]); !cSoclose(asin[i], f, 1e-14) {
	1010  			t.Errorf("Asin(%g) = %g, want %g", vc[i], f, asin[i])
	1011  		}
	1012  	}
	1013  	for _, v := range asinSC {
	1014  		if f := Asin(v.in); !cAlike(v.want, f) {
	1015  			t.Errorf("Asin(%g) = %g, want %g", v.in, f, v.want)
	1016  		}
	1017  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1018  			// Negating NaN is undefined with regard to the sign bit produced.
	1019  			continue
	1020  		}
	1021  		// Asin(Conj(z))	== Asin(Sinh(z))
	1022  		if f := Asin(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1023  			t.Errorf("Asin(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1024  		}
	1025  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1026  			// Negating NaN is undefined with regard to the sign bit produced.
	1027  			continue
	1028  		}
	1029  		// Asin(-z)	== -Asin(z)
	1030  		if f := Asin(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1031  			t.Errorf("Asin(%g) = %g, want %g", -v.in, f, -v.want)
	1032  		}
	1033  	}
	1034  	for _, pt := range branchPoints {
	1035  		if f0, f1 := Asin(pt[0]), Asin(pt[1]); !cVeryclose(f0, f1) {
	1036  			t.Errorf("Asin(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1037  		}
	1038  	}
	1039  }
	1040  func TestAsinh(t *testing.T) {
	1041  	for i := 0; i < len(vc); i++ {
	1042  		if f := Asinh(vc[i]); !cSoclose(asinh[i], f, 4e-15) {
	1043  			t.Errorf("Asinh(%g) = %g, want %g", vc[i], f, asinh[i])
	1044  		}
	1045  	}
	1046  	for _, v := range asinhSC {
	1047  		if f := Asinh(v.in); !cAlike(v.want, f) {
	1048  			t.Errorf("Asinh(%g) = %g, want %g", v.in, f, v.want)
	1049  		}
	1050  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1051  			// Negating NaN is undefined with regard to the sign bit produced.
	1052  			continue
	1053  		}
	1054  		// Asinh(Conj(z))	== Asinh(Sinh(z))
	1055  		if f := Asinh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1056  			t.Errorf("Asinh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1057  		}
	1058  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1059  			// Negating NaN is undefined with regard to the sign bit produced.
	1060  			continue
	1061  		}
	1062  		// Asinh(-z)	== -Asinh(z)
	1063  		if f := Asinh(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1064  			t.Errorf("Asinh(%g) = %g, want %g", -v.in, f, -v.want)
	1065  		}
	1066  	}
	1067  	for _, pt := range branchPoints {
	1068  		if f0, f1 := Asinh(pt[0]), Asinh(pt[1]); !cVeryclose(f0, f1) {
	1069  			t.Errorf("Asinh(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1070  		}
	1071  	}
	1072  }
	1073  func TestAtan(t *testing.T) {
	1074  	for i := 0; i < len(vc); i++ {
	1075  		if f := Atan(vc[i]); !cVeryclose(atan[i], f) {
	1076  			t.Errorf("Atan(%g) = %g, want %g", vc[i], f, atan[i])
	1077  		}
	1078  	}
	1079  	for _, v := range atanSC {
	1080  		if f := Atan(v.in); !cAlike(v.want, f) {
	1081  			t.Errorf("Atan(%g) = %g, want %g", v.in, f, v.want)
	1082  		}
	1083  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1084  			// Negating NaN is undefined with regard to the sign bit produced.
	1085  			continue
	1086  		}
	1087  		// Atan(Conj(z))	== Conj(Atan(z))
	1088  		if f := Atan(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1089  			t.Errorf("Atan(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1090  		}
	1091  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1092  			// Negating NaN is undefined with regard to the sign bit produced.
	1093  			continue
	1094  		}
	1095  		// Atan(-z)	== -Atan(z)
	1096  		if f := Atan(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1097  			t.Errorf("Atan(%g) = %g, want %g", -v.in, f, -v.want)
	1098  		}
	1099  	}
	1100  	for _, pt := range branchPoints {
	1101  		if f0, f1 := Atan(pt[0]), Atan(pt[1]); !cVeryclose(f0, f1) {
	1102  			t.Errorf("Atan(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1103  		}
	1104  	}
	1105  }
	1106  func TestAtanh(t *testing.T) {
	1107  	for i := 0; i < len(vc); i++ {
	1108  		if f := Atanh(vc[i]); !cVeryclose(atanh[i], f) {
	1109  			t.Errorf("Atanh(%g) = %g, want %g", vc[i], f, atanh[i])
	1110  		}
	1111  	}
	1112  	for _, v := range atanhSC {
	1113  		if f := Atanh(v.in); !cAlike(v.want, f) {
	1114  			t.Errorf("Atanh(%g) = %g, want %g", v.in, f, v.want)
	1115  		}
	1116  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1117  			// Negating NaN is undefined with regard to the sign bit produced.
	1118  			continue
	1119  		}
	1120  		// Atanh(Conj(z))	== Conj(Atanh(z))
	1121  		if f := Atanh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1122  			t.Errorf("Atanh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1123  		}
	1124  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1125  			// Negating NaN is undefined with regard to the sign bit produced.
	1126  			continue
	1127  		}
	1128  		// Atanh(-z)	== -Atanh(z)
	1129  		if f := Atanh(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1130  			t.Errorf("Atanh(%g) = %g, want %g", -v.in, f, -v.want)
	1131  		}
	1132  	}
	1133  	for _, pt := range branchPoints {
	1134  		if f0, f1 := Atanh(pt[0]), Atanh(pt[1]); !cVeryclose(f0, f1) {
	1135  			t.Errorf("Atanh(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1136  		}
	1137  	}
	1138  }
	1139  func TestConj(t *testing.T) {
	1140  	for i := 0; i < len(vc); i++ {
	1141  		if f := Conj(vc[i]); !cVeryclose(conj[i], f) {
	1142  			t.Errorf("Conj(%g) = %g, want %g", vc[i], f, conj[i])
	1143  		}
	1144  	}
	1145  	for i := 0; i < len(vcConjSC); i++ {
	1146  		if f := Conj(vcConjSC[i]); !cAlike(conjSC[i], f) {
	1147  			t.Errorf("Conj(%g) = %g, want %g", vcConjSC[i], f, conjSC[i])
	1148  		}
	1149  	}
	1150  }
	1151  func TestCos(t *testing.T) {
	1152  	for i := 0; i < len(vc); i++ {
	1153  		if f := Cos(vc[i]); !cSoclose(cos[i], f, 3e-15) {
	1154  			t.Errorf("Cos(%g) = %g, want %g", vc[i], f, cos[i])
	1155  		}
	1156  	}
	1157  	for _, v := range cosSC {
	1158  		if f := Cos(v.in); !cAlike(v.want, f) {
	1159  			t.Errorf("Cos(%g) = %g, want %g", v.in, f, v.want)
	1160  		}
	1161  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1162  			// Negating NaN is undefined with regard to the sign bit produced.
	1163  			continue
	1164  		}
	1165  		// Cos(Conj(z))	== Cos(Cosh(z))
	1166  		if f := Cos(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1167  			t.Errorf("Cos(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1168  		}
	1169  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1170  			// Negating NaN is undefined with regard to the sign bit produced.
	1171  			continue
	1172  		}
	1173  		// Cos(-z)	== Cos(z)
	1174  		if f := Cos(-v.in); !cAlike(v.want, f) && !cAlike(v.in, -v.in) {
	1175  			t.Errorf("Cos(%g) = %g, want %g", -v.in, f, v.want)
	1176  		}
	1177  	}
	1178  }
	1179  func TestCosh(t *testing.T) {
	1180  	for i := 0; i < len(vc); i++ {
	1181  		if f := Cosh(vc[i]); !cSoclose(cosh[i], f, 2e-15) {
	1182  			t.Errorf("Cosh(%g) = %g, want %g", vc[i], f, cosh[i])
	1183  		}
	1184  	}
	1185  	for _, v := range coshSC {
	1186  		if f := Cosh(v.in); !cAlike(v.want, f) {
	1187  			t.Errorf("Cosh(%g) = %g, want %g", v.in, f, v.want)
	1188  		}
	1189  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1190  			// Negating NaN is undefined with regard to the sign bit produced.
	1191  			continue
	1192  		}
	1193  		// Cosh(Conj(z))	== Conj(Cosh(z))
	1194  		if f := Cosh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1195  			t.Errorf("Cosh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1196  		}
	1197  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1198  			// Negating NaN is undefined with regard to the sign bit produced.
	1199  			continue
	1200  		}
	1201  		// Cosh(-z)	== Cosh(z)
	1202  		if f := Cosh(-v.in); !cAlike(v.want, f) && !cAlike(v.in, -v.in) {
	1203  			t.Errorf("Cosh(%g) = %g, want %g", -v.in, f, v.want)
	1204  		}
	1205  	}
	1206  }
	1207  func TestExp(t *testing.T) {
	1208  	for i := 0; i < len(vc); i++ {
	1209  		if f := Exp(vc[i]); !cSoclose(exp[i], f, 1e-15) {
	1210  			t.Errorf("Exp(%g) = %g, want %g", vc[i], f, exp[i])
	1211  		}
	1212  	}
	1213  	for _, v := range expSC {
	1214  		if f := Exp(v.in); !cAlike(v.want, f) {
	1215  			t.Errorf("Exp(%g) = %g, want %g", v.in, f, v.want)
	1216  		}
	1217  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1218  			// Negating NaN is undefined with regard to the sign bit produced.
	1219  			continue
	1220  		}
	1221  		// Exp(Conj(z))	== Exp(Cosh(z))
	1222  		if f := Exp(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1223  			t.Errorf("Exp(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1224  		}
	1225  	}
	1226  }
	1227  func TestIsNaN(t *testing.T) {
	1228  	for i := 0; i < len(vcIsNaNSC); i++ {
	1229  		if f := IsNaN(vcIsNaNSC[i]); isNaNSC[i] != f {
	1230  			t.Errorf("IsNaN(%v) = %v, want %v", vcIsNaNSC[i], f, isNaNSC[i])
	1231  		}
	1232  	}
	1233  }
	1234  func TestLog(t *testing.T) {
	1235  	for i := 0; i < len(vc); i++ {
	1236  		if f := Log(vc[i]); !cVeryclose(log[i], f) {
	1237  			t.Errorf("Log(%g) = %g, want %g", vc[i], f, log[i])
	1238  		}
	1239  	}
	1240  	for _, v := range logSC {
	1241  		if f := Log(v.in); !cAlike(v.want, f) {
	1242  			t.Errorf("Log(%g) = %g, want %g", v.in, f, v.want)
	1243  		}
	1244  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1245  			// Negating NaN is undefined with regard to the sign bit produced.
	1246  			continue
	1247  		}
	1248  		// Log(Conj(z))	== Conj(Log(z))
	1249  		if f := Log(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1250  			t.Errorf("Log(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1251  		}
	1252  	}
	1253  	for _, pt := range branchPoints {
	1254  		if f0, f1 := Log(pt[0]), Log(pt[1]); !cVeryclose(f0, f1) {
	1255  			t.Errorf("Log(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1256  		}
	1257  	}
	1258  }
	1259  func TestLog10(t *testing.T) {
	1260  	for i := 0; i < len(vc); i++ {
	1261  		if f := Log10(vc[i]); !cVeryclose(log10[i], f) {
	1262  			t.Errorf("Log10(%g) = %g, want %g", vc[i], f, log10[i])
	1263  		}
	1264  	}
	1265  	for _, v := range log10SC {
	1266  		if f := Log10(v.in); !cAlike(v.want, f) {
	1267  			t.Errorf("Log10(%g) = %g, want %g", v.in, f, v.want)
	1268  		}
	1269  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1270  			// Negating NaN is undefined with regard to the sign bit produced.
	1271  			continue
	1272  		}
	1273  		// Log10(Conj(z))	== Conj(Log10(z))
	1274  		if f := Log10(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1275  			t.Errorf("Log10(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1276  		}
	1277  	}
	1278  }
	1279  func TestPolar(t *testing.T) {
	1280  	for i := 0; i < len(vc); i++ {
	1281  		if r, theta := Polar(vc[i]); !veryclose(polar[i].r, r) && !veryclose(polar[i].theta, theta) {
	1282  			t.Errorf("Polar(%g) = %g, %g want %g, %g", vc[i], r, theta, polar[i].r, polar[i].theta)
	1283  		}
	1284  	}
	1285  	for i := 0; i < len(vcPolarSC); i++ {
	1286  		if r, theta := Polar(vcPolarSC[i]); !alike(polarSC[i].r, r) && !alike(polarSC[i].theta, theta) {
	1287  			t.Errorf("Polar(%g) = %g, %g, want %g, %g", vcPolarSC[i], r, theta, polarSC[i].r, polarSC[i].theta)
	1288  		}
	1289  	}
	1290  }
	1291  func TestPow(t *testing.T) {
	1292  	// Special cases for Pow(0, c).
	1293  	var zero = complex(0, 0)
	1294  	zeroPowers := [][2]complex128{
	1295  		{0, 1 + 0i},
	1296  		{1.5, 0 + 0i},
	1297  		{-1.5, complex(math.Inf(0), 0)},
	1298  		{-1.5 + 1.5i, Inf()},
	1299  	}
	1300  	for _, zp := range zeroPowers {
	1301  		if f := Pow(zero, zp[0]); f != zp[1] {
	1302  			t.Errorf("Pow(%g, %g) = %g, want %g", zero, zp[0], f, zp[1])
	1303  		}
	1304  	}
	1305  	var a = complex(3.0, 3.0)
	1306  	for i := 0; i < len(vc); i++ {
	1307  		if f := Pow(a, vc[i]); !cSoclose(pow[i], f, 4e-15) {
	1308  			t.Errorf("Pow(%g, %g) = %g, want %g", a, vc[i], f, pow[i])
	1309  		}
	1310  	}
	1311  	for i := 0; i < len(vcPowSC); i++ {
	1312  		if f := Pow(vcPowSC[i][0], vcPowSC[i][1]); !cAlike(powSC[i], f) {
	1313  			t.Errorf("Pow(%g, %g) = %g, want %g", vcPowSC[i][0], vcPowSC[i][1], f, powSC[i])
	1314  		}
	1315  	}
	1316  	for _, pt := range branchPoints {
	1317  		if f0, f1 := Pow(pt[0], 0.1), Pow(pt[1], 0.1); !cVeryclose(f0, f1) {
	1318  			t.Errorf("Pow(%g, 0.1) not continuous, got %g want %g", pt[0], f0, f1)
	1319  		}
	1320  	}
	1321  }
	1322  func TestRect(t *testing.T) {
	1323  	for i := 0; i < len(vc); i++ {
	1324  		if f := Rect(polar[i].r, polar[i].theta); !cVeryclose(vc[i], f) {
	1325  			t.Errorf("Rect(%g, %g) = %g want %g", polar[i].r, polar[i].theta, f, vc[i])
	1326  		}
	1327  	}
	1328  	for i := 0; i < len(vcPolarSC); i++ {
	1329  		if f := Rect(polarSC[i].r, polarSC[i].theta); !cAlike(vcPolarSC[i], f) {
	1330  			t.Errorf("Rect(%g, %g) = %g, want %g", polarSC[i].r, polarSC[i].theta, f, vcPolarSC[i])
	1331  		}
	1332  	}
	1333  }
	1334  func TestSin(t *testing.T) {
	1335  	for i := 0; i < len(vc); i++ {
	1336  		if f := Sin(vc[i]); !cSoclose(sin[i], f, 2e-15) {
	1337  			t.Errorf("Sin(%g) = %g, want %g", vc[i], f, sin[i])
	1338  		}
	1339  	}
	1340  	for _, v := range sinSC {
	1341  		if f := Sin(v.in); !cAlike(v.want, f) {
	1342  			t.Errorf("Sin(%g) = %g, want %g", v.in, f, v.want)
	1343  		}
	1344  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1345  			// Negating NaN is undefined with regard to the sign bit produced.
	1346  			continue
	1347  		}
	1348  		// Sin(Conj(z))	== Conj(Sin(z))
	1349  		if f := Sin(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1350  			t.Errorf("Sinh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1351  		}
	1352  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1353  			// Negating NaN is undefined with regard to the sign bit produced.
	1354  			continue
	1355  		}
	1356  		// Sin(-z)	== -Sin(z)
	1357  		if f := Sin(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1358  			t.Errorf("Sinh(%g) = %g, want %g", -v.in, f, -v.want)
	1359  		}
	1360  	}
	1361  }
	1362  func TestSinh(t *testing.T) {
	1363  	for i := 0; i < len(vc); i++ {
	1364  		if f := Sinh(vc[i]); !cSoclose(sinh[i], f, 2e-15) {
	1365  			t.Errorf("Sinh(%g) = %g, want %g", vc[i], f, sinh[i])
	1366  		}
	1367  	}
	1368  	for _, v := range sinhSC {
	1369  		if f := Sinh(v.in); !cAlike(v.want, f) {
	1370  			t.Errorf("Sinh(%g) = %g, want %g", v.in, f, v.want)
	1371  		}
	1372  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1373  			// Negating NaN is undefined with regard to the sign bit produced.
	1374  			continue
	1375  		}
	1376  		// Sinh(Conj(z))	== Conj(Sinh(z))
	1377  		if f := Sinh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1378  			t.Errorf("Sinh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1379  		}
	1380  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1381  			// Negating NaN is undefined with regard to the sign bit produced.
	1382  			continue
	1383  		}
	1384  		// Sinh(-z)	== -Sinh(z)
	1385  		if f := Sinh(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1386  			t.Errorf("Sinh(%g) = %g, want %g", -v.in, f, -v.want)
	1387  		}
	1388  	}
	1389  }
	1390  func TestSqrt(t *testing.T) {
	1391  	for i := 0; i < len(vc); i++ {
	1392  		if f := Sqrt(vc[i]); !cVeryclose(sqrt[i], f) {
	1393  			t.Errorf("Sqrt(%g) = %g, want %g", vc[i], f, sqrt[i])
	1394  		}
	1395  	}
	1396  	for _, v := range sqrtSC {
	1397  		if f := Sqrt(v.in); !cAlike(v.want, f) {
	1398  			t.Errorf("Sqrt(%g) = %g, want %g", v.in, f, v.want)
	1399  		}
	1400  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1401  			// Negating NaN is undefined with regard to the sign bit produced.
	1402  			continue
	1403  		}
	1404  		// Sqrt(Conj(z)) == Conj(Sqrt(z))
	1405  		if f := Sqrt(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1406  			t.Errorf("Sqrt(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1407  		}
	1408  	}
	1409  	for _, pt := range branchPoints {
	1410  		if f0, f1 := Sqrt(pt[0]), Sqrt(pt[1]); !cVeryclose(f0, f1) {
	1411  			t.Errorf("Sqrt(%g) not continuous, got %g want %g", pt[0], f0, f1)
	1412  		}
	1413  	}
	1414  }
	1415  func TestTan(t *testing.T) {
	1416  	for i := 0; i < len(vc); i++ {
	1417  		if f := Tan(vc[i]); !cSoclose(tan[i], f, 3e-15) {
	1418  			t.Errorf("Tan(%g) = %g, want %g", vc[i], f, tan[i])
	1419  		}
	1420  	}
	1421  	for _, v := range tanSC {
	1422  		if f := Tan(v.in); !cAlike(v.want, f) {
	1423  			t.Errorf("Tan(%g) = %g, want %g", v.in, f, v.want)
	1424  		}
	1425  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1426  			// Negating NaN is undefined with regard to the sign bit produced.
	1427  			continue
	1428  		}
	1429  		// Tan(Conj(z))	== Conj(Tan(z))
	1430  		if f := Tan(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1431  			t.Errorf("Tan(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1432  		}
	1433  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1434  			// Negating NaN is undefined with regard to the sign bit produced.
	1435  			continue
	1436  		}
	1437  		// Tan(-z)	== -Tan(z)
	1438  		if f := Tan(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1439  			t.Errorf("Tan(%g) = %g, want %g", -v.in, f, -v.want)
	1440  		}
	1441  	}
	1442  }
	1443  func TestTanh(t *testing.T) {
	1444  	for i := 0; i < len(vc); i++ {
	1445  		if f := Tanh(vc[i]); !cSoclose(tanh[i], f, 2e-15) {
	1446  			t.Errorf("Tanh(%g) = %g, want %g", vc[i], f, tanh[i])
	1447  		}
	1448  	}
	1449  	for _, v := range tanhSC {
	1450  		if f := Tanh(v.in); !cAlike(v.want, f) {
	1451  			t.Errorf("Tanh(%g) = %g, want %g", v.in, f, v.want)
	1452  		}
	1453  		if math.IsNaN(imag(v.in)) || math.IsNaN(imag(v.want)) {
	1454  			// Negating NaN is undefined with regard to the sign bit produced.
	1455  			continue
	1456  		}
	1457  		// Tanh(Conj(z))	== Conj(Tanh(z))
	1458  		if f := Tanh(Conj(v.in)); !cAlike(Conj(v.want), f) && !cAlike(v.in, Conj(v.in)) {
	1459  			t.Errorf("Tanh(%g) = %g, want %g", Conj(v.in), f, Conj(v.want))
	1460  		}
	1461  		if math.IsNaN(real(v.in)) || math.IsNaN(real(v.want)) {
	1462  			// Negating NaN is undefined with regard to the sign bit produced.
	1463  			continue
	1464  		}
	1465  		// Tanh(-z)	== -Tanh(z)
	1466  		if f := Tanh(-v.in); !cAlike(-v.want, f) && !cAlike(v.in, -v.in) {
	1467  			t.Errorf("Tanh(%g) = %g, want %g", -v.in, f, -v.want)
	1468  		}
	1469  	}
	1470  }
	1471  
	1472  // See issue 17577
	1473  func TestInfiniteLoopIntanSeries(t *testing.T) {
	1474  	want := Inf()
	1475  	if got := Cot(0); got != want {
	1476  		t.Errorf("Cot(0): got %g, want %g", got, want)
	1477  	}
	1478  }
	1479  
	1480  func BenchmarkAbs(b *testing.B) {
	1481  	for i := 0; i < b.N; i++ {
	1482  		Abs(complex(2.5, 3.5))
	1483  	}
	1484  }
	1485  func BenchmarkAcos(b *testing.B) {
	1486  	for i := 0; i < b.N; i++ {
	1487  		Acos(complex(2.5, 3.5))
	1488  	}
	1489  }
	1490  func BenchmarkAcosh(b *testing.B) {
	1491  	for i := 0; i < b.N; i++ {
	1492  		Acosh(complex(2.5, 3.5))
	1493  	}
	1494  }
	1495  func BenchmarkAsin(b *testing.B) {
	1496  	for i := 0; i < b.N; i++ {
	1497  		Asin(complex(2.5, 3.5))
	1498  	}
	1499  }
	1500  func BenchmarkAsinh(b *testing.B) {
	1501  	for i := 0; i < b.N; i++ {
	1502  		Asinh(complex(2.5, 3.5))
	1503  	}
	1504  }
	1505  func BenchmarkAtan(b *testing.B) {
	1506  	for i := 0; i < b.N; i++ {
	1507  		Atan(complex(2.5, 3.5))
	1508  	}
	1509  }
	1510  func BenchmarkAtanh(b *testing.B) {
	1511  	for i := 0; i < b.N; i++ {
	1512  		Atanh(complex(2.5, 3.5))
	1513  	}
	1514  }
	1515  func BenchmarkConj(b *testing.B) {
	1516  	for i := 0; i < b.N; i++ {
	1517  		Conj(complex(2.5, 3.5))
	1518  	}
	1519  }
	1520  func BenchmarkCos(b *testing.B) {
	1521  	for i := 0; i < b.N; i++ {
	1522  		Cos(complex(2.5, 3.5))
	1523  	}
	1524  }
	1525  func BenchmarkCosh(b *testing.B) {
	1526  	for i := 0; i < b.N; i++ {
	1527  		Cosh(complex(2.5, 3.5))
	1528  	}
	1529  }
	1530  func BenchmarkExp(b *testing.B) {
	1531  	for i := 0; i < b.N; i++ {
	1532  		Exp(complex(2.5, 3.5))
	1533  	}
	1534  }
	1535  func BenchmarkLog(b *testing.B) {
	1536  	for i := 0; i < b.N; i++ {
	1537  		Log(complex(2.5, 3.5))
	1538  	}
	1539  }
	1540  func BenchmarkLog10(b *testing.B) {
	1541  	for i := 0; i < b.N; i++ {
	1542  		Log10(complex(2.5, 3.5))
	1543  	}
	1544  }
	1545  func BenchmarkPhase(b *testing.B) {
	1546  	for i := 0; i < b.N; i++ {
	1547  		Phase(complex(2.5, 3.5))
	1548  	}
	1549  }
	1550  func BenchmarkPolar(b *testing.B) {
	1551  	for i := 0; i < b.N; i++ {
	1552  		Polar(complex(2.5, 3.5))
	1553  	}
	1554  }
	1555  func BenchmarkPow(b *testing.B) {
	1556  	for i := 0; i < b.N; i++ {
	1557  		Pow(complex(2.5, 3.5), complex(2.5, 3.5))
	1558  	}
	1559  }
	1560  func BenchmarkRect(b *testing.B) {
	1561  	for i := 0; i < b.N; i++ {
	1562  		Rect(2.5, 1.5)
	1563  	}
	1564  }
	1565  func BenchmarkSin(b *testing.B) {
	1566  	for i := 0; i < b.N; i++ {
	1567  		Sin(complex(2.5, 3.5))
	1568  	}
	1569  }
	1570  func BenchmarkSinh(b *testing.B) {
	1571  	for i := 0; i < b.N; i++ {
	1572  		Sinh(complex(2.5, 3.5))
	1573  	}
	1574  }
	1575  func BenchmarkSqrt(b *testing.B) {
	1576  	for i := 0; i < b.N; i++ {
	1577  		Sqrt(complex(2.5, 3.5))
	1578  	}
	1579  }
	1580  func BenchmarkTan(b *testing.B) {
	1581  	for i := 0; i < b.N; i++ {
	1582  		Tan(complex(2.5, 3.5))
	1583  	}
	1584  }
	1585  func BenchmarkTanh(b *testing.B) {
	1586  	for i := 0; i < b.N; i++ {
	1587  		Tanh(complex(2.5, 3.5))
	1588  	}
	1589  }
	1590  

View as plain text