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
@@ -9,6 +9,7 @@
|
||||
#include <cstdlib>
|
||||
|
||||
#include <memory>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
@@ -19,6 +20,7 @@
|
||||
#include <faiss/clone_index.h>
|
||||
#include <faiss/IVFlib.h>
|
||||
|
||||
|
||||
using namespace faiss;
|
||||
|
||||
typedef Index::idx_t idx_t;
|
||||
@@ -47,8 +49,10 @@ int window_size = 10;
|
||||
std::vector<float> make_data(size_t n)
|
||||
{
|
||||
std::vector <float> database (n * d);
|
||||
std::mt19937 rng;
|
||||
std::uniform_real_distribution<> distrib;
|
||||
for (size_t i = 0; i < n * d; i++) {
|
||||
database[i] = drand48();
|
||||
database[i] = distrib(rng);
|
||||
}
|
||||
return database;
|
||||
}
|
||||
@@ -92,8 +96,10 @@ void make_index_slices (const Index* trained_index,
|
||||
|
||||
auto xb = make_data(nb * d);
|
||||
std::vector<faiss::Index::idx_t> ids (nb);
|
||||
std::mt19937 rng;
|
||||
std::uniform_int_distribution<> distrib;
|
||||
for (int j = 0; j < nb; j++) {
|
||||
ids[j] = lrand48();
|
||||
ids[j] = distrib(rng);
|
||||
}
|
||||
index->add_with_ids (nb, xb.data(), ids.data());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user