generate_n#

Header File: Kokkos_StdAlgorithms.hpp

namespace Kokkos{
namespace Experimental{

template <class ExecutionSpace, class IteratorType, class SizeType, class GeneratorType>
IteratorType generate_n(const ExecutionSpace& exespace,                      (1)
                        IteratorType first, SizeType n,
                        GeneratorType g);

template <class ExecutionSpace, class IteratorType, class SizeType, class GeneratorType>
IteratorType generate_n(const std::string& label,
                        const ExecutionSpace& exespace,                      (2)
                        IteratorType first, SizeType n,
                        GeneratorType g);

template <
  class ExecutionSpace, class DataType, class... Properties, class SizeType, class GeneratorType
>
auto generate_n(const ExecutionSpace& exespace,                              (3)
                const Kokkos::View<DataType, Properties...>& view,
                SizeType n, GeneratorType g);

template <
  class ExecutionSpace, class DataType, class... Properties, class SizeType, class GeneratorType
>
auto generate_n(const std::string& label,                                    (4)
                const ExecutionSpace& exespace,
                const Kokkos::View<DataType, Properties...>& view,
                SizeType n, GeneratorType g);

} //end namespace Experimental
} //end namespace Kokkos

Description#

Assigns the value generated by the functor g to the first n elements starting at first (overloads 1,2) or the first n elements in view (overloads 3,4).

Parameters and Requirements#

  • exespace, first, view, g: same as generate

  • label:

    • for 1, the default string is: “Kokkos::generate_n_iterator_api_default”

    • for 3, the default string is: “Kokkos::generate_n_view_api_default”

  • n:

    • number of elements to modify (must be non-negative)

Return#

If n>0, returns an iterator to the element after the last element modified.

Otherwise, returns first (for 1,2) or Kokkos::begin(view) (for 3,4).