diff --git a/C/samples.c b/C/samples.c index c32fa7ab..0a16ee9b 100644 --- a/C/samples.c +++ b/C/samples.c @@ -85,8 +85,8 @@ float split_array_sum(float** meta_array, int length, int divided_into) float rand_float(float to, unsigned int* seed) { return ((float)rand_r(seed) / (float)RAND_MAX) * to; - // See: for why to use rand_r: - // rand() is not thread-safe, as it relies on (shared) hidden state. + // See: for why to use rand_r: + // rand() is not thread-safe, as it relies on (shared) hidden state. } float ur_normal(unsigned int* seed) @@ -99,7 +99,7 @@ float ur_normal(unsigned int* seed) inline float random_uniform(float from, float to, unsigned int* seed) { - return ((float) rand_r(seed) / (float)RAND_MAX) * (to - from) + from; + return ((float)rand_r(seed) / (float)RAND_MAX) * (to - from) + from; } inline float random_normal(float mean, float sigma, unsigned int* seed) @@ -123,10 +123,10 @@ inline float random_to(float low, float high, unsigned int* seed) } // Mixture function -void mixture(float (*samplers[])(unsigned int* ), float* weights, int n_dists, float** results, int n_threads) +void mixture(float (*samplers[])(unsigned int*), float* weights, int n_dists, float** results, int n_threads) { - // You can see a simpler version of this function in the git history - // or in C-02-better-algorithm-one-thread/ + // You can see a simpler version of this function in the git history + // or in C-02-better-algorithm-one-thread/ float sum_weights = array_sum(weights, n_dists); float* normalized_weights = malloc(n_dists * sizeof(float)); for (int i = 0; i < n_dists; i++) { @@ -139,11 +139,11 @@ void mixture(float (*samplers[])(unsigned int* ), float* weights, int n_dists, f //create var holders float p1; int sample_index, i, own_length; - unsigned int* seeds[n_threads]; - for(unsigned int i=0; i