Modules |
| | Filling |
| | Modifying |
| | Replacing |
Functions |
| template<typename InputIterator , typename OutputIterator > |
| OutputIterator | thrust::adjacent_difference (InputIterator first, InputIterator last, OutputIterator result) |
| template<typename InputIterator , typename OutputIterator , typename BinaryFunction > |
| OutputIterator | thrust::adjacent_difference (InputIterator first, InputIterator last, OutputIterator result, BinaryFunction binary_op) |
| template<typename ForwardIterator , typename Generator > |
| void | thrust::generate (ForwardIterator first, ForwardIterator last, Generator gen) |
| template<typename OutputIterator , typename Size , typename Generator > |
| OutputIterator | thrust::generate_n (OutputIterator first, Size n, Generator gen) |
| template<typename ForwardIterator > |
| void | thrust::sequence (ForwardIterator first, ForwardIterator last) |
| template<typename ForwardIterator , typename T > |
| void | thrust::sequence (ForwardIterator first, ForwardIterator last, T init) |
| template<typename ForwardIterator , typename T > |
| void | thrust::sequence (ForwardIterator first, ForwardIterator last, T init, T step) |
| template<typename InputIterator , typename OutputIterator , typename UnaryFunction > |
| OutputIterator | thrust::transform (InputIterator first, InputIterator last, OutputIterator result, UnaryFunction op) |
| template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename BinaryFunction > |
| OutputIterator | thrust::transform (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, OutputIterator result, BinaryFunction op) |
| template<typename InputIterator , typename ForwardIterator , typename UnaryFunction , typename Predicate > |
| ForwardIterator | thrust::transform_if (InputIterator first, InputIterator last, ForwardIterator result, UnaryFunction op, Predicate pred) |
| template<typename InputIterator1 , typename InputIterator2 , typename ForwardIterator , typename UnaryFunction , typename Predicate > |
| ForwardIterator | thrust::transform_if (InputIterator1 first, InputIterator1 last, InputIterator2 stencil, ForwardIterator result, UnaryFunction op, Predicate pred) |
| template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename ForwardIterator , typename BinaryFunction , typename Predicate > |
| ForwardIterator | thrust::transform_if (InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator3 stencil, ForwardIterator result, BinaryFunction binary_op, Predicate pred) |
template<typename InputIterator , typename OutputIterator >
| OutputIterator thrust::adjacent_difference |
( |
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
OutputIterator |
result |
|
) |
| |
adjacent_difference calculates the differences of adjacent elements in the range [first, last). That is, *first is assigned to *result, and, for each iterator i in the range [first + 1, last), the difference of *i and *(i - 1) is assigned to *(result + (i - first)).
This version of adjacent_difference uses operator- to calculate differences.
- Parameters:
-
| first | The beginning of the input range. |
| last | The end of the input range. |
| result | The beginning of the output range. |
- Returns:
- The iterator
result + (last - first)
- Template Parameters:
-
| InputIterator | is a model of Input Iterator, and x and y are objects of InputIterator's value_type, then x - is defined, and InputIterator's value_type is convertible to a type in OutputIterator's set of value_types, and the return type of x - y is convertible to a type in OutputIterator's set of value_types. |
| OutputIterator | is a model of Output Iterator. |
The following code snippet demonstrates how to use adjacent_difference to compute the difference between adjacent elements of a range.
#include <thrust/adjacent_difference.h>
#include <thrust/device_vector.h>
...
int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
thrust::device_vector<int> d_data(h_data, h_data + 8);
thrust::device_vector<int> d_result(8);
thrust::adjacent_difference(d_data.begin(), d_data.end(), d_result.begin());
- See also:
- http://www.sgi.com/tech/stl/adjacent_difference.html
-
inclusive_scan
- Note:
- Note that
result is permitted to be the same iterator as first. This is useful for computing differences "in place".
template<typename InputIterator , typename OutputIterator , typename BinaryFunction >
| OutputIterator thrust::adjacent_difference |
( |
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
OutputIterator |
result, |
|
|
BinaryFunction |
binary_op |
|
) |
| |
adjacent_difference calculates the differences of adjacent elements in the range [first, last). That is, *first is assigned to *result, and, for each iterator i in the range [first + 1, last), binary_op(*i, *(i - 1)) is assigned to *(result + (i - first)).
This version of adjacent_difference uses the binary function binary_op to calculate differences.
- Parameters:
-
| first | The beginning of the input range. |
| last | The end of the input range. |
| result | The beginning of the output range. |
| binary_op | The binary function used to compute differences. |
- Returns:
- The iterator
result + (last - first)
- Template Parameters:
-
| InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to BinaryFunction's first_argument_type and second_argument_type, and InputIterator's value_type is convertible to a type in OutputIterator's set of value_types. |
| OutputIterator | is a model of Output Iterator. |
| BinaryFunction's | result_type is convertible to a type in OutputIterator's set of value_types. |
The following code snippet demonstrates how to use adjacent_difference to compute the sum between adjacent elements of a range.
#include <thrust/adjacent_difference.h>
#include <thrust/functional.h>
#include <thrust/device_vector.h>
...
int h_data[8] = {1, 2, 1, 2, 1, 2, 1, 2};
thrust::device_vector<int> d_data(h_data, h_data + 8);
thrust::device_vector<int> d_result(8);
thrust::adjacent_difference(d_data.begin(), d_data.end(), d_result.begin(), thrust::plus<int>());
- See also:
- http://www.sgi.com/tech/stl/adjacent_difference.html
-
inclusive_scan
- Note:
- Note that
result is permitted to be the same iterator as first. This is useful for computing differences "in place".
template<typename ForwardIterator , typename T >
| void thrust::sequence |
( |
ForwardIterator |
first, |
|
|
ForwardIterator |
last, |
|
|
T |
init, |
|
|
T |
step |
|
) |
| |
sequence fills the range [first, last) with a sequence of numbers.
For each iterator i in the range [first, last), this version of sequence performs the assignment *i = init + step * (i - first).
- 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 ForwardIterator is mutable, and if x and y are objects of ForwardIterator's value_type, then x + y is defined, and if T is ForwardIterator's value_type, then T(0) is defined. |
| T | is a model of Assignable, and T is convertible to ForwardIterator's value_type. |
The following code snippet demonstrates how to use sequence to fill a range with a sequence of numbers starting from the value 1 with a step size of 3.
- Note:
- Unlike the similar C++ STL function
std::iota, sequence offers no guarantee on order of execution.
- See also:
- http://www.sgi.com/tech/stl/iota.html
template<typename InputIterator1 , typename InputIterator2 , typename OutputIterator , typename BinaryFunction >
| OutputIterator thrust::transform |
( |
InputIterator1 |
first1, |
|
|
InputIterator1 |
last1, |
|
|
InputIterator2 |
first2, |
|
|
OutputIterator |
result, |
|
|
BinaryFunction |
op |
|
) |
| |
This version of transform applies a binary function to each pair of elements from two input sequences and stores the result in the corresponding position in an output sequence. Specifically, for each iterator i in the range [first1, last1) and j = first + (i - first1) in the range [first2, last2) the operation op(*i,*j) is performed and the result is assigned to *o, where o is the corresponding output iterator in the range [result, result + (last - first) ). The input and output sequences may coincide, resulting in an in-place transformation.
- Parameters:
-
| first1 | The beginning of the first input sequence. |
| last1 | The end of the first input sequence. |
| first2 | The beginning of the second input sequence. |
| result | The beginning of the output sequence. |
| op | The tranformation operation. |
- Returns:
- The end of the output sequence.
- Template Parameters:
-
| InputIterator1 | is a model of Input Iterator and InputIterator1's value_type is convertible to BinaryFunction's first_argument_type. |
| InputIterator2 | is a model of Input Iterator and InputIterator2's value_type is convertible to BinaryFunction's second_argument_type. |
| OutputIterator | is a model of Output Iterator. |
| BinaryFunction | is a model of Binary Function and BinaryFunction's result_type is convertible to OutputIterator's value_type. |
The following code snippet demonstrates how to use transform
#include <thrust/transform.h>
#include <thrust/functional.h>
int input1[6] = {-5, 0, 2, 3, 2, 4};
int input2[6] = { 3, 6, -2, 1, 2, 3};
int output[6];
thrust::plus<int> op;
thrust::transform(input1, input1 + 6, input2, output, op);
- See also:
- http://www.sgi.com/tech/stl/transform.html
template<typename InputIterator , typename OutputIterator , typename UnaryFunction >
| OutputIterator thrust::transform |
( |
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
OutputIterator |
result, |
|
|
UnaryFunction |
op |
|
) |
| |
This version of transform applies a unary function to each element of an input sequence and stores the result in the corresponding position in an output sequence. Specifically, for each iterator i in the range [first, last) the operation op(*i) is performed and the result is assigned to *o, where o is the corresponding output iterator in the range [result, result + (last - first) ). The input and output sequences may coincide, resulting in an in-place transformation.
- Parameters:
-
| first | The beginning of the input sequence. |
| last | The end of the input sequence. |
| result | The beginning of the output sequence. |
| op | The tranformation operation. |
- Returns:
- The end of the output sequence.
- Template Parameters:
-
| InputIterator | is a model of Input Iterator and InputIterator's value_type is convertible to UnaryFunction's argument_type. |
| OutputIterator | is a model of Output Iterator. |
| UnaryFunction | is a model of Unary Function and UnaryFunction's result_type is convertible to OutputIterator's value_type. |
The following code snippet demonstrates how to use transform
#include <thrust/transform.h>
#include <thrust/functional.h>
int data[10] = {-5, 0, 2, -3, 2, 4, 0, -1, 2, 8};
thrust::negate<int> op;
thrust::transform(data, data + 10, data, op);
- See also:
- http://www.sgi.com/tech/stl/transform.html
template<typename InputIterator1 , typename InputIterator2 , typename ForwardIterator , typename UnaryFunction , typename Predicate >
| ForwardIterator thrust::transform_if |
( |
InputIterator1 |
first, |
|
|
InputIterator1 |
last, |
|
|
InputIterator2 |
stencil, |
|
|
ForwardIterator |
result, |
|
|
UnaryFunction |
op, |
|
|
Predicate |
pred |
|
) |
| |
This version of transform_if conditionally applies a unary function to each element of an input sequence and stores the result in the corresponding position in an output sequence if the corresponding position in a stencil sequence satisfies a predicate. Otherwise, the corresponding position in the output sequence is not modified.
Specifically, for each iterator i in the range [first, last) the predicate pred(*s) is evaluated, where s is the corresponding input iterator in the range [stencil, stencil + (last - first) ). If this predicate evaluates to true, the result of op(*i) is assigned to *o, where o is the corresponding output iterator in the range [result, result + (last - first) ). Otherwise, op(*i) is not evaluated and no assignment occurs. The input and output sequences may coincide, resulting in an in-place transformation.
- Parameters:
-
| first | The beginning of the input sequence. |
| last | The end of the input sequence. |
| stencil | The beginning of the stencil sequence. |
| result | The beginning of the output sequence. |
| op | The tranformation operation. |
| pred | The predicate operation. |
- Returns:
- The end of the output sequence.
- Template Parameters:
-
| InputIterator1 | is a model of Input Iterator and InputIterator1's value_type is convertible to UnaryFunction's argument_type. |
| InputIterator2 | is a model of Input Iterator and InputIterator2's value_type is convertible to Predicate's argument_type. |
| ForwardIterator | is a model of Forward Iterator. |
| UnaryFunction | is a model of Unary Function and UnaryFunction's result_type is convertible to OutputIterator's value_type. |
| Predicate | is a model of Predicate. |
The following code snippet demonstrates how to use transform_if:
#include <thrust/transform.h>
#include <thrust/functional.h>
int data[10] = {-5, 0, 2, -3, 2, 4, 0, -1, 2, 8};
int stencil[10] = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0};
thrust::negate<int> op;
thrust::identity<int> identity;
thrust::transform_if(data, data + 10, stencil, data, op, identity);
- See also:
- thrust::transform
template<typename InputIterator1 , typename InputIterator2 , typename InputIterator3 , typename ForwardIterator , typename BinaryFunction , typename Predicate >
| ForwardIterator thrust::transform_if |
( |
InputIterator1 |
first1, |
|
|
InputIterator1 |
last1, |
|
|
InputIterator2 |
first2, |
|
|
InputIterator3 |
stencil, |
|
|
ForwardIterator |
result, |
|
|
BinaryFunction |
binary_op, |
|
|
Predicate |
pred |
|
) |
| |
This version of transform_if conditionally applies a binary function to each pair of elements from two input sequences and stores the result in the corresponding position in an output sequence if the corresponding position in a stencil sequence satifies a predicate. Otherwise, the corresponding position in the output sequence is not modified.
Specifically, for each iterator i in the range [first1, last1) and j = first2 + (i - first1) in the range [first2, first2 + (last1 - first1) ), the predicate pred(*s) is evaluated, where s is the corresponding input iterator in the range [stencil, stencil + (last1 - first1) ). If this predicate evaluates to true, the result of binary_op(*i,*j) is assigned to *o, where o is the corresponding output iterator in the range [result, result + (last1 - first1) ). Otherwise, binary_op(*i,*j) is not evaluated and no assignment occurs. The input and output sequences may coincide, resulting in an in-place transformation.
- Parameters:
-
| first1 | The beginning of the first input sequence. |
| last1 | The end of the first input sequence. |
| first2 | The beginning of the second input sequence. |
| stencil | The beginning of the stencil sequence. |
| result | The beginning of the output sequence. |
| binary_op | The transformation operation. |
| pred | The predicate operation. |
- Returns:
- The end of the output sequence.
- Template Parameters:
-
| InputIterator1 | is a model of Input Iterator and InputIterator1's value_type is convertible to BinaryFunction's first_argument_type. |
| InputIterator2 | is a model of Input Iterator and InputIterator2's value_type is convertible to BinaryFunction's second_argument_type. |
| ForwardIterator | is a model of Forward Iterator. |
| BinaryFunction | is a model of Binary Function and BinaryFunction's result_type is convertible to OutputIterator's value_type. |
| Predicate | is a model of Predicate. |
The following code snippet demonstrates how to use transform_if:
#include <thrust/transform.h>
#include <thrust/functional.h>
int input1[6] = {-5, 0, 2, 3, 2, 4};
int input2[6] = { 3, 6, -2, 1, 2, 3};
int stencil[8] = { 1, 0, 1, 0, 1, 0};
int output[6];
thrust::plus<int> op;
thrust::identity<int> identity;
thrust::transform_if(input1, input1 + 6, input2, stencil, output, op, identity);
- See also:
- thrust::transform
template<typename InputIterator , typename ForwardIterator , typename UnaryFunction , typename Predicate >
| ForwardIterator thrust::transform_if |
( |
InputIterator |
first, |
|
|
InputIterator |
last, |
|
|
ForwardIterator |
result, |
|
|
UnaryFunction |
op, |
|
|
Predicate |
pred |
|
) |
| |
This version of transform_if conditionally applies a unary function to each element of an input sequence and stores the result in the corresponding position in an output sequence if the corresponding position in the input sequence satifies a predicate. Otherwise, the corresponding position in the output sequence is not modified.
Specifically, for each iterator i in the range [first, last) the predicate pred(*i) is evaluated. If this predicate evaluates to true, the result of op(*i) is assigned to *o, where o is the corresponding output iterator in the range [result, result + (last - first) ). Otherwise, op(*i) is not evaluated and no assignment occurs. The input and output sequences may coincide, resulting in an in-place transformation.
- Parameters:
-
| first | The beginning of the input sequence. |
| last | The end of the input sequence. |
| result | The beginning of the output sequence. |
| op | The tranformation operation. |
| pred | The predicate operation. |
- Returns:
- The end of the output sequence.
- Template Parameters:
-
| InputIterator | is a model of Input Iterator, and InputIterator's value_type is convertible to Predicate's argument_type, and InputIterator's value_type is convertible to UnaryFunction's argument_type. |
| ForwardIterator | is a model of Forward Iterator. |
| UnaryFunction | is a model of Unary Function and UnaryFunction's result_type is convertible to OutputIterator's value_type. |
| Predicate | is a model of Predicate. |
The following code snippet demonstrates how to use transform_if:
#include <thrust/transform.h>
#include <thrust/functional.h>
int data[10] = {-5, 0, 2, -3, 2, 4, 0, -1, 2, 8};
struct is_odd
{
__host__ __device__
bool operator()(int x)
{
return x % 2;
}
};
thrust::negate<int> op;
thrust::identity<int> identity;
thrust::transform_if(data, data + 10, data, op, is_odd());
- See also:
- thrust::transform