468 lines
54 KiB
Plaintext
468 lines
54 KiB
Plaintext
# Tests of std::math: each function of real numbers against correctly rounded
|
|||
|
|
# results, worked out once with mpmath at 256 bits, to within the ulp musl
|
||
|
|
# promises; their values at the edges, exactly; the exact operations to the bit;
|
||
|
|
# classifying and the constants; and the operations of integers at the edges of
|
||
|
|
# each type. The corpus program `math_functions_agree_everywhere_1` compares their
|
||
|
|
# bits between the compilers, the machine, executables, and constants.
|
||
|
|
import std::testing;
|
||
|
|
import std::time;
|
||
|
|
import std::math;
|
||
|
|
|
||
|
|
|
||
|
|
# How many doubles lie between two, so 0 where they are the same, and 1 where they
|
||
|
|
# are neighbours. Zeros of either sign are the same, and so are NaNs.
|
||
|
|
def ulps_apart(a: f64, b: f64): u64 {
|
||
|
|
return 0 if math::is_nan(a) && math::is_nan(b);
|
||
|
|
return 0xFFFFFFFFFFFFFFFFu if math::is_nan(a) || math::is_nan(b);
|
||
|
|
val x := ordered_bits(a);
|
||
|
|
val y := ordered_bits(b);
|
||
|
|
return x > y ? x - y : y - x;
|
||
|
|
}
|
||
|
|
|
||
|
|
# A double's bits as an integer whose order is the doubles', with both zeros at
|
||
|
|
# 2^63.
|
||
|
|
def ordered_bits(x: f64): u64 {
|
||
|
|
val bits := math::bits_of(x);
|
||
|
|
return (bits >> 63) != 0 ? 0x8000000000000000u - (bits & 0x7FFFFFFFFFFFFFFFu) : 0x8000000000000000u + bits;
|
||
|
|
}
|
||
|
|
|
||
|
|
# The most ulps a function of one double is from the results wanted.
|
||
|
|
def worst_one(inputs: span<u64>, wanted: span<u64>, f: def(f64): f64): u64 {
|
||
|
|
var most: u64 = 0;
|
||
|
|
for i in 0..inputs.length {
|
||
|
|
val apart := ulps_apart(f(math::real_of_bits(inputs[i])), math::real_of_bits(wanted[i]));
|
||
|
|
most = apart > most ? apart : most;
|
||
|
|
}
|
||
|
|
return most;
|
||
|
|
}
|
||
|
|
|
||
|
|
# The most ulps a function of two doubles is from the results wanted.
|
||
|
|
def worst_two(firsts: span<u64>, seconds: span<u64>, wanted: span<u64>, f: def(f64, f64): f64): u64 {
|
||
|
|
var most: u64 = 0;
|
||
|
|
for i in 0..firsts.length {
|
||
|
|
val apart := ulps_apart(f(math::real_of_bits(firsts[i]), math::real_of_bits(seconds[i])), math::real_of_bits(wanted[i]));
|
||
|
|
most = apart > most ? apart : most;
|
||
|
|
}
|
||
|
|
return most;
|
||
|
|
}
|
||
|
|
|
||
|
|
# The tables: inputs, as bits, and the correctly rounded result of each.
|
||
|
|
|
||
|
|
const sqrt_input: u64[28] = [0x19762ca3153dd30, 0x1a0765c69b0a886, 0x7e2c3ddd571da857, 0x7e2e400a609f99ae, 0x7e29254528313218, 0x4022aedd9bdd036a, 0x7e335bced374a9e7, 0x7e24a9b6199c8f2a, 0x3fe32e74abfa1aa2, 0x7e30d899f8344704, 0x19591b1721a7c3a, 0x199039ae1460bc2, 0x7e1e0e84648e3f54, 0x7e3210d67eadfb57, 0x181365973e69d56, 0x401c187fbbada0c0, 0x3ff1bfa1dfa2e507, 0x3fbeabd851241140, 0x1607a1195c230da, 0x7e22b9ef953901ad, 0x4021f16fa99614d0, 0x7e012eb870fd5a5a, 0x4020909f0d04a550, 0x1a04e1139618a50, 0x3fe0000000000000, 0x4000000000000000, 0x12688b70e62b, 0x7fefffffffffffff];
|
||
|
|
const sqrt_want: u64[28] = [0x20c357f553aa4901, 0x20c6f3b7712213f5, 0x5f0e0fe94b9aa308, 0x5f0f1cdf232018ac, 0x5f0c5dd375807ff8, 0x4008737ddb8d51b3, 0x5f119970a117f5a9, 0x5f09b6cdf44a612d, 0x3fe8c66eca4cb657, 0x5f106ae7d5a3306b, 0x20c293b7d8bdf204, 0x20c40171199af29f, 0x5f05edfa371a3b40, 0x5f110064ef263c3d, 0x20b7780ffd2f207d, 0x400533c02236f8b6, 0x3ff0da039e8166a4, 0x3fd62714ad2d7e42, 0x20a6f64cf8725125, 0x5f087abb3e2505bb, 0x4007f648797e94ef, 0x5ef772dbf2114cf6, 0x400705fe8eff463c, 0x20c6d78f62fdb6a0, 0x3fe6a09e667f3bcd, 0x3ff6a09e667f3bcd, 0x1fc1297872d9cbae, 0x5fefffffffffffff];
|
||
|
|
const cbrt_input: u64[32] = [0xfe1a496afffbe734, 0x7e3079721f273116, 0xc0562241c339c587, 0x405663f3285a5804, 0xc058e7cf918a7838, 0x7e31bc68ad9d9b28, 0x7dfe3f34c7928d70, 0x7e26d43d8cf3dba8, 0xfe3793d9210b53da, 0xc0535bc7dd3eaf3a, 0x7e35a334d4243cd0, 0xc04ca27c64e03b81, 0xc04c8ee32192d3c6, 0x7e2231c52c223974, 0xfe24bb3c50b5075b, 0xc051949f33a66a6c, 0xc049edb7e753c9dd, 0xc03b2da21a331938, 0x7de5ce2bc3592ac0, 0xc051f4e3649b22c0, 0xc0221d725d81a9b0, 0xfdf71ac40c7e0ca0, 0x7e1fa419b1fd02f4, 0xc0172df88893ca00, 0xc03b000000000000, 0x12688b70e62b, 0xc020000000000000, 0x4008000000000000, 0x403b000000000000, 0x800012688b70e62b, 0x4020000000000000, 0xc008000000000000];
|
||
|
|
const cbrt_want: u64[32] = [0xd4a7c96b0ccde6d7, 0x54b028169aaf728e, 0xc011d3ed640f0017, 0x4011e57f48934270, 0xc0128afdc86171b7, 0x54b08f148008deff, 0x549f6795785a64f3, 0x54ac97dba370906e, 0xd4b235132279082f, 0xc0110c986d6aca31, 0x54b1b18ed14690fb, 0xc00ed62103a791d3, 0xc00ecf16649952b7, 0x54aa829b2eeee0de, 0xd4abb06b6b91bb25, 0xc01082a95c3463bd, 0xc00dd52d86383fed, 0xc0080d7dc62dab21, 0x5496599a369b3685, 0xc010a095afa826f1, 0xc000ad1115606031, 0xd49cb52f37ca4981, 0x54a94d96f1ae10c1, 0xbffcbd2149547445, 0xc008000000000000, 0x2a7a9d1b0b5d7427, 0xc000000000000000, 0x3ff7137449123ef6, 0x4008000000000000, 0xaa7a9d1b0b5d7427, 0x4000000000000000, 0xbff7137449123ef6];
|
||
|
|
const exp_input: u64[36] = [0x3fe2a761e26391ea, 0xbfe1d56bb14c0390, 0xbfeb1c91119835dc, 0xbf90118aa05f9340, 0x3fe2f21bc4b606aa, 0x4085a5e59181d33c, 0xbf8a19c76dccd400, 0xbf96a0e40ce2f600, 0x3fcc8abf477f7820, 0x3fede0b173792792, 0xbfd3ce4979bd4a8c, 0x407c6911c529eae8, 0x3fc51a7a55614288, 0x40832f156d982282, 0xc066b7853cb16458, 0x407ec1f8ed4bd608, 0x3fef86e8ba37463c, 0xbfe0eb63e208c6d8, 0xbfced4d99da81748, 0x3fbac68b0790d1e0, 0x3f909cb00d2c8100, 0x4078b14489aa8fc0, 0x407fc956f44bd840, 0x3fe96a5556eaf6aa, 0x3ff0000000000000, 0xbff0000000000000, 0x40862e3d70a3d70a, 0xc087490a3d70a3d7, 0x3bc79ca10c924223, 0x3fe0000000000000, 0xbff0000000000000, 0x3ff0000000000000, 0xc0862e3d70a3d70a, 0x4087490a3d70a3d7, 0xbbc79ca10c924223, 0xbfe0000000000000];
|
||
|
|
const exp_want: u64[36] = [0x3ffca918ea6446ae, 0x3fe253fc2ad2f948, 0x3fdb6e2400f22163, 0x3fef807485221754, 0x3ffcec54d24bfb5e, 0x7e653c26e5d5cc2e, 0x3fef9842796e2d3c, 0x3fef4cf52ba5fed6, 0x3ff3ff2f303deed4, 0x400459cd9b688cc3, 0x3fe77b9bb62c8609, 0x68ebe218843d1b40, 0x3ff2de2b3a849234, 0x77491924d8f38047, 0x2f8c16199afd839a, 0x6c4fa48f0ea2ab95, 0x40056d5b4900602c, 0x3fe2dbf5a28726a2, 0x3fe926727e998597, 0x3ff1c39d6f2b9048, 0x3ff042fd7af2ec86, 0x638f88c7de96fc0c, 0x6dca8f8d1b7f2a99, 0x4001b3af619baf6a, 0x4005bf0a8b145769, 0x3fd78b56362cef38, 0x7fefe9ce5c4c52b4, 0x1, 0x3ff0000000000000, 0x3ffa61298e1e069c, 0x3fd78b56362cef38, 0x4005bf0a8b145769, 0x402c8225ec681, 0x7ff0000000000000, 0x3ff0000000000000, 0x3fe368b2fc6f960a];
|
||
|
|
const exp2_input: u64[32] = [0x3fdc02b9b38c843c, 0xbfbad8fd09b53330, 0xc07c7abfc06f488e, 0xbfd04b5f4d024ec8, 0x408b4f303737b2f4, 0xc0724f5becc62308, 0x4074853fcddb63bc, 0xbfe0e4ad433ff4e6, 0x4079d4f1efd878a0, 0xbfe4e5e7d09d21be, 0xbfe5d55552f46fec, 0xbfe324b5017894ca, 0xbfe899680fac0246, 0xc063b327d8f35b50, 0xc065b7408ea11a58, 0x407eb39936eaebb0, 0x4056bcfc4811b5c0, 0xc0898e8a955b89ba, 0xbfd11eaaa028bcb4, 0xc08c1080da70417f, 0xbfe9be1e4b118a7e, 0xbfbb15b431093dc0, 0x3fe94fceca2d5e20, 0xc0864cda65ff4c3f, 0x3fe0000000000000, 0xc090ca0000000000, 0x408fffeb851eb852, 0x3bc79ca10c924223, 0xbfe0000000000000, 0x4090ca0000000000, 0xc08fffeb851eb852, 0xbbc79ca10c924223];
|
||
|
|
const exp2_want: u64[32] = [0x3ff5abab9b4b23d7, 0x3fedc1a14e3f4570, 0x2374164172307055, 0x3fead2b1470abf36, 0x768dd3b0a4a22c1e, 0x2da07352601890a8, 0x547415de8032f9df, 0x3fe6319d6e7d6a41, 0x59c3d28f01046adc, 0x3fe45985b2c93385, 0x3fe3f10bdc0d0aa7, 0x3fe5235610681097, 0x3fe2c82cbdd3265b, 0x361521e603387a55, 0x35135689a0aa43a4, 0x5ea2b2ffd42cebf6, 0x459ef8dc96da3c99, 0xcd227ccd4859531, 0x3fea95958503b95d, 0x7cea26bc18f6088, 0x3fe2528d79dc8c68, 0x3fedbcbd6b2fcf89, 0x3ffbaf2947f55c39, 0x135503e30f8019de, 0x3ff6a09e667f3bcd, 0x1, 0x7fefc769e9b9c396, 0x3ff0000000000000, 0x3fe6a09e667f3bcd, 0x7ff0000000000000, 0x4071f5b1013bc, 0x3ff0000000000000];
|
||
|
|
const expm1_input: u64[32] = [0xbee2bb464c2721f5, 0xbee0a138caeb723a, 0x407903eb846c505f, 0x3ece3c1abbf651a4, 0x3feb005253c90646, 0x3feb2c3f2aa6e68c, 0x3febd028a8772c1c, 0xbee2c98d5a67c74e, 0x3fed191644bc3c42, 0x40860a430be62110, 0xbed85cb22b2517f9, 0xbecc616e9e90f196, 0x3fd4457106e01c0c, 0xbebc20cab4d21448, 0xbee17eec2cfc43d8, 0x40846e67241d99c7, 0xc0332f2a83893b46, 0xbeadc62af19c31e0, 0xbfe6ebd73602fbf6, 0xbec6165ad5ef68ac, 0x404af2642a6f2510, 0x3edf48cac69b991e, 0xbfe85a2e9b40a3d0, 0x4046b1396baa6e8e, 0x3ddb7cdfd9d7bdbb, 0xbfd3333333333333, 0x3fd6666666666666, 0x4043733333333333, 0xbddb7cdfd9d7bdbb, 0x3fd3333333333333, 0xbfd6666666666666, 0xc043733333333333];
|
||
|
|
const expm1_want: u64[32] = [0xbee2bb40d0aca9de, 0xbee0a13478b9aa74, 0x640593ea82f2fe33, 0x3ece3c1e4e1afa37, 0x3ff533dbf44db955, 0x3ff56710189b4d8c, 0x3ff62893f2c80003, 0xbee2c987d68e9ba9, 0x3ff7b8ca5707aa52, 0x7f86c075060e5fc2, 0xbed85cad881fbd53, 0xbecc616b791be56a, 0x3fd7d963b96ba3ee, 0xbebc20c92939dd57, 0xbee17ee76493f5bf, 0x7ae2d3128ca42ed9, 0xbfeffffffd7f8787, 0xbeadc62a13fc6ddf, 0xbfe05db37a70c1e1, 0xbec61658ee15f439, 0x44caf2e28dd6f381, 0x3edf48d26c0875a3, 0xbfe10cbd12d41f4c, 0x44064165068824ed, 0x3ddb7cdfd9dda4e3, 0xbfd0966f2c7907f6, 0x3fdad200b20177b2, 0x437165d9783d23ba, 0xbddb7cdfd9d1d693, 0x3fd6641632306a56, 0xbfd2e663ed31c11e, 0xbff0000000000000];
|
||
|
|
const log_input: u64[28] = [0x3fee593c1e8b83c5, 0x3fd6ebcec463a324, 0x7e35d7f74ec798b6, 0x3ffd7a6815867d9d, 0x3fedff172fcb382e, 0x3fef40751db9a4a0, 0x3feff7b496544c7b, 0x3ff1c22d4f6a2c98, 0x3ff24e785ab0c88f, 0x3fef26e7ab8df669, 0x7e1872c22943e870, 0x3ff235fe49f57853, 0x7e20df4808422ed6, 0x3feec48fb5038240, 0x3ff0cff8c79e8916, 0x7e2d686f3f1d8a2a, 0x7e37800aae9e6e97, 0x7e03fdd713e9021f, 0x7e357acb5fab5603, 0x3fe47d722a3f8294, 0x3fa28cafdce1da00, 0x3fef55381ded663b, 0x3feda273650b86e0, 0x3fedfb9d42dd8930, 0x12688b70e62b, 0x4000000000000000, 0x3fe0000000000000, 0x3ff0000000000001];
|
||
|
|
const log_want: u64[28] = [0xbfab21080bdaeee9, 0xbff06ddf2c5db0bd, 0x4085957cbf5e8a1d, 0x3fe38dcefc3d48e6, 0xbfb08d5b8028a13d, 0xbf983a279bb42609, 0xbf5098fa1d249535, 0x3fbab1d1210af7f3, 0x3fc13cd38f6e0f8b, 0xbf9b80c077f3551e, 0x40858b4c5362f9e6, 0x3fc0913c262c1046, 0x40858de04d7eae04, 0xbfa41ac1a977bae4, 0x3fa95ba72ce12e10, 0x408592522ae76dec, 0x40859612741528cf, 0x408584249a0771db, 0x4085955a56404678, 0xbfdc87f38422138b, 0xc00a8b03f4bf49c1, 0xbf9592c132fcf815, 0xbfb3a8c8fe73d8d0, 0xbfb0ab082688f24c, 0xc0864e69394d9508, 0x3fe62e42fefa39ef, 0xbfe62e42fefa39ef, 0x3cafffffffffffff];
|
||
|
|
const log2_input: u64[28] = [0x3fed3a7e27dd396c, 0x3fb2cac0a5121040, 0x3ffcf389bb0f6e6b, 0x7e24a77f189ef7cf, 0x7dfa48b4b983383f, 0x3ffd274c274fd39c, 0x7e2b102c8be7aaa6, 0x3fef28bdb744f632, 0x7e3597de31084f77, 0x3fcd630e3e6fdb88, 0x7e34ff83d4bec06a, 0x3ffb6ccd5fdccf46, 0x7e34528dc86f27e5, 0x3fee3b4dcda5c699, 0x3fd980cf35d3e4bc, 0x7e176127e733a89d, 0x7e317ffaba61a9d7, 0x7e1e00552003648c, 0x3ff00fcd061ae308, 0x7e34f958093567bf, 0x3ff668ae153dd246, 0x3ffd97b658c430a9, 0x7e14200d0fbe2374, 0x7e33d3e7852de5fa, 0x12688b70e62b, 0x4008000000000000, 0x3fe8000000000000, 0x4090000000000000];
|
||
|
|
const log2_want: u64[28] = [0xbfc0baaba3ee085b, 0xc00e24c49c769745, 0x3feb60b993c8e010, 0x408f1af26b7ced37, 0x408f05ba99a45d05, 0x3febb2f97a0b06e7, 0x408f1e10ea54a697, 0xbfa3ab4bfc9e4bd4, 0x408f2375c6751e8f, 0xc000fbb1660dd2d9, 0x408f232333122306, 0x3fe8e0a0473c4468, 0x408f22c29199e6d1, 0xbfb4febb5ee39e42, 0xbff53d035d83246f, 0x408f14609c4ae7bc, 0x408f2108c20eb437, 0x408f1741709ae672, 0x3f76c08236309362, 0x408f231fce3dc714, 0x3fdf1aa1233f2de6, 0x3fec63a99641168d, 0x408f12a5bf3d24ab, 0x408f2279c07d4157, 0xc0901730dabca5f6, 0x3ff95c01a39fbd68, 0xbfda8ff971810a5e, 0x4024000000000000];
|
||
|
|
const log10_input: u64[28] = [0x7e304fdd4d8033ba, 0x3fdbab88bb8e7cbc, 0x3feaf8e2cc7e724e, 0x3fe93005fb60fac8, 0x3ffebc23b4891417, 0x3fefd582b93987b0, 0x3ff0ced94f6f2e51, 0x3fd58940d7b5e974, 0x3ffb2eefcd0d0293, 0x3fff5f04637b7c5e, 0x3feed681f23df704, 0x3feb77b736becb64, 0x3ff026108789c42f, 0x3fee84f23482563e, 0x3fab0ec10424c660, 0x3fee1522bb91d042, 0x3fed0891c5042d24, 0x7e197a3c8db5dac4, 0x3f8434b906aee680, 0x3fed3a62e76575f2, 0x7e02d2a6a86a3273, 0x3ff09e5a471e7154, 0x3ffa579337aaeb72, 0x3fef897960d0f71a, 0x12688b70e62b, 0x408f400000000000, 0x3f50624dd2f1a9fc, 0x401c000000000000];
|
||
|
|
const log10_want: u64[28] = [0x4072bd59233eaa13, 0xbfd74e8f79f7ef7d, 0xbfb300f6600c3d2f, 0xbfba9d576d8ba68f, 0x3fd2250ff152c0c0, 0xbf62803c06fe7413, 0x3f95e8def18bcff3, 0xbfde45d41913c608, 0x3fcd76a272a970f0, 0x3fd2b6daf85a06bf, 0xbf907350f14e0ab9, 0xbfb0fae9f20e19cc, 0x3f707473c0a0fe92, 0xbf9511a492580b52, 0xbff46e82c0a256ed, 0xbf9b7aadb4f3397b, 0xbfa5a1eb4bafb815, 0x4072b6d04a7cdbe3, 0xc0000bfb75babd9a, 0xbfa425a8b0b14dcd, 0x4072afe4c43faba7, 0x3f90de706f7002a1, 0x3fcbb7435fb26565, 0xbf79ecf24fd5df27, 0xc073600000000000, 0x4008000000000000, 0xc008000000000000, 0x3feb0b0b0b78cc3f];
|
||
|
|
const log1p_input: u64[32] = [0xbfe012eb889778e4, 0x3edd90f6f01cbade, 0xbeca6e45bba51c04, 0x7e2d3ef24ed35e9d, 0x7e306ef1de844059, 0x7e30dc6aa8982501, 0xbec4295344aebdb6, 0x3ed334a2c4e39de4, 0x3fe2f6404601e8c8, 0x7e2911acb5d81c71, 0x7de27feacc393cfe, 0x3ee3c8bfb3dddfb3, 0x3fc4d730865806b0, 0x3fe0fd870a5fccf8, 0x3ed1f37f9dfaba4e, 0x3feb60b33104cb04, 0x3e9b0991e7a5a960, 0xbfc39d9a06c8ba38, 0x7e337cbc66f5c335, 0x7e10a4f0b8282f28, 0x3ea7cea4fb27bb80, 0xbed41f07addc2e2f, 0x7df9c30b3c83c1db, 0xbfe8c0cc919fa83a, 0xbfe0000000000000, 0x1a56e1fc2f8f359, 0xbfefffeb074a771d, 0x430c6bf526340000, 0x3fe0000000000000, 0x81a56e1fc2f8f359, 0x3fefffeb074a771d, 0xc30c6bf526340000];
|
||
|
|
const log1p_want: u64[32] = [0xbfe65430815aa4b9, 0x3edd90f01bcac30c, 0xbeca6e48763b264d, 0x40859246d9a4a889, 0x40859335e6050686, 0x4085936a8265ada7, 0xbec42954db2a96e7, 0x3ed3349fe32e39f7, 0x3fddc82cf4e2c206, 0x4085910b3e23f9ca, 0x4085786ea24700cb, 0x3ee3c8b99638e1d5, 0x3fc34ee84efe26b8, 0x3fdb41bcadf5361a, 0x3ed1f37d197e15d0, 0x3fe3c828928a01dc, 0x3e9b09918c4506ad, 0xbfc54ad6a2e054d4, 0x40859492f8bf4b61, 0x40858838e2dca87c, 0x3ea7cea46d75a321, 0xbed41f0ad796c3f4, 0x408580a061581a86, 0xbff7c33c740a7916, 0xbfe62e42fefa39ef, 0x1a56e1fc2f8f359, 0xc027069e2aa2b45d, 0x404144f69ff9ffc4, 0x3fd9f323ecbf984c, 0x81a56e1fc2f8f359, 0x3fe62e38829dbdaf, 0x7ff8000000000000];
|
||
|
|
const sin_input: u64[34] = [0xc020cf7a412e1653, 0x412e39923eceae38, 0x40224f42cc739d8a, 0xbff01ef720ff01e8, 0xfe0536ba9d73a920, 0xc0156a54cc833400, 0x4127623092b3e292, 0x7de3505e1b5849a0, 0xfe2b7fd929eb3dba, 0xc01344ee53074aae, 0xc013f01ada231428, 0x40178ee18c1fd660, 0xfe0deb0e217fe400, 0xc0131c1a89639a64, 0xc0fa81adcf1f2278, 0x40141f3181bcdc4e, 0xfe2af91b219f8eea, 0xc12a02a79fc018fd, 0xc0fb69e2ead01cd8, 0xc11e09560cd6ef0b, 0xfe2d2903ee5827db, 0x7e2efa73d98cee78, 0x3fd15474ee3e4920, 0x40e6839cc9234e30, 0x3e112e0be826d695, 0x3ff921fb54442d18, 0x400921fb54442d18, 0x4480f0cf064dd592, 0x7506ac5b262ca1ff, 0xbe112e0be826d695, 0xbff921fb54442d18, 0xc00921fb54442d18, 0xc480f0cf064dd592, 0xf506ac5b262ca1ff];
|
||
|
|
const sin_want: u64[34] = [0xbfeb4288259dde08, 0xbfa84cad826a703b, 0x3fd111ad553492a0, 0xbfeb0e982438e168, 0xbfe8c1ab57bf0ca9, 0x3fe9a3aacd61a15d, 0xbfea9306f9dd92fe, 0x3f91be2b9a1ef1db, 0x3fe15caeeb47e43d, 0x3fefd2f23cbe6769, 0x3feed2a16cd193e0, 0xbfd88c52873a90f6, 0x3fc45dfa7281ef81, 0x3fefeeabb1d07caf, 0x3fe1112bf02324c8, 0xbfee651648ff082b, 0xbfef4d75e016b2ae, 0xbf80f4750cf69e98, 0x3fe2a724cd2beb7d, 0x3fd986f4a9fe88a3, 0x3fd38e1cabf5251b, 0xbfdb6f63e8261677, 0x3fd11e70bdf2a616, 0x3fd031d8fac2ea71, 0x3e112e0be826d695, 0x3ff0000000000000, 0x3ca1a62633145c07, 0xbfeb453ab76bf397, 0x3ff0000000000000, 0xbe112e0be826d695, 0xbff0000000000000, 0xbca1a62633145c07, 0x3feb453ab76bf397, 0xbff0000000000000];
|
||
|
|
const cos_input: u64[34] = [0xfe35056bd7c58ca6, 0x400f2e3232d3fe04, 0xfdc789f6cf048600, 0x7e1ee07a639e2c48, 0x400f784aeb333d98, 0xc11562872f383fc8, 0x3ffff3e9c61cc3e8, 0xc00c9383f5201ea8, 0xc12853fb304abd00, 0x4018c93f87885e80, 0xc11ce84ea66bb17c, 0x40f1d4b85cc972d0, 0x7e20d7c3103652e4, 0xc118e741c01e2f38, 0x4112e53950b527c0, 0xfe359b74b6e24aff, 0xc00b750638a1e536, 0x4125a19017dbf250, 0xc1025400cf58a9d8, 0x7e356be9158d1f9c, 0xc0018176e968307e, 0xc01f6ab4e58fcfa9, 0x7e3454e1e581e562, 0x4120d4b6a6e81f40, 0x3e112e0be826d695, 0x3ff921fb54442d18, 0x400921fb54442d18, 0x4480f0cf064dd592, 0x7506ac5b262ca1ff, 0xbe112e0be826d695, 0xbff921fb54442d18, 0xc00921fb54442d18, 0xc480f0cf064dd592, 0xf506ac5b262ca1ff];
|
||
|
|
const cos_want: u64[34] = [0xbfe87cc8eff1206b, 0xbfe74895f427b5f7, 0x3fedeff11c2cc6aa, 0x3fe7330b3814d551, 0xbfe679694679c3dd, 0x3feb8c352651d9b0, 0xbfda7628787aa1da, 0xbfed14c1a85a99eb, 0xbfe8d1c4dac892a0, 0x3fefe1434670afd5, 0x3feb10b8ef1a44df, 0x3fef34811cad7f82, 0x3fef6d02bcfd13bc, 0x3fdfda2888d2b792, 0xbfede765efabe64e, 0xbfc55549fa258c18, 0xbfeea8a60f37f789, 0xbfd56bf0333c01e5, 0x3fdcbc8690d57034, 0x3fc32913b1b8a8e4, 0xbfe2869d440f89e0, 0xbf2d5e1d4785fad0, 0xbfefc621bd279b0f, 0xbfe8b29a4a3f7716, 0x3ff0000000000000, 0x3c91a62633145c07, 0xbff0000000000000, 0x3fe0be2cef01c8f4, 0xbc214ae72e6ba22f, 0x3ff0000000000000, 0x3c91a62633145c07, 0xbff0000000000000, 0x3fe0be2cef01c8f4, 0xbc214ae72e6ba22f];
|
||
|
|
const tan_input: u64[32] = [0xc011b17d2974759d, 0x4011d04e4cec18ee, 0xbfe3fed03c7f1650, 0x7e05f5fa6856f9e8, 0xc0160e0157fd04c2, 0x7e35367e8e6fab1c, 0x7e213a5bbf8d8f2c, 0x412e1da30272f2ac, 0x401e57728c353c20, 0x7e27d037b8c50168, 0xc021e7f5b65fd551, 0xc011f62b6db04dcc, 0x412901907342979a, 0xfdfe1ce0fe502250, 0x4017809366de479a, 0xc021ea0f169cbc80, 0x40217a44b6f69ab8, 0xc120f430d571388b, 0xc010523525904ba3, 0x401b8ceecaeaae4c, 0x4121a920efc8f8be, 0xc01a4d35e4dcc09a, 0x3fe0027d8b036f30, 0x412a1bda21a580ae, 0x3e112e0be826d695, 0x3ff921fb54442d18, 0x3fe921fb54442d18, 0x4480f0cf064dd592, 0xbe112e0be826d695, 0xbff921fb54442d18, 0xbfe921fb54442d18, 0xc480f0cf064dd592];
|
||
|
|
const tan_want: u64[32] = [0xc00ae6987421cb53, 0x400e32d039a250e2, 0xbfe71498b3ae65ff, 0x3ff02105962a2732, 0x3feeffb61e6283c8, 0x3fdc683bb9c610f4, 0x3ff4ccbe90fe60e6, 0xbfddf8abb3e7f8ac, 0x400d10f10aeb9365, 0xbff6b6eda437d333, 0x3fe0531dc4932ef6, 0xc011b8d1f3119fb1, 0x3fe619e3acedee0b, 0xbfdbef67a9c68f01, 0xbfdba2be783a5104, 0x3fe028e0af0752c7, 0xbfea31de5ffbc0e4, 0xbff35a99f71537b1, 0xbff5d8f72dac998b, 0x3fe61a0f9adac430, 0x400021693b797f24, 0xbfd340c110fbc692, 0x3fe17e8b4fe9a17e, 0xc0020db4527cf42b, 0x3e112e0be826d695, 0x434d02967c31cdb5, 0x3fefffffffffffff, 0xbffa0f79c1b6b257, 0xbe112e0be826d695, 0xc34d02967c31cdb5, 0xbfefffffffffffff, 0x3ffa0f79c1b6b257];
|
||
|
|
const asin_input: u64[32] = [0xbfef80847da75dba, 0xbeb6ce41a3c9adb0, 0xbfe5c1bf9407157a, 0x3eb222155f989298, 0xbee0e25e42848624, 0x3feb9b7ac1b51466, 0xbfed191e9173ff2a, 0x3eb889be2c11de20, 0x3fe7f54fcfecf900, 0xbfb47b075d5ab560, 0x3eda162badac1a6e, 0x3fca9418c153dfb8, 0xbfe9999738cd9efa, 0x3e9c8991cfcf6e00, 0xbe63bed2b229ea00, 0xbfe349d44543ffce, 0x3fe30eaca40b5fb8, 0xbfd6e1183d16541c, 0xbfe09a2c871e9514, 0x3ec5727b37600e3c, 0xbfc8147cd89aa0b8, 0x3fcfda63ff9ef250, 0x3fe5ac978f26da8c, 0x3fa77235fbd76820, 0x3fe0000000000000, 0xbfefffeb074a771d, 0x1a56e1fc2f8f359, 0x3fefffffffffffff, 0xbfe0000000000000, 0x3fefffeb074a771d, 0x81a56e1fc2f8f359, 0xbfefffffffffffff];
|
||
|
|
const asin_want: u64[32] = [0xbff64e6de8a0af39, 0xbeb6ce41a3c9b569, 0xbfe7ec908974d462, 0x3eb222155f98967a, 0xbee0e25e42854eb2, 0x3ff0a679091720b3, 0xbff244264d1d4a51, 0x3eb889be2c11e7be, 0x3feb132ef89f9be3, 0xbfb480a3482686e8, 0x3eda162badacd359, 0x3fcac5f70953fd25, 0xbfedac630eb8c2b9, 0x3e9c8991cfcf6ef2, 0xbe63bed2b229ea01, 0xbfe4b3e2640c8f34, 0x3fe469ffb48c2e47, 0xbfd7659f29041ed3, 0xbfe1747dca360330, 0x3ec5727b376027ed, 0xbfc83970cbbcc8d6, 0x3fd0187eaf8cd517, 0x3fe7cfc2c3d6fb03, 0x3fa7744f86b4780c, 0x3fe0c152382d7366, 0xbff90fa9f3695aa5, 0x1a56e1fc2f8f359, 0x3ff921fb50442d18, 0xbfe0c152382d7366, 0x3ff90fa9f3695aa5, 0x81a56e1fc2f8f359, 0xbff921fb50442d18];
|
||
|
|
const acos_input: u64[32] = [0x3fe3836e12275004, 0x3fdff8c2f39008ec, 0xbee40184dff9c880, 0xbe93a093be822560, 0x3fda574d6d3db8e0, 0x3fe45faf02c42358, 0x3ed9ad4c2ff196ae, 0xbec16ff4d9b976e8, 0x3ed1a5e676c9ee44, 0x3e9017d594512d40, 0x3fe0bf8abd0dc094, 0xbecf29876d61a3e8, 0xbfbe09051f892470, 0xbfa52251e0c050e0, 0x3fce84a6f86dfd40, 0x3ee381d3df4543bd, 0xbfb391b8e77a96f0, 0xbebcdaf886a5f0e0, 0xbfcb62dae58da668, 0x3fedf0d9fb56bc42, 0x3feea41b035c341a, 0x3fd32d968eefe3f8, 0xbfd9c49ed3e4eeb0, 0x3fe0af3221c83ace, 0x3fe0000000000000, 0xbfefffeb074a771d, 0x1a56e1fc2f8f359, 0x3fefffffffffffff, 0xbfe0000000000000, 0x3fefffeb074a771d, 0x81a56e1fc2f8f359, 0xbfefffffffffffff];
|
||
|
|
const acos_want: u64[32] = [0x3fed47a5d2145e4c, 0x3ff0c36911dbe748, 0x3ff9220555069d16, 0x3ff921fba2c67c12, 0x3ff25884b14ff1b9, 0x3fec2df70b8a7699, 0x3ff921f4e8f1211c, 0x3ff921fd8242c84f, 0x3ff921f6eaca8f66, 0x3ff921fb13e4d6c7, 0x3ff051d847f4d7df, 0x3ff921ff39751ac5, 0x3ffb03a7a77d8bac, 0x3ff9cb1a30344907, 0x3ff547e71ec7badf, 0x3ff921f1935a3d75, 0x3ffa5b6527ce5330, 0x3ff921fd21f3b583, 0x3ffc952a944c9166, 0x3fd715abc644aeaa, 0x3fd2b7f4a9b99d7c, 0x3ff4436e67ecc61e, 0x3fffc34c019b186d, 0x3ff05b6dfdc604c8, 0x3ff0c152382d7366, 0x400918d2a3d6c3df, 0x3ff921fb54442d18, 0x3e50000000000000, 0x4000c152382d7366, 0x3f725160dad27316, 0x3ff921fb54442d18, 0x400921fb52442d18];
|
||
|
|
const atan_input: u64[34] = [0x43f462a83c40ecc0, 0xc40957ae3e2d548f, 0xc4139aa895558498, 0x440e61fa44a5936c, 0x3ffcddbc3e6ef390, 0x40177a8448e8281a, 0xbfe232c88bdb5ff0, 0xc40bd4b05784e3b8, 0xc40ed553eb227969, 0x4005355c0e1d60dc, 0x43d70418d3b1c5d0, 0x4404e92f54b06a28, 0x4019025070057b68, 0xc016ea080b9e7bea, 0xc4018365508adf9c, 0xc415ad3c60487c57, 0xbff9630f323bed40, 0xc3fa9506a77cc7a2, 0xbffcd22bc63b0380, 0xc02140d8255154e1, 0x43f12e00550a6ed8, 0x401c31fbf029438c, 0xc4028de2c2af3330, 0x3ffa28dcafac9b20, 0x3fdc000000000000, 0x3fe6000000000000, 0x3ff3000000000000, 0x4003800000000000, 0x7e37e43c8800759c, 0xbfdc000000000000, 0xbfe6000000000000, 0xbff3000000000000, 0xc003800000000000, 0xfe37e43c8800759c];
|
||
|
|
const atan_want: u64[34] = [0x3ff921fb54442d18, 0xbff921fb54442d18, 0xbff921fb54442d18, 0x3ff921fb54442d18, 0x3ff108e4b9ea19f7, 0x3ff66eca63920054, 0xbfe08bf83445d727, 0xbff921fb54442d18, 0xbff921fb54442d18, 0x3ff35c8851144af9, 0x3ff921fb54442d18, 0x3ff921fb54442d18, 0x3ff6985c5c04e48d, 0xbff65e1958772c44, 0xbff921fb54442d18, 0xbff921fb54442d18, 0xbff0228be0330fdb, 0xbff921fb54442d18, 0xbff1062c1d217c46, 0xbff74948a2967570, 0x3ff921fb54442d18, 0x3ff6e0be35bb7a08, 0xbff921fb54442d18, 0x3ff05993bb1cd361, 0x3fda64eec3cc23fd, 0x3fe345f01cce37bb, 0x3febde70ed439fe7, 0x3ff2e75728833a54, 0x3ff921fb54442d18, 0xbfda64eec3cc23fd, 0xbfe345f01cce37bb, 0xbfebde70ed439fe7, 0xbff2e75728833a54, 0xbff921fb54442d18];
|
||
|
|
const sinh_input: u64[32] = [0xc07b76ac59452e56, 0x404f9da3d6bb6b50, 0xc07097618388052a, 0x402171dd1527c120, 0xc01c748cad31399d, 0x4067d631a21dd964, 0xbfdce5155b8fb900, 0x40434d911873acb0, 0xc013a37233c8635e, 0xc0619c0c59f3b834, 0x40804a4c671e4096, 0x40778f9170dd11e0, 0x4069e366e4c27af0, 0x404b53a890e78750, 0x40737e2d433edf00, 0xc015a46b5abfd4ca, 0xc075052482999153, 0x3ff4f687e3919380, 0x3fae3e6d194a1600, 0x408027f9eacd64e2, 0x4084f96467ffee74, 0xc07a9607dfa745f5, 0xc072e2a5d9bbde67, 0xc0024455a1fea960, 0x3ddb7cdfd9d7bdbb, 0x4036000000000000, 0x40862e3d70a3d70a, 0x408633c28f5c28f6, 0xbddb7cdfd9d7bdbb, 0xc036000000000000, 0xc0862e3d70a3d70a, 0xc08633c28f5c28f6];
|
||
|
|
const sinh_want: u64[32] = [0xe77eccb0a98b3fbb, 0x4592af891759e2f7, 0xd7cf8d9a0032037c, 0x40a7fad5121ba5f4, 0xc08333513a57d7a8, 0x51114ca69c1d8ac7, 0xbfdde2f4b4fa908d, 0x4359eea2a55ec7b5, 0xc050f28e528339ba, 0xcc92eb842dd90079, 0x6ee0a9d4e9387961, 0x61dcfb69964fd71a, 0x528bb06976e6bb00, 0x44cccf1f654922e3, 0x5bff0c73e10bbcdb, 0xc05bf81e247a15dc, 0xde327f48f9f3bc1b, 0x3ffb7f2f4e85b871, 0x3fae42edf4f54b89, 0x6e7d392f74955538, 0x7c63b0cf1db935d9, 0xe639cc3cc9bbdf35, 0xdb1e8a62ed1eef76, 0xc0136a58ba61a367, 0x3ddb7cdfd9d7bdbb, 0x41dab5adb9c43600, 0x7fdfe9ce5c4c52b4, 0x7fefd02278f9df9b, 0xbddb7cdfd9d7bdbb, 0xc1dab5adb9c43600, 0xffdfe9ce5c4c52b4, 0xffefd02278f9df9b];
|
||
|
|
const cosh_input: u64[32] = [0x401619d93d148c1e, 0x40217ae72047f590, 0x402122bea2edd528, 0x40827884b533d4ec, 0xc0200b161d698261, 0x400f85f6d4badfcc, 0x4080e35a58d5f84e, 0xc07e02c5e5d32ceb, 0xc06d359a20ac8d46, 0xc0018b29bc24e970, 0x401ce38b2d6b0054, 0x407a32ae123960f0, 0x4075d234ee97ebe8, 0xc0006c6817f03916, 0x3feffd4a61eefa70, 0xc0239c0dd7a4da77, 0xc06f5769565caa06, 0x40701a541df6d094, 0x4083645859fc442a, 0x407372608b939602, 0xc01ca6f1ef1c064a, 0x407344aa8b29b2a6, 0xbfe74f27a66381b0, 0xc06afaf9589d481a, 0x3ddb7cdfd9d7bdbb, 0x4036000000000000, 0x40862e3d70a3d70a, 0x408633c28f5c28f6, 0xbddb7cdfd9d7bdbb, 0xc036000000000000, 0xc0862e3d70a3d70a, 0xc08633c28f5c28f6];
|
||
|
|
const cosh_want: u64[32] = [0x405f5e70866f0424, 0x40a8682caf332c4a, 0x40a48bdd8e8ca286, 0x752a782b147b95d6, 0x4097cc6b1a219cf8, 0x4039bac86511a7af, 0x709947ea2375da35, 0x6b2aca6b0a676b28, 0x54f168ff7d8c22eb, 0x4012257b03f698cd, 0x4085660e3c87e6df, 0x65aa8de2cf6a270b, 0x5f59fbe55cdc469e, 0x400fad2202938355, 0x3ff8aeddd6942024, 0x40c1b218f886fbc9, 0x567a863f259e5832, 0x571a1028599f7ff1, 0x77d3163f6a241099, 0x5bedb3c5f53cf052, 0x40842b47950077f1, 0x5bab4cbbc1a06fe3, 0x3ff46f8a9c46807e, 0x53550c01b4f7a058, 0x3ff0000000000000, 0x41dab5adb9c43600, 0x7fdfe9ce5c4c52b4, 0x7fefd02278f9df9b, 0x3ff0000000000000, 0x41dab5adb9c43600, 0x7fdfe9ce5c4c52b4, 0x7fefd02278f9df9b];
|
||
|
|
const tanh_input: u64[32] = [0x3fc6bbc67666dab8, 0x3fe510c96b1b29e6, 0xc0352b032094926c, 0xbfdfad16b81819b4, 0xc03879270597f7e3, 0x3fdc8fe5e4c27034, 0xbfcb2cf5fb236558, 0x3fd300fc79e3a7f8, 0x4030b65deeaddd74, 0x4037087c354bacfc, 0xbff2c95fbf3eb500, 0x403392af91c89ea4, 0x4034a8c8bbf5a30e, 0x4026641175c99290, 0xc0223215d105d05c, 0x3fdad08247df5068, 0x3ff7dffce7b6db70, 0x3fd55225d15611b8, 0x403848baedeab3f2, 0xc034762492e818b0, 0x3fe6159c7d9fec90, 0xbfe952e57524d6da, 0x4034e74ce18ef41e, 0x4025d2f975cfb514, 0x3ddb7cdfd9d7bdbb, 0x3fe199999999999a, 0x4036000000000000, 0x1a56e1fc2f8f359, 0xbddb7cdfd9d7bdbb, 0xbfe199999999999a, 0xc036000000000000, 0x81a56e1fc2f8f359];
|
||
|
|
const tanh_want: u64[32] = [0x3fc67f585f131683, 0x3fe278abe539daeb, 0xbff0000000000000, 0xbfdd51f8484f7a63, 0xbff0000000000000, 0x3fdace40dec68c5e, 0xbfcac64857b016d2, 0x3fd276df58e747d6, 0x3fefffffffffffc9, 0x3ff0000000000000, 0xbfea6b5598247a9a, 0x3ff0000000000000, 0x3ff0000000000000, 0x3fefffffffcc21cd, 0xbfeffffff28d8517, 0x3fd9592c78c31ad4, 0x3feceb529d293f41, 0x3fd490cee6647128, 0x3ff0000000000000, 0xbff0000000000000, 0x3fe323652f1757ea, 0xbfe51808fd255f5b, 0x3ff0000000000000, 0x3fefffffffa49441, 0x3ddb7cdfd9d7bdbb, 0x3fe00442f6419203, 0x3ff0000000000000, 0x1a56e1fc2f8f359, 0xbddb7cdfd9d7bdbb, 0xbfe00442f6419203, 0xbff0000000000000, 0x81a56e1fc2f8f359];
|
||
|
|
const asinh_input: u64[32] = [0x7e3259b3521622d0, 0x3ff4867bfbd18ca0, 0xc022e271fc78a1a9, 0xfe1656016de3b9d4, 0x7e2b4088567d2758, 0xc01d7ca8d0427320, 0x7e372fbe5b219ff2, 0xfe264258bc3472c7, 0xc01095f4f173fa76, 0xc01b9a048495202f, 0xfe348bbf296e93db, 0xfe36aeb9cb43e3b0, 0xc01c1755f91faa38, 0xfe3495d0b8d9d898, 0x7e2b925e2a222044, 0xc010cb82490b239d, 0x7e0c8ed38557c0e8, 0x4020a47fe49e9276, 0xfe29be45f2cbd96f, 0xc0227a519867b6e0, 0x4016ca8daceb9fa4, 0xc00d6cbd74124ae2, 0xfe320ae957e0a6a0, 0x7e1932748854c628, 0x3ddb7cdfd9d7bdbb, 0x4000000000000000, 0x41b0000000000000, 0x7e37e43c8800759c, 0xbddb7cdfd9d7bdbb, 0xc000000000000000, 0xc1b0000000000000, 0xfe37e43c8800759c];
|
||
|
|
const asinh_want: u64[32] = [0x408599a36ed78d62, 0x3ff11648e6d2f0b7, 0xc00787729a670c5c, 0xc085901ed48c29a9, 0x40859741ceef23ba, 0xc005901df8b3b095, 0x40859b827fdc5fd4, 0xc08595a357a587b8, 0xc001097c2d652df9, 0xc0050a1c8441f8b9, 0xc0859a8ae07f0bba, 0xc0859b557e65ab26, 0xc0052dbfca624c4f, 0xc0859a8ecb2ae7a4, 0x40859759b1151c89, 0xc0012272703cc952, 0x40858c8a885a9456, 0x40068641da78558c, 0xc08596cd28f2e304, 0xc0075b1bbcd4c09d, 0x400386d7ec3029f0, 0xc0001bb584bf803d, 0xc0859980cb014371, 0x40859115ad4fcef8, 0x3ddb7cdfd9d7bdbb, 0x3ff719218313d087, 0x403419ecb712c481, 0x40859bbfd8b83e44, 0xbddb7cdfd9d7bdbb, 0xbff719218313d087, 0xc03419ecb712c481, 0xc0859bbfd8b83e44];
|
||
|
|
const acosh_input: u64[28] = [0x4018eaf6364160e4, 0x7e2ce51d67be92d5, 0x7e36ce5902048f85, 0x7e0712fd95b6dfc4, 0x4014ce68d317a976, 0x3ff953d714ef5034, 0x400721b94efa8bfc, 0x7e3407aa025c282d, 0x7e28ea1bc1c33385, 0x401d594ce823f562, 0x7e1b0724cc33b87f, 0x7e2350360675a007, 0x4005da04ca61e3c8, 0x7de137e2a40a0053, 0x7df1ee7c36fffbf6, 0x7e0e5fb8c94537de, 0x4020e849b15e7e1a, 0x7e16b952f6852649, 0x400bdafc1c891e3b, 0x7e269cb5bd7fa19d, 0x401916730414060d, 0x4023905ed0d50f62, 0x7e02ff45ac4a50d3, 0x401daf4def03d4a7, 0x3ff0000000000000, 0x3ff0000000000001, 0x4000000000000000, 0x41b0000000000000];
|
||
|
|
const acosh_want: u64[28] = [0x400420a0337b2cdb, 0x408597b9b1b6667f, 0x40859b609dc9c4f8, 0x40858ad5dbc48d95, 0x4002a9722a365f88, 0x3ff08808856f59a4, 0x3ffb93bf054d48a0, 0x40859a56ca75209a, 0x4085968a248bc149, 0x40057391060d3e81, 0x408591a55390bb0f, 0x408594809c6c7696, 0x3ffa9a384072fbe1, 0x40857d6731727ef7, 0x40858345e3667b3e, 0x40858d08cab4c792, 0x400698078e302bca, 0x4085904218f2537b, 0x3ffeb60a6808c522, 0x408595c39079444a, 0x40042eb8ccad6591, 0x4007c4bdf4d3300a, 0x40858947ad135862, 0x40058b17f8ace53d, 0x0, 0x3e56a09e667f3bcc, 0x3ff5124271980435, 0x403419ecb712c481];
|
||
|
|
const atanh_input: u64[32] = [0x3ecdc3e7da4c9860, 0xbeb095a2b85de978, 0xbfa93b51e74fbf60, 0xbfddb06b778c0d58, 0x3edbb06ecba01856, 0x3fe87f3abede6d4c, 0xbfd6149306eeac94, 0xbfaf06db46f3c680, 0xbfe56a54f21bbdd8, 0xbea12e5a8ff82d20, 0x3fec9c55ed70af76, 0xbee353ee6b48ea83, 0x3fdeba8c0dffc2d4, 0x3ee4968ad42807ed, 0xbfe007339d1a4ec6, 0xbfe7154f899ab438, 0xbecd90a4778c00b2, 0xbfd2be34c877f7d0, 0xbed54aa6aca9c057, 0x3fa25784befb9dc0, 0xbfd5fb1a4472e980, 0x3ee22a4ceec6f9e7, 0x3fd2c617e98606dc, 0xbfdf4198b9b4b8dc, 0x3fe0000000000000, 0xbfefffeb074a771d, 0x1a56e1fc2f8f359, 0x3fefffffffffffff, 0xbfe0000000000000, 0x3fefffeb074a771d, 0x81a56e1fc2f8f359, 0xbfefffffffffffff];
|
||
|
|
const atanh_want: u64[32] = [0x3ecdc3e7da4d21ba, 0xbeb095a2b85def69, 0xbfa9408e7bc6d33d, 0xbfe01283ee8ca401, 0x3edbb06ecba1d29c, 0x3ff026ac301291c3, 0xbfd7065dc080c85c, 0xbfaf1099cca55a8e, 0xbfe9e62bfec120b9, 0xbea12e5a8ff82ec7, 0x3ff7121ca7f87727, 0xbee353ee6b4b4433, 0x3fe0bdbbf7022cec, 0x3ee4968ad42adf25, 0xbfe19d8612ca3c10, 0xbfed22762cce9385, 0xbecd90a4778c874b, 0xbfd34ee764eacd64, 0xbed54aa6acaa896d, 0x3fa259875cef3bca, 0xbfd6e9787616793f, 0x3ee22a4ceec8ed69, 0x3fd3578848a49d76, 0xbfe115f23ef34d00, 0x3fe193ea7aad030b, 0xc0186981b2cc9038, 0x1a56e1fc2f8f359, 0x4032b708872320e2, 0xbfe193ea7aad030b, 0x40186981b2cc9038, 0x81a56e1fc2f8f359, 0xc032b708872320e2];
|
||
|
|
const pow_input0: u64[30] = [0xbfe2a656ffd4d080, 0x3ffa560ccc86a930, 0x4009f20a8d67e78f, 0x4014c174ec7c47b8, 0xc01677de9f6d18b2, 0x400e3fce0e4b96b8, 0x4006e073130b2568, 0xc0093c141013408c, 0x40037a9af0d72626, 0x400ea9979f241438, 0xbfccc6c11783cb00, 0x3fe843ae24e227cc, 0x3ff9b02ee2f220d8, 0xc015d1bc798a818b, 0xc00c45539e16a7d4, 0x3ff54701be6d1398, 0xc023f993708089e8, 0x40217533df711da4, 0x4011350fad67f9d0, 0x3ff704dde29218f0, 0x401584ab3a33b3c6, 0x3fea56899c491be4, 0xc01e20465b456674, 0x3ff47e8445ed8e00, 0x4000000000000000, 0xc020000000000000, 0x4024000000000000, 0x3fe0000000000000, 0x3ff0000000000001, 0x4000000000000000];
|
||
|
|
const pow_input1: u64[30] = [0xc02076aad345c469, 0x402143cc6604f74c, 0x3ffea3d3f63080a6, 0xc003ba546ef2f190, 0xc007eeb2195b82be, 0xc01e76f52f72ed6a, 0x40066c461e7b2410, 0x4017136731949cb6, 0x3ff9852ee58df260, 0x40217142a744993a, 0x40236bb4c5eb7ade, 0x400a914152e42b3a, 0x40002c4775ef4e47, 0xc0132275c0ae994c, 0xc0235a25b383ee9d, 0x40045c2099864d66, 0x3ff8744298b53a90, 0x401cb36c932ce4ac, 0xc023cbf5edc333ab, 0x4004d772b6115674, 0xc01280c43bb1b08d, 0x3fe658d5821bef48, 0x402026eed992c7e0, 0x3fa3b49ac9234800, 0x3fe0000000000000, 0x4008000000000000, 0xc072c00000000000, 0x4090c80000000000, 0x4341c37937e08000, 0x408ffc0000000000];
|
||
|
|
const pow_want: u64[30] = [0x7ff8000000000000, 0x405276326f75e0ca, 0x402308ce47e71621, 0x3f91a85bd3b98d89, 0x7ff8000000000000, 0x3f04e81913af28fc, 0x4033025359d84ca3, 0x7ff8000000000000, 0x401089d4f1e229ae, 0x40fdf714ac75e33e, 0x7ff8000000000000, 0x3fd987f193684bd6, 0x4004d563ec8655a7, 0x7ff8000000000000, 0x7ff8000000000000, 0x400086854549ed98, 0x7ff8000000000000, 0x415587d085553750, 0x3ea1eea59a61d8da, 0x4004a2ce2c386bf3, 0x3f3b4ddfbf917e4e, 0x3febee7340eead34, 0x7ff8000000000000, 0x3ff02736384e8f84, 0x3ff6a09e667f3bcd, 0xc080000000000000, 0x1a56e1fc2f8f359, 0x1, 0x40226c41b1a61c92, 0x7fe6a09e667f3bcd];
|
||
|
|
const atan2_input0: u64[28] = [0x7e12fac12c3023dc, 0x402066c51763b46e, 0xfe1aeaff713dd048, 0xfe35f40137c1777b, 0x7e37c699954f21b8, 0xbffee5dc532a5220, 0x3fe66dd4c35bb520, 0xfe101e3697006630, 0xbff6c12526786be0, 0x40202cac3345fc0e, 0x7e3572bf73b376bc, 0x401c2dccc52f4c18, 0xbff5460a95782768, 0x7e339dfe1d74bd56, 0xc01894e73e5dab26, 0x7e25d06c64e127a0, 0xfe16dab3427beab8, 0xfe16cf566632cc0c, 0xfe1f70d8add477fc, 0x7e35d09c66bef6e0, 0xc01097b3eec03f42, 0x40179a578a31b5e8, 0x4004e5111bf28b84, 0xfe2dd8f503fadf4d, 0x3ff0000000000000, 0x81a56e1fc2f8f359, 0x7e37e43c8800759c, 0xbfe0000000000000];
|
||
|
|
const atan2_input1: u64[28] = [0xfe34d348a1b0e402, 0x40101f514bb1c6ae, 0xfe31f8104e42048e, 0xfe31cd503ccf400e, 0xfe12a7408afc4ca0, 0xc0164177985ddac4, 0xc02084f7e8715c64, 0xfe0f66d046596e28, 0xc0084e13f4843888, 0x4007639713989148, 0xfe2144f9b97f5eb9, 0x4012fde6ee024b84, 0xc02144fba5b59a16, 0xfe2d2ae4483344b8, 0x3fd160c5347e9500, 0xfe2967234c05e9cd, 0xfe28e737b63209a1, 0xfe230370d8254ccf, 0x7e255745b9e4df60, 0x7e2b8bff841ddc2c, 0xc018f7143d49d5d4, 0xc0200a1a31fa2060, 0x400d418616f8e868, 0x7e372663b3bb4d04, 0xbff0000000000000, 0x7e37e43c8800759c, 0x1a56e1fc2f8f359, 0xbfe0000000000000];
|
||
|
|
const atan2_want: u64[28] = [0x400757319e80bb0d, 0x3ff1d2db78a361fc, 0xc006441b79c03e3c, 0xc00204694349fb87, 0x3ffc3b4ac4c9fba6, 0xc00675ced0ae0168, 0x4008749b4d7b45b4, 0xc002bea25b518617, 0xc005a15af63c4421, 0x3ff3951c5c854468, 0x3fff41a6fa41d074, 0x3fef49c08a32b105, 0xc007e915277013d6, 0x4001ae3a72943dd1, 0xbff86d1ebe7ede07, 0x400374d8831e4cdb, 0xc005b0eec5ed1d89, 0xc004cf72e5b8a4f5, 0xbfe4510678822ad4, 0x3ff01f3a3f933a56, 0xc00470a48fe4d380, 0x40040edceccde305, 0x3fe3d8a77e3aaba8, 0xbfe252cfb1a4809c, 0x4002d97c7f3321d2, 0x8000000000000000, 0x3ff921fb54442d18, 0xc002d97c7f3321d2];
|
||
|
|
const hypot_input0: u64[28] = [0x7dff2e74572ea210, 0xfe34518048622af1, 0x7e0f7f70b21aca68, 0xfe0c6b837af83760, 0xfe0e424fc07e0470, 0xfe1990d806f08480, 0x40182e72b1ac4690, 0xc008ed63eeb2b5cc, 0xc011a2ff04062d7c, 0xbffc12d73fbb5b58, 0x400b919e1f0844a0, 0xfe375df7f35781a1, 0xbfe4ec8c86b23910, 0xc02311b0a813d9b4, 0x401057c683f28c4a, 0x3ff05d5e3ef66250, 0xc0070f4e9f157948, 0xfdc444b7b399ea00, 0xc0229d41c2e3bfb1, 0x3fdb4439e91e7d80, 0xfe20a28a45ab9763, 0x40229915040c11c0, 0xfe02db65dffd76a0, 0x400af3462eecde74, 0x4008000000000000, 0x12688b70e62b, 0x7fe1ccf385ebc8a0, 0x1];
|
||
|
|
const hypot_input1: u64[28] = [0x7e1b05ed3a754820, 0x7df8d566f9c280b0, 0xfe0e7deff14bd8c8, 0x7e2442d38df7b788, 0x7e289785814a5118, 0xfe32202682688999, 0x401df58ff648bb40, 0x3fbbd1c7c656a080, 0xc005b04da94987c8, 0x4007b0b8151dcf70, 0x400e7f4762ae2070, 0xfe33ae3010998c59, 0x4005e24001339e40, 0x4023e255154fea08, 0x4016c5a9374c2376, 0xc01231315aa20985, 0xc00eb50f907ddd3c, 0xfe33211a8d63cb64, 0x4006caf76392a744, 0xbfcacc76a33d3a40, 0x7e309c3435cc9188, 0x400d3798a71acd88, 0xfe21df5647b48404, 0xc01bca2ab9d4c22e, 0x4010000000000000, 0x12688b70e62b, 0x7fe1ccf385ebc8a0, 0x0];
|
||
|
|
const hypot_want: u64[28] = [0x7e1c2003418b8714, 0x7e3460a7b7d35f7f, 0x7e15eb692a86225c, 0x7e25787f66f3aa20, 0x7e29baa5c0a4bf1e, 0x7e33382e5e3cdee5, 0x402340141ce22c00, 0x4008f14523bcf776, 0x4014b43555bf117f, 0x400b895c5d3ab55e, 0x40148e36b1e7faf8, 0x7e3e8cf39ae5b102, 0x40068013dcab6f11, 0x402b8cd3f14081af, 0x401c07940d908b75, 0x4012a581d1332ea6, 0x4013336ad8e75056, 0x7e33214580983498, 0x402377886c1b9938, 0x3fde6188e8cf7760, 0x7e329386b4c2c5c8, 0x4023fb1e09001f75, 0x7e227bd3ecd7618b, 0x401ee269babbcd13, 0x4014000000000000, 0x1a088b6bf34f, 0x7fe92c80954c51f5, 0x1];
|
||
|
|
|
||
|
|
@test def sqrt_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(sqrt_input[:], sqrt_want[:], math::sqrt::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def cbrt_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(cbrt_input[:], cbrt_want[:], math::cbrt::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def exp_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(exp_input[:], exp_want[:], math::exp::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def exp2_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(exp2_input[:], exp2_want[:], math::exp2::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def expm1_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(expm1_input[:], expm1_want[:], math::expm1::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def log_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(log_input[:], log_want[:], math::log::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def log2_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(log2_input[:], log2_want[:], math::log2::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def log10_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(log10_input[:], log10_want[:], math::log10::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def log1p_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(log1p_input[:], log1p_want[:], math::log1p::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def sin_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(sin_input[:], sin_want[:], math::sin::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def cos_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(cos_input[:], cos_want[:], math::cos::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def tan_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(tan_input[:], tan_want[:], math::tan::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def asin_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(asin_input[:], asin_want[:], math::asin::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def acos_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(acos_input[:], acos_want[:], math::acos::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def atan_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(atan_input[:], atan_want[:], math::atan::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def sinh_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(sinh_input[:], sinh_want[:], math::sinh::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def cosh_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(cosh_input[:], cosh_want[:], math::cosh::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def tanh_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(tanh_input[:], tanh_want[:], math::tanh::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def asinh_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(asinh_input[:], asinh_want[:], math::asinh::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def acosh_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(acosh_input[:], acosh_want[:], math::acosh::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def atanh_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_one(atanh_input[:], atanh_want[:], math::atanh::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def pow_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_two(pow_input0[:], pow_input1[:], pow_want[:], math::pow::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def atan2_is_within_two_ulps(t: &mut tester): void {
|
||
|
|
t.expects(worst_two(atan2_input0[:], atan2_input1[:], atan2_want[:], math::atan2::<f64>) <= 2);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def hypot_is_within_an_ulp(t: &mut tester): void {
|
||
|
|
t.expects(worst_two(hypot_input0[:], hypot_input1[:], hypot_want[:], math::hypot::<f64>) <= 1);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
# What IEEE 754 and C say each function gives at the edges of its domain.
|
||
|
|
|
||
|
|
def inf(): f64 { return math::infinity::<f64>(); }
|
||
|
|
def nan(): f64 { return math::nan::<f64>(); }
|
||
|
|
def is_negative_zero(x: f64): bool { return x == 0 && math::sign_bit(x); }
|
||
|
|
def is_positive_zero(x: f64): bool { return x == 0 && !math::sign_bit(x); }
|
||
|
|
|
||
|
|
@test def roots_and_exponentials_at_the_edges(t: &mut tester): void {
|
||
|
|
t.expects(is_negative_zero(math::sqrt(-0.0)) && math::sqrt(inf()) == inf() && math::is_nan(math::sqrt(-1.0)));
|
||
|
|
t.expects(is_negative_zero(math::cbrt(-0.0)) && math::cbrt(-inf()) == -inf() && math::cbrt(-8.0) == -2.0);
|
||
|
|
t.expects(math::exp(0.0) == 1.0 && is_positive_zero(math::exp(-inf())) && math::exp(inf()) == inf());
|
||
|
|
t.expects(math::exp(710.0) == inf() && is_positive_zero(math::exp(-746.0)) && math::is_nan(math::exp(nan())));
|
||
|
|
t.expects(math::exp2(10.0) == 1024.0 && math::exp2(-1074.0) == 5e-324 && math::exp2(1024.0) == inf());
|
||
|
|
t.expects(is_negative_zero(math::expm1(-0.0)) && math::expm1(-inf()) == -1.0 && math::expm1(inf()) == inf());
|
||
|
|
t.expects(math::hypot(inf(), nan()) == inf() && math::hypot(nan(), -inf()) == inf() && math::hypot(3.0, 4.0) == 5.0);
|
||
|
|
t.expects(math::hypot(1e308, 1e308) == 1.4142135623730951e308 && math::hypot(-0.0, 0.0) == 0.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def logarithms_at_the_edges(t: &mut tester): void {
|
||
|
|
t.expects(math::log(0.0) == -inf() && math::log(-0.0) == -inf() && math::is_nan(math::log(-1.0)));
|
||
|
|
t.expects(is_positive_zero(math::log(1.0)) && math::log(inf()) == inf() && math::is_nan(math::log(-inf())));
|
||
|
|
t.expects(math::log2(1024.0) == 10.0 && math::log2(5e-324) == -1074.0 && math::log2(0.0) == -inf());
|
||
|
|
t.expects(math::log10(1000.0) == 3.0 && math::log10(1e-300) == -300.0 && math::is_nan(math::log10(-2.0)));
|
||
|
|
t.expects(math::log1p(-1.0) == -inf() && math::is_nan(math::log1p(-2.0)) && is_negative_zero(math::log1p(-0.0)));
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def powers_follow_c_at_the_edges(t: &mut tester): void {
|
||
|
|
t.expects(math::pow(-2.0, 3.0) == -8.0 && math::is_nan(math::pow(-8.0, 1.0 / 3.0)) && math::pow(2.0, 0.5) == math::sqrt(2.0));
|
||
|
|
t.expects(math::pow(0.0, -1.0) == inf() && math::pow(-0.0, -3.0) == -inf() && math::pow(-0.0, -2.0) == inf());
|
||
|
|
t.expects(math::pow(1.0, nan()) == 1.0 && math::pow(nan(), 0.0) == 1.0 && math::pow(-1.0, inf()) == 1.0);
|
||
|
|
t.expects(math::pow(2.0, 1024.0) == inf() && is_positive_zero(math::pow(2.0, -1075.0)) && math::pow(0.5, -inf()) == inf());
|
||
|
|
t.expects(math::pow(-inf(), 3.0) == -inf() && is_negative_zero(math::pow(-inf(), -3.0)) && math::pow(10.0, 15.0) == 1e15);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def trigonometry_at_the_edges(t: &mut tester): void {
|
||
|
|
t.expects(is_negative_zero(math::sin(-0.0)) && is_positive_zero(math::tan(0.0)) && math::cos(0.0) == 1.0);
|
||
|
|
t.expects(math::is_nan(math::sin(inf())) && math::is_nan(math::cos(-inf())) && math::is_nan(math::tan(nan())));
|
||
|
|
t.expects(math::sin(math::pi / 6) == 0.49999999999999994 && math::cos(math::pi) == -1.0);
|
||
|
|
t.expects(math::sin(1e22) == -0.8522008497671888 && math::cos(1e22) == 0.523214785395139);
|
||
|
|
t.expects(math::asin(1.0) == math::pi / 2 && math::acos(-1.0) == math::pi && is_positive_zero(math::acos(1.0)));
|
||
|
|
t.expects(math::is_nan(math::asin(1.0000000000000002)) && math::is_nan(math::acos(-2.0)));
|
||
|
|
t.expects(math::atan(inf()) == math::pi / 2 && is_negative_zero(math::atan(-0.0)));
|
||
|
|
t.expects(math::atan2(0.0, -0.0) == math::pi && is_negative_zero(math::atan2(-0.0, 0.0)) && math::atan2(-0.0, -0.0) == -math::pi);
|
||
|
|
t.expects(math::atan2(1.0, 0.0) == math::pi / 2 && math::atan2(inf(), -inf()) == 3 * math::pi / 4);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def hyperbolic_functions_at_the_edges(t: &mut tester): void {
|
||
|
|
t.expects(is_negative_zero(math::sinh(-0.0)) && math::sinh(-inf()) == -inf() && math::cosh(-inf()) == inf());
|
||
|
|
t.expects(math::cosh(0.0) == 1.0 && math::tanh(inf()) == 1.0 && math::tanh(-30.0) == -1.0);
|
||
|
|
t.expects(math::sinh(711.0) == inf() && math::cosh(-711.0) == inf() && is_negative_zero(math::tanh(-0.0)));
|
||
|
|
t.expects(is_negative_zero(math::asinh(-0.0)) && math::asinh(-inf()) == -inf() && is_positive_zero(math::acosh(1.0)));
|
||
|
|
t.expects(math::is_nan(math::acosh(0.5)) && math::atanh(1.0) == inf() && math::atanh(-1.0) == -inf());
|
||
|
|
t.expects(math::is_nan(math::atanh(2.0)));
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
# The exact operations, which have one result each.
|
||
|
|
|
||
|
|
@test def rounding_gives_integers_to_the_bit(t: &mut tester): void {
|
||
|
|
t.expects(math::floor(-2.5) == -3.0 && math::ceil(-2.5) == -2.0 && math::trunc(-2.5) == -2.0);
|
||
|
|
t.expects(math::round(-2.5) == -3.0 && math::round_even(-2.5) == -2.0 && math::round_even(3.5) == 4.0);
|
||
|
|
t.expects(math::round(0.49999999999999994) == 0.0 && math::round(-0.5) == -1.0 && math::round(2.5) == 3.0);
|
||
|
|
t.expects(is_negative_zero(math::ceil(-0.5)) && is_negative_zero(math::trunc(-0.5)) && is_negative_zero(math::round_even(-0.5)));
|
||
|
|
t.expects(math::floor(-0.5) == -1.0 && is_negative_zero(math::floor(-0.0)) && math::floor(4503599627370497.0) == 4503599627370497.0);
|
||
|
|
t.expects(math::floor(inf()) == inf() && math::is_nan(math::ceil(nan())) && math::trunc(1e300) == 1e300);
|
||
|
|
val f: f32 = -2.5;
|
||
|
|
t.expects(math::floor(f) == -3.0f && math::round(f) == -3.0f && math::round_even(f) == -2.0f);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def signs_and_magnitudes_follow_the_bits(t: &mut tester): void {
|
||
|
|
t.expects(is_positive_zero(math::abs(-0.0)) && math::abs(-inf()) == inf() && !math::sign_bit(math::abs(-nan())));
|
||
|
|
t.expects(math::abs(-3) == 3 && math::abs(seconds(-2)) == seconds(2) && math::abs(-2.5f) == 2.5f);
|
||
|
|
val least: i8 = -128;
|
||
|
|
t.expects(math::abs(least) == least);
|
||
|
|
t.expects(is_negative_zero(math::copysign(0.0, -1.0)) && math::copysign(3.0, -0.0) == -3.0);
|
||
|
|
t.expects(math::sign_bit(math::copysign(nan(), -1.0)) && math::copysign(-2.0f, 1.0f) == 2.0f);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def fma_rounds_once(t: &mut tester): void {
|
||
|
|
# The product is exact before the sum, which multiplying then adding rounds away.
|
||
|
|
t.expects(math::fma(0.1, 10.0, -1.0) == 5.551115123125783e-17 && 0.1 * 10.0 - 1.0 == 0.0);
|
||
|
|
t.expects(math::fma(1.0000000000000002, 1.0000000000000002, -1.0000000000000004) == 4.930380657631324e-32);
|
||
|
|
t.expects(math::fma(1e308, 10.0, -1e308) == inf() && math::fma(2.2250738585072014e-308, 0.5, 0.0) == 1.1125369292536007e-308);
|
||
|
|
t.expects(is_positive_zero(math::fma(5e-324, 0.5, 0.0)) && math::fma(1.0, 2.0, 3.0) == 5.0);
|
||
|
|
t.expects(math::is_nan(math::fma(inf(), 0.0, 1.0)) && math::fma(inf(), 1.0, 1.0) == inf());
|
||
|
|
val a: f32 = 0.1;
|
||
|
|
val b: f32 = 10.0;
|
||
|
|
val c: f32 = -1.0;
|
||
|
|
t.expects(math::fma(a, b, c) == 1.4901161e-08f && a * b + c == 0.0f);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def fma_gives_the_nan_fma3_does(t: &mut tester): void {
|
||
|
|
# A factor's, the first's before the second's, and otherwise the addend's,
|
||
|
|
# even where the product is NaN.
|
||
|
|
val p := math::real_of_bits(0x7FF8000000000001u);
|
||
|
|
val q := math::real_of_bits(0x7FF8000000000002u);
|
||
|
|
val r := math::real_of_bits(0x7FF8000000000003u);
|
||
|
|
t.expects(math::bits_of(math::fma(p, q, r)) == 0x7FF8000000000001u && math::bits_of(math::fma(1.0, q, r)) == 0x7FF8000000000002u);
|
||
|
|
t.expects(math::bits_of(math::fma(inf(), 0.0, r)) == 0x7FF8000000000003u && math::bits_of(math::fma(1.0, 1.0, r)) == 0x7FF8000000000003u);
|
||
|
|
val s := math::real_of_bits(0x7FC00001 as u32);
|
||
|
|
val n := math::real_of_bits(0x7FC00003 as u32);
|
||
|
|
val big := math::infinity::<f32>();
|
||
|
|
t.expects(math::bits_of(math::fma(s, 1.0f, n)) == 0x7FC00001 && math::bits_of(math::fma(big, 0.0f, n)) == 0x7FC00003);
|
||
|
|
}
|
||
|
|
|
||
|
|
# Reals rounding and `fma` meet at their hardest, as bits: halves and what is
|
||
|
|
# just below one, signed zeros, subnormals, the largest, infinities, and NaNs
|
||
|
|
# with payloads, quiet and signalling.
|
||
|
|
const hard_doubles: u64[24] = [
|
||
|
|
0x0000000000000000, 0x8000000000000000, 0x3FE0000000000000, 0xBFE0000000000000, 0x3FF8000000000000,
|
||
|
|
0xC004000000000000, 0x3FDFFFFFFFFFFFFF, 0xBFDFFFFFFFFFFFFF, 0x432FFFFFFFFFFFFF, 0xC32FFFFFFFFFFFFF,
|
||
|
|
0x4330000000000000, 0x4340000000000001, 0x0000000000000001, 0x8000000000000001, 0x7FEFFFFFFFFFFFFF,
|
||
|
|
0x7FF0000000000000, 0xFFF0000000000000, 0x7FF8000000000123, 0xFFF8000000000456, 0x7FF0000000000789,
|
||
|
|
0x3FB999999999999A, 0xBFE6666666666666, 0x40FE240C9FBE76C9, 0xC0C3880000000001,
|
||
|
|
];
|
||
|
|
const hard_singles: u32[18] = [
|
||
|
|
0x00000000, 0x80000000, 0x3F000000, 0xBF000000, 0x3FC00000, 0xC0200000, 0x3EFFFFFF, 0xBEFFFFFF,
|
||
|
|
0x4AFFFFFF, 0xCAFFFFFF, 0x4B000000, 0x00000001, 0x7F7FFFFF, 0x7F800000, 0xFF800000, 0x7FC00123,
|
||
|
|
0xFFC00456, 0x7F800789,
|
||
|
|
];
|
||
|
|
|
||
|
|
# FNV-1a, the hash of each value's bits, which wraps as it multiplies.
|
||
|
|
def fold(hash: u64, bits: u64): u64 {
|
||
|
|
return math::wrapping_mul(hash ^ bits, 0x100000001B3);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def rounding_and_fma_give_the_same_bits_everywhere(t: &mut tester): void {
|
||
|
|
# Worked by SSE4.1's and FMA3's instructions where the processor has them, and
|
||
|
|
# otherwise as std writes them, which the machine runs: the same either way.
|
||
|
|
var h: u64 = 0xCBF29CE484222325;
|
||
|
|
for i in 0..24u {
|
||
|
|
val x := math::real_of_bits(hard_doubles[i]);
|
||
|
|
h = fold(fold(fold(h, math::bits_of(math::floor(x))), math::bits_of(math::ceil(x))), math::bits_of(math::trunc(x)));
|
||
|
|
h = fold(fold(h, math::bits_of(math::round(x))), math::bits_of(math::round_even(x)));
|
||
|
|
for j in 0..24u {
|
||
|
|
val y := math::real_of_bits(hard_doubles[j]);
|
||
|
|
h = fold(fold(h, math::bits_of(math::fma(x, y, x))), math::bits_of(math::fma(y, 3.0, -x)));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for i in 0..18u {
|
||
|
|
val x := math::real_of_bits(hard_singles[i]);
|
||
|
|
h = fold(fold(fold(h, math::bits_of(math::floor(x)) as u64), math::bits_of(math::ceil(x)) as u64), math::bits_of(math::trunc(x)) as u64);
|
||
|
|
h = fold(fold(h, math::bits_of(math::round(x)) as u64), math::bits_of(math::round_even(x)) as u64);
|
||
|
|
for j in 0..18u {
|
||
|
|
val y := math::real_of_bits(hard_singles[j]);
|
||
|
|
h = fold(fold(h, math::bits_of(math::fma(x, y, x)) as u64), math::bits_of(math::fma(y, 3.0f, -x)) as u64);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
t.expects(h == rounded_bits);
|
||
|
|
}
|
||
|
|
|
||
|
|
# What `rounding_and_fma_give_the_same_bits_everywhere` folds, as the machine
|
||
|
|
# works it.
|
||
|
|
const rounded_bits: u64 = 8197392432731182516;
|
||
|
|
|
||
|
|
@test def least_and_greatest_order_zeros_and_keep_nan(t: &mut tester): void {
|
||
|
|
t.expects(math::min(1, 2) == 1 && math::max(1, 2) == 2 && math::min(seconds(3), seconds(1)) == seconds(1));
|
||
|
|
t.expects(is_negative_zero(math::min(0.0, -0.0)) && is_negative_zero(math::min(-0.0, 0.0)));
|
||
|
|
t.expects(is_positive_zero(math::max(-0.0, 0.0)) && is_positive_zero(math::max(0.0, -0.0)));
|
||
|
|
t.expects(math::is_nan(math::min(1.0, nan())) && math::is_nan(math::max(nan(), 1.0)));
|
||
|
|
t.expects(math::clamp(5, 0, 3) == 3 && math::clamp(-1.0, 0.0, 1.0) == 0.0 && math::clamp(0.5, 0.0, 1.0) == 0.5);
|
||
|
|
t.expects(math::is_nan(math::clamp(nan(), 0.0, 1.0)) && math::clamp(7, 9, 3) == 9);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
# Classifying, bits, and the constants.
|
||
|
|
|
||
|
|
@test def reals_are_classified_by_their_bits(t: &mut tester): void {
|
||
|
|
t.expects(math::is_nan(nan()) && !math::is_nan(inf()) && math::is_infinite(-inf()) && !math::is_finite(nan()));
|
||
|
|
t.expects(math::is_finite(1.7976931348623157e308) && math::is_subnormal(5e-324) && !math::is_subnormal(2.2250738585072014e-308));
|
||
|
|
t.expects(math::is_subnormal(1e-40f) && !math::is_subnormal(1e-40) && !math::is_subnormal(0.0));
|
||
|
|
t.expects(math::sign_bit(-0.0) && !math::sign_bit(0.0) && math::sign_bit(-inf()));
|
||
|
|
t.expects(math::bits_of(1.0) == 0x3FF0000000000000u && math::bits_of(1.5f) == 0x3FC00000);
|
||
|
|
t.expects(math::real_of_bits(0x4000000000000000u) == 2.0 && math::bits_of(math::real_of_bits(0x7FF0000000000001u)) == 0x7FF0000000000001u);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def constants_fit_each_real(t: &mut tester): void {
|
||
|
|
val single: f32 = math::pi as f32;
|
||
|
|
t.expects(math::pi == 3.141592653589793 && single == 3.1415927f && math::tau == 2 * math::pi);
|
||
|
|
t.expects(math::exp(1.0) == math::e && math::sqrt(2.0) == math::sqrt_2 && math::log(2.0) == math::ln_2 && math::log(10.0) == math::ln_10);
|
||
|
|
t.expects(math::largest::<f64>() == 1.7976931348623157e308 && math::largest::<f32>() == 3.4028234663852886e38f);
|
||
|
|
t.expects(math::smallest::<f64>() == 2.2250738585072014e-308 && math::epsilon::<f64>() == 2.220446049250313e-16);
|
||
|
|
t.expects(math::epsilon::<f32>() == 1.1920928955078125e-07f && 1.0 + math::epsilon::<f64>() > 1.0);
|
||
|
|
t.expects(math::infinity::<f32>() > math::largest::<f32>() && math::is_nan(math::nan::<f32>()));
|
||
|
|
}
|
||
|
|
|
||
|
|
const at_compile: f64[6] = [math::sin(1.0), math::exp(1.0), math::log(10.0), math::pow(2.0, 0.5), math::atan2(1.0, 2.0), math::cbrt(5.0)];
|
||
|
|
|
||
|
|
@test def a_constant_is_what_running_gives(t: &mut tester): void {
|
||
|
|
val one: f64 = 1.0;
|
||
|
|
t.expects(at_compile[0] == math::sin(one) && at_compile[1] == math::exp(one) && at_compile[2] == math::log(10 * one));
|
||
|
|
t.expects(at_compile[3] == math::pow(2 * one, 0.5) && at_compile[4] == math::atan2(one, 2 * one) && at_compile[5] == math::cbrt(5 * one));
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def f32_is_worked_in_f64_and_rounded(t: &mut tester): void {
|
||
|
|
val x: f32 = 0.5;
|
||
|
|
t.expects(math::sin(x) == math::sin(0.5) as f32 && math::exp(x) == math::exp(0.5) as f32 && math::log(x) == math::log(0.5) as f32);
|
||
|
|
t.expects(math::pow(x, 3.0f) == 0.125f && math::sqrt(2.0f) == 1.4142135f && math::atan2(x, x) == 0.7853982f);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
# The operations of integers, at the edges of each width.
|
||
|
|
|
||
|
|
def overflows<T>(value: maybe<T>): bool where T: integer { return value is none; }
|
||
|
|
def gives<T>(value: maybe<T>, want: T): bool where T: integer { return value is some(got) && got == want; }
|
||
|
|
|
||
|
|
@test def bits_are_counted_as_each_type_holds_them(t: &mut tester): void {
|
||
|
|
val neg: i8 = -1;
|
||
|
|
val least: i8 = -128;
|
||
|
|
val one: u8 = 1;
|
||
|
|
t.expects(count_ones(neg) == 8 && count_ones(-1) == 64 && count_ones(least) == 1);
|
||
|
|
t.expects(leading_zeros(one) == 7 && leading_zeros(neg) == 0 && leading_zeros(0 as u32) == 32);
|
||
|
|
t.expects(trailing_zeros(0 as u8) == 8 && trailing_zeros(least) == 7 && trailing_zeros(0 as u64) == 64);
|
||
|
|
t.expects(math::rotate_left(0x81 as u8, 1) == 3 && math::rotate_right(0x81 as u8, 1) == 192 && math::rotate_left(1 as u64, 65) == 2);
|
||
|
|
t.expects(math::rotate_left(1 as i8, 7) == least && math::rotate_right(1 as u32, 33) == 0x80000000);
|
||
|
|
t.expects(swap_bytes(0x1234 as u16) == 0x3412 && swap_bytes(0x00FF as i16) == -256);
|
||
|
|
t.expects(swap_bytes(0x0102030405060708u) == 0x0807060504030201u);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def checked_arithmetic_finds_every_overflow(t: &mut tester): void {
|
||
|
|
val most: i8 = 127;
|
||
|
|
val least: i8 = -128;
|
||
|
|
val one: i8 = 1;
|
||
|
|
val neg: i8 = -1;
|
||
|
|
t.expects(overflows(math::checked_add(most, one)) && gives(math::checked_add(most, neg), 126 as i8));
|
||
|
|
t.expects(overflows(math::checked_sub(least, one)) && overflows(math::checked_sub(0 as u8, 1 as u8)));
|
||
|
|
t.expects(overflows(math::checked_mul(neg, least)) && gives(math::checked_mul(neg, most), -127 as i8));
|
||
|
|
t.expects(overflows(math::checked_mul(16 as i8, 8 as i8)) && gives(math::checked_mul(-16 as i8, 8 as i8), least));
|
||
|
|
val big: i64 = 9223372036854775807;
|
||
|
|
val small: i64 = -9223372036854775807 - 1;
|
||
|
|
t.expects(overflows(math::checked_mul(big, 2 as i64)) && overflows(math::checked_mul(small, -1 as i64)));
|
||
|
|
t.expects(overflows(math::checked_mul(0xFFFFFFFFFFFFFFFFu, 2u)) && gives(math::checked_mul(4294967295u, 4294967297u), 0xFFFFFFFFFFFFFFFFu));
|
||
|
|
t.expects(overflows(math::checked_pow(3 as i64, 40)) && gives(math::checked_pow(3 as i64, 39), 4052555153018976267 as i64));
|
||
|
|
t.expects(overflows(math::checked_pow(2 as i8, 7)) && gives(math::checked_pow(-2 as i8, 7), least));
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def saturating_arithmetic_holds_at_the_limits(t: &mut tester): void {
|
||
|
|
val most: i8 = 127;
|
||
|
|
val least: i8 = -128;
|
||
|
|
t.expects(math::saturating_add(most, 1 as i8) == most && math::saturating_add(least, -1 as i8) == least);
|
||
|
|
t.expects(math::saturating_sub(least, 1 as i8) == least && math::saturating_sub(most, -1 as i8) == most);
|
||
|
|
t.expects(math::saturating_add(255 as u8, 1 as u8) == 255 && math::saturating_sub(1 as u8, 255 as u8) == 0);
|
||
|
|
t.expects(math::saturating_mul(least, -1 as i8) == most && math::saturating_mul(-16 as i8, 9 as i8) == least);
|
||
|
|
t.expects(math::saturating_mul(0xFFFFFFFFFFFFFFFFu, 3u) == 0xFFFFFFFFFFFFFFFFu);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def powers_divisors_and_roots_of_integers(t: &mut tester): void {
|
||
|
|
t.expects(math::int_pow(3, 4) == 81 && math::int_pow(2 as u8, 9) == 0 && math::int_pow(7, 0) == 1 && math::int_pow(-3, 3) == -27);
|
||
|
|
val small: i64 = -9223372036854775807 - 1;
|
||
|
|
t.expects(math::gcd(12, 18) == 6 && math::gcd(-12, 18) == 6 && math::gcd(0, 0) == 0 && math::gcd(small, 6 as i64) == 2);
|
||
|
|
t.expects(math::gcd(small, 0 as i64) == small && math::lcm(4, 6) == 12 && math::lcm(-4, 6) == 12 && math::lcm(0, 6) == 0);
|
||
|
|
t.expects(math::isqrt(15) == 3 && math::isqrt(16) == 4 && math::isqrt(-4) == 0 && math::isqrt(0xFFFFFFFFFFFFFFFFu) == 4294967295u);
|
||
|
|
t.expects(math::isqrt(4503599761588224u) == 67108864u && math::isqrt(4503599761588225u) == 67108865u);
|
||
|
|
t.expects(math::isqrt(9223372036854775807) == 3037000499);
|
||
|
|
}
|
||
|
|
|
||
|
|
@test def floor_division_rounds_toward_negative_infinity(t: &mut tester): void {
|
||
|
|
t.expects(math::div_floor(-7, 2) == -4 && math::rem_floor(-7, 2) == 1 && math::div_floor(7, -2) == -4 && math::rem_floor(7, -2) == -1);
|
||
|
|
t.expects(math::div_floor(-8, 2) == -4 && math::rem_floor(-8, 2) == 0 && math::div_floor(7, 2) == 3 && math::rem_floor(-1, 5) == 4);
|
||
|
|
t.expects(math::div_floor(7 as u32, 2 as u32) == 3 && math::rem_floor(7 as u32, 2 as u32) == 1);
|
||
|
|
for a in -9..10 {
|
||
|
|
for b in [-4, -3, 3, 4] {
|
||
|
|
val d: i64 = b;
|
||
|
|
t.expects(math::div_floor(a, d) * d + math::rem_floor(a, d) == a);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|