-/* initialize by an array with array-length */
-/* init_key is the array for initializing keys */
-/* key_length is its length */
-/* slight change for C++, 2004/2/26 */
-void init_by_array(unsigned long init_key[], int key_length)
-{
- int i, j, k;
- init_genrand(19650218UL);
- i=1; j=0;
- k = (N>key_length ? N : key_length);
- for (; k; k--) {
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL))
- + init_key[j] + j; /* non linear */
- mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
- i++; j++;
- if (i>=N) { mt[0] = mt[N-1]; i=1; }
- if (j>=key_length) j=0;
- }
- for (k=N-1; k; k--) {
- mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL))
- - i; /* non linear */
- mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */
- i++;
- if (i>=N) { mt[0] = mt[N-1]; i=1; }
- }
-
- mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */
-}
+ // Initialize by an array with array-length
+ // init_key is the array for initializing keys
+ // key_length is its length
+ // slight change for C++, 2004/2/26
+ void init_by_array(unsigned long init_key[], int key_length) {
+
+ int i = 1;
+ int j = 0;
+ int k = (N > key_length ? N : key_length);
+
+ init_genrand(19650218UL);
+
+ for ( ; k; k--)
+ {
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + init_key[j] + j; // Non linear
+ mt[i] &= 0xffffffffUL; // For WORDSIZE > 32 machines
+ i++; j++;
+ if (i >= N)
+ {
+ mt[0] = mt[N-1];
+ i = 1;
+ }
+ if (j >= key_length)
+ j = 0;
+ }
+ for (k = N-1; k; k--)
+ {
+ mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) - i; // Non linear
+ mt[i] &= 0xffffffffUL; // For WORDSIZE > 32 machines
+ i++;
+ if (i >= N)
+ {
+ mt[0] = mt[N-1];
+ i = 1;
+ }
+ }
+ mt[0] = 0x80000000UL; // MSB is 1; assuring non-zero initial array
+ }