thrust::tabulate#
Overloads#
tabulate(exec, first, last, unary_op)#
-
template<typename DerivedPolicy, typename ForwardIterator, typename UnaryOperation>
void thrust::tabulate( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- ForwardIterator first,
- ForwardIterator last,
- UnaryOperation unary_op,
tabulatefills the range[first, last)with the value of a function applied to each element’s index.For each iterator
iin the range[first, last),tabulateperforms the assignment*i = unary_op(i - first).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
tabulateto generate the firstnnon-positive integers using thethrust::hostexecution policy for parallelization:#include <thrust/tabulate.h> #include <thrust/functional.h> #include <thrust/execution_policy.h> ... const int N = 10; int A[N]; thrust::tabulate(thrust::host, A, A + 10, ::cuda::std::negate<int>()); // A is now {0, -1, -2, -3, -4, -5, -6, -7, -8, -9}
See also
See also
See also
- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the range.
last – The end of the range.
unary_op – The unary operation to apply.
- Template Parameters:
DerivedPolicy – The name of the derived execution policy.
ForwardIterator – is a model of Forward Iterator, and
ForwardIteratoris mutable, and ifxandyare objects ofForwardIterator'svalue_type, thenx + yis defined, and ifTisForwardIterator'svalue_type, thenT(0)is defined.UnaryOperation – The function’s return type must be convertible to
OutputIterator'svalue_type.
tabulate(first, last, unary_op)#
-
template<typename ForwardIterator, typename UnaryOperation>
void thrust::tabulate( - ForwardIterator first,
- ForwardIterator last,
- UnaryOperation unary_op,
tabulatefills the range[first, last)with the value of a function applied to each element’s index.For each iterator
iin the range[first, last),tabulateperforms the assignment*i = unary_op(i - first).The following code snippet demonstrates how to use
tabulateto generate the firstnnon-positive integers:#include <thrust/tabulate.h> #include <thrust/functional.h> ... const int N = 10; int A[N]; thrust::tabulate(A, A + 10, ::cuda::std::negate<int>()); // A is now {0, -1, -2, -3, -4, -5, -6, -7, -8, -9}
See also
See also
See also
- Parameters:
first – The beginning of the range.
last – The end of the range.
unary_op – The unary operation to apply.
- Template Parameters:
ForwardIterator – is a model of Forward Iterator, and
ForwardIteratoris mutable, and ifxandyare objects ofForwardIterator'svalue_type, thenx + yis defined, and ifTisForwardIterator'svalue_type, thenT(0)is defined.UnaryOperation – The function’s return type must be convertible to
OutputIterator'svalue_type.