From: Burkhard P. <pl...@ip...> - 2004-10-01 09:46:58
|
>> >> 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; >> } >> This could be ok for most applications, but making a real good random generator is not trivial. Some detailed introduction to various random number generators can be found in the Book "Numerical Recipes in C". Here is the online version (scroll down to Chapter 7): http://www.library.cornell.edu/nr/cbookcpdf.html > And to seed it: > > > > #include <sys/time.h> > struct timeval tv; > > gettimeofday(&tv,NULL); > fastsrand(tv.tv_usec); > Yea, that's the best method :-) BTW all plugins must be changed to no longer call [s]rand(). -- _____________________________ Dr.-Ing. Burkhard Plaum Institut fuer Plasmaforschung Pfaffenwaldring 31 70569 Stuttgart Tel.: +49 711 685-2187 Fax.: -3102 |