diff options
Diffstat (limited to 'packages/base')
-rw-r--r-- | packages/base/src/C/vector-aux.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/packages/base/src/C/vector-aux.c b/packages/base/src/C/vector-aux.c index f8feb37..54cc413 100644 --- a/packages/base/src/C/vector-aux.c +++ b/packages/base/src/C/vector-aux.c | |||
@@ -700,15 +700,15 @@ int saveMatrix(char * file, char * format, KDMAT(a)){ | |||
700 | 700 | ||
701 | //////////////////////////////////////////////////////////////////////////////// | 701 | //////////////////////////////////////////////////////////////////////////////// |
702 | 702 | ||
703 | inline double urandom(struct drand48_data * buffer) { | 703 | inline double urandom(struct random_data * buffer) { |
704 | double res; | 704 | int32_t res; |
705 | drand48_r(buffer,&res); | 705 | random_r(buffer,&res); |
706 | return res; | 706 | return (double)res/RAND_MAX; |
707 | } | 707 | } |
708 | 708 | ||
709 | 709 | ||
710 | // http://c-faq.com/lib/gaussian.html | 710 | // http://c-faq.com/lib/gaussian.html |
711 | double gaussrand(struct drand48_data *buffer, | 711 | double gaussrand(struct random_data *buffer, |
712 | int *phase, double *pV1, double *pV2, double *pS) | 712 | int *phase, double *pV1, double *pV2, double *pS) |
713 | { | 713 | { |
714 | double V1=*pV1, V2=*pV2, S=*pS; | 714 | double V1=*pV1, V2=*pV2, S=*pS; |
@@ -735,8 +735,15 @@ double gaussrand(struct drand48_data *buffer, | |||
735 | } | 735 | } |
736 | 736 | ||
737 | int random_vector(unsigned int seed, int code, DVEC(r)) { | 737 | int random_vector(unsigned int seed, int code, DVEC(r)) { |
738 | struct drand48_data buffer; | 738 | struct random_data buffer; |
739 | srand48_r(seed,&buffer); | 739 | char random_state[128]; |
740 | memset(&buffer, 0, sizeof(struct random_data)); | ||
741 | memset(random_state, 0, sizeof(random_state)); | ||
742 | |||
743 | initstate_r(seed,random_state,sizeof(random_state),&buffer); | ||
744 | // setstate_r(random_state,&buffer); | ||
745 | // srandom_r(seed,&buffer); | ||
746 | |||
740 | int phase = 0; | 747 | int phase = 0; |
741 | double V1,V2,S; | 748 | double V1,V2,S; |
742 | 749 | ||