12.01.2013 Views

High-Productivity CUDA Development with the Thrust Template ...

High-Productivity CUDA Development with the Thrust Template ...

High-Productivity CUDA Development with the Thrust Template ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Custom Types & Operators<br />

struct negate_float2<br />

{<br />

__host__ __device__<br />

float2 operator()(float2 a)<br />

{<br />

return make_float2(-a.x, -a.y);<br />

}<br />

};<br />

// declare storage<br />

device_vector input = ...<br />

device_vector output = ...<br />

// create function object or ‘functor’<br />

negate_float2 func;<br />

// negate vectors<br />

transform(input.begin(), input.end(), output.begin(), func);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!