File indexing completed on 2026-04-09 07:49:13
0001
0002
0003 #include <thrust/device_vector.h>
0004 #include <stdio.h>
0005
0006 struct less_than_or_eq_zero
0007 {
0008 __host__ __device__ bool operator() (double x) { return x <= 0.; }
0009 };
0010
0011 int main(void)
0012 {
0013 int N = 6;
0014
0015 thrust::device_vector<float> D(N);
0016
0017 D[0] = 3.;
0018 D[1] = 2.3;
0019 D[2] = 1.3;
0020 D[3] = 0.1;
0021 D[4] = 3.;
0022 D[5] = 44.;
0023
0024 thrust::device_vector<float>::iterator iter1 = D.begin();
0025 thrust::device_vector<float>::iterator iter2 = thrust::find_if(D.begin(), D.begin() + N, less_than_or_eq_zero());
0026 int d = thrust::distance(iter1, iter2);
0027
0028 printf("Index = %i\n",d);
0029
0030 getchar();
0031
0032 return 0;
0033 }
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058