9 inline constexpr
double PI = 3.1415926535897932384626433832795028841971693993751058209749445923;
12 inline double urand() noexcept {
13 static std::random_device rd;
14 static thread_local std::mt19937 generator(rd());
15 std::uniform_real_distribution<double> dist(0., std::nextafter(1.0, 2.0));
16 return dist(generator);
23 template<
typename E> constexpr
auto toInteger(E enumerator) noexcept {
24 return static_cast<std::underlying_type_t<E>
>(enumerator);
29 template<
typename In1,
typename In2,
typename Out>
30 void zip(In1 begin1, In2 end1, In2 begin2, In2 end2, Out result) {
33 while (it1 != end1 && it2 != end2) { result++ = { *it1++, *it2++ }; }
37 template<
typename T,
typename U>
38 std::vector<std::pair<T, U>>
zip(
const std::vector<T>& r1,
const std::vector<U> r2) {
39 std::vector<std::pair<T, U>> result;
40 zip(std::cbegin(r1), std::cend(r1), std::cbegin(r2), std::cend(r2), std::back_inserter(result));
45 template<
typename T,
typename U, std::
size_t V>
46 std::array<std::pair<T, U>, V>
zip(
const std::array<T, V>& r1,
const std::array<U, V>& r2) {
47 std::array<std::pair<T, U>, V> result;
48 std::size_t index = 0;
49 auto it1{ std::cbegin(r1) };
50 auto it2{ std::cbegin(r2) };
51 while (it1 != std::cend(r1) && it2 != std::cend(r2)) { result[index++] = { *it1++, *it2++ }; }
double urand() noexcept
Definition: utils.h:12
constexpr double PI
Definition: utils.h:9
constexpr auto toInteger(E enumerator) noexcept
Definition: utils.h:23
void zip(In1 begin1, In2 end1, In2 begin2, In2 end2, Out result)
Definition: utils.h:30