77 using rng_type = r123::Philox4x64;
78 using ctr_type = rng_type::ctr_type;
79 using key_type = rng_type::key_type;
81 const ctr_type c{{counter, 0u, 0u, 0u}};
83 auto const id1 =
static_cast<uint32_t
>(key1);
84 auto const id2 =
static_cast<uint32_t
>(key2);
88 return rng_type{}(c, k);
112auto noise_uniform(uint64_t counter, uint32_t seed,
int key1,
int key2 = 0) {
114 auto const integers = philox_4_uint64s<salt>(counter, seed, key1, key2);
116 std::transform(integers.begin(), integers.begin() + N, noise.begin(),
117 [](std::size_t value) { return Utils::uniform(value) - 0.5; });
124 auto const integers = philox_4_uint64s<salt>(counter, seed, key1, key2);
152 auto const integers = philox_4_uint64s<salt>(counter, seed, key1, key2);
153 static const double epsilon = std::numeric_limits<double>::min();
155 constexpr std::size_t M = (N <= 2) ? 2 : 4;
157 std::transform(integers.begin(), integers.begin() + M, u.begin(),
158 [](std::size_t value) {
159 auto u = Utils::uniform(value);
160 return (u < epsilon) ? epsilon : u;
169 auto const modulo = sqrt(-2. * log(u[0]));
170 auto const angle = 2. * std::numbers::pi * u[1];
171 noise[0] = modulo * cos(angle);
173 noise[1] = modulo * sin(angle);
177 auto const modulo = sqrt(-2. * log(u[2]));
178 auto const angle = 2. * std::numbers::pi * u[3];
179 noise[2] = modulo * cos(angle);
181 noise[3] = modulo * sin(angle);