A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://kokkos.github.io/kokkos-core-wiki/API/algorithms/std-algorithms/Iterators.html below:

Iterators - Kokkos documentation

Toggle table of contents sidebar

Iterators Kokkos::Experimental::{begin, cbegin, end, cend}

Header File: <Kokkos_StdAlgorithms.hpp>

template<class DataType, class ...Properties>
KOKKOS_INLINE_FUNCTION auto begin(const Kokkos::View<DataType, Properties...> &view);

Returns a Kokkos random access iterator to the beginning of view

template<class DataType, class ...Properties>
KOKKOS_INLINE_FUNCTION auto cbegin(const Kokkos::View<DataType, Properties...> &view);

Returns a Kokkos const-qualified random access iterator to the beginning of view

template<class DataType, class ...Properties>
KOKKOS_INLINE_FUNCTION auto end(const Kokkos::View<DataType, Properties...> &view);

Returns a Kokkos random access iterator to the element past the end of view

template<class DataType, class ...Properties>
KOKKOS_INLINE_FUNCTION auto cend(const Kokkos::View<DataType, Properties...> &view);

Returns a const-qualified Kokkos random access iterator to the element past the end of view

Notes Parameters and Requirements Example
namespace KE = Kokkos::Experimental;
using view_type = Kokkos::View<int*>;
view_type a("a", 15);

auto it = KE::begin(a);
// if dereferenced (within a proper execution space), can modify the content of `a`

auto itc = KE::cbegin(a);
// if dereferenced (within a proper execution space), can only read the content of `a`
Kokkos::Experimental::distance
template<class IteratorType>
KOKKOS_INLINE_FUNCTION constexpr typename IteratorType::difference_type distance(IteratorType first, IteratorType last);

Returns the number of steps needed to go from first to last.

Parameters and Requirements Return

The number of steps needed to go from first to last. The value may be negative if random-access iterators are used.

Example
namespace KE = Kokkos::Experimental;
Kokkos::View<double*> a("a", 13);

auto it1 = KE::begin(a);
auto it2 = it1 + 4;
const auto stepsA = KE::distance(it1, it2);
// stepsA should be equal to 4

const auto stepsB = KE::distance(it2, it1);
// stepsB should be equal to -4
Kokkos::Experimental::iter_swap
template<class IteratorType>
void iter_swap(IteratorType first, IteratorType last);

Swaps the values of the elements the given iterators are pointing to.

Parameters and Requirements Notes

Currently, the API does not have an execution space parameter because the operation is performed in the default execution space. The operation fences the default execution space.

Return

None

Example
namespace KE = Kokkos::Experimental;
Kokkos::View<double*> a("a", 13);

auto it1 = KE::begin(a);
auto it2 = it1 + 4;
KE::swap(it1, it2);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4