thrust
Public Types | Public Member Functions | List of all members
thrust::square< T > Struct Template Reference

#include <thrust/functional.h>

Public Types

typedef T argument_type
 The type of the function object's argument.
 
typedef T result_type
 The type of the function object's result;.
 

Public Member Functions

__thrust_exec_check_disable__ __host__ __device__ T operator() (const T &x) const
 

Detailed Description

template<typename T>
struct thrust::square< T >

square is a function object. Specifically, it is an Adaptable Unary Function. If f is an object of class square<T>, and x is an object of class T, then f(x) returns x*x.

Template Parameters
Tis a model of Assignable, and if x is an object of type T, then x*x must be defined and must have a return type that is convertible to T.

The following code snippet demonstrates how to use square to square the elements of a device_vector of floats.

...
const int N = 1000;
thrust::sequence(V1.begin(), V1.end(), 1);
thrust::transform(V1.begin(), V1.end(), V2.begin(),
// V2 is now {1, 4, 9, ..., 1000000}
See also
unary_function

The documentation for this struct was generated from the following file: