forked from yanliu/pgap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myrng.h
29 lines (27 loc) · 1.06 KB
/
myrng.h
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
/******************************************************************************
* myrng.h: header for abstract random number generator *
* Author: Yan Y. Liu <[email protected]> *
* Date: 2014/08/17 *
* Copyright and license of this source file are specified in LICENSE.TXT *
* under the root directory of this software package. *
******************************************************************************/
#ifndef MYRNG_H
#define MYRNG_H
// macro: random number generator
#ifdef GSL_SPRNG
#include <gsl/gsl_rng.h>
#include "gsl-sprng.h"
#include <gsl/gsl_randist.h>
#define MYRANDI(kkk) ((int)(gsl_rng_uniform_int(gsl_sprng_r, (unsigned long int)(kkk))))
#define MYRANDF() (gsl_rng_uniform(gsl_sprng_r))
#else
#ifdef SPRNG
#include "mysprng.h"
#define MYRANDI(kkk) ((int)(mysprng() * (kkk)))
#define MYRANDF() (mysprng())
#else
#define MYRANDI(kkk) ((int)(drand48() * (kkk)))
#define MYRANDF() (drand48())
#endif
#endif
#endif