mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
* Replace calls to SCM_LENGTH.
This commit is contained in:
parent
b226e5f658
commit
b7ead2aee2
2 changed files with 14 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2000-10-11 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
|
* random.c (scm_seed_to_random_state): Replace SCM_LENGTH with
|
||||||
|
the appropriate SCM_<type>_LENGTH macro.
|
||||||
|
|
||||||
|
(vector_scale, vector_sum_squares, scm_random_solid_sphere_x,
|
||||||
|
scm_random_normal_vector_x): Use scm_uniform_vector_length to
|
||||||
|
determine the length of a vector object generically.
|
||||||
|
|
||||||
2000-10-11 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
2000-10-11 Dirk Herrmann <D.Herrmann@tu-bs.de>
|
||||||
|
|
||||||
* ramap.c (scm_array_fill_int, scm_array_index_map_x): Replace
|
* ramap.c (scm_array_fill_int, scm_array_index_map_x): Replace
|
||||||
|
|
|
@ -405,7 +405,7 @@ SCM_DEFINE (scm_seed_to_random_state, "seed->random-state", 1, 0, 0,
|
||||||
seed = scm_number_to_string (seed, SCM_UNDEFINED);
|
seed = scm_number_to_string (seed, SCM_UNDEFINED);
|
||||||
SCM_VALIDATE_STRING (1,seed);
|
SCM_VALIDATE_STRING (1,seed);
|
||||||
return make_rstate (scm_c_make_rstate (SCM_ROCHARS (seed),
|
return make_rstate (scm_c_make_rstate (SCM_ROCHARS (seed),
|
||||||
SCM_LENGTH (seed)));
|
SCM_STRING_LENGTH (seed)));
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
||||||
|
@ -442,7 +442,7 @@ SCM_DEFINE (scm_random_normal, "random:normal", 0, 1, 0,
|
||||||
static void
|
static void
|
||||||
vector_scale (SCM v, double c)
|
vector_scale (SCM v, double c)
|
||||||
{
|
{
|
||||||
int n = SCM_LENGTH (v);
|
int n = SCM_INUM (scm_uniform_vector_length (v));
|
||||||
if (SCM_VECTORP (v))
|
if (SCM_VECTORP (v))
|
||||||
while (--n >= 0)
|
while (--n >= 0)
|
||||||
SCM_REAL_VALUE (SCM_VELTS (v)[n]) *= c;
|
SCM_REAL_VALUE (SCM_VELTS (v)[n]) *= c;
|
||||||
|
@ -455,7 +455,7 @@ static double
|
||||||
vector_sum_squares (SCM v)
|
vector_sum_squares (SCM v)
|
||||||
{
|
{
|
||||||
double x, sum = 0.0;
|
double x, sum = 0.0;
|
||||||
int n = SCM_LENGTH (v);
|
int n = SCM_INUM (scm_uniform_vector_length (v));
|
||||||
if (SCM_VECTORP (v))
|
if (SCM_VECTORP (v))
|
||||||
while (--n >= 0)
|
while (--n >= 0)
|
||||||
{
|
{
|
||||||
|
@ -494,7 +494,7 @@ SCM_DEFINE (scm_random_solid_sphere_x, "random:solid-sphere!", 1, 1, 0,
|
||||||
scm_random_normal_vector_x (v, state);
|
scm_random_normal_vector_x (v, state);
|
||||||
vector_scale (v,
|
vector_scale (v,
|
||||||
pow (scm_c_uniform01 (SCM_RSTATE (state)),
|
pow (scm_c_uniform01 (SCM_RSTATE (state)),
|
||||||
1.0 / SCM_LENGTH (v))
|
1.0 / SCM_INUM (scm_uniform_vector_length (v)))
|
||||||
/ sqrt (vector_sum_squares (v)));
|
/ sqrt (vector_sum_squares (v)));
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ SCM_DEFINE (scm_random_normal_vector_x, "random:normal-vector!", 1, 1, 0,
|
||||||
if (SCM_UNBNDP (state))
|
if (SCM_UNBNDP (state))
|
||||||
state = SCM_CDR (scm_var_random_state);
|
state = SCM_CDR (scm_var_random_state);
|
||||||
SCM_VALIDATE_RSTATE (2,state);
|
SCM_VALIDATE_RSTATE (2,state);
|
||||||
n = SCM_LENGTH (v);
|
n = SCM_INUM (scm_uniform_vector_length (v));
|
||||||
if (SCM_VECTORP (v))
|
if (SCM_VECTORP (v))
|
||||||
while (--n >= 0)
|
while (--n >= 0)
|
||||||
SCM_VELTS (v)[n] = scm_make_real (scm_c_normal01 (SCM_RSTATE (state)));
|
SCM_VELTS (v)[n] = scm_make_real (scm_c_normal01 (SCM_RSTATE (state)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue