mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-12 02:13:36 +00:00
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:
committed by
Facebook GitHub Bot
parent
1d4b1571e9
commit
c37e71456b
@@ -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.;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user