SLOP
tiny.simd.Xoshiro
Reference › tiny.simd › Xoshiro
Defined in random.
API (10)
Actions
Public operations.
Fields and members
Public fields and members.
Static calls · unresolved targets: unknown · external targets: unknown.
Source
Source: lib/simd/src/random.zig:39
1pub const Xoshiro = struct {2 state: [4]u64,34 pub fn init(seed: u64) Xoshiro {5 var split = SplitMix64.init(seed);6 var state: [4]u64 = undefined;7 for (&state) |*value| value.* = split.next();8 return .{ .state = state };9 }1011 pub fn initThread(seed: u64, thread_id: u64) Xoshiro {12 var result = init(seed);13 var stream: u64 = 0;14 while (stream < thread_id) : (stream += 1) result.jump();15 return result;16 }1718 pub fn next(self: *Xoshiro) u64 {19 const result = std.math.rotl(u64, self.state[0] +% self.state[3], 23) +%20 self.state[0];21 const temporary = self.state[1] << 17;22 self.state[2] ^= self.state[0];23 self.state[3] ^= self.state[1];24 self.state[1] ^= self.state[2];25 self.state[0] ^= self.state[3];26 self.state[2] ^= temporary;27 self.state[3] = std.math.rotl(u64, self.state[3], 45);28 return result;29 }3031 pub fn uniform(self: *Xoshiro) f64 {32 return @as(f64, @floatFromInt(self.next() >> 11)) * uniform_scale;33 }3435 pub fn getState(self: Xoshiro) [4]u64 {36 return self.state;37 }3839 pub fn setState(self: *Xoshiro, state: [4]u64) void {40 self.state = state;41 }4243 pub fn stateSize() usize {44 return 4;45 }4647 pub fn jump(self: *Xoshiro) void {48 self.jumpWith(jump_constants);49 }5051 pub fn longJump(self: *Xoshiro) void {52 self.jumpWith(long_jump_constants);53 }5455 fn jumpWith(self: *Xoshiro, constants: [4]u64) void {56 var state: [4]u64 = @splat(0);57 for (constants) |bits| {58 for (0..64) |bit| {59 if (bits & (@as(u64, 1) << @intCast(bit)) != 0) {60 inline for (0..4) |index| state[index] ^= self.state[index];61 }62 _ = self.next();63 }64 }65 self.state = state;66 }67};
Source: lib/simd/src/root.zig:507
1pub const Xoshiro = random.Xoshiro;
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 1 · external targets: 1.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Static calls · unresolved targets: 0 · external targets: 0.
Audit
| Definitions | 10 |
|---|
| Public names | 20 |
|---|
| Members | 1 |
|---|
| Version | 26.7.0 |
|---|
| Revision | daab053ee433 |
|---|