This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <math.h> | |
/* Random float between 0 and 1 in a uniform distribution */ | |
float random_float(uint32_t uniform) | |
{ | |
return ldexpf(uniform, -32); | |
} | |
/* Random float in a Gaussian distribution with mean of 0 */ | |
float random_gaussian(uint32_t u, uint32_t v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/time.h> | |
#include <inttypes.h> | |
#include <stdio.h> | |
uint32_t ms(struct timeval *from, struct timeval *to) | |
{ | |
uint32_t from_ms, to_ms; | |
from_ms = (from->tv_sec * 1000) + (from->tv_usec / 1000); | |
to_ms = (to->tv_sec * 1000) + (to->tv_usec / 1000); |