File tree Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Expand file tree Collapse file tree 2 files changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ impl PyRandom {
77
77
78
78
#[ pymethod]
79
79
fn random ( & self ) -> f64 {
80
- gen_res53 ( & mut * self . rng . borrow_mut ( ) )
80
+ mersenne :: gen_res53 ( & mut * self . rng . borrow_mut ( ) )
81
81
}
82
82
83
83
#[ pymethod]
@@ -127,12 +127,3 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef {
127
127
"Random" => PyRandom :: make_class( ctx) ,
128
128
} )
129
129
}
130
-
131
- // taken from the translated mersenne twister
132
- /* generates a random number on [0,1) with 53-bit resolution*/
133
- fn gen_res53 < R : RngCore > ( rng : & mut R ) -> f64 {
134
- let a = rng. next_u32 ( ) >> 5 ;
135
- let b = rng. next_u32 ( ) >> 6 ;
136
- ( a as f64 * 67108864.0 + b as f64 ) * ( 1.0 / 9007199254740992.0 )
137
- }
138
- /* These real versions are due to Isaku Wada, 2002/01/09 added */
Original file line number Diff line number Diff line change @@ -186,6 +186,14 @@ impl MT19937 {
186
186
}
187
187
}
188
188
189
+ /* generates a random number on [0,1) with 53-bit resolution*/
190
+ pub fn gen_res53 < R : rand:: RngCore > ( rng : & mut R ) -> f64 {
191
+ let a = rng. next_u32 ( ) >> 5 ;
192
+ let b = rng. next_u32 ( ) >> 6 ;
193
+ ( a as f64 * 67108864.0 + b as f64 ) * ( 1.0 / 9007199254740992.0 )
194
+ }
195
+ /* These real versions are due to Isaku Wada, 2002/01/09 added */
196
+
189
197
impl rand:: RngCore for MT19937 {
190
198
fn next_u32 ( & mut self ) -> u32 {
191
199
self . gen_u32 ( )
You can’t perform that action at this time.
0 commit comments