/usr/include/fplll/nr/nr_rand.inl is in libfplll-dev 5.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | /* ---------------------------
Random generator for mpz_t
--------------------------- */
#include <time.h>
#ifndef FPLLL_NR_RAND_H
#define FPLLL_NR_RAND_H
FPLLL_BEGIN_NAMESPACE
class RandGen {
public:
static void init() {
initialized = true;
gmp_randinit_default(gmp_state);
}
static void init_with_seed(unsigned long seed) {
init();
gmp_randseed_ui(gmp_state, seed);
}
static void init_with_time() {
init();
gmp_randseed_ui(gmp_state, time(NULL));
}
static void init_with_time2() {
init();
struct timeval time;
gettimeofday(&time,NULL);
gmp_randseed_ui(gmp_state, (time.tv_sec * 1000)
+ (time.tv_usec / 1000));
}
static bool get_initialized() {
return initialized;
}
static gmp_randstate_t& get_gmp_state() {
if (!initialized) init();
return gmp_state;
}
static gmp_randstate_t gmp_state;
private:
static bool initialized;
};
class RandGenInt {
public:
static void init() {
initialized = true;
srand(time(NULL));
}
static int get() {
if (!initialized)
init();
return rand();
}
static int get_bit() {
if (!initialized)
init();
if (rand() % 2 == 0)
return -1;
else
return 1;
}
static bool initialized;
};
FPLLL_END_NAMESPACE
#endif
|