1// Copyright 2018 Developers of the Rand project.
2//
3// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
6// option. This file may not be copied, modified, or distributed
7// except according to those terms.
8
9//! This crate implements the [xoshiro] family of pseudorandom number generators
10//! designed by David Blackman and Sebastiano Vigna. They feature high
11//! perfomance and a small state and superseed the previous xorshift-based
12//! generators. However, they are no cryptographically secure and their output
13//! can be predicted by observing a few samples.
14//!
15//! The following generators are implemented:
16//!
17//! # 64-bit generators
18//! - [`Xoshiro256StarStar`]: Recommended for all purposes. Excellent speed and
19//! a state space (256 bits) large enough for any parallel application.
20//! - [`Xoshiro256PlusPlus`]: Recommended for all purposes. Excellent speed and
21//! a state space (256 bits) large enough for any parallel application.
22//! - [`Xoshiro256Plus`]: Recommended for generating 64-bit floating-point
23//! numbers. About 15% faster than `Xoshiro256StarStar`, but has a [low linear
24//! complexity] in the lowest bits (which are discarded when generating
25//! floats), making it fail linearity tests. This is unlikely to have any
26//! impact in practise.
27//! - [`Xoroshiro128StarStar`]: An alternative to `Xoshiro256StarStar`, having
28//! the same speed but using half the state. Only suited for low-scale parallel
29//! applications.
30//! - [`Xoroshiro128PlusPlus`]: An alternative to `Xoshiro256PlusPlus`, having
31//! the same speed but using half the state. Only suited for low-scale parallel
32//! applications.
33//! - [`Xoroshiro128Plus`]: An alternative to `Xoshiro256Plus`, having the same
34//! speed but using half the state. Only suited for low-scale parallel
35//! applications. Has a [low linear complexity] in the lowest bits (which are
36//! discarded when generating floats), making it fail linearity tests. This is
37//! unlikely to have any impact in practise.
38//! - [`Xoshiro512StarStar`]: An alternative to `Xoshiro256StarStar` with more
39//! state and the same speed.
40//! - [`Xoshiro512PlusPlus`]: An alternative to `Xoshiro256PlusPlus` with more
41//! state and the same speed.
42//! - [`Xoshiro512Plus`]: An alternative to `Xoshiro512Plus` with more
43//! state and the same speed. Has a [low linear complexity] in the lowest bits
44//! (which are discarded when generating floats), making it fail linearity
45//! tests. This is unlikely to have any impact in practise.
46//! - [`SplitMix64`]: Recommended for initializing generators of the xoshiro
47//! familiy from a 64-bit seed. Used for implementing `seed_from_u64`.
48//!
49//! # 32-bit generators
50//! - [`Xoshiro128StarStar`]: Recommended for all purposes. Excellent speed.
51//! - [`Xoshiro128PlusPlus`]: Recommended for all purposes. Excellent speed.
52//! - [`Xoshiro128Plus`]: Recommended for generating 32-bit floating-point
53//! numbers. Faster than `Xoshiro128StarStar`, but has a [low linear
54//! complexity] in the lowest bits (which are discarded when generating
55//! floats), making it fail linearity tests. This is unlikely to have any
56//! impact in practise.
57//! - [`Xoroshiro64StarStar`]: An alternative to `Xoshiro128StarStar`, having
58//! the same speed but using half the state.
59//! - [`Xoroshiro64Star`]: An alternative to `Xoshiro128Plus`, having the
60//! same speed but using half the state. Has a [low linear complexity] in the
61//! lowest bits (which are discarded when generating floats), making it fail
62//! linearity tests. This is unlikely to have any impact in practise.
63//!
64//! The `*PlusPlus` generators perform similarily to the `*StarStar` generators.
65//! See the [xoshiro paper], where the differences are discussed in detail.
66//!
67//! [xoshiro]: http://xoshiro.di.unimi.it/
68//! [xoshiro paper]: http://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf
69//! [low linear complexity]: http://xoshiro.di.unimi.it/lowcomp.php
70
71#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
72 html_favicon_url = "https://www.rust-lang.org/favicon.ico",
73 html_root_url = "https://docs.rs/rand_xoshiro/0.6.0")]
74
75#![deny(missing_docs)]
76#![deny(missing_debug_implementations)]
77#![allow(clippy::unreadable_literal)]
78#![no_std]
79
80#[macro_use]
81mod common;
82mod splitmix64;
83mod xoshiro128starstar;
84mod xoshiro128plusplus;
85mod xoshiro128plus;
86mod xoshiro256starstar;
87mod xoshiro256plusplus;
88mod xoshiro256plus;
89mod xoshiro512starstar;
90mod xoshiro512plusplus;
91mod xoshiro512plus;
92mod xoroshiro128plus;
93mod xoroshiro128plusplus;
94mod xoroshiro128starstar;
95mod xoroshiro64starstar;
96mod xoroshiro64star;
97
98pub use rand_core;
99pub use splitmix64::SplitMix64;
100pub use xoshiro128starstar::Xoshiro128StarStar;
101pub use xoshiro128plusplus::Xoshiro128PlusPlus;
102pub use xoshiro128plus::Xoshiro128Plus;
103pub use xoshiro256starstar::Xoshiro256StarStar;
104pub use xoshiro256plusplus::Xoshiro256PlusPlus;
105pub use xoshiro256plus::Xoshiro256Plus;
106pub use common::Seed512;
107pub use xoshiro512starstar::Xoshiro512StarStar;
108pub use xoshiro512plusplus::Xoshiro512PlusPlus;
109pub use xoshiro512plus::Xoshiro512Plus;
110pub use xoroshiro128plus::Xoroshiro128Plus;
111pub use xoroshiro128starstar::Xoroshiro128StarStar;
112pub use xoroshiro128plusplus::Xoroshiro128PlusPlus;
113pub use xoroshiro64starstar::Xoroshiro64StarStar;
114pub use xoroshiro64star::Xoroshiro64Star;
115