| 59 | } |
| 60 | |
| 61 | std::vector<uint8_t> random_rows(int t, int64_t rows, int64_t n, std::mt19937& rng) { |
| 62 | const int bv = t == 42 ? 64 : 128; |
| 63 | const size_t rb = k::iq_row_bytes(t, n), bs = k::iq_row_bytes(t, bv); |
| 64 | std::vector<uint8_t> w((size_t) rows * rb); |
| 65 | std::uniform_int_distribution<int> byte(0, 255), ex(2, 8), man(0, 1023), sgn(0, 3); |
| 66 | for (auto& b : w) b = (uint8_t) byte(rng); |
| 67 | for (size_t o = 0; o < w.size(); o += bs) { |
| 68 | const uint16_t h = (uint16_t) ((sgn(rng) == 0 ? 0x8000 : 0) | (ex(rng) << 10) | man(rng)); // 2^-13 .. 2^-6 |
| 69 | std::memcpy(&w[o], &h, 2); |
| 70 | } |
| 71 | return w; |
| 72 | } |
| 73 | |
| 74 | std::vector<float> random_x(size_t n, std::mt19937& rng) { |
| 75 | std::normal_distribution<float> nd(0.f, 1.f); |
no test coverage detected