Get rid of non-portable drand48. (#1349)

Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1349

Reviewed By: mdouze

Differential Revision: D23289393

Pulled By: beauby

fbshipit-source-id: a626bbf252ced4ae01abbc3dce4be50d9e628728
This commit is contained in:
Lucas Hosseini
2020-08-24 00:42:21 -07:00
committed by Facebook GitHub Bot
parent 1d4b1571e9
commit c37e71456b
21 changed files with 119 additions and 40 deletions
+6 -2
View File
@@ -7,6 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <random>
#include <faiss/IndexFlat.h>
#include <faiss/gpu/GpuAutoTune.h>
@@ -21,18 +22,21 @@ int main() {
int nb = 100000; // database size
int nq = 10000; // nb of queries
std::mt19937 rng;
std::uniform_real_distribution<> distrib;
float *xb = new float[d * nb];
float *xq = new float[d * nq];
for(int i = 0; i < nb; i++) {
for(int j = 0; j < d; j++)
xb[d * i + j] = drand48();
xb[d * i + j] = distrib(rng);
xb[d * i] += i / 1000.;
}
for(int i = 0; i < nq; i++) {
for(int j = 0; j < d; j++)
xq[d * i + j] = drand48();
xq[d * i + j] = distrib(rng);
xq[d * i] += i / 1000.;
}