use crate::{rng::Rng32, wrap};
use std::num::Wrapping;
#[deprecated(since = "0.2.4", note = "Use Xoshiro256++/** instead.")]
#[repr(C)]
pub struct Lcg32 {
x: Wrapping<u32>,
a: u32,
b: u32,
m: u32,
r: f32,
}
#[allow(deprecated)]
impl Lcg32 {
pub fn new(x: u32, a: u32, b: u32, m: u32) -> Self {
Self {
x: wrap!(x),
a: a | 1,
b,
m,
r: 1.0 / (m as f32 + 1.0),
}
}
}
#[allow(deprecated)]
impl Rng32 for Lcg32 {
#[inline]
fn nextu(&mut self) -> u32 {
self.x = wrap!((self.a * self.x.0 + self.b) % self.m);
self.x.0
}
}
#[allow(deprecated)]
#[cfg(test)]
mod tests {
use super::*;
crate::safe_test!(Lcg32, Lcg32::new(8, 13, 5, 24));
}