summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-12-14 11:41:50 +0100
committerAlberto Ruiz <aruiz@um.es>2014-12-14 11:41:50 +0100
commite93cd3dee7ddfb7e688ed300adcfaacc5cbad7b6 (patch)
tree60f3cdf49252be278c20be52d85a35b1b85c850e
parentd823b47bbd45f9674693c0a7bae60f897b38d6b7 (diff)
change drand48_r to random_r
-rw-r--r--packages/base/src/C/vector-aux.c21
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
703inline double urandom(struct drand48_data * buffer) { 703inline 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
711double gaussrand(struct drand48_data *buffer, 711double 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
737int random_vector(unsigned int seed, int code, DVEC(r)) { 737int 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