void fiAddNoise(float *u, float *v, float std, long int randinit, int size) { //srand48( (long int) time (NULL) + (long int) getpid() + (long int) randinit); mt_init_genrand((unsigned long int) time (NULL) + (unsigned long int) getpid() + (unsigned long int) randinit); for (int i=0; i< size; i++) { //double a = drand48(); //double b = drand48(); double a=mt_genrand_res53(); double b=mt_genrand_res53(); double z = (double)(std)*sqrt(-2.0*log(a))*cos(2.0*M_PI*b); v[i] = u[i] + (float) z; } }
void main(void){ mt_t mt; uint32_t init[4] = {61731, 24903, 614, 42143}; unsigned int length = 4; mt_init_by_array(&mt, init, length); for (int i = 0; i < 2000; i++) { printf("%.16f ", mt_genrand_res53(&mt)); if (i%5==4) printf("\n"); } }