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/all/StdReplaceIf.html below:

replace_if - Kokkos documentation

Toggle table of contents sidebar

replace_if

Header File: Kokkos_StdAlgorithms.hpp

namespace Kokkos{
namespace Experimental{

template <class ExecutionSpace, class IteratorType, class UnaryPredicateType, class T>
void replace_if(const ExecutionSpace& exespace,                              (1)
                IteratorType first, IteratorType last,
                UnaryPredicateType pred, const T& new_value);

template <class ExecutionSpace, class IteratorType, class UnaryPredicateType, class T>
void replace_if(const std::string& label, const ExecutionSpace& exespace,    (2)
                IteratorType first, IteratorType last,
                UnaryPredicateType pred, const T& new_value);

template <class ExecutionSpace, class DataType, class... Properties, class UnaryPredicateType, class T>
void replace_if(const ExecutionSpace& exespace,                              (3)
                const Kokkos::View<DataType, Properties...>& view,
                UnaryPredicateType pred, const T& new_value);

template <class ExecutionSpace, class DataType, class... Properties, class UnaryPredicateType, class T>
void replace_if(const std::string& label, const ExecutionSpace& exespace,    (4)
                const Kokkos::View<DataType, Properties...>& view,
                UnaryPredicateType pred, const T& new_value);

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

Replaces with new_value all the elements for which pred is true in the range [first, last) (overloads 1,2) or in view (overloads 3,4).

Parameters and Requirements Return

None

Example
template <class ValueType>
struct IsPositiveFunctor {
  KOKKOS_INLINE_FUNCTION
  bool operator()(const ValueType val) const { return (val > 0); }
};
// ---

namespace KE = Kokkos::Experimental;
Kokkos::View<double*> a("a", 13);
// do something with a
// ...

const double oldValue{2};
const double newValue{34};
KE::replace_if(Kokkos::DefaultExecutionSpace(), KE::begin(a), KE::end(a),
   IsPositiveFunctor<double>(), newValue);

// explicitly set label and execution space (assuming active)
KE::replace_if("mylabel", Kokkos::OpenMP(), a,
   IsPositiveFunctor<double>(), newValue);

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