Skip to content

Commit

Permalink
Sync hpcgap/lib/random.gi
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Sep 19, 2017
1 parent 96670b9 commit f2d004b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 247 deletions.
244 changes: 0 additions & 244 deletions hpcgap/lib/random.gi

This file was deleted.

17 changes: 14 additions & 3 deletions lib/random.gi
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ end);

############################################################################
## We provide the "classical" GAP random generator via a random source.
##
InstallValue(GlobalRandomSource, Objectify(NewType(RandomSourcesFamily,
IsGlobalRandomSource),rec()));
##
if IsBound(HPCGAP) then
BindThreadLocalConstructor("GlobalRandomSource", {} ->
Objectify(NewType(RandomSourcesFamily, IsGlobalRandomSource), rec()));
else
InstallValue(GlobalRandomSource,
Objectify(NewType(RandomSourcesFamily, IsGlobalRandomSource), rec()));
fi;

InstallMethod(Init, [IsGlobalRandomSource, IsObject], function(rs, seed)
if IsInt(seed) then
RANDOM_SEED(seed);
Expand Down Expand Up @@ -218,7 +224,12 @@ end);

# One global Mersenne twister random source, can be used to overwrite
# the library Random(list) and Random(a,b) methods.
if IsBound(HPCGAP) then
BindThreadLocalConstructor("GlobalMersenneTwister", {} ->
RandomSource(IsMersenneTwister, String(GET_RANDOM_SEED_COUNTER())));
else
InstallValue(GlobalMersenneTwister, RandomSource(IsMersenneTwister, "1"));
fi;

# default random method for lists and pairs of integers using the Mersenne
# twister
Expand Down

0 comments on commit f2d004b

Please sign in to comment.