thrust::sequence#
Overloads#
sequence(exec, first, last)#
-
template<typename DerivedPolicy, typename ForwardIterator>
void thrust::sequence( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- ForwardIterator first,
- ForwardIterator last,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = (i - first).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers using thethrust::hostexecution policy for parallelization:#include <thrust/sequence.h> #include <thrust/execution_policy.h> ... const int N = 10; int A[N]; thrust::sequence(thrust::host, A, A + 10); // A is now {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the sequence.
last – The end of the sequence.
- 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.
sequence(first, last)#
-
template<typename ForwardIterator>
void thrust::sequence( - ForwardIterator first,
- ForwardIterator last,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = (i - first).The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers.#include <thrust/sequence.h> ... const int N = 10; int A[N]; thrust::sequence(A, A + 10); // A is now {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
first – The beginning of the sequence.
last – The end of the sequence.
- 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.
sequence(exec, first, last, init)#
-
template<typename DerivedPolicy, typename ForwardIterator, typename T>
void thrust::sequence( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- ForwardIterator first,
- ForwardIterator last,
- T init,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = init + (i - first).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers starting from the value 1 using thethrust::hostexecution policy for parallelization:#include <thrust/sequence.h> #include <thrust/execution_policy.h> ... const int N = 10; int A[N]; thrust::sequence(thrust::host, A, A + 10, 1); // A is now {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the sequence.
last – The end of the sequence.
init – The first value of the sequence of numbers.
- 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.T – is a model of Assignable, and
Tis convertible toForwardIterator'svalue_type.
sequence(first, last, init)#
-
template<typename ForwardIterator, typename T>
void thrust::sequence( - ForwardIterator first,
- ForwardIterator last,
- T init,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = init + (i - first).The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers starting from the value 1.#include <thrust/sequence.h> ... const int N = 10; int A[N]; thrust::sequence(A, A + 10, 1); // A is now {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
first – The beginning of the sequence.
last – The end of the sequence.
init – The first value of the sequence of numbers.
- 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.T – is a model of Assignable, and
Tis convertible toForwardIterator'svalue_type.
sequence(exec, first, last, init, step)#
-
template<typename DerivedPolicy, typename ForwardIterator, typename T>
void thrust::sequence( - const thrust::detail::execution_policy_base<DerivedPolicy> &exec,
- ForwardIterator first,
- ForwardIterator last,
- T init,
- T step,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = init + step * (i - first).The algorithm’s execution is parallelized as determined by
exec.The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers starting from the value 1 with a step size of 3 using thethrust::hostexecution policy for parallelization:#include <thrust/sequence.h> #include <thrust/execution_policy.h> ... const int N = 10; int A[N]; thrust::sequence(thrust::host, A, A + 10, 1, 3); // A is now {1, 4, 7, 10, 13, 16, 19, 22, 25, 28}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
exec – The execution policy to use for parallelization.
first – The beginning of the sequence.
last – The end of the sequence.
init – The first value of the sequence of numbers
step – The difference between consecutive elements.
- 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.T – is a model of Assignable, and
Tis convertible toForwardIterator'svalue_type.
sequence(first, last, init, step)#
-
template<typename ForwardIterator, typename T>
void thrust::sequence( - ForwardIterator first,
- ForwardIterator last,
- T init,
- T step,
sequencefills the range[first, last)with a sequence of numbers.For each iterator
iin the range[first, last), this version ofsequenceperforms the assignment*i = init + step * (i - first).The following code snippet demonstrates how to use
sequenceto fill a range with a sequence of numbers starting from the value 1 with a step size of 3.#include <thrust/sequence.h> ... const int N = 10; int A[N]; thrust::sequence(A, A + 10, 1, 3); // A is now {1, 4, 7, 10, 13, 16, 19, 22, 25, 28}
Note
Unlike the similar C++ STL function
std::iota,sequenceoffers no guarantee on order of execution.- Parameters:
first – The beginning of the sequence.
last – The end of the sequence.
init – The first value of the sequence of numbers
step – The difference between consecutive elements.
- 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.T – is a model of Assignable, and
Tis convertible toForwardIterator'svalue_type.