From: Daniel Kochmański Date: Tue, 22 Sep 2015 14:16:40 +0000 (+0200) Subject: random-state: use 32 bit types for 32 bit implementation X-Git-Url: http://git.pulsar-zone.net/?a=commitdiff_plain;h=a8432f4f9cf546dc365067feb58e13abb75bbdb7;p=ecl.git random-state: use 32 bit types for 32 bit implementation Signed-off-by: Daniel Kochmański --- diff --git a/src/c/hash.d b/src/c/hash.d index 10c9ad1..ed76513 100644 --- a/src/c/hash.d +++ b/src/c/hash.d @@ -117,8 +117,12 @@ _hash_equal(int depth, cl_hashkey h, cl_object x) * because otherwise two bit arrays which are EQUAL might * have different hash keys. */ return hash_string(h, x->vector.self.bc, x->vector.fillp / 8); - case t_random: - return _hash_equal(0, h, x->random.value); + case t_random: { + cl_object array = x->random.value; + return hash_string + (h, (unsigned char*)array->vector.self.b32, + array->vector.fillp * sizeof(ecl_uint32_t)); + } #ifdef ECL_SIGNED_ZERO case t_singlefloat: { float f = ecl_single_float(x); diff --git a/src/c/num_rand.d b/src/c/num_rand.d index 588080f..2fde51b 100644 --- a/src/c/num_rand.d +++ b/src/c/num_rand.d @@ -43,7 +43,9 @@ n*/ #define UPPER_MASK 0x80000000UL /* most significant w-r bits */ #define LOWER_MASK 0x7fffffffUL /* least significant r bits */ -#define ulong unsigned long +/* INV: for 64 bit implementation modify accordingly _hash_equal in + hash.d file for case t_random */ +#define ulong ecl_uint32_t cl_object init_genrand(ulong seed) @@ -52,7 +54,7 @@ init_genrand(ulong seed) ecl_alloc_simple_vector ((MT_N + 1), ecl_symbol_to_elttype(@'ext::byte32')); - ulong *mt = (ulong*)(array->base_string.self); + ulong *mt = (ulong*)(array->vector.self.b32); int j = 0; mt[0] = seed & 0xffffffffUL; for (j=1; j < MT_N; j++) @@ -90,7 +92,7 @@ generate_int32(cl_object state) { static ulong mag01[2]={0x0UL, MATRIX_A}; ulong y; - ulong *mt = (ulong*)state->base_string.self; + ulong *mt = (ulong*)state->vector.self.b32; if (mt[MT_N] >= MT_N){ /* refresh data */ int kk;