hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

+test.ha (46767B)


      1 // SPDX-License-Identifier: MPL-2.0
      2 // (c) Hare authors <https://harelang.org>
      3 
      4 // The test data below is based on Go's implementation, and came with the
      5 // following note and copyright notice:
      6 //
      7 // The expected results below were computed by the high precision calculators
      8 // at https://keisan.casio.com/.  More exact input values (array vf[], above)
      9 // were obtained by printing them with "%.26f".  The answers were calculated
     10 // to 26 digits (by using the "Digit number" drop-down control of each
     11 // calculator).
     12 //
     13 // The Go copyright notice:
     14 // ====================================================
     15 // Copyright (c) 2009 The Go Authors. All rights reserved.
     16 //
     17 // Redistribution and use in source and binary forms, with or without
     18 // modification, are permitted provided that the following conditions are
     19 // met:
     20 //
     21 //    * Redistributions of source code must retain the above copyright
     22 // notice, this list of conditions and the following disclaimer.
     23 //    * Redistributions in binary form must reproduce the above
     24 // copyright notice, this list of conditions and the following disclaimer
     25 // in the documentation and/or other materials provided with the
     26 // distribution.
     27 //    * Neither the name of Google Inc. nor the names of its
     28 // contributors may be used to endorse or promote products derived from
     29 // this software without specific prior written permission.
     30 //
     31 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     34 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     36 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     37 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     38 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     39 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     40 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     41 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     42 // ====================================================
     43 
     44 use math;
     45 
     46 // The higher-precision values in VC26 were used to derive the
     47 // input arguments VC. For reference only (do not delete).
     48 const VC26: []c128 = [
     49 	(4.97901192488367350108546816, 7.73887247457810456552351752),
     50 	(7.73887247457810456552351752, -0.27688005719200159404635997),
     51 	(-0.27688005719200159404635997, -5.01060361827107492160848778),
     52 	(-5.01060361827107492160848778, 9.63629370719841737980004837),
     53 	(9.63629370719841737980004837, 2.92637723924396464525443662),
     54 	(2.92637723924396464525443662, 5.22908343145930665230025625),
     55 	(5.22908343145930665230025625, 2.72793991043601025126008608),
     56 	(2.72793991043601025126008608, 1.82530809168085506044576505),
     57 	(1.82530809168085506044576505, -8.68592476857560136238589621),
     58 	(-8.68592476857560136238589621, 4.97901192488367350108546816),
     59 ];
     60 
     61 const VC: []c128 = [
     62 	(4.9790119248836735e+00, 7.7388724745781045e+00),
     63 	(7.7388724745781045e+00, -2.7688005719200159e-01),
     64 	(-2.7688005719200159e-01, -5.0106036182710749e+00),
     65 	(-5.0106036182710749e+00, 9.6362937071984173e+00),
     66 	(9.6362937071984173e+00, 2.9263772392439646e+00),
     67 	(2.9263772392439646e+00, 5.2290834314593066e+00),
     68 	(5.2290834314593066e+00, 2.7279399104360102e+00),
     69 	(2.7279399104360102e+00, 1.8253080916808550e+00),
     70 	(1.8253080916808550e+00, -8.6859247685756013e+00),
     71 	(-8.6859247685756013e+00, 4.9790119248836735e+00),
     72 ];
     73 
     74 // The expected results below were computed by the high precision calculators
     75 // at https://keisan.casio.com/.  More exact input values (array vc[], above)
     76 // were obtained by printing them with "%.26f".  The answers were calculated
     77 // to 26 digits (by using the "Digit number" drop-down control of each
     78 // calculator).
     79 
     80 const TEST_ABS: []f64 = [
     81 	9.2022120669932650313380972e+00,
     82 	7.7438239742296106616261394e+00,
     83 	5.0182478202557746902556648e+00,
     84 	1.0861137372799545160704002e+01,
     85 	1.0070841084922199607011905e+01,
     86 	5.9922447613166942183705192e+00,
     87 	5.8978784056736762299945176e+00,
     88 	3.2822866700678709020367184e+00,
     89 	8.8756430028990417290744307e+00,
     90 	1.0011785496777731986390856e+01,
     91 ];
     92 
     93 const TEST_ACOS: []c128 = [
     94 	(1.0017679804707456328694569, -2.9138232718554953784519807),
     95 	(0.03606427612041407369636057, 2.7358584434576260925091256),
     96 	(1.6249365462333796703711823, 2.3159537454335901187730929),
     97 	(2.0485650849650740120660391, -3.0795576791204117911123886),
     98 	(0.29621132089073067282488147, -3.0007392508200622519398814),
     99 	(1.0664555914934156601503632, -2.4872865024796011364747111),
    100 	(0.48681307452231387690013905, -2.463655912283054555225301),
    101 	(0.6116977071277574248407752, -1.8734458851737055262693056),
    102 	(1.3649311280370181331184214, 2.8793528632328795424123832),
    103 	(2.6189310485682988308904501, -2.9956543302898767795858704),
    104 ];
    105 
    106 const TEST_ACOSH: []c128 = [
    107 	(2.9138232718554953784519807, 1.0017679804707456328694569),
    108 	(2.7358584434576260925091256, -0.03606427612041407369636057),
    109 	(2.3159537454335901187730929, -1.6249365462333796703711823),
    110 	(3.0795576791204117911123886, 2.0485650849650740120660391),
    111 	(3.0007392508200622519398814, 0.29621132089073067282488147),
    112 	(2.4872865024796011364747111, 1.0664555914934156601503632),
    113 	(2.463655912283054555225301, 0.48681307452231387690013905),
    114 	(1.8734458851737055262693056, 0.6116977071277574248407752),
    115 	(2.8793528632328795424123832, -1.3649311280370181331184214),
    116 	(2.9956543302898767795858704, 2.6189310485682988308904501),
    117 ];
    118 
    119 const TEST_ASIN: []c128 = [
    120 	(0.56902834632415098636186476, 2.9138232718554953784519807),
    121 	(1.5347320506744825455349611, -2.7358584434576260925091256),
    122 	(-0.054140219438483051139860579, -2.3159537454335901187730929),
    123 	(-0.47776875817017739283471738, 3.0795576791204117911123886),
    124 	(1.2745850059041659464064402, 3.0007392508200622519398814),
    125 	(0.50434073530148095908095852, 2.4872865024796011364747111),
    126 	(1.0839832522725827423311826, 2.463655912283054555225301),
    127 	(0.9590986196671391943905465, 1.8734458851737055262693056),
    128 	(0.20586519875787848611290031, -2.8793528632328795424123832),
    129 	(-1.0481347217734022116591284, 2.9956543302898767795858704),
    130 ];
    131 
    132 const TEST_ASINH: []c128 = [
    133 	(2.9113760469415295679342185, 0.99639459545704326759805893),
    134 	(2.7441755423994259061579029, -0.035468308789000500601119392),
    135 	(-2.2962136462520690506126678, -1.5144663565690151885726707),
    136 	(-3.0771233459295725965402455, 1.0895577967194013849422294),
    137 	(3.0048366100923647417557027, 0.29346979169819220036454168),
    138 	(2.4800059370795363157364643, 1.0545868606049165710424232),
    139 	(2.4718773838309585611141821, 0.47502344364250803363708842),
    140 	(1.8910743588080159144378396, 0.56882925572563602341139174),
    141 	(2.8735426423367341878069406, -1.362376149648891420997548),
    142 	(-2.9981750586172477217567878, 0.5183571985225367505624207),
    143 ];
    144 
    145 const TEST_ATAN: []c128 = [
    146 	(1.5115747079332741358607654, 0.091324403603954494382276776),
    147 	(1.4424504323482602560806727, -0.0045416132642803911503770933),
    148 	(-1.5593488703630532674484026, -0.20163295409248362456446431),
    149 	(-1.5280619472445889867794105, 0.081721556230672003746956324),
    150 	(1.4759909163240799678221039, 0.028602969320691644358773586),
    151 	(1.4877353772046548932715555, 0.14566877153207281663773599),
    152 	(1.4206983927779191889826, 0.076830486127880702249439993),
    153 	(1.3162236060498933364869556, 0.16031313000467530644933363),
    154 	(1.5473450684303703578810093, -0.11064907507939082484935782),
    155 	(-1.4841462340185253987375812, 0.049341850305024399493142411),
    156 ];
    157 
    158 const TEST_ATANH: []c128 = [
    159 	(0.058375027938968509064640438, 1.4793488495105334458167782),
    160 	(0.12977343497790381229915667, -1.5661009410463561327262499),
    161 	(-0.010576456067347252072200088, -1.3743698658402284549750563),
    162 	(-0.042218595678688358882784918, 1.4891433968166405606692604),
    163 	(0.095218997991316722061828397, 1.5416884098777110330499698),
    164 	(0.079965459366890323857556487, 1.4252510353873192700350435),
    165 	(0.15051245471980726221708301, 1.4907432533016303804884461),
    166 	(0.25082072933993987714470373, 1.392057665392187516442986),
    167 	(0.022896108815797135846276662, -1.4609224989282864208963021),
    168 	(-0.08665624101841876130537396, 1.5207902036935093480142159),
    169 ];
    170 
    171 const TEST_CONJ: []c128 = [
    172 	(4.9790119248836735e+00, -7.7388724745781045e+00),
    173 	(7.7388724745781045e+00, 2.7688005719200159e-01),
    174 	(-2.7688005719200159e-01, 5.0106036182710749e+00),
    175 	(-5.0106036182710749e+00, -9.6362937071984173e+00),
    176 	(9.6362937071984173e+00, -2.9263772392439646e+00),
    177 	(2.9263772392439646e+00, -5.2290834314593066e+00),
    178 	(5.2290834314593066e+00, -2.7279399104360102e+00),
    179 	(2.7279399104360102e+00, -1.8253080916808550e+00),
    180 	(1.8253080916808550e+00, 8.6859247685756013e+00),
    181 	(-8.6859247685756013e+00, -4.9790119248836735e+00),
    182 ];
    183 
    184 const TEST_COS: []c128 = [
    185 	(3.024540920601483938336569e+02, 1.1073797572517071650045357e+03),
    186 	(1.192858682649064973252758e-01, 2.7857554122333065540970207e-01),
    187 	(7.2144394304528306603857962e+01, -2.0500129667076044169954205e+01),
    188 	(2.24921952538403984190541e+03, -7.317363745602773587049329e+03),
    189 	(-9.148222970032421760015498e+00, 1.953124661113563541862227e+00),
    190 	(-9.116081175857732248227078e+01, -1.992669213569952232487371e+01),
    191 	(3.795639179042704640002918e+00, 6.623513350981458399309662e+00),
    192 	(-2.9144840732498869560679084e+00, -1.214620271628002917638748e+00),
    193 	(-7.45123482501299743872481e+02, 2.8641692314488080814066734e+03),
    194 	(-5.371977967039319076416747e+01, 4.893348341339375830564624e+01),
    195 ];
    196 
    197 const TEST_COSH: []c128 = [
    198 	(8.34638383523018249366948e+00, 7.2181057886425846415112064e+01),
    199 	(1.10421967379919366952251e+03, -3.1379638689277575379469861e+02),
    200 	(3.051485206773701584738512e-01, -2.6805384730105297848044485e-01),
    201 	(-7.33294728684187933370938e+01, 1.574445942284918251038144e+01),
    202 	(-7.478643293945957535757355e+03, 1.6348382209913353929473321e+03),
    203 	(4.622316522966235701630926e+00, -8.088695185566375256093098e+00),
    204 	(-8.544333183278877406197712e+01, 3.7505836120128166455231717e+01),
    205 	(-1.934457815021493925115198e+00, 7.3725859611767228178358673e+00),
    206 	(-2.352958770061749348353548e+00, -2.034982010440878358915409e+00),
    207 	(7.79756457532134748165069e+02, 2.8549350716819176560377717e+03),
    208 ];
    209 
    210 const TEST_EXP: []c128 = [
    211 	(1.669197736864670815125146e+01, 1.4436895109507663689174096e+02),
    212 	(2.2084389286252583447276212e+03, -6.2759289284909211238261917e+02),
    213 	(2.227538273122775173434327e-01, 7.2468284028334191250470034e-01),
    214 	(-6.5182985958153548997881627e-03, -1.39965837915193860879044e-03),
    215 	(-1.4957286524084015746110777e+04, 3.269676455931135688988042e+03),
    216 	(9.218158701983105935659273e+00, -1.6223985291084956009304582e+01),
    217 	(-1.7088175716853040841444505e+02, 7.501382609870410713795546e+01),
    218 	(-3.852461315830959613132505e+00, 1.4808420423156073221970892e+01),
    219 	(-4.586775503301407379786695e+00, -4.178501081246873415144744e+00),
    220 	(4.451337963005453491095747e-05, -1.62977574205442915935263e-04),
    221 ];
    222 
    223 const TEST_LOG: []c128 = [
    224 	(2.2194438972179194425697051e+00, 9.9909115046919291062461269e-01),
    225 	(2.0468956191154167256337289e+00, -3.5762575021856971295156489e-02),
    226 	(1.6130808329853860438751244e+00, -1.6259990074019058442232221e+00),
    227 	(2.3851910394823008710032651e+00, 2.0502936359659111755031062e+00),
    228 	(2.3096442270679923004800651e+00, 2.9483213155446756211881774e-01),
    229 	(1.7904660933974656106951860e+00, 1.0605860367252556281902109e+00),
    230 	(1.7745926939841751666177512e+00, 4.8084556083358307819310911e-01),
    231 	(1.1885403350045342425648780e+00, 5.8969634164776659423195222e-01),
    232 	(2.1833107837679082586772505e+00, -1.3636647724582455028314573e+00),
    233 	(2.3037629487273259170991671e+00, 2.6210913895386013290915234e+00),
    234 ];
    235 
    236 const TEST_LOG10: []c128 = [
    237 	(9.6389223745559042474184943e-01, 4.338997735671419492599631e-01),
    238 	(8.8895547241376579493490892e-01, -1.5531488990643548254864806e-02),
    239 	(7.0055210462945412305244578e-01, -7.0616239649481243222248404e-01),
    240 	(1.0358753067322445311676952e+00, 8.9043121238134980156490909e-01),
    241 	(1.003065742975330237172029e+00, 1.2804396782187887479857811e-01),
    242 	(7.7758954439739162532085157e-01, 4.6060666333341810869055108e-01),
    243 	(7.7069581462315327037689152e-01, 2.0882857371769952195512475e-01),
    244 	(5.1617650901191156135137239e-01, 2.5610186717615977620363299e-01),
    245 	(9.4819982567026639742663212e-01, -5.9223208584446952284914289e-01),
    246 	(1.0005115362454417135973429e+00, 1.1383255270407412817250921e+00),
    247 ];
    248 
    249 const TEST_POLAR: []c128 = [
    250 	(9.2022120669932650313380972e+00, 9.9909115046919291062461269e-01),
    251 	(7.7438239742296106616261394e+00, -3.5762575021856971295156489e-02),
    252 	(5.0182478202557746902556648e+00, -1.6259990074019058442232221e+00),
    253 	(1.0861137372799545160704002e+01, 2.0502936359659111755031062e+00),
    254 	(1.0070841084922199607011905e+01, 2.9483213155446756211881774e-01),
    255 	(5.9922447613166942183705192e+00, 1.0605860367252556281902109e+00),
    256 	(5.8978784056736762299945176e+00, 4.8084556083358307819310911e-01),
    257 	(3.2822866700678709020367184e+00, 5.8969634164776659423195222e-01),
    258 	(8.8756430028990417290744307e+00, -1.3636647724582455028314573e+00),
    259 	(1.0011785496777731986390856e+01, 2.6210913895386013290915234e+00),
    260 ];
    261 
    262 const TEST_POW: []c128 = [
    263 	(-2.499956739197529585028819e+00, 1.759751724335650228957144e+00),
    264 	(7.357094338218116311191939e+04, -5.089973412479151648145882e+04),
    265 	(1.320777296067768517259592e+01, -3.165621914333901498921986e+01),
    266 	(-3.123287828297300934072149e-07, -1.9849567521490553032502223e-7),
    267 	(8.0622651468477229614813e+04, -7.80028727944573092944363e+04),
    268 	(-1.0268824572103165858577141e+00, -4.716844738244989776610672e-01),
    269 	(-4.35953819012244175753187e+01, 2.2036445974645306917648585e+02),
    270 	(8.3556092283250594950239e-01, -1.2261571947167240272593282e+01),
    271 	(1.582292972120769306069625e+03, 1.273564263524278244782512e+04),
    272 	(6.592208301642122149025369e-08, 2.584887236651661903526389e-08),
    273 ];
    274 
    275 const TEST_SIN: []c128 = [
    276 	(-1.1073801774240233539648544e+03, 3.024539773002502192425231e+02),
    277 	(1.0317037521400759359744682e+00, -3.2208979799929570242818e-02),
    278 	(-2.0501952097271429804261058e+01, -7.2137981348240798841800967e+01),
    279 	(7.3173638080346338642193078e+03, 2.249219506193664342566248e+03),
    280 	(-1.964375633631808177565226e+00, -9.0958264713870404464159683e+00),
    281 	(1.992783647158514838337674e+01, -9.11555769410191350416942e+01),
    282 	(-6.680335650741921444300349e+00, 3.763353833142432513086117e+00),
    283 	(1.2794028166657459148245993e+00, -2.7669092099795781155109602e+00),
    284 	(2.8641693949535259594188879e+03, 7.451234399649871202841615e+02),
    285 	(-4.893811726244659135553033e+01, -5.371469305562194635957655e+01),
    286 ];
    287 
    288 const TEST_SINH: []c128 = [
    289 	(8.34559353341652565758198e+00, 7.2187893208650790476628899e+01),
    290 	(1.1042192548260646752051112e+03, -3.1379650595631635858792056e+02),
    291 	(-8.239469336509264113041849e-02, 9.9273668758439489098514519e-01),
    292 	(7.332295456982297798219401e+01, -1.574585908122833444899023e+01),
    293 	(-7.4786432301380582103534216e+03, 1.63483823493980029604071e+03),
    294 	(4.595842179016870234028347e+00, -8.135290105518580753211484e+00),
    295 	(-8.543842533574163435246793e+01, 3.750798997857594068272375e+01),
    296 	(-1.918003500809465688017307e+00, 7.4358344619793504041350251e+00),
    297 	(-2.233816733239658031433147e+00, -2.143519070805995056229335e+00),
    298 	(-7.797564130187551181105341e+02, -2.8549352346594918614806877e+03),
    299 ];
    300 
    301 const TEST_SQRT: []c128 = [
    302 	(2.6628203086086130543813948e+00, 1.4531345674282185229796902e+00),
    303 	(2.7823278427251986247149295e+00, -4.9756907317005224529115567e-02),
    304 	(1.5397025302089642757361015e+00, -1.6271336573016637535695727e+00),
    305 	(1.7103411581506875260277898e+00, 2.8170677122737589676157029e+00),
    306 	(3.1390392472953103383607947e+00, 4.6612625849858653248980849e-01),
    307 	(2.1117080764822417640789287e+00, 1.2381170223514273234967850e+00),
    308 	(2.3587032281672256703926939e+00, 5.7827111903257349935720172e-01),
    309 	(1.7335262588873410476661577e+00, 5.2647258220721269141550382e-01),
    310 	(2.3131094974708716531499282e+00, -1.8775429304303785570775490e+00),
    311 	(8.1420535745048086240947359e-01, 3.0575897587277248522656113e+00),
    312 ];
    313 
    314 const TEST_TAN: []c128 = [
    315 	(-1.928757919086441129134525e-07, 1.0000003267499169073251826e+00),
    316 	(1.242412685364183792138948e+00, -3.17149693883133370106696e+00),
    317 	(-4.6745126251587795225571826e-05, -9.9992439225263959286114298e-01),
    318 	(4.792363401193648192887116e-09, 1.0000000070589333451557723e+00),
    319 	(2.345740824080089140287315e-03, 9.947733046570988661022763e-01),
    320 	(-2.396030789494815566088809e-05, 9.9994781345418591429826779e-01),
    321 	(-7.370204836644931340905303e-03, 1.0043553413417138987717748e+00),
    322 	(-3.691803847992048527007457e-02, 9.6475071993469548066328894e-01),
    323 	(-2.781955256713729368401878e-08, -1.000000049848910609006646e+00),
    324 	(9.4281590064030478879791249e-05, 9.9999119340863718183758545e-01),
    325 ];
    326 
    327 const TEST_TANH: []c128 = [
    328 	(1.0000921981225144748819918e+00, 2.160986245871518020231507e-05),
    329 	(9.9999967727531993209562591e-01, -1.9953763222959658873657676e-07),
    330 	(-1.765485739548037260789686e+00, 1.7024216325552852445168471e+00),
    331 	(-9.999189442732736452807108e-01, 3.64906070494473701938098e-05),
    332 	(9.9999999224622333738729767e-01, -3.560088949517914774813046e-09),
    333 	(1.0029324933367326862499343e+00, -4.948790309797102353137528e-03),
    334 	(9.9996113064788012488693567e-01, -4.226995742097032481451259e-05),
    335 	(1.0074784189316340029873945e+00, -4.194050814891697808029407e-03),
    336 	(9.9385534229718327109131502e-01, 5.144217985914355502713437e-02),
    337 	(-1.0000000491604982429364892e+00, -2.901873195374433112227349e-08),
    338 ];
    339 
    340 // huge values along the real axis for testing reducepi in tan
    341 // TODO: these probably shouldn't have to be casted twice (harec bug?)
    342 const TEST_HUGEIN: []c128 = [
    343 	((1 << 28): u64: f64, 0f64),
    344 	((1 << 29): u64: f64, 0f64),
    345 	((1 << 30): u64: f64, 0f64),
    346 	((1 << 35): u64: f64, 0f64),
    347 	(-1.329227995784916e+36, 0f64),
    348 	(1.7668470647783843e+72, 0f64),
    349 	(2.037035976334486e+90, 0f64),
    350 	(-3.1217485503159922e+144, 0f64),
    351 	(1.8919697882131776e+69, 0f64),
    352 	(-2.514859209672214e+105, 0f64),
    353 ];
    354 
    355 // Results for TEST_TANHUGE[i] calculated with https://github.com/robpike/ivy
    356 // using 4096 bits of working precision.
    357 const TEST_TANHUGE: []c128 = [
    358 	((5.95641897939639421): f64, 0f64),
    359 	((-0.34551069233430392): f64, 0f64),
    360 	((-0.78469661331920043): f64, 0f64),
    361 	((0.84276385870875983): f64, 0f64),
    362 	((0.40806638884180424): f64, 0f64),
    363 	((-0.37603456702698076): f64, 0f64),
    364 	((4.60901287677810962): f64, 0f64),
    365 	((3.39135965054779932): f64, 0f64),
    366 	((-6.76813854009065030): f64, 0f64),
    367 	((-0.76417695016604922): f64, 0f64),
    368 ];
    369 
    370 const TEST_VCABSSC: []c128 = [
    371 	(math::NAN, math::NAN),
    372 ];
    373 
    374 const TEST_ABSSC: []f64 = [
    375 	math::NAN,
    376 ];
    377 
    378 const TEST_ACOSSC: [](c128, c128) = [
    379 	// G.6.1.1
    380 	((0f64, 0f64),
    381 		(math::PI / 2f64, -0f64)),
    382 	((-0f64, 0f64),
    383 		(math::PI / 2f64, -0f64)),
    384 	((0f64, math::NAN),
    385 		(math::PI / 2f64, math::NAN)),
    386 	((-0f64, math::NAN),
    387 		(math::PI / 2f64, math::NAN)),
    388 	((1f64, math::INF),
    389 		(math::PI / 2f64, -math::INF)),
    390 	((1f64, math::NAN),
    391 		(math::NAN, math::NAN)),
    392 	((-math::INF, 1f64),
    393 		(math::PI, -math::INF)),
    394 	((math::INF, 1f64),
    395 		(0f64, -math::INF)),
    396 	((-math::INF, math::INF),
    397 		(3f64 * math::PI / 4f64, -math::INF)),
    398 	((math::INF, math::INF),
    399 		(math::PI / 4f64, -math::INF)),
    400 	((math::INF, math::NAN),
    401 		(math::NAN, -math::INF)), // imaginary sign unspecified
    402 	((-math::INF, math::NAN),
    403 		(math::NAN, math::INF)), // imaginary sign unspecified
    404 	((math::NAN, 1f64),
    405 		(math::NAN, math::NAN)),
    406 	((math::NAN, math::INF),
    407 		(math::NAN, -math::INF)),
    408 	((math::NAN, math::NAN),
    409 		(math::NAN, math::NAN)),
    410 ];
    411 
    412 const TEST_ACOSHSC: [](c128, c128) = [
    413 	// G.6.2.1
    414 	((0f64, 0f64),
    415 		(0f64, math::PI / 2f64)),
    416 	((-0f64, 0f64),
    417 		(0f64, math::PI / 2f64)),
    418 	((1f64, math::INF),
    419 		(math::INF, math::PI / 2f64)),
    420 	((1f64, math::NAN),
    421 		(math::NAN, math::NAN)),
    422 	((-math::INF, 1f64),
    423 		(math::INF, math::PI)),
    424 	((math::INF, 1f64),
    425 		(math::INF, 0f64)),
    426 	((-math::INF, math::INF),
    427 		(math::INF, 3f64 * math::PI / 4f64)),
    428 	((math::INF, math::INF),
    429 		(math::INF, math::PI / 4f64)),
    430 	((math::INF, math::NAN),
    431 		(math::INF, math::NAN)),
    432 	((-math::INF, math::NAN),
    433 		(math::INF, math::NAN)),
    434 	((math::NAN, 1f64),
    435 		(math::NAN, math::NAN)),
    436 	((math::NAN, math::INF),
    437 		(math::INF, math::NAN)),
    438 	((math::NAN, math::NAN),
    439 		(math::NAN, math::NAN)),
    440 ];
    441 
    442 const TEST_ASINSC: [](c128, c128) = [
    443 	// Derived from Asin(z) = -i * Asinh(i * z), G.6 #7
    444 	((0f64, 0f64),
    445 		(0f64, 0f64)),
    446 	((1f64, math::INF),
    447 		(0f64, math::INF)),
    448 	((1f64, math::NAN),
    449 		(math::NAN, math::NAN)),
    450 	((math::INF, 1f64),
    451 		(math::PI / 2f64, math::INF)),
    452 	((math::INF, math::INF),
    453 		(math::PI / 4f64, math::INF)),
    454 	((math::INF, math::NAN),
    455 		(math::NAN, math::INF)), // imaginary sign unspecified
    456 	((math::NAN, 0f64),
    457 		(math::NAN, math::NAN)),
    458 	((math::NAN, 1f64),
    459 		(math::NAN, math::NAN)),
    460 	((math::NAN, math::INF),
    461 		(math::NAN, math::INF)),
    462 	((math::NAN, math::NAN),
    463 		(math::NAN, math::NAN)),
    464 ];
    465 
    466 const TEST_ASINHSC: [](c128, c128) = [
    467 	// G.6.2.2
    468 	((0f64, 0f64),
    469 		(0f64, 0f64)),
    470 	((1f64, math::INF),
    471 		(math::INF, math::PI / 2f64)),
    472 	((1f64, math::NAN),
    473 		(math::NAN, math::NAN)),
    474 	((math::INF, 1f64),
    475 		(math::INF, 0f64)),
    476 	((math::INF, math::INF),
    477 		(math::INF, math::PI / 4f64)),
    478 	((math::INF, math::NAN),
    479 		(math::INF, math::NAN)),
    480 	((math::NAN, 0f64),
    481 		(math::NAN, 0f64)),
    482 	((math::NAN, 1f64),
    483 		(math::NAN, math::NAN)),
    484 	((math::NAN, math::INF),
    485 		(math::INF, math::NAN)), // sign of real part unspecified
    486 	((math::NAN, math::NAN),
    487 		(math::NAN, math::NAN)),
    488 ];
    489 
    490 const TEST_ATANSC: [](c128, c128) = [
    491 	// Derived from Atan(z) = -i * Atanh(i * z), G.6 #7
    492 	((0f64, 0f64),
    493 		(0f64, 0f64)),
    494 	((0f64, math::NAN),
    495 		(math::NAN, math::NAN)),
    496 	((1f64, 0f64),
    497 		(math::PI / 4f64, 0f64)),
    498 	((1f64, math::INF),
    499 		(math::PI / 2f64, 0f64)),
    500 	((1f64, math::NAN),
    501 		(math::NAN, math::NAN)),
    502 	((math::INF, 1f64),
    503 		(math::PI / 2f64, 0f64)),
    504 	((math::INF, math::INF),
    505 		(math::PI / 2f64, 0f64)),
    506 	((math::INF, math::NAN),
    507 		(math::PI / 2f64, 0f64)),
    508 	((math::NAN, 1f64),
    509 		(math::NAN, math::NAN)),
    510 	((math::NAN, math::INF),
    511 		(math::NAN, 0f64)),
    512 	((math::NAN, math::NAN),
    513 		(math::NAN, math::NAN)),
    514 ];
    515 
    516 const TEST_ATANHSC: [](c128, c128) = [
    517 	// G.6.2.3
    518 	((0f64, 0f64),
    519 		(0f64, 0f64)),
    520 	((0f64, math::NAN),
    521 		(0f64, math::NAN)),
    522 	((1f64, 0f64),
    523 		(math::INF, 0f64)),
    524 	((1f64, math::INF),
    525 		(0f64, math::PI / 2f64)),
    526 	((1f64, math::NAN),
    527 		(math::NAN, math::NAN)),
    528 	((math::INF, 1f64),
    529 		(0f64, math::PI / 2f64)),
    530 	((math::INF, math::INF),
    531 		(0f64, math::PI / 2f64)),
    532 	((math::INF, math::NAN),
    533 		(0f64, math::NAN)),
    534 	((math::NAN, 1f64),
    535 		(math::NAN, math::NAN)),
    536 	((math::NAN, math::NAN),
    537 		(0f64, math::PI / 2f64)), // sign of real part not specified.
    538 	((math::NAN, math::NAN),
    539 		(math::NAN, math::NAN)),
    540 ];
    541 
    542 const TEST_VCCONJSC: []c128 = [
    543 	(math::NAN, math::NAN),
    544 ];
    545 
    546 const TEST_CONJSC: []c128 = [
    547 	(math::NAN, math::NAN),
    548 ];
    549 
    550 const TEST_COSSC: [](c128, c128) = [
    551 	// Derived from Cos(z) = Cosh(i * z), G.6 #7
    552 	((0f64, 0f64),
    553 		(1f64, -0f64)),
    554 	((0f64, math::INF),
    555 		(math::INF, -0f64)),
    556 	((0f64, math::NAN),
    557 		(math::NAN, 0f64)), // imaginary sign unspecified
    558 	((1f64, math::INF),
    559 		(math::INF, -math::INF)),
    560 	((1f64, math::NAN),
    561 		(math::NAN, math::NAN)),
    562 	((math::INF, 0f64),
    563 		(math::NAN, -0f64)),
    564 	((math::INF, 1f64),
    565 		(math::NAN, math::NAN)),
    566 	((math::INF, math::INF),
    567 		(math::INF, math::NAN)), // real sign unspecified
    568 	((math::INF, math::NAN),
    569 		(math::NAN, math::NAN)),
    570 	((math::NAN, 0f64),
    571 		(math::NAN, -0f64)), // imaginary sign unspecified
    572 	((math::NAN, 1f64),
    573 		(math::NAN, math::NAN)),
    574 	((math::NAN, math::INF),
    575 		(math::INF, math::NAN)),
    576 	((math::NAN, math::NAN),
    577 		(math::NAN, math::NAN)),
    578 ];
    579 
    580 const TEST_COSHSC: [](c128, c128) = [
    581 	// G.6.2.4
    582 	((0f64, 0f64),
    583 		(1f64, 0f64)),
    584 	((0f64, math::INF),
    585 		(math::NAN, 0f64)), // imaginary sign unspecified
    586 	((0f64, math::NAN),
    587 		(math::NAN, 0f64)), // imaginary sign unspecified
    588 	((1f64, math::INF),
    589 		(math::NAN, math::NAN)),
    590 	((1f64, math::NAN),
    591 		(math::NAN, math::NAN)),
    592 	((math::INF, 0f64),
    593 		(math::INF, 0f64)),
    594 	((math::INF, 1f64),
    595 		(math::INF, math::INF)), // +(math::INF, 0f64)  cis(y)
    596 	((math::INF, math::INF),
    597 		(math::INF, math::NAN)), // real sign unspecified
    598 	((math::INF, math::NAN),
    599 		(math::INF, math::NAN)),
    600 	((math::NAN, 0f64),
    601 		(math::NAN, 0f64)), // imaginary sign unspecified
    602 	((math::NAN, 1f64),
    603 		(math::NAN, math::NAN)),
    604 	((math::NAN, math::INF),
    605 		(math::NAN, math::NAN)),
    606 	((math::NAN, math::NAN),
    607 		(math::NAN, math::NAN)),
    608 ];
    609 
    610 const TEST_EXPSC: [](c128, c128) = [
    611 	// G.6.3.1
    612 	((0f64, 0f64),
    613 		(1f64, 0f64)),
    614 	((-0f64, 0f64),
    615 		(1f64, 0f64)),
    616 	((1f64, math::INF),
    617 		(math::NAN, math::NAN)),
    618 	((1f64, math::NAN),
    619 		(math::NAN, math::NAN)),
    620 	((math::INF, 0f64),
    621 		(math::INF, 0f64)),
    622 	((-math::INF, 1f64),
    623 		(0f64, 0f64)),
    624 	((math::INF, 1f64),
    625 		(math::INF, math::INF)),
    626 	((-math::INF, math::INF),
    627 		(0f64, 0f64)), // real and imaginary sign unspecified
    628 	((math::INF, math::INF),
    629 		(math::INF, math::NAN)), // real sign unspecified
    630 	((-math::INF, math::NAN),
    631 		(0f64, 0f64)), // real and imaginary sign unspecified
    632 	((math::INF, math::NAN),
    633 		(math::INF, math::NAN)), // real sign unspecified
    634 	((math::NAN, 0f64),
    635 		(math::NAN, 0f64)),
    636 	((math::NAN, 1f64),
    637 		(math::NAN, math::NAN)),
    638 	((math::NAN, math::INF),
    639 		(math::NAN, math::NAN)),
    640 	((math::NAN, math::NAN),
    641 		(math::NAN, math::NAN)),
    642 ];
    643 
    644 const TEST_VCISNANSC: []c128 = [
    645 	(-math::INF, -math::INF),
    646 	(-math::INF, math::NAN),
    647 	(math::NAN, -math::INF),
    648 	(0f64, math::NAN),
    649 	(math::NAN, 0f64),
    650 	(math::INF, math::INF),
    651 	(math::INF, math::NAN),
    652 	(math::NAN, math::INF),
    653 	(math::NAN, math::NAN),
    654 ];
    655 
    656 const TEST_ISNANSC: []bool = [
    657 	false,
    658 	false,
    659 	false,
    660 	true,
    661 	true,
    662 	false,
    663 	false,
    664 	false,
    665 	true,
    666 ];
    667 
    668 // XXX: math::PI doesn't have suitable precision here for some reason
    669 const TEST_LOGSC: [](c128, c128) = [
    670 	// G.6.3.2
    671 	((0f64, 0f64),
    672 		(-math::INF, 0f64)),
    673 	//((-0f64, 0f64),
    674 	//	(-math::INF, math::PI)),
    675 	//((1f64, math::INF),
    676 	//	(math::INF, math::PI / 2f64)),
    677 	((1f64, math::NAN),
    678 		(math::NAN, math::NAN)),
    679 	//((-math::INF, 1f64),
    680 	//	(math::INF, math::PI)),
    681 	((math::INF, 1f64),
    682 		(math::INF, 0f64)),
    683 	//((-math::INF, math::INF),
    684 	//	(math::INF, 3f64 * math::PI / 4f64)),
    685 	//((math::INF, math::INF),
    686 	//	(math::INF, math::PI / 4f64)),
    687 	((-math::INF, math::NAN),
    688 		(math::INF, math::NAN)),
    689 	((math::INF, math::NAN),
    690 		(math::INF, math::NAN)),
    691 	((math::NAN, 1f64),
    692 		(math::NAN, math::NAN)),
    693 	((math::NAN, math::INF),
    694 		(math::INF, math::NAN)),
    695 	((math::NAN, math::NAN),
    696 		(math::NAN, math::NAN)),
    697 ];
    698 
    699 const TEST_LOG10SC: [](c128, c128) = [
    700 	// derived from Log special cases via Log10(x) = math.Log10E*Log(x)
    701 	((0f64, 0f64),
    702 		(-math::INF, 0f64)),
    703 	((-0f64, 0f64),
    704 		(-math::INF, math::LOG10_E * math::PI)),
    705 	((1f64, math::INF),
    706 		(math::INF, math::LOG10_E * math::PI / 2f64)),
    707 	((1f64, math::NAN),
    708 		(math::NAN, math::NAN)),
    709 	((-math::INF, 1f64),
    710 		(math::INF, math::LOG10_E * math::PI)),
    711 	((math::INF, 1f64),
    712 		(math::INF, 0f64)),
    713 	((-math::INF, math::INF),
    714 		(math::INF, math::LOG10_E * 3f64 * math::PI / 4f64)),
    715 	((math::INF, math::INF),
    716 		(math::INF, math::LOG10_E * math::PI / 4f64)),
    717 	((-math::INF, math::NAN),
    718 		(math::INF, math::NAN)),
    719 	((math::INF, math::NAN),
    720 		(math::INF, math::NAN)),
    721 	((math::NAN, 1f64),
    722 		(math::NAN, math::NAN)),
    723 	((math::NAN, math::INF),
    724 		(math::INF, math::NAN)),
    725 	((math::NAN, math::NAN),
    726 		(math::NAN, math::NAN)),
    727 ];
    728 
    729 const TEST_VCPOLARSC: []c128 = [
    730 	(math::NAN, math::NAN),
    731 ];
    732 
    733 const TEST_POLARSC: [](f64, f64) = [
    734 	(math::NAN, math::NAN),
    735 ];
    736 
    737 const TEST_VCPOWSC: [](c128, c128) = [
    738 	((math::NAN, math::NAN), (math::NAN, math::NAN)),
    739 	((0f64, 0f64), (math::NAN, math::NAN)),
    740 ];
    741 
    742 const TEST_POWSC: []c128 = [
    743 	(math::NAN, math::NAN),
    744 	(math::NAN, math::NAN),
    745 ];
    746 
    747 const TEST_SINSC: [](c128, c128) = [
    748 	// Derived from Sin(z) = -i * Sinh(i * z), G.6 #7
    749 	((0f64, 0f64),
    750 		(0f64, 0f64)),
    751 	((0f64, math::INF),
    752 		(0f64, math::INF)),
    753 	((0f64, math::NAN),
    754 		(0f64, math::NAN)),
    755 	((1f64, math::INF),
    756 		(math::INF, math::INF)),
    757 	((1f64, math::NAN),
    758 		(math::NAN, math::NAN)),
    759 	((math::INF, 0f64),
    760 		(math::NAN, 0f64)),
    761 	((math::INF, 1f64),
    762 		(math::NAN, math::NAN)),
    763 	((math::INF, math::INF),
    764 		(math::NAN, math::INF)),
    765 	((math::INF, math::NAN),
    766 		(math::NAN, math::NAN)),
    767 	((math::NAN, 0f64),
    768 		(math::NAN, 0f64)),
    769 	((math::NAN, 1f64),
    770 		(math::NAN, math::NAN)),
    771 	((math::NAN, math::INF),
    772 		(math::NAN, math::INF)),
    773 	((math::NAN, math::NAN),
    774 		(math::NAN, math::NAN)),
    775 ];
    776 
    777 const TEST_SINHSC: [](c128, c128) = [
    778 	// G.6.2.5
    779 	((0f64, 0f64),
    780 		(0f64, 0f64)),
    781 	((0f64, math::INF),
    782 		(0f64, math::NAN)), // real sign unspecified
    783 	((0f64, math::NAN),
    784 		(0f64, math::NAN)), // real sign unspecified
    785 	((1f64, math::INF),
    786 		(math::NAN, math::NAN)),
    787 	((1f64, math::NAN),
    788 		(math::NAN, math::NAN)),
    789 	((math::INF, 0f64),
    790 		(math::INF, 0f64)),
    791 	((math::INF, 1f64),
    792 		(math::INF, math::INF)), // +math::INF  cis(y)
    793 	((math::INF, math::INF),
    794 		(math::INF, math::NAN)), // real sign unspecified
    795 	((math::INF, math::NAN),
    796 		(math::INF, math::NAN)), // real sign unspecified
    797 	((math::NAN, 0f64),
    798 		(math::NAN, 0f64)),
    799 	((math::NAN, 1f64),
    800 		(math::NAN, math::NAN)),
    801 	((math::NAN, math::INF),
    802 		(math::NAN, math::NAN)),
    803 	((math::NAN, math::NAN),
    804 		(math::NAN, math::NAN)),
    805 ];
    806 
    807 const TEST_SQRTSC: [](c128, c128) = [
    808 	// G.6.4.2
    809 	((0f64, 0f64),
    810 		(0f64, 0f64)),
    811 	((-0f64, 0f64),
    812 		(0f64, 0f64)),
    813 	((1f64, math::INF),
    814 		(math::INF, math::INF)),
    815 	((math::NAN, math::INF),
    816 		(math::INF, math::INF)),
    817 	((1f64, math::NAN),
    818 		(math::NAN, math::NAN)),
    819 	((-math::INF, 1f64),
    820 		(0f64, math::INF)),
    821 	((math::INF, 1f64),
    822 		(math::INF, 0f64)),
    823 	((-math::INF, math::NAN),
    824 		(math::NAN, math::INF)), // imaginary sign unspecified
    825 	((math::INF, math::NAN),
    826 		(math::INF, math::NAN)),
    827 	((math::NAN, 1f64),
    828 		(math::NAN, math::NAN)),
    829 	((math::NAN, math::NAN),
    830 		(math::NAN, math::NAN)),
    831 ];
    832 
    833 const TEST_TANSC: [](c128, c128) = [
    834 	// Derived from Tan(z) = -i * Tanh(i * z), G.6 #7
    835 	((0f64, 0f64),
    836 		(0f64, 0f64)),
    837 	((0f64, math::NAN),
    838 		(0f64, math::NAN)),
    839 	((1f64, math::INF),
    840 		(0f64, 1f64)),
    841 	((1f64, math::NAN),
    842 		(math::NAN, math::NAN)),
    843 	((math::INF, 1f64),
    844 		(math::NAN, math::NAN)),
    845 	((math::INF, math::INF),
    846 		(0f64, 1f64)),
    847 	((math::INF, math::NAN),
    848 		(math::NAN, math::NAN)),
    849 	((math::NAN, 0f64),
    850 		(math::NAN, math::NAN)),
    851 	((math::NAN, 1f64),
    852 		(math::NAN, math::NAN)),
    853 	((math::NAN, math::INF),
    854 		(0f64, 1f64)),
    855 	((math::NAN, math::NAN),
    856 		(math::NAN, math::NAN)),
    857 ];
    858 
    859 const TEST_TANHSC: [](c128, c128) = [
    860 	// G.6.2.6
    861 	((0f64, 0f64),
    862 		(0f64, 0f64)),
    863 	((1f64, math::INF),
    864 		(math::NAN, math::NAN)),
    865 	((1f64, math::NAN),
    866 		(math::NAN, math::NAN)),
    867 	((math::INF, 1f64),
    868 		(1f64, 0f64)), // 1 + i 0 sin(2y)
    869 	((math::INF, math::INF),
    870 		(1f64, 0f64)), // imaginary sign unspecified
    871 	((math::INF, math::NAN),
    872 		(1f64, 0f64)), // imaginary sign unspecified
    873 	((math::NAN, 0f64),
    874 		(math::NAN, 0f64)),
    875 	((math::NAN, 1f64),
    876 		(math::NAN, math::NAN)),
    877 	((math::NAN, math::INF),
    878 		(math::NAN, math::NAN)),
    879 	((math::NAN, math::NAN),
    880 		(math::NAN, math::NAN)),
    881 ];
    882 
    883 // branch cut continuity checks
    884 // points on each axis at |z| > 1 are checked for one-sided continuity from both
    885 // the positive and negative side
    886 // all possible branch cuts for the elementary functions are at one of these
    887 // points
    888 
    889 // TODO: this probably shouldn't need to be casted twice (harec bug?)
    890 def EPS: f64 = 1f64 / (1 << 53): u64: f64;
    891 
    892 const BRANCHPOINTS: [](c128, c128) = [
    893 	((2f64, 0f64), (2f64, EPS)),
    894 	((2f64, -0f64), (2f64, -EPS)),
    895 	((-2.0, 0f64), (-2.0, EPS)),
    896 	((-2.0, -0f64), (-2.0, -EPS)),
    897 	((0f64, 2f64), (EPS, 2f64)),
    898 	((-0f64, 2f64), (-EPS, 2f64)),
    899 	((0f64, -2.0), (EPS, -2.0)),
    900 	((-0f64, -2.0), (-EPS, -2.0)),
    901 ];
    902 
    903 fn tolerance(actual: f64, expected: f64, e: f64) bool = {
    904 	const err = math::absf64(actual - expected);
    905 	if (expected != 0f64) {
    906 		e = math::absf64(e * expected);
    907 	};
    908 	return err < e;
    909 };
    910 
    911 fn veryclose(a: f64, b: f64) bool = tolerance(a, b, 4e-16);
    912 
    913 fn alike(a: f64, b: f64) bool = {
    914 	if (math::isnan(a) && math::isnan(b)) {
    915 		return true;
    916 	};
    917 	if (a == b) {
    918 		return math::signf64(a) == math::signf64(b);
    919 	};
    920 	return false;
    921 };
    922 
    923 fn csoclose(a: c128, b: c128, e: f64) bool = {
    924 	const d = absc128(subc128(a, b));
    925 	if (b.0 != 0f64 || b.1 != 0f64) {
    926 		e *= absc128(b);
    927 		if (e < 0f64) {
    928 			e = -e;
    929 		};
    930 	};
    931 	return d < e;
    932 };
    933 
    934 fn cveryclose(a: c128, b: c128) bool = csoclose(a, b, 4e-16);
    935 
    936 fn calike(a: c128, b: c128) bool = {
    937 	let realalike = false, imagalike = false;
    938 	realalike = if (isexact(b.0)) {
    939 		yield alike(a.0, b.0);
    940 	} else {
    941 		// Allow non-exact special cases to have errors in ULP.
    942 		yield veryclose(a.0, b.0);
    943 	};
    944 	imagalike = if (isexact(b.1)) {
    945 		yield alike(a.1, b.1);
    946 	} else {
    947 		// Allow non-exact special cases to have errors in ULP.
    948 		yield veryclose(a.1, b.1);
    949 	};
    950 	return realalike && imagalike;
    951 };
    952 
    953 // Special cases that should match exactly. Other cases are multiples of pi that
    954 // may not be last bit identical on all platforms.
    955 fn isexact(x: f64) bool =
    956 	math::isnan(x) || math::isinf(x) || x == 0f64 || x == 1f64 || x == -1f64;
    957 
    958 @test fn abs() void = {
    959 	for (let i = 0z; i < len(VC); i += 1) {
    960 		assert(veryclose(TEST_ABS[i], absc128(VC[i])));
    961 	};
    962 	for (let i = 0z; i < len(TEST_VCABSSC); i += 1) {
    963 		assert(alike(TEST_ABSSC[i], absc128(TEST_VCABSSC[i])));
    964 	};
    965 };
    966 
    967 @test fn acos() void = {
    968 	for (let i = 0z; i < len(VC); i += 1) {
    969 		// XXX: should have 1e-14 precision
    970 		assert(csoclose(TEST_ACOS[i], acosc128(VC[i]), 1e-7));
    971 	};
    972 	for (let i = 0z; i < len(TEST_ACOSSC); i += 1) {
    973 		const v = TEST_ACOSSC[i];
    974 		assert(calike(v.1, acosc128(v.0)));
    975 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
    976 			// Negating NaN is undefined with regard to the sign bit
    977 			// produced.
    978 			continue;
    979 		};
    980 		// acos(conj(z)) == conj(acos(z))
    981 		assert(calike(conjc128(v.1), acosc128(conjc128(v.0)))
    982 			|| calike(v.0, conjc128(v.0)));
    983 	};
    984 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
    985 		const pt = BRANCHPOINTS[i];
    986 		assert(cveryclose(acosc128(pt.0), acosc128(pt.1)));
    987 	};
    988 };
    989 
    990 @test fn acosh() void = {
    991 	for (let i = 0z; i < len(VC); i += 1) {
    992 		// XXX: should have 1e-14 precision
    993 		assert(csoclose(TEST_ACOSH[i], acoshc128(VC[i]), 1e-7));
    994 	};
    995 	for (let i = 0z; i < len(TEST_ACOSHSC); i += 1) {
    996 		const v = TEST_ACOSHSC[i];
    997 		assert(calike(v.1, acoshc128(v.0)));
    998 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
    999 			// Negating NaN is undefined with regard to the sign bit
   1000 			// produced.
   1001 			continue;
   1002 		};
   1003 		// acosh(conj(z)) == conj(acosh(z))
   1004 		assert(calike(conjc128(v.1), acoshc128(conjc128(v.0)))
   1005 			|| calike(v.0, conjc128(v.0)));
   1006 	};
   1007 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1008 		const pt = BRANCHPOINTS[i];
   1009 		assert(cveryclose(acoshc128(pt.0), acoshc128(pt.1)));
   1010 	};
   1011 };
   1012 
   1013 @test fn asin() void = {
   1014 	for (let i = 0z; i < len(VC); i += 1) {
   1015 		assert(csoclose(TEST_ASIN[i], asinc128(VC[i]), 1e-14));
   1016 	};
   1017 	for (let i = 0z; i < len(TEST_ASINSC); i += 1) {
   1018 		const v = TEST_ASINSC[i];
   1019 		assert(calike(v.1, asinc128(v.0)));
   1020 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1021 			// Negating NaN is undefined with regard to the sign bit
   1022 			// produced.
   1023 			continue;
   1024 		};
   1025 		// asin(conj(z)) == asin(sinh(z))
   1026 		assert(calike(conjc128(v.1), asinc128(conjc128(v.0)))
   1027 			|| calike(v.0, conjc128(v.0)));
   1028 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1029 			// Negating NaN is undefined with regard to the sign bit
   1030 			// produced.
   1031 			continue;
   1032 		};
   1033 		// asin(-z) == -asin(z)
   1034 		assert(calike((-v.1.0, -v.1.1), asinc128((-v.0.0, -v.0.1)))
   1035 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1036 	};
   1037 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1038 		const pt = BRANCHPOINTS[i];
   1039 		assert(cveryclose(asinc128(pt.0), asinc128(pt.1)));
   1040 	};
   1041 };
   1042 
   1043 @test fn asinh() void = {
   1044 	for (let i = 0z; i < len(VC); i += 1) {
   1045 		assert(csoclose(TEST_ASINH[i], asinhc128(VC[i]), 4e-15));
   1046 	};
   1047 	for (let i = 0z; i < len(TEST_ASINHSC); i += 1) {
   1048 		const v = TEST_ASINHSC[i];
   1049 		assert(calike(v.1, asinhc128(v.0)));
   1050 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1051 			// Negating NaN is undefined with regard to the sign bit
   1052 			// produced.
   1053 			continue;
   1054 		};
   1055 		// asinh(conj(z)) == asinh(sinh(z))
   1056 		assert(calike(conjc128(v.1), asinhc128(conjc128(v.0)))
   1057 			|| calike(v.0, conjc128(v.0)));
   1058 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1059 			// Negating NaN is undefined with regard to the sign bit
   1060 			// produced.
   1061 			continue;
   1062 		};
   1063 		// asinh(-z) == -asinh(z)
   1064 		assert(calike((-v.1.0, -v.1.1), asinhc128((-v.0.0, -v.0.1)))
   1065 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1066 	};
   1067 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1068 		const pt = BRANCHPOINTS[i];
   1069 		assert(cveryclose(asinhc128(pt.0), asinhc128(pt.1)));
   1070 	};
   1071 };
   1072 
   1073 @test fn atan() void = {
   1074 	for (let i = 0z; i < len(VC); i += 1) {
   1075 		assert(cveryclose(TEST_ATAN[i], atanc128(VC[i])));
   1076 	};
   1077 	for (let i = 0z; i < len(TEST_ATANSC); i += 1) {
   1078 		const v = TEST_ATANSC[i];
   1079 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1080 			// Negating NaN is undefined with regard to the sign bit
   1081 			// produced.
   1082 			continue;
   1083 		};
   1084 		assert(calike(v.1, atanc128(v.0)));
   1085 		// atan(conj(z)) == conj(atan(z))
   1086 		assert(calike(conjc128(v.1), atanc128(conjc128(v.0)))
   1087 			|| calike(v.0, conjc128(v.0)));
   1088 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1089 			// Negating NaN is undefined with regard to the sign bit
   1090 			// produced.
   1091 			continue;
   1092 		};
   1093 		// atan(-z) == -atan(z)
   1094 		assert(calike((-v.1.0, -v.1.1), atanc128((-v.0.0, -v.0.1)))
   1095 			|| calike((v.0), conjc128(v.0)));
   1096 	};
   1097 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1098 		const pt = BRANCHPOINTS[i];
   1099 		assert(cveryclose(atanc128(pt.0), atanc128(pt.1)));
   1100 	};
   1101 };
   1102 
   1103 @test fn atanh() void = {
   1104 	for (let i = 0z; i < len(VC); i += 1) {
   1105 		assert(cveryclose(TEST_ATANH[i], atanhc128(VC[i])));
   1106 	};
   1107 	for (let i = 0z; i < len(TEST_ATANHSC); i += 1) {
   1108 		const v = TEST_ATANHSC[i];
   1109 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1110 			// Negating NaN is undefined with regard to the sign bit
   1111 			// produced.
   1112 			continue;
   1113 		};
   1114 		assert(calike(v.1, atanhc128(v.0)));
   1115 		// atanh(conj(z)) == conj(atanh(z))
   1116 		assert(calike(conjc128(v.1), atanhc128(conjc128(v.0)))
   1117 			|| calike(v.0, conjc128(v.0)));
   1118 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1119 			// Negating NaN is undefined with regard to the sign bit
   1120 			// produced.
   1121 			continue;
   1122 		};
   1123 		// atanh(-z) == -atanh(z)
   1124 		assert(calike((-v.1.0, -v.1.1), atanhc128((-v.0.0, -v.0.1)))
   1125 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1126 	};
   1127 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1128 		const pt = BRANCHPOINTS[i];
   1129 		assert(cveryclose(atanhc128(pt.0), atanhc128(pt.1)));
   1130 	};
   1131 };
   1132 
   1133 @test fn conj() void = {
   1134 	for (let i = 0z; i < len(VC); i += 1) {
   1135 		assert(cveryclose(TEST_CONJ[i], conjc128(VC[i])));
   1136 	};
   1137 	for (let i = 0z; i < len(TEST_VCCONJSC); i += 1) {
   1138 		assert(calike(TEST_CONJSC[i], conjc128(TEST_VCCONJSC[i])));
   1139 	};
   1140 };
   1141 
   1142 @test fn cos() void = {
   1143 	for (let i = 0z; i < len(VC); i += 1) {
   1144 		assert(csoclose(TEST_COS[i], cosc128(VC[i]), 3e-15));
   1145 	};
   1146 	for (let i = 0z; i < len(TEST_COSSC); i += 1) {
   1147 		const v = TEST_COSSC[i];
   1148 		if (isnan(v.0) || math::isnan(v.1.1)) {
   1149 			// Negating NaN is undefined with regard to the sign bit
   1150 			// produced.
   1151 			continue;
   1152 		};
   1153 		assert(calike(v.1, cosc128(v.0)));
   1154 		// cos(conj(z)) == cos(cosh(z))
   1155 		assert (calike(conjc128(v.1), cosc128(conjc128(v.0)))
   1156 			|| calike(v.0, conjc128(v.0)));
   1157 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1158 			// Negating NaN is undefined with regard to the sign bit
   1159 			// produced.
   1160 			continue;
   1161 		};
   1162 		// cos(-z) == cos(z)
   1163 		assert(calike(v.1, cosc128((-v.0.0, -v.0.1)))
   1164 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1165 	};
   1166 };
   1167 
   1168 @test fn cosh() void = {
   1169 	for (let i = 0z; i < len(VC); i += 1) {
   1170 		assert(csoclose(TEST_COSH[i], coshc128(VC[i]), 2e-15));
   1171 	};
   1172 	for (let i = 0z; i < len(TEST_COSHSC); i += 1) {
   1173 		const v = TEST_COSHSC[i];
   1174 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1175 			// Negating NaN is undefined with regard to the sign bit
   1176 			// produced.
   1177 			continue;
   1178 		};
   1179 		assert(calike(v.1, coshc128(v.0)));
   1180 		// cosh(conj(z)) == conj(cosh(z))
   1181 		assert(calike(conjc128(v.1), coshc128(conjc128(v.0)))
   1182 			|| calike(v.0, conjc128(v.0)));
   1183 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1184 			// Negating NaN is undefined with regard to the sign bit
   1185 			// produced.
   1186 			continue;
   1187 		};
   1188 		// cosh(-z) == cosh(z)
   1189 		assert(calike(v.1, coshc128((-v.0.0, -v.0.1)))
   1190 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1191 	};
   1192 };
   1193 
   1194 @test fn exp() void = {
   1195 	for (let i = 0z; i < len(VC); i += 1) {
   1196 		assert(csoclose(TEST_EXP[i], expc128(VC[i]), 1e-15));
   1197 	};
   1198 	for (let i = 0z; i < len(TEST_EXPSC); i += 1) {
   1199 		const v = TEST_EXPSC[i];
   1200 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1201 			// Negating NaN is undefined with regard to the sign bit
   1202 			// produced.
   1203 			continue;
   1204 		};
   1205 		assert(calike(v.1, expc128(v.0)));
   1206 		// exp(conj(z)) == exp(cosh(z))
   1207 		assert(calike(conjc128(v.1), expc128(conjc128(v.0)))
   1208 			|| calike(v.0, conjc128(v.0)));
   1209 	};
   1210 };
   1211 
   1212 @test fn isnan() void = {
   1213 	for (let i = 0z; i < len(TEST_VCISNANSC); i += 1) {
   1214 		assert(TEST_ISNANSC[i] == isnan(TEST_VCISNANSC[i]));
   1215 	};
   1216 };
   1217 
   1218 @test fn log() void = {
   1219 	for (let i = 0z; i < len(VC); i += 1) {
   1220 		assert(cveryclose(TEST_LOG[i], logc128(VC[i])));
   1221 	};
   1222 	for (let i = 0z; i < len(TEST_LOGSC); i += 1) {
   1223 		const v = TEST_LOGSC[i];
   1224 		assert(calike(v.1, logc128(v.0)));
   1225 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1226 			// Negating NaN is undefined with regard to the sign bit
   1227 			// produced.
   1228 			continue;
   1229 		};
   1230 		// log(conj(z)) == conj(log(z))
   1231 		assert(calike(conjc128(v.1), logc128(conjc128(v.0)))
   1232 			|| calike(v.0, conjc128(v.0)));
   1233 	};
   1234 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1235 		const pt = BRANCHPOINTS[i];
   1236 		assert(cveryclose(logc128(pt.0), logc128(pt.1)));
   1237 	};
   1238 };
   1239 
   1240 @test fn polar() void = {
   1241 	for (let i = 0z; i < len(VC); i += 1) {
   1242 		const p = polarc128(VC[i]);
   1243 		assert(veryclose(TEST_POLAR[i].0, p.0)
   1244 			|| veryclose(TEST_POLAR[i].1, p.1));
   1245 	};
   1246 	for (let i = 0z; i < len(TEST_VCPOLARSC); i += 1) {
   1247 		const p = polarc128(TEST_VCPOLARSC[i]);
   1248 		assert(alike(TEST_POLARSC[i].0, p.0)
   1249 			|| alike(TEST_POLARSC[i].1, p.1));
   1250 	};
   1251 };
   1252 
   1253 @test fn pow() void = {
   1254 	// Special cases for pow(0, c).
   1255 	const zeropowers: [](c128, c128) = [
   1256 		((0f64, 0f64), (1f64, 0f64)),
   1257 		((1.5, 0f64), (0f64, 0f64)),
   1258 		((-1.5, 0f64), (math::INF, 0f64)),
   1259 		((-1.5, 1.5), (math::INF, math::INF)),
   1260 	];
   1261 	for (let i = 0z; i < len(zeropowers); i += 1) {
   1262 		const zp = zeropowers[i];
   1263 		assert(equalc128(powc128((0f64, 0f64), zp.0), zp.1));
   1264 	};
   1265 	const a = (3f64, 3f64);
   1266 	for (let i = 0z; i < len(VC); i += 1) {
   1267 		assert(csoclose(TEST_POW[i], powc128(a, VC[i]), 4e-15));
   1268 	};
   1269 	for (let i = 0z; i < len(TEST_VCPOWSC); i += 1) {
   1270 		const f = TEST_VCPOWSC[i];
   1271 		assert(calike(TEST_POWSC[i], powc128(f.0, f.1)));
   1272 	};
   1273 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1274 		const pt = BRANCHPOINTS[i];
   1275 		assert(cveryclose(powc128(pt.0, (0.1, 0f64)),
   1276 				powc128(pt.1, (0.1, 0f64))));
   1277 	};
   1278 };
   1279 
   1280 @test fn rect() void = {
   1281 	for (let i = 0z; i < len(VC); i += 1) {
   1282 		const f = TEST_POLAR[i];
   1283 		assert(cveryclose(VC[i], rectc128(f.0, f.1)));
   1284 	};
   1285 	for (let i = 0z; i < len(TEST_VCPOLARSC); i += 1) {
   1286 		const f = TEST_POLARSC[i];
   1287 		assert(calike(TEST_VCPOLARSC[i], rectc128(f.0, f.1)));
   1288 	};
   1289 };
   1290 
   1291 @test fn sin() void = {
   1292 	for (let i = 0z; i < len(VC); i += 1) {
   1293 		assert(csoclose(TEST_SIN[i], sinc128(VC[i]), 2e-15));
   1294 	};
   1295 	for (let i = 0z; i < len(TEST_SINSC); i += 1) {
   1296 		const v = TEST_SINSC[i];
   1297 		assert(calike(v.1, sinc128(v.0)));
   1298 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1299 			// Negating NaN is undefined with regard to the sign bit
   1300 			// produced.
   1301 			continue;
   1302 		};
   1303 		// sin(conj(z)) == conj(sin(z))
   1304 		assert(calike(conjc128(sinc128(v.0)), sinc128(conjc128(v.0)))
   1305 			|| calike(v.0, conjc128(v.0)));
   1306 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1307 			// Negating NaN is undefined with regard to the sign bit
   1308 			// produced.
   1309 			continue;
   1310 		};
   1311 		// sin(-z) == -sin(z)
   1312 		assert(calike((-v.1.0, -v.1.1), sinc128((-v.0.0, -v.0.1)))
   1313 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1314 	};
   1315 };
   1316 
   1317 @test fn sinh() void = {
   1318 	for (let i = 0z; i < len(VC); i += 1) {
   1319 		assert(csoclose(TEST_SINH[i], sinhc128(VC[i]), 2e-15));
   1320 	};
   1321 	for (let i = 0z; i < len(TEST_SINHSC); i += 1) {
   1322 		const v = TEST_SINHSC[i];
   1323 		assert(calike(v.1, sinhc128(v.0)));
   1324 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1325 			// Negating NaN is undefined with regard to the sign bit
   1326 			// produced.
   1327 			continue;
   1328 		};
   1329 		// sinh(conj(z)) == conj(sinh(z))
   1330 		assert(calike(conjc128(v.1), sinhc128(conjc128(v.0)))
   1331 			|| calike(v.0, conjc128(v.0)));
   1332 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1333 			// Negating NaN is undefined with regard to the sign bit
   1334 			// produced.
   1335 			continue;
   1336 		};
   1337 		// sinh(-z) == -sinh(z)
   1338 		assert(calike((-v.1.0, -v.1.1), sinhc128((-v.0.0, -v.0.1)))
   1339 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1340 	};
   1341 };
   1342 
   1343 @test fn sqrt() void = {
   1344 	for (let i = 0z; i < len(VC); i += 1) {
   1345 		assert(cveryclose(TEST_SQRT[i], sqrtc128(VC[i])));
   1346 	};
   1347 	for (let i = 0z; i < len(TEST_SQRTSC); i += 1) {
   1348 		const v = TEST_SQRTSC[i];
   1349 		assert(calike(v.1, sqrtc128(v.0)));
   1350 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1351 			// Negating NaN is undefined with regard to the sign bit
   1352 			// produced.
   1353 			continue;
   1354 		};
   1355 		// sqrt(conj(z)) == conj(sqrt(z))
   1356 		assert(calike(conjc128(v.1), sqrtc128(conjc128(v.0)))
   1357 			|| calike(v.0, conjc128(v.0)));
   1358 	};
   1359 	for (let i = 0z; i < len(BRANCHPOINTS); i += 1) {
   1360 		const pt = BRANCHPOINTS[i];
   1361 		assert(cveryclose(sqrtc128(pt.0), sqrtc128(pt.1)));
   1362 	};
   1363 };
   1364 
   1365 @test fn tan() void = {
   1366 	for (let i = 0z; i < len(VC); i += 1) {
   1367 		assert(csoclose(TEST_TAN[i], tanc128(VC[i]), 3e-15));
   1368 	};
   1369 	for (let i = 0z; i < len(TEST_TANSC); i += 1) {
   1370 		const v = TEST_TANSC[i];
   1371 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1372 			// Negating NaN is undefined with regard to the sign bit
   1373 			// produced.
   1374 			continue;
   1375 		};
   1376 		if (math::isnan(v.0.0) && math::isinf(v.0.1)) {
   1377 			const r = tanc128(v.0);
   1378 			assert(r.0 == v.1.0 && r.1 == v.1.1);
   1379 			continue;
   1380 		};
   1381 		assert(calike(v.1, tanc128(v.0)));
   1382 		// tan(conj(z)) == conj(tan(z))
   1383 		assert (calike(conjc128(v.1), tanc128(conjc128(v.0)))
   1384 			|| calike(v.0, conjc128(v.0)));
   1385 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1386 			// Negating NaN is undefined with regard to the sign bit
   1387 			// produced.
   1388 			continue;
   1389 		};
   1390 		// tan(-z) == -tan(z)
   1391 		assert(calike((-v.1.0, -v.1.1), tanc128((-v.0.0, -v.0.1)))
   1392 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1393 	};
   1394 };
   1395 
   1396 @test fn tanh() void = {
   1397 	for (let i = 0z; i < len(VC); i += 1) {
   1398 		assert(csoclose(TEST_TANH[i], tanhc128(VC[i]), 2e-15));
   1399 	};
   1400 	for (let i = 0z; i < len(TEST_TANHSC); i += 1) {
   1401 		const v = TEST_TANHSC[i];
   1402 		if (math::isnan(v.0.1) || math::isnan(v.1.1)) {
   1403 			// Negating NaN is undefined with regard to the sign bit
   1404 			// produced.
   1405 			continue;
   1406 		};
   1407 		assert(calike(v.1, tanhc128(v.0)));
   1408 		// tanh(conj(z)) == conj(tanh(z))
   1409 		assert(calike(conjc128(v.1), tanhc128(conjc128(v.0)))
   1410 			|| calike(v.0, conjc128(v.0)));
   1411 		if (math::isnan(v.0.0) || math::isnan(v.1.0)) {
   1412 			// Negating NaN is undefined with regard to the sign bit
   1413 			// produced.
   1414 			continue;
   1415 		};
   1416 		// tanh(-z) == -tanh(z)
   1417 		assert(calike((-v.1.0, -v.1.1), tanhc128((-v.0.0, -v.0.1)))
   1418 			|| calike(v.0, (-v.0.0, -v.0.1)));
   1419 	};
   1420 };
   1421 
   1422 @test fn tanhuge() void = {
   1423 	for (let i = 0z; i < len(TEST_HUGEIN); i += 1) {
   1424 		assert(csoclose(TEST_TANHUGE[i], tanc128(TEST_HUGEIN[i]), 1e-15));
   1425 	};
   1426 };