From: salsaman <sal...@xs...> - 2004-09-30 09:24:34
|
salsaman wrote: > Vitaly V. Bursov wrote: > >> >> One thing: we need to borrow nice pseudo-random numbger gen algo. >> >> OK? >> >> >> > You can use these two functions adapted from LiVES: > > static uint32_t fastrand_val; > > inline uint32_t fastrand(void) > { > return (fastrand_val=fastrand_val*1073741789+32749); > } > > void fastsrand(uint32_t seed) > { > fastrand_val = seed; > } > > > > > Salsaman. > And to seed it: #include <sys/time.h> struct timeval tv; gettimeofday(&tv,NULL); fastsrand(tv.tv_usec); Salsaman. |