Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Random/ › Isaac64.zig › seed
seed
Isaac64.seed
fn seed (self : *Isaac64 , init_s : u64 , comptime rounds : usize ) void
File
Code
fn seed (self : *Isaac64 , init_s : u64 , comptime rounds : usize ) void {
// seeding the self.m array completely.
@memset (self .m [0 ..], 0 );
self .m [0 ] = init_s ;
var a = [_ ]u64 {
0x647c4677a2884b7c ,
0xb9f8b322c73ac862 ,
0x8c0ea5053d4712a0 ,
0xb29b2e824a595524 ,
0x82f053db8355e0ce ,
0x48fe4a0fa5a09315 ,
0xae985bf2cbfc89ed ,
0x98f5704f6c44c0ab ,
};
comptime var i : usize = 0 ;
inline while (i < rounds ) : (i += 1 ) {
var j : usize = 0 ;
while (j < self .m .len ) : (j += 8 ) {
comptime var x1 : usize = 0 ;
inline while (x1 < 8 ) : (x1 += 1 ) {
a [x1 ] +%= self .m [j + x1 ];
}
a [0 ] -%= a [4 ];
a [5 ] ^= a [7 ] >> 9 ;
a [7 ] +%= a [0 ];
a [1 ] -%= a [5 ];
a [6 ] ^= a [0 ] << 9 ;
a [0 ] +%= a [1 ];
a [2 ] -%= a [6 ];
a [7 ] ^= a [1 ] >> 23 ;
a [1 ] +%= a [2 ];
a [3 ] -%= a [7 ];
a [0 ] ^= a [2 ] << 15 ;
a [2 ] +%= a [3 ];
a [4 ] -%= a [0 ];
a [1 ] ^= a [3 ] >> 14 ;
a [3 ] +%= a [4 ];
a [5 ] -%= a [1 ];
a [2 ] ^= a [4 ] << 20 ;
a [4 ] +%= a [5 ];
a [6 ] -%= a [2 ];
a [3 ] ^= a [5 ] >> 17 ;
a [5 ] +%= a [6 ];
a [7 ] -%= a [3 ];
a [4 ] ^= a [6 ] << 14 ;
a [6 ] +%= a [7 ];
comptime var x2 : usize = 0 ;
inline while (x2 < 8 ) : (x2 += 1 ) {
self .m [j + x2 ] = a [x2 ];
}
}
}
@memset (self .r [0 ..], 0 );
self .a = 0 ;
self .b = 0 ;
self .c = 0 ;
self .i = self .r .len ;
}