Permalink
Browse files

Modified sfmt.erl and other source files

* seed/1 when seed(integer) will call init_by_list32([integer])
  instead of init_gen_rand(integer).  This prevents the seed
  value to be guessed from the internal state after the initialization.
* Changed the @doc comments as well.
  • Loading branch information...
1 parent 99236e3 commit 2cef010c9c718e369ac65dfa57a4aa8367b25d3c @jj1bdx committed May 25, 2012
Showing with 18 additions and 12 deletions.
  1. +3 −2 src/sfmt.erl
  2. +3 −2 src/sfmt216091.erl
  3. +3 −2 src/sfmt4253.erl
  4. +3 −2 src/sfmt607.erl
  5. +3 −2 src/sfmt86243.erl
  6. +3 −2 src/sfmt_pure.erl
View
@@ -365,13 +365,14 @@ seed() ->
end.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state.
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
RS = {?N32, I},
put(?PDIC_SEED, RS);
View
@@ -365,13 +365,14 @@ seed() ->
end.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state.
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
RS = {?N32, I},
put(?PDIC_SEED, RS);
View
@@ -365,13 +365,14 @@ seed() ->
end.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state.
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
RS = {?N32, I},
put(?PDIC_SEED, RS);
View
@@ -365,13 +365,14 @@ seed() ->
end.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state.
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
RS = {?N32, I},
put(?PDIC_SEED, RS);
View
@@ -365,13 +365,14 @@ seed() ->
end.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state.
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
RS = {?N32, I},
put(?PDIC_SEED, RS);
View
@@ -488,13 +488,14 @@ seed() ->
RS.
%% @spec seed(integer()) -> ran_sfmt()
-%% @doc Puts the seed computed from the given integer list by init_gen_rand/1
+%% @doc Puts the seed computed from the given integer
+%% as a single-element list by init_by_list32/1
%% and puts the internal state into the process dictionary
%% and initializes the random number list with the internal state
%% and returns the old internal state
seed(N) when is_integer(N) ->
- I = init_gen_rand(N),
+ I = init_by_list32([N]),
% this operation is intstate() type dependent
R = I,
RS = {R, I},

0 comments on commit 2cef010

Please sign in to comment.