mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
rstates point to rngs
* libguile/random.h (scm_t_rstate): Include the rng in the rstate, so we can actually have multiple rngs. Instead of reserved0 / reserved1, reserve a double explicitly for scm_c_normal01. (scm_c_uniform32): Change to call the rstate's rng. * libguile/random.c: Change to access an rstate's rng through its rng pointer. (scm_c_normal01): Instead of a flag and a next double, just check that the double is equal to 0.0. Excluding one value shouldn't affect the distribution, right?
This commit is contained in:
parent
1d454874c1
commit
a2a95453eb
2 changed files with 26 additions and 22 deletions
|
@ -39,8 +39,8 @@
|
|||
*/
|
||||
|
||||
typedef struct scm_t_rstate {
|
||||
int reserved0;
|
||||
double reserved1;
|
||||
struct scm_t_rng *rng;
|
||||
double normal_next; /* For scm_c_uniform01 */
|
||||
/* Custom fields follow here */
|
||||
} scm_t_rstate;
|
||||
|
||||
|
@ -62,7 +62,7 @@ SCM_API scm_t_rng scm_the_rng;
|
|||
SCM_API scm_t_rstate *scm_c_make_rstate (const char *, int);
|
||||
SCM_API scm_t_rstate *scm_c_rstate_from_datum (SCM datum);
|
||||
SCM_API scm_t_rstate *scm_c_default_rstate (void);
|
||||
#define scm_c_uniform32(RSTATE) scm_the_rng.random_bits (RSTATE)
|
||||
#define scm_c_uniform32(RSTATE) ((RSTATE)->rng->random_bits (RSTATE))
|
||||
SCM_API double scm_c_uniform01 (scm_t_rstate *);
|
||||
SCM_API double scm_c_normal01 (scm_t_rstate *);
|
||||
SCM_API double scm_c_exp1 (scm_t_rstate *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue