Distributed Ranges
Loading...
Searching...
No Matches
iota.hpp
1// SPDX-FileCopyrightText: Intel Corporation
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
5#pragma once
6
7#include <limits>
8
9#include <dr/concepts/concepts.hpp>
10#include <dr/detail/ranges_shim.hpp>
11#include <dr/sp/algorithms/for_each.hpp>
12#include <dr/views/iota.hpp>
13
14namespace dr::sp {
15
16template <dr::distributed_range R, std::integral T> void iota(R &&r, T value) {
17 auto iota_view = rng::views::iota(value, T(value + rng::distance(r)));
18
19 for_each(par_unseq, views::zip(iota_view, r), [](auto &&elem) {
20 auto &&[idx, v] = elem;
21 v = idx;
22 });
23}
24
25template <dr::distributed_iterator Iter, std::integral T>
26void iota(Iter begin, Iter end, T value) {
27 auto r = rng::subrange(begin, end);
28 iota(r, value);
29}
30
31} // namespace dr::sp