mirror of
https://github.com/instant-labs/instant-distance.git
synced 2025-02-02 22:12:12 +00:00
Use more idiomatic way of generating random numbers
This commit is contained in:
parent
a3f07f790f
commit
4b3cb28820
@ -7,7 +7,7 @@ use ahash::AHashSet as HashSet;
|
|||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use rand::rngs::SmallRng;
|
use rand::rngs::SmallRng;
|
||||||
use rand::{RngCore, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@ -550,7 +550,7 @@ struct LayerId(usize);
|
|||||||
|
|
||||||
impl LayerId {
|
impl LayerId {
|
||||||
fn random(ml: f32, rng: &mut SmallRng) -> Self {
|
fn random(ml: f32, rng: &mut SmallRng) -> Self {
|
||||||
let layer = rng.next_u32() as f32 / u32::MAX as f32;
|
let layer = rng.gen::<f32>();
|
||||||
LayerId((-(layer.ln() * ml)).floor() as usize)
|
LayerId((-(layer.ln() * ml)).floor() as usize)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user