-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrutil.cpp
More file actions
38 lines (30 loc) · 825 Bytes
/
rutil.cpp
File metadata and controls
38 lines (30 loc) · 825 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
//
// rutil.cpp
// ABQ_cpp
//
// Created by Elliot Meyerson on 3/25/15.
// Copyright (c) 2015 Elliot Meyerson. All rights reserved.
//
#include "rutil.h"
#include <iostream>
namespace rutil {
std::mt19937_64 & global_urng( ) {
static std::mt19937_64 u{};
return u;
}
void randomize( ) {
static std::random_device rd{};
global_urng().seed( rd() );
}
int pick_a_number( int from, int thru ) {
static std::uniform_int_distribution<> d{};
using parm_t = decltype(d)::param_type;
//std::cout << d( global_urng(), parm_t{from, thru} );
return d( global_urng(), parm_t{from, thru} );
}
double pick_a_number( double from, double upto ) {
static std::uniform_real_distribution<> d{};
using parm_t = decltype(d)::param_type;
return d( global_urng(), parm_t{from, upto} );
}
}