xorshift minor tweaks

This commit is contained in:
NunoSempere 2023-06-03 10:02:01 -06:00
parent c73476e5aa
commit a7bb3bc812
3 changed files with 2 additions and 2 deletions

Binary file not shown.

View File

@ -167,7 +167,7 @@ void mixture(float (*samplers[])(uint32_t*), float* weights, int n_dists, float*
uint32_t** seeds = malloc(n_threads * sizeof(uint32_t*)); uint32_t** seeds = malloc(n_threads * sizeof(uint32_t*));
for (uint32_t i = 0; i < n_threads; i++) { for (uint32_t i = 0; i < n_threads; i++) {
seeds[i] = malloc(sizeof(uint32_t)); seeds[i] = malloc(sizeof(uint32_t));
*seeds[i] = i + 1; *seeds[i] = i + 1; // xorshift can't start with 0
} }
#pragma omp parallel private(i, p1, sample_index, split_array_length) #pragma omp parallel private(i, p1, sample_index, split_array_length)

View File

@ -13,7 +13,7 @@ uint32_t xorshift32(uint32_t* state)
} }
float rand_xorshift32(uint32_t* state){ float rand_xorshift32(uint32_t* state){
return (float) xorshift32(state) / UINT32_MAX; return (float) xorshift32(state) / (float) UINT32_MAX;
} }
int main(){ int main(){