Last active
August 29, 2015 14:19
-
-
Save imneme/ed3dd53ac43358289a58 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// badseed: | |
// Provides examples showing std::seed_seq is not a bijection | |
// i.e., that some seeds get repeated for different inputs | |
// and thus some other seeds must never be generated | |
#include <random> | |
#include <iostream> | |
#include <iomanip> | |
#include <cstddef> | |
void show_seedresult(uint32_t a, uint32_t b) | |
{ | |
std::seed_seq seeder{a, b}; | |
uint32_t output[2]; | |
seeder.generate(output, output+2); | |
auto&& pad = std::setw(10); | |
std::cout << std::hex << std::showbase << std::setfill('0') << std::internal | |
<< "std::seed_seq{" | |
<< pad << a << ", " << pad << b | |
<< "} -> {" | |
<< pad << output[0] << ", " << pad << output[1] | |
<< "}\n"; | |
} | |
const uint32_t examples[][2][2] = { | |
{ {0xf5e5b5c0, 0xdcb8e4b1}, {0xd34295df, 0xba15c4d0} }, | |
// -> {0x3bf5972a, 0xe304114d} | |
{ {0xb77a5049, 0x9c05c9ee}, {0xf2341087, 0xd6bf8a2c} }, | |
// -> {0xf5994f68, 0x67938036} | |
{ {0x635678a7, 0xc6743e31}, {0x05f99888, 0x69175e12} }, | |
// -> {0xd310ec08, 0xa46a8f1b} | |
{ {0x2c5574a2, 0x133c2711}, {0x20c9bf57, 0x07b071c6} }, | |
// -> {0xefd7e31f, 0x3f5c314c} | |
{ {0x45aa00c0, 0x31e5a816}, {0xa40616a6, 0x9041bdfc} }, | |
// -> {0x909f86c7, 0xeefd7050} | |
{ {0x3d992b4b, 0x37c2dfae}, {0xc924e096, 0xc34e94f9} }, | |
// -> {0x9ffcdb54, 0x902f6647} | |
{ {0x522c2aef, 0x35330fbd}, {0x74cf4ad0, 0x57d62f9e} }, | |
// -> {0x9af8b196, 0xd6c9966c} | |
{ {0xc52a8863, 0xe7e1985c}, {0x66ce727d, 0x89858276} }, | |
// -> {0x2580dd80, 0x2b261c22} | |
{ {0x02ff16fc, 0xa570fcdf}, {0x27a0a26b, 0xca12884e} }, | |
// -> {0x16214d5e, 0xeb384166} | |
{ {0x31727a70, 0x224192f9}, {0x54159a51, 0x44e4b2da} }, | |
// -> {0x2aac0c22, 0x36f511cc} ; | |
{ {0x09c8eba7, 0x83a547eb}, {0xcf0f2b69, 0x48eb87ad} }, | |
// -> {0xa8bc5efc, 0xe4f41cc1} | |
{ {0xd9b80af2, 0xc64a81a8}, {0x2c886b8d, 0x191ae243} }, | |
// -> {0x00976f32, 0x643e0bc7} | |
{ {0xf3739f68, 0x47afaae2}, {0xb8b9df2a, 0x0cf5eaa4} }, | |
// -> {0x55d488f4, 0x6012b67d} | |
{ {0x5b3c3d10, 0x9e2ecbd4}, {0x0a6a4803, 0x4d5cd6c7} }, | |
// -> {0x8441cb38, 0x459f17b9} | |
{ {0x564536a4, 0xeb1eafaa}, {0x31a3ab35, 0xc67d243b} }, | |
// -> {0x6da29616, 0x90264649} | |
{ {0xd4e151b0, 0x0a9488e0}, {0xf7847191, 0x2d37a8c1} }, | |
// -> {0xd7a7a0c7, 0x44119462} ; | |
{ {0x7e5e66bf, 0x5a28e0f5}, {0x89ea1c0a, 0x65b49640} }, | |
// -> {0x49867960, 0x6da418e5} | |
{ {0xd91213a1, 0x03bcd559}, {0x4d865e56, 0x7831200e} }, | |
// -> {0x656e3a67, 0x32759236} | |
{ {0x85139647, 0x6449a2b5}, {0xa7b6b628, 0x86ecc296} }, | |
// -> {0x6f96e8ed, 0x6938e292} | |
{ {0x38478220, 0x43701d65}, {0x15a4623f, 0x20ccfd84} }, | |
// -> {0x07941606, 0x093a028d} | |
{ {0xd5eefe2a, 0x4ad6122b}, {0x334bde49, 0xa832f24a} }, | |
// -> {0x1b20c12b, 0xa9859daa} | |
{ {0x00ad0ede, 0xfe4698f3}, {0xdf0924c4, 0xdca2aed9} }, | |
// -> {0x12e1f230, 0x485763c9} | |
{ {0x699d4465, 0xaedf2f05}, {0x7fb57934, 0xc4f763d4} }, | |
// -> {0xcdb8f1d1, 0xe2db1b82} ; | |
{ {0x35b10527, 0xbdf6b463}, {0xd8542508, 0x6099d444} }, | |
// -> {0xda375265, 0xd650dab8} | |
{ {0x91996541, 0xabb6e023}, {0xb43c8522, 0xce5a0004} }, | |
// -> {0xee754ff6, 0xe43518e1} | |
{ {0x99ee3e60, 0x5b4fead5}, {0x8e628915, 0x4fc4358a} }, | |
// -> {0xb01fa5fc, 0x8483d6a6} | |
{ {0x02180d39, 0x5c972070}, {0x24bb2d1a, 0x7f3a4051} }, | |
// -> {0xfecf039d, 0x33d0975c} | |
{ {0xdb76db24, 0x33de0a99}, {0xfd1ac53e, 0x5581f4b3} }, | |
// -> {0x8b88cc22, 0xa9481875} ; | |
{ {0xe4cea5e7, 0x768eef74}, {0x8771c5c8, 0x19320f55} }, | |
// -> {0xe209012f, 0x4ef54290} | |
{ {0x1403d97f, 0x69e34709}, {0x36a6f960, 0x8c8666ea} }, | |
// -> {0x256bbf43, 0x5edcd91c} | |
{ {0x5e8b8f8b, 0xa20f722a}, {0xea1744d6, 0x2d9b2775} }, | |
// -> {0x5f9ab958, 0xc6112510} | |
{ {0xdb0204dd, 0x0d44e768}, {0x395e1ac3, 0x6ba0fd4e} }, | |
// -> {0x92a6e9e4, 0xc33b3418} | |
{ {0x01f6fe59, 0x85c762ad}, {0x249a1e3a, 0xa86a828e} }, | |
// -> {0xbb621d85, 0x938cd2de} | |
{ {0x02b58b3d, 0x7b548672}, {0xe111a123, 0x59b09c58} }, | |
// -> {0x7272bceb, 0x3673da65} | |
{ {0xff1768b3, 0x27594975}, {0x0aa31dfe, 0x32e4fec0} }, | |
// -> {0x0ed2a3ec, 0xfcc78f18} | |
{ {0x469bec02, 0x55551468}, {0x23f8cc21, 0x32b1f487} }, | |
// -> {0xda4f5cae, 0x3967a5a6} ; | |
{ {0x0930cf2c, 0x3ba8e635}, {0x4e770eee, 0x80ef25f7} }, | |
// -> {0x65e822b0, 0x424c5d8e} | |
{ {0x25f9aac9, 0x51a23f72}, {0xc89ccaaa, 0xf4455f53} }, | |
// -> {0xf65d6eba, 0x75a8ebb9} | |
{ {0x149c57c1, 0x3d808ce8}, {0x373f77a2, 0x6023acc9} }, | |
// -> {0x2310d24d, 0xf46c9b3e} | |
{ {0xf7bee688, 0x81f2bd97}, {0x3278a6c6, 0xbcac7dd5} }, | |
// -> {0x583963a4, 0x4e26dd50} | |
{ {0xdaeaff21, 0xf7e1a02e}, {0x8a190a14, 0xa70fab21} }, | |
// -> {0xaef01417, 0xd8665a07} ; | |
{ {0xb6b3dfba, 0x6337c809}, {0xf16d9ff8, 0x9df18847} }, | |
// -> {0x4573adb1, 0x9e60a15a} | |
{ {0x873dffc7, 0xd503f787}, {0xc0f88a3e, 0x0ebe81fe} }, | |
// -> {0xed5e314e, 0x4ce46a05} | |
{ {0x3171b85d, 0x46b3711b}, {0x76b7f81f, 0x8bf9b0dd} }, | |
// -> {0xbfff85d8, 0xaa36cb21} | |
{ {0xc2583939, 0x6590251e}, {0xe4fb591a, 0x883344ff} }, | |
// -> {0x96638e33, 0x1c88a963} | |
{ {0x70a1009e, 0xb72b248f}, {0x5a88cbcf, 0xa112efc0} }, | |
// -> {0xec292e12, 0x3b907a57} | |
{ {0x737ca414, 0x47cbc5de}, {0x38c2e3d6, 0x0d1205a0} }, | |
// -> {0xbe046829, 0x771e6697} | |
{ {0x513e90d4, 0x52aa70e1}, {0x75e01c43, 0x774bfc50} }, | |
// -> {0x61795c06, 0x9f201fe9} | |
{ {0xb1c9792c, 0x9fa2f52c}, {0xf70fb8ee, 0xe4e934ee} }, | |
// -> {0xbe291739, 0x27b7ba91} | |
{ {0x6a23701e, 0x2c7df23e}, {0xbcf3d0b9, 0x7f4e52d9} }, | |
// -> {0x97b5a814, 0x08756641} ; | |
{ {0x12b68536, 0xc060d803}, {0x7211d0e3, 0x1fbc23b0} }, | |
// -> {0xb20fd299, 0x380e495f} | |
{ {0x4921de91, 0xb8ae5013}, {0xbd962946, 0x2d229ac8} }, | |
// -> {0x57af36ea, 0x6a630e43} | |
{ {0x66b599e5, 0x5c29315e}, {0x42140e76, 0x3787a5ef} }, | |
// -> {0xde4bccd6, 0x8c02a914} | |
{ {0x71a11544, 0x1c9045a3}, {0x36e75506, 0xe1d68565} }, | |
// -> {0xf2940258, 0x0fa1a236} | |
{ {0x9ef392db, 0xb8989405}, {0xaa7f4826, 0xc4244950} }, | |
// -> {0x3d34bc56, 0x81551be2} | |
{ {0xea317fa6, 0x810660c0}, {0x0049b475, 0x971e958f} }, | |
// -> {0x5cd8f787, 0x2388d01e} | |
{ {0x4cb5be1b, 0xb81016f6}, {0x4eb429a9, 0xba0e8284} }, | |
// -> {0x722cfa68, 0x7a4f04d6} | |
{ {0xff5bd0fc, 0xff880abd}, {0x69439c2d, 0x696fd5ee} }, | |
// -> {0x55f4b638, 0x031936d4} | |
{ {0xd7d6df8a, 0x70859dff}, {0x3533bfa9, 0xcde27e1e} }, | |
// -> {0xbd7b77a8, 0xab57d364} | |
{ {0xc70a5390, 0xe8d77c1c}, {0xa46733af, 0xc6345c3b} }, | |
// -> {0x5685374d, 0xab656a30} | |
{ {0x94c1119a, 0x3deadc4d}, {0x3764317b, 0xe08dfc2e} }, | |
// -> {0x4ac514eb, 0x156616d4} | |
{ {0x21bf9d69, 0x01d8b1d7}, {0xc462bd4a, 0xa47bd1b8} }, | |
// -> {0x401c564b, 0x6822bcca} | |
{ {0x5430b91b, 0xc78f9f83}, {0x562f24a9, 0xc98e0b11} }, | |
// -> {0x6a4b19e0, 0x2825a91a} ; | |
{ {0x35b10527, 0xbdf6b463}, {0xd8542508, 0x6099d444} }, | |
// -> {0xda375265, 0xd650dab8} | |
{ {0x91996541, 0xabb6e023}, {0xb43c8522, 0xce5a0004} }, | |
// -> {0xee754ff6, 0xe43518e1} | |
{ {0x99ee3e60, 0x5b4fead5}, {0x8e628915, 0x4fc4358a} }, | |
// -> {0xb01fa5fc, 0x8483d6a6} | |
{ {0x02180d39, 0x5c972070}, {0x24bb2d1a, 0x7f3a4051} }, | |
// -> {0xfecf039d, 0x33d0975c} | |
{ {0xdb76db24, 0x33de0a99}, {0xfd1ac53e, 0x5581f4b3} }, | |
// -> {0x8b88cc22, 0xa9481875} ; | |
{ {0xa7720c82, 0xf0846abc}, {0x84ceeca1, 0xcde14adb} }, | |
// -> {0xa916d5d9, 0xda369376} | |
{ {0x71ff6fce, 0xf39a8d33}, {0xb745af90, 0x38e0ccf5} }, | |
// -> {0x981be8ad, 0x863b1c92} | |
{ {0xf152c3bf, 0x70d6ae6d}, {0x13f5e3a0, 0x9379ce4e} }, | |
// -> {0x4d565b80, 0x717ea4ba} | |
{ {0xe79be55f, 0x59bb60d4}, {0xe89b1b26, 0x5aba969b} }, | |
// -> {0x0182f7ea, 0x895cc994} | |
{ {0x94979098, 0x4ea26bbd}, {0xf1f470b7, 0xabff4bdc} }, | |
// -> {0x612fffef, 0x38bf13f2} | |
{ {0xee5fdb7c, 0x45888735}, {0x1d8de66f, 0x74b69228} }, | |
// -> {0xa004ee26, 0x6dc53428} ; | |
{ {0xebbc03b6, 0xf4763d57}, {0x60304e6b, 0x68ea880c} }, | |
// -> {0x421a1d5e, 0x027cf6b7} | |
{ {0xb5fe8d37, 0xbc7207f8}, {0x58a1ad18, 0x5f1527d9} }, | |
// -> {0xe4a51a85, 0x45c537c6} | |
{ {0xbfe63f7c, 0xcc1a2a71}, {0x29ce0aad, 0x3601f5a2} }, | |
// -> {0x782dacce, 0x4722b972} | |
{ {0x35ca9107, 0xa3656b9d}, {0xd86db0e8, 0x46088b7e} }, | |
// -> {0xf438f3cc, 0x9495af4c} ; | |
{ {0xaa5c6438, 0x75a8dcc8}, {0x6fa2a3fa, 0x3aef1c8a} }, | |
// -> {0xd6d1a333, 0xba7b12e3} | |
{ {0xd158919c, 0x1d7a878c}, {0x169ed15e, 0x62c0c74e} }, | |
// -> {0x5530e50b, 0xa06d9612} | |
{ {0x3ec9ae3d, 0x8bb64e60}, {0xedf7b930, 0x3ae45953} }, | |
// -> {0x68ae0188, 0xd0d7d49b} | |
{ {0xc01faeb9, 0xb8569858}, {0x6d4f4e1e, 0x658637bd} }, | |
// -> {0xdb8907c4, 0x86aecf73} | |
{ {0x0a17d0cf, 0x2b6643ed}, {0x4f5e1091, 0x70ac83af} }, | |
// -> {0xa93b1c2e, 0xc8c51a66} | |
{ {0x6b5519e7, 0xa7969fc4}, {0x309b59a9, 0x6cdcdf86} }, | |
// -> {0xfb2d2859, 0xb4433169} | |
{ {0x0af64d0e, 0x4713b6b1}, {0xff6a97c3, 0x3b880166} }, | |
// -> {0xfe753dfb, 0xf342d59d} | |
{ {0x6904b36e, 0x7d7d09dc}, {0xdd78fe23, 0xf1f15491} }, | |
// -> {0x6293a5f8, 0x14ed5d0d} | |
{ {0xf91d5764, 0xd7435bab}, {0x1ac1417e, 0xf8e745c5} }, | |
// -> {0x5ebd0089, 0xf5f0e521} | |
{ {0x8453369f, 0x97e824c4}, {0xa6f65680, 0xba8b44a5} }, | |
// -> {0xfe04a576, 0x4110b96b} | |
{ {0xde114e13, 0x5a68abbb}, {0xaee34320, 0x2b3aa0c8} }, | |
// -> {0x990435f7, 0xf05a2ab4} ; | |
{ {0x94e862e0, 0x51d9ca73}, {0xb78b82c1, 0x747cea54} }, | |
// -> {0xd3787f2a, 0xd7f2d8d1} | |
{ {0xde045863, 0x41ac6866}, {0x69900dae, 0xcd381db1} }, | |
// -> {0x9f5ef523, 0x6d84401f} | |
{ {0xa09f80f1, 0x05adb46d}, {0xcfcd8be4, 0x34dbbf60} }, | |
// -> {0xa746675d, 0x63508058} | |
{ {0x3795c318, 0x3ce982bd}, {0x14f2a337, 0x1a4662dc} }, | |
// -> {0xd2ce7a74, 0xd55d0501} | |
{ {0x8bb6dc6d, 0x5e24176f}, {0x802b2722, 0x52986224} }, | |
// -> {0x10bf09e6, 0x661a8b51} | |
{ {0xefba1a07, 0x804da32d}, {0x408c0f14, 0xd11f983a} }, | |
// -> {0x5a312a42, 0x103f9661} | |
{ {0x8732ec1f, 0x071fa1d8}, {0x40ed7696, 0xc0da2c4f} }, | |
// -> {0xe6857525, 0xe7340ee9} | |
{ {0x27d12a58, 0x6c635275}, {0x052e0a77, 0x49c03294} }, | |
// -> {0x15867316, 0xd505207b} ; | |
{ {0x2e64eeaf, 0x8c6943ef}, {0x7f36e3bc, 0xdd3b38fc} }, | |
// -> {0xc9650e1b, 0xc6e2103d} | |
{ {0xfc35f784, 0xe19e9b72}, {0x1dd9e19e, 0x0342858c} }, | |
// -> {0xb62cb52f, 0x371b33d8} | |
{ {0x55b32dcf, 0x9a0fb38a}, {0x78564db0, 0xbcb2d36b} }, | |
// -> {0x3c4a0c4d, 0x4cbe12e1} | |
{ {0x29f70d85, 0x35a7cd90}, {0xef3d4d47, 0xfaee0d52} }, | |
// -> {0x44593751, 0xc5b0b4d8} | |
{ {0x89b406c2, 0x9f27eb81}, {0x7e285177, 0x939c3636} }, | |
// -> {0x1868e213, 0x4f946faa} | |
{ {0xacbd4ec0, 0x7052feb2}, {0xdbeb59b3, 0x9f8109a5} }, | |
// -> {0x53f0a2e2, 0xbfa5dd29} | |
{ {0x3fb4a65c, 0x34f0c2ad}, {0xa99c718d, 0x9ed88dde} } | |
// -> {0xae422d8a, 0xc2c7ad18} ; | |
}; | |
int main() | |
{ | |
for (auto& example : examples) { | |
show_seedresult(example[0][0], example[0][1]); | |
show_seedresult(example[1][0], example[1][1]); | |
std::cout << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment