-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathrunif.h
More file actions
41 lines (29 loc) · 740 Bytes
/
runif.h
File metadata and controls
41 lines (29 loc) · 740 Bytes
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
#ifndef Rcpp__stats__random_runif_h
#define Rcpp__stats__random_runif_h
namespace Rcpp {
namespace stats {
class UnifGenerator : public ::Rcpp::Generator<double> {
public:
UnifGenerator( double min_ = 0.0, double max_ = 1.0) :
min(min_), diff(max_ - min_) {}
inline double operator()() const {
double u;
do {u = unif_rand();} while (u <= 0 || u >= 1);
return min + diff * u;
}
private:
double min;
double diff ;
} ;
class UnifGenerator__0__1 : public ::Rcpp::Generator<double> {
public:
UnifGenerator__0__1() {}
inline double operator()() const {
double u;
do {u = unif_rand();} while (u <= 0 || u >= 1);
return u;
}
} ;
} // stats
} // Rcpp
#endif