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