diff --git a/lib/padics.gi b/lib/padics.gi index a098aabb98..6ac4757eed 100644 --- a/lib/padics.gi +++ b/lib/padics.gi @@ -480,17 +480,17 @@ end ); ## may get two pure p-adic numbers that have no "digit" in common, so by ## adding them, one of the two vanishes. ## -InstallOtherMethod( Random, +InstallOtherMethodWithRandomSource( Random, "for a random source and a pure p-adic family", true, - [ IsPurePadicNumberFamily ], + [ IsRandomSource, IsPurePadicNumberFamily ], 0, -function ( fam ) +function ( rg, fam ) local c; c := []; - c[1] := Random( -fam!.precision, fam!.precision ); - c[2] := Random( 0, fam!.modulus-1 ); + c[1] := Random( rg, -fam!.precision, fam!.precision ); + c[2] := Random( rg, 0, fam!.modulus-1 ); while c[2] mod fam!.prime = 0 do c[1] := c[1] + 1; c[2] := c[2] / fam!.prime; @@ -903,19 +903,19 @@ end ); ## Again this is just something that returns an extended p-adic number. The ## p-part is not totally covered (just ranges from -precision to precision). ## -InstallOtherMethod( Random, +InstallOtherMethodWithRandomSource( Random, "for a random source and p-adic extension family", true, - [ IsPadicExtensionNumberFamily ], + [ IsRandomSource, IsPadicExtensionNumberFamily ], 0, -function ( fam ) +function ( rg, fam ) local c, l; c := []; - c[1] := Random( -fam!.precision, fam!.precision ); + c[1] := Random( rg, -fam!.precision, fam!.precision ); c[2] := []; for l in [ 1 .. fam!.n ] do - c[2][l] := Random( 0, fam!.modulus-1 ); + c[2][l] := Random( rg, 0, fam!.modulus-1 ); od; while ForAll( c[2], x-> x mod fam!.prime = 0 ) do c[1] := c[1] + 1; diff --git a/tst/testinstall/random.tst b/tst/testinstall/random.tst index 058c49aa4b..1dcd996ba8 100644 --- a/tst/testinstall/random.tst +++ b/tst/testinstall/random.tst @@ -3,4 +3,6 @@ gap> Read( Filename( DirectoriesLibrary( "tst" ), "testrandom.g" ) ); gap> randomTest(Integers, Random); gap> randomTest([1..10], Random); gap> randomTest([1,-6,"cheese", Group(())], Random); +gap> randomTest(PadicExtensionNumberFamily(3, 5, [1,1,1], [1,1]), Random, function(x,y) return IsPadicExtensionNumber(x); end); +gap> randomTest(PurePadicNumberFamily(2,20), Random, function(x,y) return IsPurePadicNumber(x); end); gap> STOP_TEST("random.tst", 1);