mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
rand: add pub to next/jump
I specifically needed jump for an application and it doesn't appear to be exposed in any way.
This commit is contained in:
parent
4809e0ea7f
commit
0ccdc511ce
@ -20,7 +20,7 @@ pub fn random(self: *Xoroshiro128) Random {
|
||||
return Random.init(self, fill);
|
||||
}
|
||||
|
||||
fn next(self: *Xoroshiro128) u64 {
|
||||
pub fn next(self: *Xoroshiro128) u64 {
|
||||
const s0 = self.s[0];
|
||||
var s1 = self.s[1];
|
||||
const r = s0 +% s1;
|
||||
@ -33,7 +33,7 @@ fn next(self: *Xoroshiro128) u64 {
|
||||
}
|
||||
|
||||
// Skip 2^64 places ahead in the sequence
|
||||
fn jump(self: *Xoroshiro128) void {
|
||||
pub fn jump(self: *Xoroshiro128) void {
|
||||
var s0: u64 = 0;
|
||||
var s1: u64 = 0;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ pub fn random(self: *Xoshiro256) Random {
|
||||
return Random.init(self, fill);
|
||||
}
|
||||
|
||||
fn next(self: *Xoshiro256) u64 {
|
||||
pub fn next(self: *Xoshiro256) u64 {
|
||||
const r = math.rotl(u64, self.s[0] +% self.s[3], 23) +% self.s[0];
|
||||
|
||||
const t = self.s[1] << 17;
|
||||
@ -40,7 +40,7 @@ fn next(self: *Xoshiro256) u64 {
|
||||
}
|
||||
|
||||
// Skip 2^128 places ahead in the sequence
|
||||
fn jump(self: *Xoshiro256) void {
|
||||
pub fn jump(self: *Xoshiro256) void {
|
||||
var s: u256 = 0;
|
||||
|
||||
var table: u256 = 0x39abdc4529b1661ca9582618e03fc9aad5a61266f0c9392c180ec6d33cfd0aba;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user