... | ... |
@@ -1,5 +1,7 @@ |
1 | 1 |
#include "GapsRunner.h" |
2 | 2 |
#include "math/SIMD.h" |
3 |
+#include "math/Random.h" |
|
4 |
+#include <algorithm> |
|
3 | 5 |
|
4 | 6 |
#ifdef __GAPS_OPENMP__ |
5 | 7 |
#include <omp.h> |
... | ... |
@@ -13,15 +15,23 @@ static std::vector< std::vector<unsigned> > sampleIndices(unsigned n, unsigned n |
13 | 15 |
{ |
14 | 16 |
// TODO implement |
15 | 17 |
std::vector< std::vector<unsigned> > sampleIndices; |
16 |
- unsigned count = 1; |
|
18 |
+ std::vector<unsigned> sampled; |
|
17 | 19 |
|
18 | 20 |
for (unsigned i = 0; i < (n - 1) % nSets; ++i) |
19 | 21 |
{ |
20 | 22 |
std::vector<unsigned> set; |
21 | 23 |
for (unsigned i = 0; i < ((unsigned) (n - 1) / nSets) + 1; ++i) |
22 | 24 |
{ |
23 |
- set.push_back(count); |
|
24 |
- ++count; |
|
25 |
+ while(true) |
|
26 |
+ { |
|
27 |
+ unsigned sample = gaps::random::uniform64(1, n); |
|
28 |
+ if (find(sampled.begin(), sampled.end(), sample) == sampled.end()) |
|
29 |
+ { |
|
30 |
+ set.push_back(sample); |
|
31 |
+ sampled.push_back(sample); |
|
32 |
+ break; |
|
33 |
+ } |
|
34 |
+ } |
|
25 | 35 |
} |
26 | 36 |
sampleIndices.push_back(set); |
27 | 37 |
} |
... | ... |
@@ -31,8 +41,16 @@ static std::vector< std::vector<unsigned> > sampleIndices(unsigned n, unsigned n |
31 | 41 |
std::vector<unsigned> set; |
32 | 42 |
for (unsigned i = 0; i < (unsigned) (n - 1) / nSets; ++i) |
33 | 43 |
{ |
34 |
- set.push_back(count); |
|
35 |
- ++count; |
|
44 |
+ while(true) |
|
45 |
+ { |
|
46 |
+ unsigned sample = gaps::random::uniform64(1, n); |
|
47 |
+ if (find(sampled.begin(), sampled.end(), sample) == sampled.end()) |
|
48 |
+ { |
|
49 |
+ set.push_back(sample); |
|
50 |
+ sampled.push_back(sample); |
|
51 |
+ break; |
|
52 |
+ } |
|
53 |
+ } |
|
36 | 54 |
} |
37 | 55 |
sampleIndices.push_back(set); |
38 | 56 |
} |