1 #include <thrust/copy.h>
2 #include <thrust/host_vector.h>
3 #include <thrust/device_vector.h>
4 #include <thrust/sort.h>
10 int main(int argc
, char *argv
[])
14 std::random_device rd
;
15 std::mt19937
gen(rd());
16 std::uniform_real_distribution
<float> dist(-1.0, 1.0);
18 auto myrand
= [&]() -> float {return dist(gen
);};
20 thrust::host_vector
<float> xin(size
);
21 std::generate(xin
.begin(), xin
.end(), myrand
);
23 thrust::device_vector
<float> x(size
);
26 thrust::sort(x
.begin(), x
.end());
27 thrust::copy(x
.begin(), x
.end(), xin
.begin());
29 for(size_t i
= 1; i
< size
; i
++){
30 if(xin
[i
- 1] > xin
[i
]){
31 std::cout
<< "Elements " << i
- 1 << " and " << i
32 << "are not sorted:\n";
33 std::cout
<< xin
[i
- 1] << " " << xin
[i
] << std::endl
;
38 std::cout
<< "TESTS PASSED!" << std::endl
;