hmatrix 0.16.1.0 → 0.16.1.1
raw patch · 3 files changed
+17/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- THANKS.md +2/−0
- hmatrix.cabal +1/−1
- src/C/vector-aux.c +14/−7
THANKS.md view
@@ -177,3 +177,5 @@ - "yongqli" reported the bug in randomVector (rand() is not thread-safe). +- "yongqli" and Kiwamu Ishikura reported that drand48_r() is not portable.+
hmatrix.cabal view
@@ -1,5 +1,5 @@ Name: hmatrix-Version: 0.16.1.0+Version: 0.16.1.1 License: BSD3 License-file: LICENSE Author: Alberto Ruiz
src/C/vector-aux.c view
@@ -700,15 +700,15 @@ //////////////////////////////////////////////////////////////////////////////// -inline double urandom(struct drand48_data * buffer) {- double res;- drand48_r(buffer,&res);- return res;+inline double urandom(struct random_data * buffer) {+ int32_t res;+ random_r(buffer,&res);+ return (double)res/RAND_MAX; } // http://c-faq.com/lib/gaussian.html-double gaussrand(struct drand48_data *buffer,+double gaussrand(struct random_data *buffer, int *phase, double *pV1, double *pV2, double *pS) { double V1=*pV1, V2=*pV2, S=*pS;@@ -735,8 +735,15 @@ } int random_vector(unsigned int seed, int code, DVEC(r)) {- struct drand48_data buffer;- srand48_r(seed,&buffer);+ struct random_data buffer;+ char random_state[128];+ memset(&buffer, 0, sizeof(struct random_data));+ memset(random_state, 0, sizeof(random_state));+ + initstate_r(seed,random_state,sizeof(random_state),&buffer);+ // setstate_r(random_state,&buffer);+ // srandom_r(seed,&buffer);+ int phase = 0; double V1,V2,S;