authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-12-18 01:23:36-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2022-12-18 01:46:09-05:00
log0ccdc511cebfa3db1dfcbd05fe849843da117657
tree7e578ef352916654c58c66336c4ab0a03126a87f
parent4809e0ea7f53d1b56cbc4c6e62e4b8ea40936d44

rand: add pub to next/jump

I specifically needed jump for an application and it doesn't appear to be exposed in any way.

2 files changed, 4 insertions(+), 4 deletions(-)

lib/std/rand/Xoroshiro128.zig+2-2
...@@ -20,7 +20,7 @@ pub fn random(self: *Xoroshiro128) Random {...@@ -20,7 +20,7 @@ pub fn random(self: *Xoroshiro128) Random {
20 return Random.init(self, fill);20 return Random.init(self, fill);
21}21}
2222
23fn next(self: *Xoroshiro128) u64 {23pub fn next(self: *Xoroshiro128) u64 {
24 const s0 = self.s[0];24 const s0 = self.s[0];
25 var s1 = self.s[1];25 var s1 = self.s[1];
26 const r = s0 +% s1;26 const r = s0 +% s1;
...@@ -33,7 +33,7 @@ fn next(self: *Xoroshiro128) u64 {...@@ -33,7 +33,7 @@ fn next(self: *Xoroshiro128) u64 {
33}33}
3434
35// Skip 2^64 places ahead in the sequence35// Skip 2^64 places ahead in the sequence
36fn jump(self: *Xoroshiro128) void {36pub fn jump(self: *Xoroshiro128) void {
37 var s0: u64 = 0;37 var s0: u64 = 0;
38 var s1: u64 = 0;38 var s1: u64 = 0;
3939
lib/std/rand/Xoshiro256.zig+2-2
...@@ -22,7 +22,7 @@ pub fn random(self: *Xoshiro256) Random {...@@ -22,7 +22,7 @@ pub fn random(self: *Xoshiro256) Random {
22 return Random.init(self, fill);22 return Random.init(self, fill);
23}23}
2424
25fn next(self: *Xoshiro256) u64 {25pub fn next(self: *Xoshiro256) u64 {
26 const r = math.rotl(u64, self.s[0] +% self.s[3], 23) +% self.s[0];26 const r = math.rotl(u64, self.s[0] +% self.s[3], 23) +% self.s[0];
2727
28 const t = self.s[1] << 17;28 const t = self.s[1] << 17;
...@@ -40,7 +40,7 @@ fn next(self: *Xoshiro256) u64 {...@@ -40,7 +40,7 @@ fn next(self: *Xoshiro256) u64 {
40}40}
4141
42// Skip 2^128 places ahead in the sequence42// Skip 2^128 places ahead in the sequence
43fn jump(self: *Xoshiro256) void {43pub fn jump(self: *Xoshiro256) void {
44 var s: u256 = 0;44 var s: u256 = 0;
4545
46 var table: u256 = 0x39abdc4529b1661ca9582618e03fc9aad5a61266f0c9392c180ec6d33cfd0aba;46 var table: u256 = 0x39abdc4529b1661ca9582618e03fc9aad5a61266f0c9392c180ec6d33cfd0aba;