15 #ifndef CORE_ALGORITHM_H_
16 #define CORE_ALGORITHM_H_
33 uint64_t logn =
static_cast<uint64_t
>(std::ceil(std::log2(n)));
34 for (uint64_t d = 0; d < logn; ++d) {
35 uint64_t stride = 1 << (d + 1);
36 uint64_t delta = 1 << d;
38 #pragma omp parallel for
39 for (uint64_t i = delta - 1; i < n - delta; i += stride) {
45 for (uint64_t d = 0; d < logn - 1; ++d) {
46 uint64_t stride = 1 << (logn - d - 1);
47 uint64_t delta = 1 << (logn - d - 2);
49 #pragma omp parallel for
50 for (uint64_t i = stride - 1; i < n - delta; i += stride) {
64 for (uint64_t i = 1; i <= n; ++i) {
65 auto result = (*v)[i - 1] + tmp;
75 template <
typename TSearch,
typename TContainer>
76 uint64_t
BinarySearch(
const TSearch& search_val,
const TContainer& container,
77 uint64_t from, uint64_t to) {
79 if (container[from] != search_val && from > 0) {
87 auto m = (from + to) / 2;
88 if (container[m] == search_val) {
89 if (m + 1 <= to && container[m + 1] == search_val) {
93 }
else if (container[m] > search_val) {
102 #endif // CORE_ALGORITHM_H_