39 #ifndef ECUDA_NUMERIC_HPP
40 #define ECUDA_NUMERIC_HPP
53 template<
class InputIterator,
typename T,
class BinaryOperation>
58 while( first != last ) { init = op(init,*first); ++first; }
61 const bool isIteratorContiguous = ecuda::is_same<typename ecuda::iterator_traits<InputIterator>::is_contiguous,ecuda::true_type>::value;
62 ECUDA_STATIC_ASSERT(isIteratorContiguous,CANNOT_ACCUMULATE_RANGE_REPRESENTED_BY_NONCONTIGUOUS_DEVICE_MEMORY);
64 std::vector<typename ecuda::iterator_traits<InputIterator>::value_type> hostVector( n );
66 return std::accumulate( hostVector.begin(), hostVector.end(), init, op );
70 template<
class InputIterator,
typename T>
75 while( first != last ) { init += *first; ++first; }
78 const bool isIteratorContiguous = ecuda::is_same<typename ecuda::iterator_traits<InputIterator>::is_contiguous,ecuda::true_type>::value;
79 ECUDA_STATIC_ASSERT(isIteratorContiguous,CANNOT_ACCUMULATE_RANGE_REPRESENTED_BY_NONCONTIGUOUS_DEVICE_MEMORY);
81 std::vector<typename ecuda::iterator_traits<InputIterator>::value_type> hostVector( n );
87 template<
class InputIterator,
typename T,
class BinaryOperation>
98 template<
class InputIterator,
typename T>
121 template<
class InputIterator,
typename T>
142 template<
class InputIterator,
typename T,
class BinaryOperation>
__HOST__ __DEVICE__ OutputIterator copy(InputIterator first, InputIterator last, OutputIterator result)
Replacement for std::copy.
__HOST__ __DEVICE__ T accumulate(InputIterator first, InputIterator last, T init, BinaryOperation op)
Computes the sum of a sequence of elements.
__HOST__ __DEVICE__ T accumulate(InputIterator first, InputIterator last, T init)
Computes the sum of a sequence of elements.
ecuda::false_type is_device_iterator
#define ECUDA_STATIC_ASSERT(x, msg)
base_type::difference_type difference_type
ECUDA_SUPPRESS_HD_WARNINGS __HOST__ __DEVICE__ std::iterator_traits< Iterator >::difference_type distance(const Iterator &first, const Iterator &last)