| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
|
|
| #pragma once |
|
|
| #include <thrust/detail/config.h> |
|
|
| #if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC) |
| # pragma GCC system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG) |
| # pragma clang system_header |
| #elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC) |
| # pragma system_header |
| #endif |
| #include <thrust/system/detail/sequential/execution_policy.h> |
| #include <thrust/iterator/iterator_traits.h> |
| #include <thrust/detail/type_traits.h> |
| #include <thrust/detail/type_traits/function_traits.h> |
| #include <thrust/detail/type_traits/iterator/is_output_iterator.h> |
| #include <thrust/detail/function.h> |
|
|
| THRUST_NAMESPACE_BEGIN |
| namespace system |
| { |
| namespace detail |
| { |
| namespace sequential |
| { |
|
|
|
|
| __thrust_exec_check_disable__ |
| template<typename DerivedPolicy, |
| typename InputIterator, |
| typename OutputIterator, |
| typename BinaryFunction> |
| __host__ __device__ |
| OutputIterator inclusive_scan(sequential::execution_policy<DerivedPolicy> &, |
| InputIterator first, |
| InputIterator last, |
| OutputIterator result, |
| BinaryFunction binary_op) |
| { |
| using namespace thrust::detail; |
|
|
| |
| using ValueType = typename thrust::iterator_value<InputIterator>::type; |
|
|
| |
| thrust::detail::wrapped_function< |
| BinaryFunction, |
| ValueType |
| > wrapped_binary_op(binary_op); |
|
|
| if(first != last) |
| { |
| ValueType sum = *first; |
|
|
| *result = *first; |
|
|
| for(++first, ++result; first != last; ++first, ++result) |
| *result = sum = wrapped_binary_op(sum,*first); |
| } |
|
|
| return result; |
| } |
|
|
|
|
| __thrust_exec_check_disable__ |
| template<typename DerivedPolicy, |
| typename InputIterator, |
| typename OutputIterator, |
| typename InitialValueType, |
| typename BinaryFunction> |
| __host__ __device__ |
| OutputIterator exclusive_scan(sequential::execution_policy<DerivedPolicy> &, |
| InputIterator first, |
| InputIterator last, |
| OutputIterator result, |
| InitialValueType init, |
| BinaryFunction binary_op) |
| { |
| using namespace thrust::detail; |
|
|
| |
| using ValueType = InitialValueType; |
|
|
| if(first != last) |
| { |
| ValueType tmp = *first; |
| ValueType sum = init; |
|
|
| *result = sum; |
| sum = binary_op(sum, tmp); |
|
|
| for(++first, ++result; first != last; ++first, ++result) |
| { |
| tmp = *first; |
| *result = sum; |
| sum = binary_op(sum, tmp); |
| } |
| } |
|
|
| return result; |
| } |
|
|
|
|
| } |
| } |
| } |
| THRUST_NAMESPACE_END |
|
|
|
|