xoshiro/lib.rs
1//! This crate implements the [xoshiro] family of pseudorandom number generators
2//! designed by David Blackman and Sebastiano Vigna. They feature high
3//! perfomance and a small state and superseed the previous xorshift-based
4//! generators. However, they are no cryptographically secure and their output
5//! can be predicted by observing a few samples.
6//!
7//! The following generators are implemented:
8//!
9//! # 64-bit generators
10//! - [`Xoshiro256StarStar`]: Recommended for all purposes. Excellent speed and
11//! a state space (256 bits) large enough for any parallel application.
12//! - [`Xoshiro256Plus`]: Recommended for generating 64-bit floating-point
13//! numbers. About 15% faster than `Xoshiro256StarStar`, but has a [low linear
14//! complexity] in the lowest bits (which are discarded when generating
15//! floats), making it fail linearity tests. This is unlikely to have any
16//! impact in practise.
17//! - [`Xoroshiro128StarStar`]: An alternative to `Xoshiro256StarStar`, having
18//! the same speed but using half the state. Only suited for low-scale parallel
19//! applications.
20//! - [`Xoroshiro128Plus`]: An alternative to `Xoshiro256Plus`, having the same
21//! speed but using half the state. Only suited for low-scale parallel
22//! applications. Has a [low linear complexity] in the lowest bits (which are
23//! discarded when generating floats), making it fail linearity tests. This is
24//! unlikely to have any impact in practise.
25//! - [`Xoshiro512StarStar`]: An alternative to `Xoshiro256StarStar` with more
26//! state and the same speed.
27//! - [`Xoshiro512Plus`]: An alternative to `Xoshiro512Plus` with more
28//! state and the same speed. Has a [low linear complexity] in the lowest bits
29//! (which are discarded when generating floats), making it fail linearity
30//! tests. This is unlikely to have any impact in practise.
31//! - [`SplitMix64`]: Recommended for initializing generators of the xoshiro
32//! familiy from a 64-bit seed. Used for implementing `seed_from_u64`.
33//!
34//! # 32-bit generators
35//! - [`Xoshiro128StarStar`]: Recommended for all purposes. Excellent speed.
36//! - [`Xoshiro128Plus`]: Recommended for generating 32-bit floating-point
37//! numbers. Faster than `Xoshiro128StarStar`, but has a [low linear
38//! complexity] in the lowest bits (which are discarded when generating
39//! floats), making it fail linearity tests. This is unlikely to have any
40//! impact in practise.
41//! - [`Xoroshiro64StarStar`]: An alternative to `Xoshiro128StarStar`, having
42//! the same speed but using half the state.
43//! - [`Xoroshiro64Star`]: An alternative to `Xoshiro128Plus`, having the
44//! same speed but using half the state. Has a [low linear complexity] in the
45//! lowest bits (which are discarded when generating floats), making it fail
46//! linearity tests. This is unlikely to have any impact in practise.
47//!
48//! [xoshiro]: http://xoshiro.di.unimi.it/
49//! [low linear complexity]: http://xoshiro.di.unimi.it/lowcomp.php
50//! [`Xoshiro256StarStar`]: ./struct.Xoshiro256StarStar.html
51//! [`Xoshiro256Plus`]: ./struct.Xoshiro256Plus.html
52//! [`Xoroshiro128StarStar`]: ./struct.Xoroshiro128StarStar.html
53//! [`Xoroshiro128Plus`]: ./struct.Xoroshiro128Plus.html
54//! [`Xoshiro512StarStar`]: ./struct.Xoshiro512StarStar.html
55//! [`Xoshiro512Plus`]: ./struct.Xoshiro512Plus.html
56//! [`SplitMix64`]: ./struct.SplitMix64.html
57//! [`Xoshiro128StarStar`]: ./struct.Xoshiro128StarStar.html
58//! [`Xoshiro128Plus`]: ./struct.Xoshiro128Plus.html
59//! [`Xoroshiro64StarStar`]: ./struct.Xoroshiro64StarStar.html
60//! [`Xoroshiro64Star`]: ./struct.Xoroshiro64Star.html
61
62#![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
63
64extern crate byteorder;
65extern crate rand_core;
66
67#[macro_use]
68mod common;
69mod splitmix64;
70mod xoshiro128starstar;
71mod xoshiro128plus;
72mod xoshiro256starstar;
73mod xoshiro256plus;
74mod xoshiro512starstar;
75mod xoshiro512plus;
76mod xoroshiro128plus;
77mod xoroshiro128starstar;
78mod xoroshiro64starstar;
79mod xoroshiro64star;
80
81pub use splitmix64::SplitMix64;
82pub use xoshiro128starstar::Xoshiro128StarStar;
83pub use xoshiro128plus::Xoshiro128Plus;
84pub use xoshiro256starstar::Xoshiro256StarStar;
85pub use xoshiro256plus::Xoshiro256Plus;
86pub use common::Seed512;
87pub use xoshiro512starstar::Xoshiro512StarStar;
88pub use xoshiro512plus::Xoshiro512Plus;
89pub use xoroshiro128plus::Xoroshiro128Plus;
90pub use xoroshiro128starstar::Xoroshiro128StarStar;
91pub use xoroshiro64starstar::Xoroshiro64StarStar;
92pub use xoroshiro64star::Xoroshiro64Star;