Skip to content

Commit

Permalink
lib: add RandomSource support to ZmodnZ Random
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Sep 14, 2017
1 parent a5c084d commit cd9bcbb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/zmodnz.gi
Original file line number Diff line number Diff line change
Expand Up @@ -772,12 +772,12 @@ InstallMethod( AsSSortedList,
##
#M Random( <R> ) . . . . . . . . . . . . . . . . . method for full ring Z/nZ
##
InstallMethod( Random,
"for full ring Z/nZ",
[ IsZmodnZObjNonprimeCollection and IsWholeFamily ],
InstallMethodWithRandomSource(Random,
"for a random source and full ring Z/nZ",
[ IsRandomSource, IsZmodnZObjNonprimeCollection and IsWholeFamily ],
RankFilter( IsRing ),
R -> ZmodnZObj( ElementsFamily( FamilyObj( R ) ),
Random( [ 0 .. Size( R ) - 1 ] ) ) );
{ rs, R } -> ZmodnZObj( ElementsFamily( FamilyObj( R ) ),
Random( rs, [ 0 .. Size( R ) - 1 ] ) ) );


#############################################################################
Expand Down
7 changes: 7 additions & 0 deletions tst/testinstall/zmodnz.tst
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ matrix over Integers mod 170141183460469231731687303715884105728:
[ [ 92709463147897837085761925410587, 92709463147897837085761925410587 ],
[ 92709463147897837085761925410587, 92709463147897837085761925410587 ] ]
# test the methods for Random
gap> R := Integers mod 10;;
gap> Random(R);
ZmodnZObj( 4, 10 )
gap> Random(GlobalRandomSource, R);
ZmodnZObj( 9, 10 )
#
gap> STOP_TEST( "zmodnz.tst", 1);
Expand Down

0 comments on commit cd9bcbb

Please sign in to comment.