Download examples/constant_iterator.cu from camenduru/thrust: direct link, hf CLI and curl.
- Browser
- Download file 721 Bytes
-
https://huggingface.co/camenduru/thrust/resolve/main/examples/constant_iterator.cu
- Command line
-
hf download hf://camenduru/thrust/examples/constant_iterator.cu
-
curl -L -o constant_iterator.cu https://huggingface.co/camenduru/thrust/resolve/main/examples/constant_iterator.cu
721 Bytes
| int main(void) | |
| { | |
| thrust::device_vector<int> data(4); | |
| data[0] = 3; | |
| data[1] = 7; | |
| data[2] = 2; | |
| data[3] = 5; | |
| // add 10 to all values in data | |
| thrust::transform(data.begin(), data.end(), | |
| thrust::constant_iterator<int>(10), | |
| data.begin(), | |
| thrust::plus<int>()); | |
| // data is now [13, 17, 12, 15] | |
| // print result | |
| thrust::copy(data.begin(), data.end(), std::ostream_iterator<int>(std::cout, "\n")); | |
| return 0; | |
| } | |