Skip to documentation
SLOP

tiny.simd.VectorXoshiro

Reference tiny.simd VectorXoshiro

Defined in random.

Called byCallsrandomCachedXoshirotest sourcelib.simd.src.randomtest: Highway AVX2 scalar and vector ...test sourcelib.simd.src.randomtest: Highway cached xoshiro refills ...test sourcelib.simd.src.randomtest: Highway vector xoshiro fills aw...test sourcelib.simd.src.randomtest: Highway vector xoshiro interlea...test sourcelib.simd.src.randomtest: Highway vector xoshiro thread s...XoshirogetStateXoshiroinitXoshiroinitThreadXoshirojumpXoshirolongJump+4 morerandomVectorXoshiro
Static calls · unresolved targets: 3 · external targets: 2.

Source

Source: lib/simd/src/random.zig:107

zig
pub fn VectorXoshiro(comptime D: type) type {    requireU64(D);    return struct {        state: [4]D.Vector,        const Self = @This();        const DF: type = D.rebind(f64);        pub fn init(seed: u64) Self {            return initThread(seed, 0);        }        pub fn initThread(seed: u64, thread_number: u64) Self {            var scalar = Xoshiro.init(seed);            var stream: u64 = 0;            while (stream < thread_number) : (stream += 1) scalar.longJump();            var state: [4]D.Vector = @splat(@splat(0));            inline for (0..D.lane_count) |lane| {                const scalar_state = scalar.getState();                inline for (0..4) |index| state[index][lane] = scalar_state[index];                scalar.jump();            }            return .{ .state = state };        }        pub fn next(self: *Self) D.Vector {            return update(&self.state);        }        pub fn fill(self: *Self, output: []u64) void {            var index: usize = 0;            while (index + D.lane_count <= output.len) : (index += D.lane_count) {                const value: [D.lane_count]u64 = self.next();                @memcpy(output[index .. index + D.lane_count], &value);            }            if (index != output.len) {                const value: [D.lane_count]u64 = self.next();                @memcpy(output[index..], value[0 .. output.len - index]);            }        }        pub fn uniform(self: *Self) DF.Vector {            return toUniform(self.next());        }        pub fn fillUniform(self: *Self, output: []f64) void {            var index: usize = 0;            while (index + D.lane_count <= output.len) : (index += D.lane_count) {                const value: [D.lane_count]f64 = self.uniform();                @memcpy(output[index .. index + D.lane_count], &value);            }            if (index != output.len) {                const value: [D.lane_count]f64 = self.uniform();                @memcpy(output[index..], value[0 .. output.len - index]);            }        }        pub fn getState(self: Self) [4]D.Vector {            return self.state;        }        pub fn setState(self: *Self, state: [4]D.Vector) void {            self.state = state;        }        pub fn stateSize() usize {            return 4 * D.lane_count;        }        fn update(state: *[4]D.Vector) D.Vector {            const result = rotate.rotateRightSame(D, state[0] +% state[3], 41) +% state[0];            const temporary = shift.shiftLeft(D, 17, state[1]);            state[2] ^= state[0];            state[3] ^= state[1];            state[1] ^= state[2];            state[0] ^= state[3];            state[2] ^= temporary;            state[3] = rotate.rotateRightSame(D, state[3], 19);            return result;        }        fn toUniform(value: D.Vector) DF.Vector {            const bits = shift.shiftRight(D, 11, value);            var result: DF.Vector = undefined;            inline for (0..D.lane_count) |index| {                result[index] = @as(f64, @floatFromInt(bits[index])) * uniform_scale;            }            return result;        }    };}

Source: lib/simd/src/root.zig:508

zig
pub const VectorXoshiro = random.VectorXoshiro;

Complete call list

9 direct calls.

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433