21 #ifndef __stdAlgorithms_hpp__
22 #define __stdAlgorithms_hpp__
34 template<
typename Type,
bool useParallel = useStdParallel__>
38 if constexpr (useParallel)
40 std::execution::par_unseq,
41 first, first+numElems,
42 [=](
const Type& check){
return equal(check,val);} );
45 first, first+numElems,
46 [=](
const Type& check){
return equal(check,val);} );
51 template<
typename Type,
bool useParallel = useStdParallel__>
53 void fill(Type* first,
int32 numElems,
const Type& val)
55 if constexpr (useParallel)
56 std::fill(std::execution::par_unseq, first, first+numElems, val);
61 template<
typename Type,
typename indexType,
bool useParallel = useStdParallel__>
63 void fillSelected(Type* first,
const indexType* indices,
const int32 numElems,
const Type val)
65 if constexpr(useParallel)
68 std::execution::par_unseq,
86 template<
typename Type,
typename indexType,
bool useParallel = useStdParallel__>
88 void fillSelected(Type* first,
const indexType* indices,
const Type* vals,
const int32 numElems)
90 for(indexType i=0; i<numElems; i++)
92 first[indices[i]]=vals[i];
96 template<
typename Type,
bool useParallel = useStdParallel__>
100 if constexpr (useParallel)
102 std::execution::par_unseq,
105 [=](Type& ref){ ref = firstVal+std::distance(first,&ref);});
107 std::iota(first, first+numElems, firstVal);
110 template<
typename Type,
bool useParallel = useStdParallel__>
114 if constexpr(useParallel)
115 return *std::max_element(
116 std::execution::par_unseq,
121 return *std::max_element(
127 template<
typename Type,
bool useParallel = useStdParallel__>
131 if constexpr(useParallel)
132 return *(std::min_element(
133 std::execution::par_unseq,
138 return *(std::min_element(
144 template<
typename Type,
bool useParallel = useStdParallel__>
148 if constexpr(useParallel)
165 template<
typename Type,
typename CompareFunc,
bool useParallel = useStdParallel__>
167 void sort(Type* first,
int32 numElems, CompareFunc compare)
169 if constexpr(useParallel)
172 std::execution::par_unseq,
186 template<
typename Type,
typename PermuteType,
bool useParallel = useStdParallel__>
193 bool operator()(
const PermuteType& lhs,
const PermuteType& rhs)
const {
194 return first_[lhs]<first_[rhs]; }
197 compOperator compare{first};
198 fillSequence<PermuteType, useParallel>(pFirst, numElems,
static_cast<PermuteType
>(0));
199 sort<PermuteType, compOperator, useParallel>(pFirst, numElems, compare);
203 template<
typename Type,
typename DestType,
bool useParallel = useStdParallel__>
206 if constexpr (useParallel)
211 first, first+numElems,
217 first, first+numElems,
222 template<
typename Type,
typename DestType,
bool useParallel = useStdParallel__>
225 if constexpr (useParallel)
228 std::execution::par_unseq,
229 first, first+numElems,
235 first, first+numElems,
243 #endif //__stdAlgorithms_hpp__