Distributed Ranges
Loading...
Searching...
No Matches
include
dr
sp
containers
detail.hpp
1
// SPDX-FileCopyrightText: Intel Corporation
2
//
3
// SPDX-License-Identifier: BSD-3-Clause
4
5
#pragma once
6
7
#include <cmath>
8
9
namespace
dr::sp {
10
11
namespace
detail {
12
13
// Factor n into 2 roughly equal factors
14
// n = pq, p >= q
15
inline
std::tuple<std::size_t, std::size_t> factor(std::size_t n) {
16
std::size_t q = std::sqrt(n);
17
18
while
(q > 1 && n / q !=
static_cast<
double
>
(n) / q) {
19
q--;
20
}
21
std::size_t p = n / q;
22
23
return
{p, q};
24
}
25
26
}
// namespace detail
27
28
}
// namespace dr::sp
Generated by
1.9.6