xoro/
xoro.rs

1#!/usr/bin/env rust-script
2//! ```cargo
3//! [dependencies]
4//! devela = { path = "../../../..", features = ["rand"] }
5//! ```
6//$ cargo rb xoro -F rand
7
8#![allow(unused)]
9use devela::all::*;
10
11fn main() {
12    // let mut rng0 = XorShift32::default();
13    // for _ in 0..4 { cdbg![rng0.next_u32()]; }
14
15    // FIXME: const-generic-default
16    // let mut rng = XorShift32::<0, 1, 3, 10>::default();
17
18    println!(); // replicate canonical settings
19    let mut rng1 = xorshift_custom![bits:32, basis:1, triplet:40, seed:0xDEFA_0017];
20    for _ in 0..4 {
21        cdbg![rng1.next_u32()];
22    }
23    println!(); // new seed
24    let mut rng2 = xorshift_custom![bits:32, basis:1, triplet:40, seed:0xDEFA_0017];
25    for _ in 0..4 {
26        cdbg![rng2.next_u32()];
27    }
28
29    println!(); // new
30    let mut rng3 = xorshift_custom![bits:32, basis:1, triplet:20, seed:0xDEFA_0017];
31    for _ in 0..4 {
32        cdbg![rng3.next_u32()];
33    }
34    println!();
35    let mut rng4 = xorshift_custom![bits:32, basis:2, triplet:20, seed:0xDEFA_0017];
36    for _ in 0..4 {
37        cdbg![rng4.next_u32()];
38    }
39
40    let mut rng5 = xorshift_custom![bits:32, basis:0, triplet:10, seed:0];
41    for _ in 0..4 {
42        cdbg![rng5.next_u32()];
43    }
44
45    // 64-bit
46    println!("\n64-bit");
47    let mut rng6 = xorshift_custom![bits:64, basis:0, triplet:274, seed:0];
48    for _ in 0..4 {
49        cdbg![rng6.next_u64()];
50    }
51}