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
//! Sources of randomness.
//!
//! ## Example
//!
//! ```
//! use random::Source;
//!
//! let mut source = random::default(42);
//! println!("Scalar: {:?}", source.read::<f64>());
//! println!("Vector: {:?}", source.iter().take(2).collect::<Vec<f64>>());
//! ```

#![no_std]

mod sequence;
mod source;
mod value;
mod xorshift;

pub use sequence::Sequence;
pub use source::Source;
pub use value::Value;
pub use xorshift::Xorshift128Plus;

pub use Xorshift128Plus as Default;

/// Create an instance of the default source.
///
/// The default source is the Xorshift128+ algorithm.
#[inline(always)]
pub fn default(seed: u64) -> Default {
    Xorshift128Plus::new([seed.wrapping_sub(1), seed.wrapping_add(1)])
}