summaryrefslogtreecommitdiff
path: root/libguile/random.h
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2010-07-26 14:57:46 +0200
committerAndy Wingo <wingo@pobox.com>2010-07-26 15:01:02 +0200
commit99a0ee662050ad31e74acb3390d6901e3c916f57 (patch)
tree5e16269200f0d1847bd466d77e8345316119e648 /libguile/random.h
parentb606ff6af9c9ec7fc3c4473c09ce1e95c18f024a (diff)
downloadguile-99a0ee662050ad31e74acb3390d6901e3c916f57.tar.gz
refactor datum->random-state / random-state->datum
* libguile/random.c (scm_t_i_rstate): Move here from random.h, along with prototypes for functions (scm_i_uniform32, scm_i_init_rstate, scm_i_copy_rstate): Change to take a stock scm_t_rstate as an arg, and cast it. This way we don't cast the pointers below. (scm_i_rstate_from_datum, scm_i_rstate_from_datum): Same and rename from scm_i_init_rstate_scm / scm_i_expose_rstate. (scm_c_rstate_from_datum): Rename from scm_c_make_rstate_scm. (scm_datum_to_random_state, scm_random_state_to_datum): Rename from scm_external_to_random_state and scm_random_state_to_external. (scm_init_random): Remove casts. * libguile/random.h (scm_t_rng): Rename init_rstate_scm, expose_rstate vmethods to from_datum, to_datum. Remove internal definitions. Rename to scm_c_rstate_from_datum, and provide scm_random_state_to_datum and scm_datum_to_random_state.
Diffstat (limited to 'libguile/random.h')
-rw-r--r--libguile/random.h24
1 files changed, 5 insertions, 19 deletions
diff --git a/libguile/random.h b/libguile/random.h
index 92800ccfa..3b2966c1a 100644
--- a/libguile/random.h
+++ b/libguile/random.h
@@ -49,34 +49,18 @@ typedef struct scm_t_rng {
scm_t_uint32 (*random_bits) (scm_t_rstate *state); /* gives 32 random bits */
void (*init_rstate) (scm_t_rstate *state, const char *seed, int n);
scm_t_rstate *(*copy_rstate) (scm_t_rstate *state);
- void (*init_rstate_scm) (scm_t_rstate *state, SCM exposed);
- SCM (*expose_rstate) (scm_t_rstate *state);
+ void (*from_datum) (scm_t_rstate *state, SCM datum);
+ SCM (*to_datum) (scm_t_rstate *state);
} scm_t_rng;
SCM_API scm_t_rng scm_the_rng;
/*
- * Default RNG
- */
-typedef struct scm_t_i_rstate {
- scm_t_rstate rstate;
- scm_t_uint32 w;
- scm_t_uint32 c;
-} scm_t_i_rstate;
-
-SCM_INTERNAL scm_t_uint32 scm_i_uniform32 (scm_t_i_rstate *);
-SCM_INTERNAL void scm_i_init_rstate (scm_t_i_rstate *, const char *seed, int n);
-SCM_INTERNAL scm_t_i_rstate *scm_i_copy_rstate (scm_t_i_rstate *);
-SCM_INTERNAL void scm_i_init_rstate_scm (scm_t_i_rstate *state, SCM value);
-SCM_INTERNAL SCM scm_i_expose_rstate (scm_t_i_rstate *state);
-
-
-/*
* Random number library functions
*/
SCM_API scm_t_rstate *scm_c_make_rstate (const char *, int);
-SCM_API scm_t_rstate *scm_c_make_rstate_scm (SCM external);
+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)
SCM_API double scm_c_uniform01 (scm_t_rstate *);
@@ -99,6 +83,8 @@ SCM_API SCM scm_var_random_state;
SCM_API SCM scm_random (SCM n, SCM state);
SCM_API SCM scm_copy_random_state (SCM state);
SCM_API SCM scm_seed_to_random_state (SCM seed);
+SCM_API SCM scm_datum_to_random_state (SCM datum);
+SCM_API SCM scm_random_state_to_datum (SCM state);
SCM_API SCM scm_random_uniform (SCM state);
SCM_API SCM scm_random_solid_sphere_x (SCM v, SCM state);
SCM_API SCM scm_random_hollow_sphere_x (SCM v, SCM state);