thrust::minus

Defined in thrust/functional.h

template<typename T = void>
struct minus : public cuda::std::minus<void>

minus is a function object. Specifically, it is an Adaptable Binary Function. If f is an object of class minus<T>, and x and y are objects of class T, then f(x,y) returns x-y.

The following code snippet demonstrates how to use minus to subtract a device_vector of floats from another.

#include <thrust/device_vector.h>
#include <thrust/functional.h>
#include <thrust/sequence.h>
#include <thrust/fill.h>
#include <thrust/transform.h>
...
const int N = 1000;
thrust::device_vector<float> V1(N);
thrust::device_vector<float> V2(N);
thrust::device_vector<float> V3(N);

thrust::sequence(V1.begin(), V1.end(), 1);
thrust::fill(V2.begin(), V2.end(), 75);

thrust::transform(V1.begin(), V1.end(), V2.begin(), V3.begin(),
                  thrust::minus<float>());
// V3 is now {-74, -73, -72, ..., 925}

See also

binary_function

Template Parameters

T – is a model of Assignable, and if x and y are objects of type T, then x-y must be defined and must have a return type that is convertible to T.

Public Types

using first_argument_type = T
using second_argument_type = T
using result_type = T