thrust
|
Functions | |
template<typename DerivedPolicy , typename ForwardIterator , typename T > | |
__host__ __device__ void | thrust::replace (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, const T &old_value, const T &new_value) |
template<typename ForwardIterator , typename T > | |
void | thrust::replace (ForwardIterator first, ForwardIterator last, const T &old_value, const T &new_value) |
template<typename DerivedPolicy , typename ForwardIterator , typename Predicate , typename T > | |
__host__ __device__ void | thrust::replace_if (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, Predicate pred, const T &new_value) |
template<typename ForwardIterator , typename Predicate , typename T > | |
void | thrust::replace_if (ForwardIterator first, ForwardIterator last, Predicate pred, const T &new_value) |
template<typename DerivedPolicy , typename ForwardIterator , typename InputIterator , typename Predicate , typename T > | |
__host__ __device__ void | thrust::replace_if (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred, const T &new_value) |
template<typename ForwardIterator , typename InputIterator , typename Predicate , typename T > | |
void | thrust::replace_if (ForwardIterator first, ForwardIterator last, InputIterator stencil, Predicate pred, const T &new_value) |
template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename T > | |
__host__ __device__ OutputIterator | thrust::replace_copy (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value) |
template<typename InputIterator , typename OutputIterator , typename T > | |
OutputIterator | thrust::replace_copy (InputIterator first, InputIterator last, OutputIterator result, const T &old_value, const T &new_value) |
template<typename DerivedPolicy , typename InputIterator , typename OutputIterator , typename Predicate , typename T > | |
__host__ __device__ OutputIterator | thrust::replace_copy_if (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T &new_value) |
template<typename InputIterator , typename OutputIterator , typename Predicate , typename T > | |
OutputIterator | thrust::replace_copy_if (InputIterator first, InputIterator last, OutputIterator result, Predicate pred, const T &new_value) |
template<typename DerivedPolicy , typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate , typename T > | |
__host__ __device__ OutputIterator | thrust::replace_copy_if (const thrust::detail::execution_policy_base< DerivedPolicy > &exec, InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred, const T &new_value) |
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename Predicate , typename T > | |
OutputIterator | thrust::replace_copy_if (InputIterator1 first, InputIterator1 last, InputIterator2 stencil, OutputIterator result, Predicate pred, const T &new_value) |
__host__ __device__ void thrust::replace | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
ForwardIterator | first, | ||
ForwardIterator | last, | ||
const T & | old_value, | ||
const T & | new_value | ||
) |
replace
replaces every element in the range [first, last) equal to old_value
with new_value
. That is: for every iterator i
, if *i == old_value
then it performs the assignment *i = new_value
.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
old_value | The value to replace. |
new_value | The new value to replace old_value . |
DerivedPolicy | The name of the derived execution policy. |
ForwardIterator | is a model of Forward Iterator, and ForwardIterator is mutable. |
T | is a model of Assignable, T is a model of EqualityComparable, objects of T may be compared for equality with objects of ForwardIterator's value_type , and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace
to replace a value of interest in a device_vector
with another using the thrust::device
execution policy for parallelization:
void thrust::replace | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
const T & | old_value, | ||
const T & | new_value | ||
) |
replace
replaces every element in the range [first, last) equal to old_value
with new_value
. That is: for every iterator i
, if *i == old_value
then it performs the assignment *i = new_value
.
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
old_value | The value to replace. |
new_value | The new value to replace old_value . |
ForwardIterator | is a model of Forward Iterator, and ForwardIterator is mutable. |
T | is a model of Assignable, T is a model of EqualityComparable, objects of T may be compared for equality with objects of ForwardIterator's value_type , and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace
to replace a value of interest in a device_vector
with another.
__host__ __device__ OutputIterator thrust::replace_copy | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
InputIterator | first, | ||
InputIterator | last, | ||
OutputIterator | result, | ||
const T & | old_value, | ||
const T & | new_value | ||
) |
replace_copy
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element equal to old_value
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first
, replace_copy
performs the assignment *(result+n) = new_value
if *(first+n) == old_value
, and *(result+n) = *(first+n)
otherwise.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
result | The beginning of the sequence to copy to. |
old_value | The value to replace. |
new_value | The replacement value for which *i == old_value evaluates to true . |
result + (last-first)
DerivedPolicy | The name of the derived execution policy. |
InputIterator | is a model of Input Iterator. |
OutputIterator | is a model of Output Iterator. |
T | is a model of Assignable, T is a model of Equality Comparable, T may be compared for equality with InputIterator's value_type , and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise.OutputIterator thrust::replace_copy | ( | InputIterator | first, |
InputIterator | last, | ||
OutputIterator | result, | ||
const T & | old_value, | ||
const T & | new_value | ||
) |
replace_copy
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element equal to old_value
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first
, replace_copy
performs the assignment *(result+n) = new_value
if *(first+n) == old_value
, and *(result+n) = *(first+n)
otherwise.
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
result | The beginning of the sequence to copy to. |
old_value | The value to replace. |
new_value | The replacement value for which *i == old_value evaluates to true . |
result + (last-first)
InputIterator | is a model of Input Iterator. |
OutputIterator | is a model of Output Iterator. |
T | is a model of Assignable, T is a model of Equality Comparable, T may be compared for equality with InputIterator's value_type , and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise.__host__ __device__ OutputIterator thrust::replace_copy_if | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
InputIterator | first, | ||
InputIterator | last, | ||
OutputIterator | result, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_copy_if
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element for which pred
is true
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first, replace_copy_if
performs the assignment *(result+n) = new_value
if pred(*(first+n))
, and *(result+n) = *(first+n)
otherwise.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
result | The beginning of the sequence to copy to. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The replacement value to assign pred(*i) evaluates to true . |
result + (last-first)
DerivedPolicy | The name of the derived execution policy. |
InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to Predicate's argument_type . |
OutputIterator | is a model of Output Iterator. |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise.OutputIterator thrust::replace_copy_if | ( | InputIterator | first, |
InputIterator | last, | ||
OutputIterator | result, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_copy_if
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element for which pred
is true
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first, replace_copy_if
performs the assignment *(result+n) = new_value
if pred(*(first+n))
, and *(result+n) = *(first+n)
otherwise.
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
result | The beginning of the sequence to copy to. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The replacement value to assign pred(*i) evaluates to true . |
result + (last-first)
InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to Predicate's argument_type . |
OutputIterator | is a model of Output Iterator. |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise.__host__ __device__ OutputIterator thrust::replace_copy_if | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
InputIterator1 | first, | ||
InputIterator1 | last, | ||
InputIterator2 | stencil, | ||
OutputIterator | result, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
This version of replace_copy_if
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element whose corresponding stencil element causes pred
to be true
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first
, replace_copy_if
performs the assignment *(result+n) = new_value
if pred(*(stencil+n))
, and *(result+n) = *(first+n)
otherwise.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
stencil | The beginning of the stencil sequence. |
result | The beginning of the sequence to copy to. |
pred | The predicate to test on every value of the range [stencil, stencil + (last - first)) . |
new_value | The replacement value to assign when pred(*s) evaluates to true . |
result + (last-first)
DerivedPolicy | The name of the derived execution policy. |
InputIterator1 | is a model of Input Iterator. |
InputIterator2 | is a model of Input Iterator and InputIterator2's value_type is convertible to Predicate's argument_type . |
OutputIterator | is a model of Output Iterator. |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise. stencil
may equal result
, but the ranges [stencil, stencil + (last - first))
and [result, result + (last - first))
shall not overlap otherwise.replace_copy
replace_if
OutputIterator thrust::replace_copy_if | ( | InputIterator1 | first, |
InputIterator1 | last, | ||
InputIterator2 | stencil, | ||
OutputIterator | result, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
This version of replace_copy_if
copies elements from the range [first, last)
to the range [result, result + (last-first))
, except that any element whose corresponding stencil element causes pred
to be true
is not copied; new_value
is copied instead.
More precisely, for every integer n
such that 0 <= n < last-first
, replace_copy_if
performs the assignment *(result+n) = new_value
if pred(*(stencil+n))
, and *(result+n) = *(first+n)
otherwise.
first | The beginning of the sequence to copy from. |
last | The end of the sequence to copy from. |
stencil | The beginning of the stencil sequence. |
result | The beginning of the sequence to copy to. |
pred | The predicate to test on every value of the range [stencil, stencil + (last - first)) . |
new_value | The replacement value to assign when pred(*s) evaluates to true . |
result + (last-first)
InputIterator1 | is a model of Input Iterator. |
InputIterator2 | is a model of Input Iterator and InputIterator2's value_type is convertible to Predicate's argument_type . |
OutputIterator | is a model of Output Iterator. |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to OutputIterator's value_type . |
first
may equal result
, but the ranges [first, last)
and [result, result + (last - first))
shall not overlap otherwise. stencil
may equal result
, but the ranges [stencil, stencil + (last - first))
and [result, result + (last - first))
shall not overlap otherwise.replace_copy
replace_if
__host__ __device__ void thrust::replace_if | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
ForwardIterator | first, | ||
ForwardIterator | last, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_if
replaces every element in the range [first, last)
for which pred
returns true
with new_value
. That is: for every iterator i
, if pred(*i)
is true
then it performs the assignment *i = new_value
.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The new value to replace elements which pred(*i) evaluates to true . |
DerivedPolicy | The name of the derived execution policy. |
ForwardIterator | is a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type is convertible to Predicate's argument_type . |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace_if
to replace a device_vector's
negative elements with 0
using the thrust::device
execution policy for parallelization:
void thrust::replace_if | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_if
replaces every element in the range [first, last)
for which pred
returns true
with new_value
. That is: for every iterator i
, if pred(*i)
is true
then it performs the assignment *i = new_value
.
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The new value to replace elements which pred(*i) evaluates to true . |
ForwardIterator | is a model of Forward Iterator, ForwardIterator is mutable, and ForwardIterator's value_type is convertible to Predicate's argument_type . |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace_if
to replace a device_vector's
negative elements with 0
.
__host__ __device__ void thrust::replace_if | ( | const thrust::detail::execution_policy_base< DerivedPolicy > & | exec, |
ForwardIterator | first, | ||
ForwardIterator | last, | ||
InputIterator | stencil, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_if
replaces every element in the range [first, last)
for which pred(*s)
returns true
with new_value
. That is: for every iterator i
in the range [first, last)
, and s
in the range [stencil, stencil + (last - first))
, if pred(*s)
is true
then it performs the assignment *i = new_value
.
The algorithm's execution is parallelized as determined by exec
.
exec | The execution policy to use for parallelization. |
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
stencil | The beginning of the stencil sequence. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The new value to replace elements which pred(*i) evaluates to true . |
DerivedPolicy | The name of the derived execution policy. |
ForwardIterator | is a model of Forward Iterator, and ForwardIterator is mutable. |
InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to Predicate's argument_type . |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace_if
to replace a device_vector's
element with 0
when its corresponding stencil element is less than zero using the thrust::device
execution policy for parallelization:
void thrust::replace_if | ( | ForwardIterator | first, |
ForwardIterator | last, | ||
InputIterator | stencil, | ||
Predicate | pred, | ||
const T & | new_value | ||
) |
replace_if
replaces every element in the range [first, last)
for which pred(*s)
returns true
with new_value
. That is: for every iterator i
in the range [first, last)
, and s
in the range [stencil, stencil + (last - first))
, if pred(*s)
is true
then it performs the assignment *i = new_value
.
first | The beginning of the sequence of interest. |
last | The end of the sequence of interest. |
stencil | The beginning of the stencil sequence. |
pred | The predicate to test on every value of the range [first,last) . |
new_value | The new value to replace elements which pred(*i) evaluates to true . |
ForwardIterator | is a model of Forward Iterator, and ForwardIterator is mutable. |
InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to Predicate's argument_type . |
Predicate | is a model of Predicate. |
T | is a model of Assignable, and T is convertible to ForwardIterator's value_type . |
The following code snippet demonstrates how to use replace_if
to replace a device_vector's
element with 0
when its corresponding stencil element is less than zero.