thrust
Public Types | Public Member Functions | List of all members
thrust::negate< 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::negate< T >

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

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

The following code snippet demonstrates how to use negate to negate 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, -2, -3, ..., -1000}
See also
http://www.sgi.com/tech/stl/negate.html
unary_function

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