summaryrefslogtreecommitdiffstats
path: root/vendor/rand_xoshiro/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/rand_xoshiro/src
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rand_xoshiro/src')
-rw-r--r--vendor/rand_xoshiro/src/common.rs265
-rw-r--r--vendor/rand_xoshiro/src/lib.rs114
-rw-r--r--vendor/rand_xoshiro/src/splitmix64.rs149
-rw-r--r--vendor/rand_xoshiro/src/xoroshiro128plus.rs129
-rw-r--r--vendor/rand_xoshiro/src/xoroshiro128plusplus.rs126
-rw-r--r--vendor/rand_xoshiro/src/xoroshiro128starstar.rs126
-rw-r--r--vendor/rand_xoshiro/src/xoroshiro64star.rs101
-rw-r--r--vendor/rand_xoshiro/src/xoroshiro64starstar.rs100
-rw-r--r--vendor/rand_xoshiro/src/xoshiro128plus.rs112
-rw-r--r--vendor/rand_xoshiro/src/xoshiro128plusplus.rs120
-rw-r--r--vendor/rand_xoshiro/src/xoshiro128starstar.rs120
-rw-r--r--vendor/rand_xoshiro/src/xoshiro256plus.rs131
-rw-r--r--vendor/rand_xoshiro/src/xoshiro256plusplus.rs130
-rw-r--r--vendor/rand_xoshiro/src/xoshiro256starstar.rs130
-rw-r--r--vendor/rand_xoshiro/src/xoshiro512plus.rs137
-rw-r--r--vendor/rand_xoshiro/src/xoshiro512plusplus.rs137
-rw-r--r--vendor/rand_xoshiro/src/xoshiro512starstar.rs137
17 files changed, 2264 insertions, 0 deletions
diff --git a/vendor/rand_xoshiro/src/common.rs b/vendor/rand_xoshiro/src/common.rs
new file mode 100644
index 000000000..108ae1f8e
--- /dev/null
+++ b/vendor/rand_xoshiro/src/common.rs
@@ -0,0 +1,265 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+/// Initialize a RNG from a `u64` seed using `SplitMix64`.
+macro_rules! from_splitmix {
+ ($seed:expr) => { {
+ let mut rng = crate::SplitMix64::seed_from_u64($seed);
+ Self::from_rng(&mut rng).unwrap()
+ } }
+}
+
+/// Apply the ** scrambler used by some RNGs from the xoshiro family.
+macro_rules! starstar_u64 {
+ ($x:expr) => {
+ $x.wrapping_mul(5).rotate_left(7).wrapping_mul(9)
+ }
+}
+
+/// Apply the ** scrambler used by some RNGs from the xoshiro family.
+macro_rules! starstar_u32 {
+ ($x:expr) => {
+ $x.wrapping_mul(0x9E3779BB).rotate_left(5).wrapping_mul(5)
+ }
+}
+
+/// Apply the ++ scrambler used by some RNGs from the xoshiro family.
+macro_rules! plusplus_u64 {
+ ($x:expr, $y:expr, $rot:expr) => {
+ $x.wrapping_add($y).rotate_left($rot).wrapping_add($x)
+ }
+}
+
+/// Apply the ++ scrambler used by some RNGs from the xoshiro family.
+macro_rules! plusplus_u32 {
+ ($x:expr, $y:expr) => {
+ $x.wrapping_add($y).rotate_left(7).wrapping_add($x)
+ }
+}
+
+/// Implement a jump function for an RNG from the xoshiro family.
+macro_rules! impl_jump {
+ (u32, $self:expr, [$j0:expr, $j1:expr]) => {
+ const JUMP: [u32; 2] = [$j0, $j1];
+ let mut s0 = 0;
+ let mut s1 = 0;
+ for j in &JUMP {
+ for b in 0..32 {
+ if (j & 1 << b) != 0 {
+ s0 ^= $self.s0;
+ s1 ^= $self.s1;
+ }
+ $self.next_u32();
+ }
+ }
+ $self.s0 = s0;
+ $self.s1 = s1;
+ };
+ (u64, $self:expr, [$j0:expr, $j1:expr]) => {
+ const JUMP: [u64; 2] = [$j0, $j1];
+ let mut s0 = 0;
+ let mut s1 = 0;
+ for j in &JUMP {
+ for b in 0..64 {
+ if (j & 1 << b) != 0 {
+ s0 ^= $self.s0;
+ s1 ^= $self.s1;
+ }
+ $self.next_u64();
+ }
+ }
+ $self.s0 = s0;
+ $self.s1 = s1;
+ };
+ (u32, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr]) => {
+ const JUMP: [u32; 4] = [$j0, $j1, $j2, $j3];
+ let mut s0 = 0;
+ let mut s1 = 0;
+ let mut s2 = 0;
+ let mut s3 = 0;
+ for j in &JUMP {
+ for b in 0..32 {
+ if (j & 1 << b) != 0 {
+ s0 ^= $self.s[0];
+ s1 ^= $self.s[1];
+ s2 ^= $self.s[2];
+ s3 ^= $self.s[3];
+ }
+ $self.next_u32();
+ }
+ }
+ $self.s[0] = s0;
+ $self.s[1] = s1;
+ $self.s[2] = s2;
+ $self.s[3] = s3;
+ };
+ (u64, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr]) => {
+ const JUMP: [u64; 4] = [$j0, $j1, $j2, $j3];
+ let mut s0 = 0;
+ let mut s1 = 0;
+ let mut s2 = 0;
+ let mut s3 = 0;
+ for j in &JUMP {
+ for b in 0..64 {
+ if (j & 1 << b) != 0 {
+ s0 ^= $self.s[0];
+ s1 ^= $self.s[1];
+ s2 ^= $self.s[2];
+ s3 ^= $self.s[3];
+ }
+ $self.next_u64();
+ }
+ }
+ $self.s[0] = s0;
+ $self.s[1] = s1;
+ $self.s[2] = s2;
+ $self.s[3] = s3;
+ };
+ (u64, $self:expr, [$j0:expr, $j1:expr, $j2:expr, $j3:expr,
+ $j4:expr, $j5:expr, $j6:expr, $j7:expr]) => {
+ const JUMP: [u64; 8] = [$j0, $j1, $j2, $j3, $j4, $j5, $j6, $j7];
+ let mut s = [0; 8];
+ for j in &JUMP {
+ for b in 0..64 {
+ if (j & 1 << b) != 0 {
+ s[0] ^= $self.s[0];
+ s[1] ^= $self.s[1];
+ s[2] ^= $self.s[2];
+ s[3] ^= $self.s[3];
+ s[4] ^= $self.s[4];
+ s[5] ^= $self.s[5];
+ s[6] ^= $self.s[6];
+ s[7] ^= $self.s[7];
+ }
+ $self.next_u64();
+ }
+ }
+ $self.s = s;
+ };
+}
+
+/// Implement the xoroshiro iteration.
+macro_rules! impl_xoroshiro_u32 {
+ ($self:expr) => {
+ $self.s1 ^= $self.s0;
+ $self.s0 = $self.s0.rotate_left(26) ^ $self.s1 ^ ($self.s1 << 9);
+ $self.s1 = $self.s1.rotate_left(13);
+ }
+}
+
+/// Implement the xoroshiro iteration.
+macro_rules! impl_xoroshiro_u64 {
+ ($self:expr) => {
+ $self.s1 ^= $self.s0;
+ $self.s0 = $self.s0.rotate_left(24) ^ $self.s1 ^ ($self.s1 << 16);
+ $self.s1 = $self.s1.rotate_left(37);
+ }
+}
+
+/// Implement the xoroshiro iteration for the ++ scrambler.
+macro_rules! impl_xoroshiro_u64_plusplus {
+ ($self:expr) => {
+ $self.s1 ^= $self.s0;
+ $self.s0 = $self.s0.rotate_left(49) ^ $self.s1 ^ ($self.s1 << 21);
+ $self.s1 = $self.s1.rotate_left(28);
+ }
+}
+
+/// Implement the xoshiro iteration for `u32` output.
+macro_rules! impl_xoshiro_u32 {
+ ($self:expr) => {
+ let t = $self.s[1] << 9;
+
+ $self.s[2] ^= $self.s[0];
+ $self.s[3] ^= $self.s[1];
+ $self.s[1] ^= $self.s[2];
+ $self.s[0] ^= $self.s[3];
+
+ $self.s[2] ^= t;
+
+ $self.s[3] = $self.s[3].rotate_left(11);
+ }
+}
+
+/// Implement the xoshiro iteration for `u64` output.
+macro_rules! impl_xoshiro_u64 {
+ ($self:expr) => {
+ let t = $self.s[1] << 17;
+
+ $self.s[2] ^= $self.s[0];
+ $self.s[3] ^= $self.s[1];
+ $self.s[1] ^= $self.s[2];
+ $self.s[0] ^= $self.s[3];
+
+ $self.s[2] ^= t;
+
+ $self.s[3] = $self.s[3].rotate_left(45);
+ }
+}
+
+/// Implement the large-state xoshiro iteration.
+macro_rules! impl_xoshiro_large {
+ ($self:expr) => {
+ let t = $self.s[1] << 11;
+
+ $self.s[2] ^= $self.s[0];
+ $self.s[5] ^= $self.s[1];
+ $self.s[1] ^= $self.s[2];
+ $self.s[7] ^= $self.s[3];
+ $self.s[3] ^= $self.s[4];
+ $self.s[4] ^= $self.s[5];
+ $self.s[0] ^= $self.s[6];
+ $self.s[6] ^= $self.s[7];
+
+ $self.s[6] ^= t;
+
+ $self.s[7] = $self.s[7].rotate_left(21);
+ }
+}
+
+/// Map an all-zero seed to a different one.
+macro_rules! deal_with_zero_seed {
+ ($seed:expr, $Self:ident) => {
+ if $seed.iter().all(|&x| x == 0) {
+ return $Self::seed_from_u64(0);
+ }
+ }
+}
+
+/// 512-bit seed for a generator.
+///
+/// This wrapper is necessary, because some traits required for a seed are not
+/// implemented on large arrays.
+#[derive(Clone)]
+pub struct Seed512(pub [u8; 64]);
+
+impl Seed512 {
+ /// Return an iterator over the seed.
+ pub fn iter(&self) -> core::slice::Iter<u8> {
+ self.0.iter()
+ }
+}
+
+impl core::fmt::Debug for Seed512 {
+ fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
+ self.0[..].fmt(f)
+ }
+}
+
+impl Default for Seed512 {
+ fn default() -> Seed512 {
+ Seed512([0; 64])
+ }
+}
+
+impl AsMut<[u8]> for Seed512 {
+ fn as_mut(&mut self) -> &mut [u8] {
+ &mut self.0
+ }
+}
+
diff --git a/vendor/rand_xoshiro/src/lib.rs b/vendor/rand_xoshiro/src/lib.rs
new file mode 100644
index 000000000..267c10141
--- /dev/null
+++ b/vendor/rand_xoshiro/src/lib.rs
@@ -0,0 +1,114 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+//! This crate implements the [xoshiro] family of pseudorandom number generators
+//! designed by David Blackman and Sebastiano Vigna. They feature high
+//! perfomance and a small state and superseed the previous xorshift-based
+//! generators. However, they are no cryptographically secure and their output
+//! can be predicted by observing a few samples.
+//!
+//! The following generators are implemented:
+//!
+//! # 64-bit generators
+//! - [`Xoshiro256StarStar`]: Recommended for all purposes. Excellent speed and
+//! a state space (256 bits) large enough for any parallel application.
+//! - [`Xoshiro256PlusPlus`]: Recommended for all purposes. Excellent speed and
+//! a state space (256 bits) large enough for any parallel application.
+//! - [`Xoshiro256Plus`]: Recommended for generating 64-bit floating-point
+//! numbers. About 15% faster than `Xoshiro256StarStar`, but has a [low linear
+//! complexity] in the lowest bits (which are discarded when generating
+//! floats), making it fail linearity tests. This is unlikely to have any
+//! impact in practise.
+//! - [`Xoroshiro128StarStar`]: An alternative to `Xoshiro256StarStar`, having
+//! the same speed but using half the state. Only suited for low-scale parallel
+//! applications.
+//! - [`Xoroshiro128PlusPlus`]: An alternative to `Xoshiro256PlusPlus`, having
+//! the same speed but using half the state. Only suited for low-scale parallel
+//! applications.
+//! - [`Xoroshiro128Plus`]: An alternative to `Xoshiro256Plus`, having the same
+//! speed but using half the state. Only suited for low-scale parallel
+//! applications. Has a [low linear complexity] in the lowest bits (which are
+//! discarded when generating floats), making it fail linearity tests. This is
+//! unlikely to have any impact in practise.
+//! - [`Xoshiro512StarStar`]: An alternative to `Xoshiro256StarStar` with more
+//! state and the same speed.
+//! - [`Xoshiro512PlusPlus`]: An alternative to `Xoshiro256PlusPlus` with more
+//! state and the same speed.
+//! - [`Xoshiro512Plus`]: An alternative to `Xoshiro512Plus` with more
+//! state and the same speed. Has a [low linear complexity] in the lowest bits
+//! (which are discarded when generating floats), making it fail linearity
+//! tests. This is unlikely to have any impact in practise.
+//! - [`SplitMix64`]: Recommended for initializing generators of the xoshiro
+//! familiy from a 64-bit seed. Used for implementing `seed_from_u64`.
+//!
+//! # 32-bit generators
+//! - [`Xoshiro128StarStar`]: Recommended for all purposes. Excellent speed.
+//! - [`Xoshiro128PlusPlus`]: Recommended for all purposes. Excellent speed.
+//! - [`Xoshiro128Plus`]: Recommended for generating 32-bit floating-point
+//! numbers. Faster than `Xoshiro128StarStar`, but has a [low linear
+//! complexity] in the lowest bits (which are discarded when generating
+//! floats), making it fail linearity tests. This is unlikely to have any
+//! impact in practise.
+//! - [`Xoroshiro64StarStar`]: An alternative to `Xoshiro128StarStar`, having
+//! the same speed but using half the state.
+//! - [`Xoroshiro64Star`]: An alternative to `Xoshiro128Plus`, having the
+//! same speed but using half the state. Has a [low linear complexity] in the
+//! lowest bits (which are discarded when generating floats), making it fail
+//! linearity tests. This is unlikely to have any impact in practise.
+//!
+//! The `*PlusPlus` generators perform similarily to the `*StarStar` generators.
+//! See the [xoshiro paper], where the differences are discussed in detail.
+//!
+//! [xoshiro]: http://xoshiro.di.unimi.it/
+//! [xoshiro paper]: http://vigna.di.unimi.it/ftp/papers/ScrambledLinear.pdf
+//! [low linear complexity]: http://xoshiro.di.unimi.it/lowcomp.php
+
+#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
+ html_favicon_url = "https://www.rust-lang.org/favicon.ico",
+ html_root_url = "https://docs.rs/rand_xoshiro/0.6.0")]
+
+#![deny(missing_docs)]
+#![deny(missing_debug_implementations)]
+#![allow(clippy::unreadable_literal)]
+#![no_std]
+
+#[macro_use]
+mod common;
+mod splitmix64;
+mod xoshiro128starstar;
+mod xoshiro128plusplus;
+mod xoshiro128plus;
+mod xoshiro256starstar;
+mod xoshiro256plusplus;
+mod xoshiro256plus;
+mod xoshiro512starstar;
+mod xoshiro512plusplus;
+mod xoshiro512plus;
+mod xoroshiro128plus;
+mod xoroshiro128plusplus;
+mod xoroshiro128starstar;
+mod xoroshiro64starstar;
+mod xoroshiro64star;
+
+pub use rand_core;
+pub use splitmix64::SplitMix64;
+pub use xoshiro128starstar::Xoshiro128StarStar;
+pub use xoshiro128plusplus::Xoshiro128PlusPlus;
+pub use xoshiro128plus::Xoshiro128Plus;
+pub use xoshiro256starstar::Xoshiro256StarStar;
+pub use xoshiro256plusplus::Xoshiro256PlusPlus;
+pub use xoshiro256plus::Xoshiro256Plus;
+pub use common::Seed512;
+pub use xoshiro512starstar::Xoshiro512StarStar;
+pub use xoshiro512plusplus::Xoshiro512PlusPlus;
+pub use xoshiro512plus::Xoshiro512Plus;
+pub use xoroshiro128plus::Xoroshiro128Plus;
+pub use xoroshiro128starstar::Xoroshiro128StarStar;
+pub use xoroshiro128plusplus::Xoroshiro128PlusPlus;
+pub use xoroshiro64starstar::Xoroshiro64StarStar;
+pub use xoroshiro64star::Xoroshiro64Star;
diff --git a/vendor/rand_xoshiro/src/splitmix64.rs b/vendor/rand_xoshiro/src/splitmix64.rs
new file mode 100644
index 000000000..38d6b3933
--- /dev/null
+++ b/vendor/rand_xoshiro/src/splitmix64.rs
@@ -0,0 +1,149 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u64_into;
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::{RngCore, SeedableRng, Error};
+
+/// A splitmix64 random number generator.
+///
+/// The splitmix algorithm is not suitable for cryptographic purposes, but is
+/// very fast and has a 64 bit state.
+///
+/// The algorithm used here is translated from [the `splitmix64.c`
+/// reference source code](http://xoshiro.di.unimi.it/splitmix64.c) by
+/// Sebastiano Vigna. For `next_u32`, a more efficient mixing function taken
+/// from [`dsiutils`](http://dsiutils.di.unimi.it/) is used.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct SplitMix64 {
+ x: u64,
+}
+
+const PHI: u64 = 0x9e3779b97f4a7c15;
+
+impl RngCore for SplitMix64 {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ self.x = self.x.wrapping_add(PHI);
+ let mut z = self.x;
+ // David Stafford's
+ // (http://zimbry.blogspot.com/2011/09/better-bit-mixing-improving-on.html)
+ // "Mix4" variant of the 64-bit finalizer in Austin Appleby's
+ // MurmurHash3 algorithm.
+ z = (z ^ (z >> 33)).wrapping_mul(0x62A9D9ED799705F5);
+ z = (z ^ (z >> 28)).wrapping_mul(0xCB24D0A5C88C35B3);
+ (z >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ self.x = self.x.wrapping_add(PHI);
+ let mut z = self.x;
+ z = (z ^ (z >> 30)).wrapping_mul(0xbf58476d1ce4e5b9);
+ z = (z ^ (z >> 27)).wrapping_mul(0x94d049bb133111eb);
+ z ^ (z >> 31)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for SplitMix64 {
+ type Seed = [u8; 8];
+
+ /// Create a new `SplitMix64`.
+ fn from_seed(seed: [u8; 8]) -> SplitMix64 {
+ let mut state = [0; 1];
+ read_u64_into(&seed, &mut state);
+ SplitMix64 {
+ x: state[0],
+ }
+ }
+
+ /// Seed a `SplitMix64` from a `u64`.
+ fn seed_from_u64(seed: u64) -> SplitMix64 {
+ SplitMix64::from_seed(seed.to_le_bytes())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = SplitMix64::seed_from_u64(1477776061723855037);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/splitmix64.c
+ let expected : [u64 ; 50]= [
+ 1985237415132408290, 2979275885539914483, 13511426838097143398,
+ 8488337342461049707, 15141737807933549159, 17093170987380407015,
+ 16389528042912955399, 13177319091862933652, 10841969400225389492,
+ 17094824097954834098, 3336622647361835228, 9678412372263018368,
+ 11111587619974030187, 7882215801036322410, 5709234165213761869,
+ 7799681907651786826, 4616320717312661886, 4251077652075509767,
+ 7836757050122171900, 5054003328188417616, 12919285918354108358,
+ 16477564761813870717, 5124667218451240549, 18099554314556827626,
+ 7603784838804469118, 6358551455431362471, 3037176434532249502,
+ 3217550417701719149, 9958699920490216947, 5965803675992506258,
+ 12000828378049868312, 12720568162811471118, 245696019213873792,
+ 8351371993958923852, 14378754021282935786, 5655432093647472106,
+ 5508031680350692005, 8515198786865082103, 6287793597487164412,
+ 14963046237722101617, 3630795823534910476, 8422285279403485710,
+ 10554287778700714153, 10871906555720704584, 8659066966120258468,
+ 9420238805069527062, 10338115333623340156, 13514802760105037173,
+ 14635952304031724449, 15419692541594102413,
+ ];
+ for &e in expected.iter() {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+
+ #[test]
+ fn next_u32() {
+ let mut rng = SplitMix64::seed_from_u64(10);
+ // These values were produced with the reference implementation:
+ // http://dsiutils.di.unimi.it/dsiutils-2.5.1-src.tar.gz
+ let expected : [u32 ; 100]= [
+ 3930361779, 4016923089, 4113052479, 925926767, 1755287528,
+ 802865554, 954171070, 3724185978, 173676273, 1414488795, 12664133,
+ 1784889697, 1303817078, 261610523, 941280008, 2571813643,
+ 2954453492, 378291111, 2546873158, 3923319175, 645257028,
+ 3881821278, 2681538690, 3037029984, 1999958137, 1853970361,
+ 2989951788, 2126166628, 839962987, 3989679659, 3656977858,
+ 684284364, 1673258011, 170979192, 3037622326, 1600748179,
+ 1780764218, 1141430714, 4139736875, 3336905707, 2262051600,
+ 3830850262, 2430765325, 1073032139, 1668888979, 2716938970,
+ 4102420032, 40305196, 386350562, 2754480591, 622869439, 2129598760,
+ 2306038241, 4218338739, 412298926, 3453855056, 3061469690,
+ 4284292697, 994843708, 1591016681, 414726151, 1238182607, 18073498,
+ 1237631493, 351884714, 2347486264, 2488990876, 802846256, 645670443,
+ 957607012, 3126589776, 1966356370, 3036485766, 868696717,
+ 2808613630, 2070968151, 1025536863, 1743949425, 466212687,
+ 2994327271, 209776458, 1246125124, 3344380309, 2203947859,
+ 968313105, 2805485302, 197484837, 3472483632, 3931823935,
+ 3288490351, 4165666529, 3671080416, 689542830, 1272555356,
+ 1039141475, 3984640460, 4142959054, 2252788890, 2459379590,
+ 991872507,
+ ];
+ for &e in expected.iter() {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoroshiro128plus.rs b/vendor/rand_xoshiro/src/xoroshiro128plus.rs
new file mode 100644
index 000000000..d2a0b8c6d
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoroshiro128plus.rs
@@ -0,0 +1,129 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u64_into;
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::{RngCore, SeedableRng};
+
+/// A xoroshiro128+ random number generator.
+///
+/// The xoroshiro128+ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has good statistical properties, besides a low linear
+/// complexity in the lowest bits.
+///
+/// The algorithm used here is translated from [the `xoroshiro128plus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoroshiro128plus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoroshiro128Plus {
+ s0: u64,
+ s1: u64,
+}
+
+impl Xoroshiro128Plus {
+ /// Jump forward, equivalently to 2^64 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128Plus;
+ ///
+ /// let rng1 = Xoroshiro128Plus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [0xdf900294d8f554a5, 0x170865df4b3201fc]);
+ }
+
+ /// Jump forward, equivalently to 2^96 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^32 starting points, from each of which
+ /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1]);
+ }
+}
+
+impl RngCore for Xoroshiro128Plus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The two lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let r = self.s0.wrapping_add(self.s1);
+ impl_xoroshiro_u64!(self);
+ r
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for Xoroshiro128Plus {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoroshiro128Plus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ fn from_seed(seed: [u8; 16]) -> Xoroshiro128Plus {
+ deal_with_zero_seed!(seed, Self);
+ let mut s = [0; 2];
+ read_u64_into(&seed, &mut s);
+
+ Xoroshiro128Plus {
+ s0: s[0],
+ s1: s[1],
+ }
+ }
+
+ /// Seed a `Xoroshiro128Plus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoroshiro128Plus {
+ from_splitmix!(seed)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoroshiro128Plus::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128starstar.c
+ let expected = [
+ 3, 412333834243, 2360170716294286339, 9295852285959843169,
+ 2797080929874688578, 6019711933173041966, 3076529664176959358,
+ 3521761819100106140, 7493067640054542992, 920801338098114767,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoroshiro128plusplus.rs b/vendor/rand_xoshiro/src/xoroshiro128plusplus.rs
new file mode 100644
index 000000000..fcdd2710c
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoroshiro128plusplus.rs
@@ -0,0 +1,126 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u64_into;
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::{RngCore, SeedableRng};
+
+/// A xoroshiro128++ random number generator.
+///
+/// The xoroshiro128++ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoroshiro128plusplus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoroshiro128plusplus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoroshiro128PlusPlus {
+ s0: u64,
+ s1: u64,
+}
+
+impl Xoroshiro128PlusPlus {
+ /// Jump forward, equivalently to 2^64 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128PlusPlus;
+ ///
+ /// let rng1 = Xoroshiro128PlusPlus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [0x2bd7a6a6e99c2ddc, 0x0992ccaf6a6fca05]);
+ }
+
+ /// Jump forward, equivalently to 2^96 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^32 starting points, from each of which
+ /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [0x360fd5f2cf8d5d99, 0x9c6e6877736c46e3]);
+ }
+}
+
+impl RngCore for Xoroshiro128PlusPlus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ self.next_u64() as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let r = plusplus_u64!(self.s0, self.s1, 17);
+ impl_xoroshiro_u64_plusplus!(self);
+ r
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for Xoroshiro128PlusPlus {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoroshiro128PlusPlus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ fn from_seed(seed: [u8; 16]) -> Xoroshiro128PlusPlus {
+ deal_with_zero_seed!(seed, Self);
+ let mut s = [0; 2];
+ read_u64_into(&seed, &mut s);
+
+ Xoroshiro128PlusPlus {
+ s0: s[0],
+ s1: s[1],
+ }
+ }
+
+ /// Seed a `Xoroshiro128PlusPlus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoroshiro128PlusPlus {
+ from_splitmix!(seed)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoroshiro128PlusPlus::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128plusplus.c
+ let expected = [
+ 393217, 669327710093319, 1732421326133921491, 11394790081659126983,
+ 9555452776773192676, 3586421180005889563, 1691397964866707553,
+ 10735626796753111697, 15216282715349408991, 14247243556711267923,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoroshiro128starstar.rs b/vendor/rand_xoshiro/src/xoroshiro128starstar.rs
new file mode 100644
index 000000000..7709d07b7
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoroshiro128starstar.rs
@@ -0,0 +1,126 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u64_into;
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::{RngCore, SeedableRng};
+
+/// A xoroshiro128** random number generator.
+///
+/// The xoroshiro128** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoroshiro128starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoroshiro128starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoroshiro128StarStar {
+ s0: u64,
+ s1: u64,
+}
+
+impl Xoroshiro128StarStar {
+ /// Jump forward, equivalently to 2^64 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128StarStar;
+ ///
+ /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [0xdf900294d8f554a5, 0x170865df4b3201fc]);
+ }
+
+ /// Jump forward, equivalently to 2^96 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^32 starting points, from each of which
+ /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [0xd2a98b26625eee7b, 0xdddf9b1090aa7ac1]);
+ }
+}
+
+impl RngCore for Xoroshiro128StarStar {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ self.next_u64() as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let r = starstar_u64!(self.s0);
+ impl_xoroshiro_u64!(self);
+ r
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for Xoroshiro128StarStar {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoroshiro128StarStar`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ fn from_seed(seed: [u8; 16]) -> Xoroshiro128StarStar {
+ deal_with_zero_seed!(seed, Self);
+ let mut s = [0; 2];
+ read_u64_into(&seed, &mut s);
+
+ Xoroshiro128StarStar {
+ s0: s[0],
+ s1: s[1],
+ }
+ }
+
+ /// Seed a `Xoroshiro128StarStar` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoroshiro128StarStar {
+ from_splitmix!(seed)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoroshiro128StarStar::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128starstar.c
+ let expected = [
+ 5760, 97769243520, 9706862127477703552, 9223447511460779954,
+ 8358291023205304566, 15695619998649302768, 8517900938696309774,
+ 16586480348202605369, 6959129367028440372, 16822147227405758281,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoroshiro64star.rs b/vendor/rand_xoshiro/src/xoroshiro64star.rs
new file mode 100644
index 000000000..b3bd134e8
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoroshiro64star.rs
@@ -0,0 +1,101 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u32_into;
+use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
+use rand_core::{RngCore, SeedableRng};
+
+/// A xoroshiro64* random number generator.
+///
+/// The xoroshiro64* algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has good statistical properties, besides a low linear
+/// complexity in the lowest bits.
+///
+/// The algorithm used here is translated from [the `xoroshiro64star.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoroshiro64star.c) by
+/// David Blackman and Sebastiano Vigna.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoroshiro64Star {
+ s0: u32,
+ s1: u32,
+}
+
+impl RngCore for Xoroshiro64Star {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ let r = self.s0.wrapping_mul(0x9E3779BB);
+ impl_xoroshiro_u32!(self);
+ r
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ next_u64_via_u32(self)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for Xoroshiro64Star {
+ type Seed = [u8; 8];
+
+ /// Create a new `Xoroshiro64Star`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ fn from_seed(seed: [u8; 8]) -> Xoroshiro64Star {
+ deal_with_zero_seed!(seed, Self);
+ let mut s = [0; 2];
+ read_u32_into(&seed, &mut s);
+
+ Xoroshiro64Star {
+ s0: s[0],
+ s1: s[1],
+ }
+ }
+
+ /// Seed a `Xoroshiro64Star` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoroshiro64Star {
+ from_splitmix!(seed)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoroshiro64Star::from_seed([1, 0, 0, 0, 2, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro64star.c
+ let expected = [
+ 2654435771, 327208753, 4063491769, 4259754937, 261922412, 168123673,
+ 552743735, 1672597395, 1031040050, 2755315674,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+
+ #[test]
+ fn zero_seed() {
+ let mut rng = Xoroshiro64Star::seed_from_u64(0);
+ assert_ne!(rng.next_u64(), 0);
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoroshiro64starstar.rs b/vendor/rand_xoshiro/src/xoroshiro64starstar.rs
new file mode 100644
index 000000000..6610ad82f
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoroshiro64starstar.rs
@@ -0,0 +1,100 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::le::read_u32_into;
+use rand_core::impls::{fill_bytes_via_next, next_u64_via_u32};
+use rand_core::{RngCore, SeedableRng};
+
+/// A xoroshiro64** random number generator.
+///
+/// The xoshiro64** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoroshiro64starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoroshiro64starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[allow(missing_copy_implementations)]
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoroshiro64StarStar {
+ s0: u32,
+ s1: u32,
+}
+
+impl RngCore for Xoroshiro64StarStar {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ let r = starstar_u32!(self.s0);
+ impl_xoroshiro_u32!(self);
+ r
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ next_u64_via_u32(self)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand_core::Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+impl SeedableRng for Xoroshiro64StarStar {
+ type Seed = [u8; 8];
+
+ /// Create a new `Xoroshiro64StarStar`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ fn from_seed(seed: [u8; 8]) -> Xoroshiro64StarStar {
+ deal_with_zero_seed!(seed, Self);
+ let mut s = [0; 2];
+ read_u32_into(&seed, &mut s);
+
+ Xoroshiro64StarStar {
+ s0: s[0],
+ s1: s[1],
+ }
+ }
+
+ /// Seed a `Xoroshiro64StarStar` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoroshiro64StarStar {
+ from_splitmix!(seed)
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoroshiro64StarStar::from_seed([1, 0, 0, 0, 2, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro64starstar.c
+ let expected = [
+ 3802928447, 813792938, 1618621494, 2955957307, 3252880261,
+ 1129983909, 2539651700, 1327610908, 1757650787, 2763843748,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+
+ #[test]
+ fn zero_seed() {
+ let mut rng = Xoroshiro64StarStar::seed_from_u64(0);
+ assert_ne!(rng.next_u64(), 0);
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro128plus.rs b/vendor/rand_xoshiro/src/xoshiro128plus.rs
new file mode 100644
index 000000000..b4308caf6
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro128plus.rs
@@ -0,0 +1,112 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next};
+use rand_core::le::read_u32_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro128+ random number generator.
+///
+/// The xoshiro128+ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has good statistical properties, besides a low linear
+/// complexity in the lowest bits.
+///
+/// The algorithm used here is translated from [the `xoshiro128starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro128Plus {
+ s: [u32; 4],
+}
+
+impl Xoshiro128Plus {
+ /// Jump forward, equivalently to 2^64 calls to `next_u32()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128StarStar;
+ ///
+ /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u32, self, [0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b]);
+ }
+}
+
+impl SeedableRng for Xoshiro128Plus {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoshiro128Plus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 16]) -> Xoshiro128Plus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u32_into(&seed, &mut state);
+ Xoshiro128Plus { s: state }
+ }
+
+ /// Seed a `Xoshiro128Plus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro128Plus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro128Plus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ let result_plus = self.s[0].wrapping_add(self.s[3]);
+ impl_xoshiro_u32!(self);
+ result_plus
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ next_u64_via_u32(self)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro128Plus::from_seed(
+ [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128plus.c
+ let expected = [
+ 5, 12295, 25178119, 27286542, 39879690, 1140358681, 3276312097,
+ 4110231701, 399823256, 2144435200,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro128plusplus.rs b/vendor/rand_xoshiro/src/xoshiro128plusplus.rs
new file mode 100644
index 000000000..9fe6f6bd1
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro128plusplus.rs
@@ -0,0 +1,120 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next};
+use rand_core::le::read_u32_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro128++ random number generator.
+///
+/// The xoshiro128++ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro128plusplus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro128plusplus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro128PlusPlus {
+ s: [u32; 4],
+}
+
+impl Xoshiro128PlusPlus {
+ /// Jump forward, equivalently to 2^64 calls to `next_u32()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128PlusPlus;
+ ///
+ /// let rng1 = Xoroshiro128PlusPlus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u32, self, [0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b]);
+ }
+
+ /// Jump forward, equivalently to 2^96 calls to `next_u32()`.
+ ///
+ /// This can be used to generate 2^32 starting points, from each of which
+ /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u32, self, [0xb523952e, 0x0b6f099f, 0xccf5a0ef, 0x1c580662]);
+ }
+}
+
+impl SeedableRng for Xoshiro128PlusPlus {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoshiro128PlusPlus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 16]) -> Xoshiro128PlusPlus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u32_into(&seed, &mut state);
+ Xoshiro128PlusPlus { s: state }
+ }
+
+ /// Seed a `Xoshiro128PlusPlus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro128PlusPlus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro128PlusPlus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ let result_starstar = plusplus_u32!(self.s[0], self.s[3]);
+ impl_xoshiro_u32!(self);
+ result_starstar
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ next_u64_via_u32(self)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro128PlusPlus::from_seed(
+ [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128plusplus.c
+ let expected = [
+ 641, 1573767, 3222811527, 3517856514, 836907274, 4247214768,
+ 3867114732, 1355841295, 495546011, 621204420,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro128starstar.rs b/vendor/rand_xoshiro/src/xoshiro128starstar.rs
new file mode 100644
index 000000000..893d2428f
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro128starstar.rs
@@ -0,0 +1,120 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::{next_u64_via_u32, fill_bytes_via_next};
+use rand_core::le::read_u32_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro128** random number generator.
+///
+/// The xoshiro128** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro128starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro128starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro128StarStar {
+ s: [u32; 4],
+}
+
+impl Xoshiro128StarStar {
+ /// Jump forward, equivalently to 2^64 calls to `next_u32()`.
+ ///
+ /// This can be used to generate 2^64 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoroshiro128StarStar;
+ ///
+ /// let rng1 = Xoroshiro128StarStar::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u32, self, [0x8764000b, 0xf542d2d3, 0x6fa035c3, 0x77f2db5b]);
+ }
+
+ /// Jump forward, equivalently to 2^96 calls to `next_u32()`.
+ ///
+ /// This can be used to generate 2^32 starting points, from each of which
+ /// `jump()` will generate 2^32 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u32, self, [0xb523952e, 0x0b6f099f, 0xccf5a0ef, 0x1c580662]);
+ }
+}
+
+impl SeedableRng for Xoshiro128StarStar {
+ type Seed = [u8; 16];
+
+ /// Create a new `Xoshiro128StarStar`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 16]) -> Xoshiro128StarStar {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u32_into(&seed, &mut state);
+ Xoshiro128StarStar { s: state }
+ }
+
+ /// Seed a `Xoshiro128StarStar` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro128StarStar {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro128StarStar {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ let result_starstar = starstar_u64!(self.s[1]);
+ impl_xoshiro_u32!(self);
+ result_starstar
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ next_u64_via_u32(self)
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro128StarStar::from_seed(
+ [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]);
+ // These values were produced with the reference implementation (v1.1):
+ // http://xoshiro.di.unimi.it/xoshiro128starstar.c
+ let expected = [
+ 11520, 0, 5927040, 70819200, 2031721883, 1637235492, 1287239034,
+ 3734860849, 3729100597, 4258142804,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u32(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro256plus.rs b/vendor/rand_xoshiro/src/xoshiro256plus.rs
new file mode 100644
index 000000000..67ce8ab8a
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro256plus.rs
@@ -0,0 +1,131 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro256+ random number generator.
+///
+/// The xoshiro256+ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has good statistical properties, besides a low linear
+/// complexity in the lowest bits.
+///
+/// The algorithm used here is translated from [the `xoshiro256plus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro256plus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro256Plus {
+ s: [u64; 4],
+}
+
+impl Xoshiro256Plus {
+ /// Jump forward, equivalently to 2^128 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro256Plus;
+ ///
+ /// let rng1 = Xoshiro256Plus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c,
+ 0xa9582618e03fc9aa, 0x39abdc4529b1661c
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^192 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 starting points, from each of which
+ /// `jump()` will generate 2^64 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x76e15d3efefdcbbf, 0xc5004e441c522fb3,
+ 0x77710069854ee241, 0x39109bb02acbe635
+ ]);
+ }
+}
+
+impl SeedableRng for Xoshiro256Plus {
+ type Seed = [u8; 32];
+
+ /// Create a new `Xoshiro256Plus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 32]) -> Xoshiro256Plus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u64_into(&seed, &mut state);
+ Xoshiro256Plus { s: state }
+ }
+
+ /// Seed a `Xoshiro256Plus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro256Plus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro256Plus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_plus = self.s[0].wrapping_add(self.s[3]);
+ impl_xoshiro_u64!(self);
+ result_plus
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro256Plus::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro256plus.c
+ let expected = [
+ 5, 211106232532999, 211106635186183, 9223759065350669058,
+ 9250833439874351877, 13862484359527728515, 2346507365006083650,
+ 1168864526675804870, 34095955243042024, 3466914240207415127,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro256plusplus.rs b/vendor/rand_xoshiro/src/xoshiro256plusplus.rs
new file mode 100644
index 000000000..267500ff3
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro256plusplus.rs
@@ -0,0 +1,130 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro256** random number generator.
+///
+/// The xoshiro256** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro256plusplus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro256plusplus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro256PlusPlus {
+ s: [u64; 4],
+}
+
+impl Xoshiro256PlusPlus {
+ /// Jump forward, equivalently to 2^128 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro256PlusPlus;
+ ///
+ /// let rng1 = Xoshiro256PlusPlus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c,
+ 0xa9582618e03fc9aa, 0x39abdc4529b1661c
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^192 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 starting points, from each of which
+ /// `jump()` will generate 2^64 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x76e15d3efefdcbbf, 0xc5004e441c522fb3,
+ 0x77710069854ee241, 0x39109bb02acbe635
+ ]);
+ }
+}
+
+impl SeedableRng for Xoshiro256PlusPlus {
+ type Seed = [u8; 32];
+
+ /// Create a new `Xoshiro256PlusPlus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 32]) -> Xoshiro256PlusPlus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u64_into(&seed, &mut state);
+ Xoshiro256PlusPlus { s: state }
+ }
+
+ /// Seed a `Xoshiro256PlusPlus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro256PlusPlus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro256PlusPlus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_plusplus = plusplus_u64!(self.s[0], self.s[3], 23);
+ impl_xoshiro_u64!(self);
+ result_plusplus
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro256PlusPlus::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro256plusplus.c
+ let expected = [
+ 41943041, 58720359, 3588806011781223, 3591011842654386,
+ 9228616714210784205, 9973669472204895162, 14011001112246962877,
+ 12406186145184390807, 15849039046786891736, 10450023813501588000,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro256starstar.rs b/vendor/rand_xoshiro/src/xoshiro256starstar.rs
new file mode 100644
index 000000000..3ee41ae45
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro256starstar.rs
@@ -0,0 +1,130 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+/// A xoshiro256** random number generator.
+///
+/// The xoshiro256** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro256starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro256starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro256StarStar {
+ s: [u64; 4],
+}
+
+impl Xoshiro256StarStar {
+ /// Jump forward, equivalently to 2^128 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro256StarStar;
+ ///
+ /// let rng1 = Xoshiro256StarStar::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x180ec6d33cfd0aba, 0xd5a61266f0c9392c,
+ 0xa9582618e03fc9aa, 0x39abdc4529b1661c
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^192 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^64 starting points, from each of which
+ /// `jump()` will generate 2^64 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x76e15d3efefdcbbf, 0xc5004e441c522fb3,
+ 0x77710069854ee241, 0x39109bb02acbe635
+ ]);
+ }
+}
+
+impl SeedableRng for Xoshiro256StarStar {
+ type Seed = [u8; 32];
+
+ /// Create a new `Xoshiro256StarStar`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: [u8; 32]) -> Xoshiro256StarStar {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 4];
+ read_u64_into(&seed, &mut state);
+ Xoshiro256StarStar { s: state }
+ }
+
+ /// Seed a `Xoshiro256StarStar` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro256StarStar {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro256StarStar {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_starstar = starstar_u64!(self.s[1]);
+ impl_xoshiro_u64!(self);
+ result_starstar
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro256StarStar::from_seed(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]);
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro128starstar.c
+ let expected = [
+ 11520, 0, 1509978240, 1215971899390074240, 1216172134540287360,
+ 607988272756665600, 16172922978634559625, 8476171486693032832,
+ 10595114339597558777, 2904607092377533576,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro512plus.rs b/vendor/rand_xoshiro/src/xoshiro512plus.rs
new file mode 100644
index 000000000..e9600a329
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro512plus.rs
@@ -0,0 +1,137 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+use crate::Seed512;
+
+/// A xoshiro512+ random number generator.
+///
+/// The xoshiro512+ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has good statistical properties, besides a low linear
+/// complexity in the lowest bits.
+///
+/// The algorithm used here is translated from [the `xoshiro512plus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro512plus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro512Plus {
+ s: [u64; 8],
+}
+
+impl Xoshiro512Plus {
+ /// Jump forward, equivalently to 2^256 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^256 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro512Plus;
+ ///
+ /// let rng1 = Xoshiro512Plus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae,
+ 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c,
+ 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^384 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 starting points, from each of which
+ /// `jump()` will generate 2^128 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x11467fef8f921d28, 0xa2a819f2e79c8ea8, 0xa8299fc284b3959a,
+ 0xb4d347340ca63ee1, 0x1cb0940bedbff6ce, 0xd956c5c4fa1f8e17,
+ 0x915e38fd4eda93bc, 0x5b3ccdfa5d7daca5
+ ]);
+ }
+}
+
+impl SeedableRng for Xoshiro512Plus {
+ type Seed = Seed512;
+
+ /// Create a new `Xoshiro512Plus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: Seed512) -> Xoshiro512Plus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 8];
+ read_u64_into(&seed.0, &mut state);
+ Xoshiro512Plus { s: state }
+ }
+
+ /// Seed a `Xoshiro512Plus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro512Plus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro512Plus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_plus = self.s[0].wrapping_add(self.s[2]);
+ impl_xoshiro_large!(self);
+ result_plus
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro512Plus::from_seed(Seed512(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
+ 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
+ 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0]));
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro512plus.c
+ let expected = [
+ 4, 8, 4113, 25169936, 52776585412635, 57174648719367,
+ 9223482039571869716, 9331471677901559830, 9340533895746033672,
+ 14078399799840753678,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro512plusplus.rs b/vendor/rand_xoshiro/src/xoshiro512plusplus.rs
new file mode 100644
index 000000000..3ae50b121
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro512plusplus.rs
@@ -0,0 +1,137 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+use crate::Seed512;
+
+/// A xoshiro512++ random number generator.
+///
+/// The xoshiro512++ algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro512plusplus.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro512plusplus.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro512PlusPlus {
+ s: [u64; 8],
+}
+
+impl Xoshiro512PlusPlus {
+ /// Jump forward, equivalently to 2^256 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^256 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro512PlusPlus;
+ ///
+ /// let rng1 = Xoshiro512PlusPlus::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae,
+ 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c,
+ 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^384 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 starting points, from each of which
+ /// `jump()` will generate 2^128 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x11467fef8f921d28, 0xa2a819f2e79c8ea8, 0xa8299fc284b3959a,
+ 0xb4d347340ca63ee1, 0x1cb0940bedbff6ce, 0xd956c5c4fa1f8e17,
+ 0x915e38fd4eda93bc, 0x5b3ccdfa5d7daca5
+ ]);
+ }
+}
+
+
+impl SeedableRng for Xoshiro512PlusPlus {
+ type Seed = Seed512;
+
+ /// Create a new `Xoshiro512PlusPlus`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: Seed512) -> Xoshiro512PlusPlus {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 8];
+ read_u64_into(&seed.0, &mut state);
+ Xoshiro512PlusPlus { s: state }
+ }
+
+ /// Seed a `Xoshiro512PlusPlus` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro512PlusPlus {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro512PlusPlus {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_plusplus = plusplus_u64!(self.s[2], self.s[0], 17);
+ impl_xoshiro_large!(self);
+ result_plusplus
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro512PlusPlus::from_seed(Seed512(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
+ 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
+ 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0]));
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro512plusplus.c
+ let expected = [
+ 524291, 1048578, 539099140, 3299073855497, 6917532603230064654,
+ 7494048333530275843, 14418333309547923463, 10960079161595355914,
+ 18279570946505382726, 10209173166699159237,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}
diff --git a/vendor/rand_xoshiro/src/xoshiro512starstar.rs b/vendor/rand_xoshiro/src/xoshiro512starstar.rs
new file mode 100644
index 000000000..4637febc9
--- /dev/null
+++ b/vendor/rand_xoshiro/src/xoshiro512starstar.rs
@@ -0,0 +1,137 @@
+// Copyright 2018 Developers of the Rand project.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[cfg(feature="serde1")] use serde::{Serialize, Deserialize};
+use rand_core::impls::fill_bytes_via_next;
+use rand_core::le::read_u64_into;
+use rand_core::{SeedableRng, RngCore, Error};
+
+use crate::Seed512;
+
+/// A xoshiro512** random number generator.
+///
+/// The xoshiro512** algorithm is not suitable for cryptographic purposes, but
+/// is very fast and has excellent statistical properties.
+///
+/// The algorithm used here is translated from [the `xoshiro512starstar.c`
+/// reference source code](http://xoshiro.di.unimi.it/xoshiro512starstar.c) by
+/// David Blackman and Sebastiano Vigna.
+#[derive(Debug, Clone, PartialEq, Eq)]
+#[cfg_attr(feature="serde1", derive(Serialize, Deserialize))]
+pub struct Xoshiro512StarStar {
+ s: [u64; 8],
+}
+
+impl Xoshiro512StarStar {
+ /// Jump forward, equivalently to 2^256 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^256 non-overlapping subsequences for
+ /// parallel computations.
+ ///
+ /// ```
+ /// use rand_xoshiro::rand_core::SeedableRng;
+ /// use rand_xoshiro::Xoshiro512StarStar;
+ ///
+ /// let rng1 = Xoshiro512StarStar::seed_from_u64(0);
+ /// let mut rng2 = rng1.clone();
+ /// rng2.jump();
+ /// let mut rng3 = rng2.clone();
+ /// rng3.jump();
+ /// ```
+ pub fn jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x33ed89b6e7a353f9, 0x760083d7955323be, 0x2837f2fbb5f22fae,
+ 0x4b8c5674d309511c, 0xb11ac47a7ba28c25, 0xf1be7667092bcc1c,
+ 0x53851efdb6df0aaf, 0x1ebbc8b23eaf25db
+ ]);
+ }
+
+ /// Jump forward, equivalently to 2^384 calls to `next_u64()`.
+ ///
+ /// This can be used to generate 2^128 starting points, from each of which
+ /// `jump()` will generate 2^128 non-overlapping subsequences for parallel
+ /// distributed computations.
+ pub fn long_jump(&mut self) {
+ impl_jump!(u64, self, [
+ 0x11467fef8f921d28, 0xa2a819f2e79c8ea8, 0xa8299fc284b3959a,
+ 0xb4d347340ca63ee1, 0x1cb0940bedbff6ce, 0xd956c5c4fa1f8e17,
+ 0x915e38fd4eda93bc, 0x5b3ccdfa5d7daca5
+ ]);
+ }
+}
+
+
+impl SeedableRng for Xoshiro512StarStar {
+ type Seed = Seed512;
+
+ /// Create a new `Xoshiro512StarStar`. If `seed` is entirely 0, it will be
+ /// mapped to a different seed.
+ #[inline]
+ fn from_seed(seed: Seed512) -> Xoshiro512StarStar {
+ deal_with_zero_seed!(seed, Self);
+ let mut state = [0; 8];
+ read_u64_into(&seed.0, &mut state);
+ Xoshiro512StarStar { s: state }
+ }
+
+ /// Seed a `Xoshiro512StarStar` from a `u64` using `SplitMix64`.
+ fn seed_from_u64(seed: u64) -> Xoshiro512StarStar {
+ from_splitmix!(seed)
+ }
+}
+
+impl RngCore for Xoshiro512StarStar {
+ #[inline]
+ fn next_u32(&mut self) -> u32 {
+ // The lowest bits have some linear dependencies, so we use the
+ // upper bits instead.
+ (self.next_u64() >> 32) as u32
+ }
+
+ #[inline]
+ fn next_u64(&mut self) -> u64 {
+ let result_starstar = starstar_u64!(self.s[1]);
+ impl_xoshiro_large!(self);
+ result_starstar
+ }
+
+ #[inline]
+ fn fill_bytes(&mut self, dest: &mut [u8]) {
+ fill_bytes_via_next(self, dest);
+ }
+
+ #[inline]
+ fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), Error> {
+ self.fill_bytes(dest);
+ Ok(())
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn reference() {
+ let mut rng = Xoshiro512StarStar::from_seed(Seed512(
+ [1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,
+ 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
+ 5, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0,
+ 7, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0]));
+ // These values were produced with the reference implementation:
+ // http://xoshiro.di.unimi.it/xoshiro512starstar.c
+ let expected = [
+ 11520, 0, 23040, 23667840, 144955163520, 303992986974289920,
+ 25332796375735680, 296904390158016, 13911081092387501979,
+ 15304787717237593024,
+ ];
+ for &e in &expected {
+ assert_eq!(rng.next_u64(), e);
+ }
+ }
+}