Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several fixes for Random on long lists in 64-bit GAP #781

Merged
merged 3 commits into from
May 10, 2016

Conversation

frankluebeck
Copy link
Member

  • removes the kernel function RandomListMT
  • adjusts RandomList to documentation
  • fixes several problems by using new RandomList instead of RANDOM_LIST
  • ensures that RANDOM_LIST is only called for lists of length < 2^28
  • introduces a simple scheme for test code that runs differently on 32bit and 64bit GAP
  • adds some test code for Random on lists

As reported by Stefan Kohl, RandomListMT did not work as expected
in 64-bit GAP on lists of length >= 2^28.
Kernel function removed, corresponding GAP function now uses
Random(1,Length(list)).
RANDOM_LIST (compiled function from lib/random.g) does not work
as expected in 64-bit GAP on list of length >= 2^28 (it only returns
positions which are equal mod 2^28).

RandomList did not use the Mersenne twister as is explicitly documented
(but was synonym to RANDOM_LIST).

- Now RandomList works as documented.
- RandomList is used in several places of the library instead of
  RANDOM_LIST.
- Functions for the GlobalRandomSource and GAPRandomSource now use
  RANDOM_LIST only for lists of length < 2^28.
Introduced two directories for code that behaves differently in
32-bit GAP and 64-bit GAP. Only one is used in tst/teststandard.g
depending on the current GAP.
@markuspf
Copy link
Member

markuspf commented May 5, 2016

@james-d-mitchell does the partial permutations test code rely on some (previously wrong?) behaviour of Random?

@ChrisJefferson
Copy link
Contributor

This all looks good and all correct to me, better than my previous pull request.

@james-d-mitchell
Copy link
Contributor

@markuspf I don't think so, but who knows. I plan to rewrite those tests when I get some time!

@markuspf
Copy link
Member

markuspf commented May 9, 2016

I suppose we can just use the usual kludge of updating the test for the time being...

@olexandr-konovalov
Copy link
Member

yes, it's only two lines in testinstall/pperm.tst that need updating. Let's merge this and fix them.

@olexandr-konovalov
Copy link
Member

This certainly leads to diffs in manual examples - I will update these within a couple of days:

============================================================
########> Diff in [ "./../../lib/random.gd", 114, 123 ]
# Input is:
List([1..10],i->Random(Integers));
# Expected output:
[ -1, -3, -2, 1, -2, -1, 0, 1, 0, 1 ]
# But found:
[ 2, -1, -2, -1, -1, 1, -4, 1, 0, -1 ]
########
########> Diff in [ "./../../lib/random.gd", 114, 123 ]
# Input is:
List([1..10],i->Random(Integers));
# Expected output:
[ -1, 0, 2, 0, 4, -1, -3, 1, -4, -1 ]
# But found:
[ -1, -1, 1, -1, 1, -2, -1, -2, 0, -1 ]
########
########> Diff in [ "./../../lib/random.gd", 114, 123 ]
# Input is:
List([1..10],i->Random(Integers));
# Expected output:
[ -1, -3, -2, 1, -2, -1, 0, 1, 0, 1 ]
# But found:
[ 2, -1, -2, -1, -1, 1, -4, 1, 0, -1 ]
########
########> Diff in [ "./../../lib/random.gd", 208, 221 ]
# Input is:
n := Random(rs1, 1, 2^220);
# Expected output:
1598617776705343302477918831699169150767442847525442557699717518961
# But found:
1077726777923092117987668044202944212469136000816111066409337432400
########
########> Diff in [ "./../../lib/list.gd", 1426, 1439 ]
# Input is:
m := Shuffle(ShallowCopy(l));
# Expected output:
[ 15, 13, 3, 19, 8, 11, 14, 7, 16, 4, 17, 18, 5, 1, 10, 6, 2, 9, 12, 
 20 ]
# But found:
[ 8, 13, 1, 3, 20, 15, 4, 7, 5, 18, 6, 12, 16, 11, 2, 10, 19, 17, 9, 
 14 ]
########
########> Diff in [ "./../../lib/list.gd", 1426, 1439 ]
# Input is:
l;
# Expected output:
[ 3, 4, 18, 13, 10, 7, 9, 8, 14, 17, 16, 6, 19, 12, 1, 11, 20, 2, 15, 
 5 ]
# But found:
[ 19, 5, 7, 20, 16, 1, 10, 15, 12, 11, 13, 2, 14, 3, 4, 17, 6, 8, 9, 
 18 ]
########
########> Diff in [ "./../../lib/matrix.gd", 1628, 1635 ]
# Input is:
m := RandomInvertibleMat(4);
# Expected output:
[ [ 1, -2, -1, 0 ], [ 1, 0, 1, -1 ], [ 0, 2, 0, 4 ], 
 [ -1, -3, 1, -4 ] ]
# But found:
[ [ -4, 1, 0, -1 ], [ -1, -1, 1, -1 ], [ 1, -2, -1, -2 ], 
 [ 0, -1, 2, -2 ] ]
########
########> Diff in [ "./../../lib/matrix.gd", 1628, 1635 ]
# Input is:
m^-1;
# Expected output:
[ [ 1/4, 1/2, -1/8, -1/4 ], [ -1/3, 0, -1/3, -1/3 ], 
 [ -1/12, 1/2, 13/24, 5/12 ], [ 1/6, 0, 5/12, 1/6 ] ]
# But found:
[ [ -1/8, -11/24, 1/24, 1/4 ], [ 1/4, -13/12, -1/12, 1/2 ], 
 [ -1/8, 5/24, -7/24, 1/4 ], [ -1/4, 3/4, -1/4, -1/2 ] ]
########
########> Diff in [ "./../../lib/matrix.gd", 1677, 1682 ]
# Input is:
m := RandomUnimodularMat(3);
# Expected output:
[ [ 1, 0, 0 ], [ 156, -39, -25 ], [ -100, 25, 16 ] ]
# But found:
[ [ -5, 1, 0 ], [ 12, -2, -1 ], [ -14, 3, 0 ] ]
########
########> Diff in [ "./../../lib/matrix.gd", 1677, 1682 ]
# Input is:
m^-1;
# Expected output:
[ [ 1, 0, 0 ], [ 4, 16, 25 ], [ 0, -25, -39 ] ]
# But found:
[ [ -3, 0, 1 ], [ -14, 0, 5 ], [ -8, -1, 2 ] ]
########
########> Diff in [ "./../../lib/coll.gd", 1621, 1631 ]
# Input is:
Random([1..6]);
# Expected output:
1
# But found:
6
########
########> Diff in [ "./../../lib/coll.gd", 1621, 1631 ]
# Input is:
g:= Group( (1,2,3) );;  Random( g );  Random( g );
# Expected output:
(1,3,2)
(1,2,3)
# But found:
(1,3,2)
()
########
########> Diff in [ "./../../lib/coll.gd", 1621, 1631 ]
# Input is:
Random(Rationals);
# Expected output:
-2
# But found:
-4
########
########> Diff in [ "./../../lib/straight.gd", 631, 645 ]
# Input is:
Random(g);
# Expected output:
<
[ [ 1, -1, 2, -1, 1, 1, 2, -1, 1, -1, 2, 1, 1, 1, 2, 1, 1, -1, 2, 2, 
     1, 1 ], 
 [ 3, -2, 2, -2, 1, -1, 2, -2, 1, 1, 2, -1, 1, -1, 2, -2, 1, 1, 2, 
     -1, 1, -1, 2, -1, 1, 1, 2, 1, 1, -1, 2, 1, 1, 1 ] ]>
# But found:
<
[ [ 1, -1, 2, -1, 1, 1, 2, -1, 1, -1, 2, 1, 1, 1, 2, 1, 1, -1, 2, 2, 
     1, 1 ], [ 3, -2, 2, -2 ], 
 [ 4, 1, 1, -1, 2, -2, 1, 1, 2, -1, 4, 1 ] ]|(1,3)>
########
########> Diff in [ "./../../lib/grp.gd", 3166, 3170 ]
# Input is:
s:=SubnormalSeries(g,Group((1,2)(3,4)));
# Expected output:
[ Group([ (1,2,3,4), (1,2) ]), Group([ (1,2)(3,4), (1,3)(2,4) ]), 
Group([ (1,2)(3,4) ]) ]
# But found:
[ Group([ (1,2,3,4), (1,2) ]), Group([ (1,2)(3,4), (1,4)(2,3) ]), 
 Group([ (1,2)(3,4) ]) ]
########
########> Diff in [ "./../../lib/teaching.g", 195, 200 ]
# Input is:
AllHomomorphismClasses(SymmetricGroup(4),SymmetricGroup(3)); 
# Expected output:
[ [ (1,3,4,2), (1,2,4) ] -> [ (), () ], 
 [ (1,3,4,2), (1,2,4) ] -> [ (1,2), () ], 
 [ (1,3,4,2), (1,2,4) ] -> [ (2,3), (1,2,3) ] ]
# But found:
[ [ (1,3,4,2), (1,3,4) ] -> [ (), () ], 
 [ (1,3,4,2), (1,3,4) ] -> [ (1,2), () ], 
 [ (1,3,4,2), (1,3,4) ] -> [ (2,3), (1,2,3) ] ]
########
########> Diff in [ "./../../lib/morpheus.gd", 504, 511 ]
# Input is:
quo:=GQuotients(g,h);
# Expected output:
[ [ (1,2,4,3), (1,2,3) ] -> [ (2,3), (1,2,3) ] ]
# But found:
[ [ (1,3,2,4), (1,3,2) ] -> [ (2,3), (1,2,3) ] ]
########
########> Diff in [ "./grpfp.xml", 266, 279 ]
# Input is:
h := IsomorphismPermGroup( g );
# Expected output:
[ a, b ] -> [ (1,2)(4,5), (2,3,4) ]
# But found:
[ a, b ] -> [ (2,4)(5,6), (1,2,3)(4,5,6) ]
########
########> Diff in [ "./../../lib/grp.gd", 4068, 4077 ]
# Input is:
RelatorsOfFpGroup( fp );
# Expected output:
[ F1^2, F2^5, (F2^-1*F1)^4, (F2^-1*F1*F2*F1)^3, (F2^2*F1*F2^-2*F1)^2 ]
# But found:
[ F1^2, F2^5, (F2^-1*F1)^4, (F2*F1*F2^-1*F1)^3, (F2*F1*F2^-2*F1*F2)^2 
]
########
########> Diff in [ "./../../lib/grp.gd", 4097, 4106 ]
# Input is:
iso := IsomorphismFpGroupByGenerators( M12, gens );;
# Expected output:
#I  the image group has 3 gens and 23 rels of total length 628
# But found:
#I  the image group has 3 gens and 18 rels of total length 337
########
########> Diff in [ "./../../lib/grp.gd", 4097, 4106 ]
# Input is:
iso := IsomorphismFpGroupByGenerators( M12, gens );;
# Expected output:
#I  the image group has 3 gens and 23 rels of total length 569
# But found:
#I  the image group has 3 gens and 19 rels of total length 493
########
########> Diff in [ "./../../lib/grp.gd", 4148, 4155 ]
# Input is:
iso := IsomorphismFpGroupByGenerators( M12, gens : 
                                         method := "fast" );;
# Expected output:
#I  the image group has 3 gens and 150 rels of total length 3336
# But found:
#I  the image group has 3 gens and 154 rels of total length 3389
########
########> Diff in [ "./../../lib/grp.gd", 4167, 4189 ]
# Input is:
iso := IsomorphismFpGroupByGenerators( G, gens );;
# Expected output:
#I  the image group has 2 gens and 10 rels of total length 128
# But found:
#I  the image group has 2 gens and 9 rels of total length 94
########
########> Diff in [ "./xtndxmpl.xml", 846, 860 ]
# Input is:
gens:= GeneratorsOfGroup( syl3 );
# Expected output:
[ [ [ ( 15 mod 16 ), ( 5 mod 16 ) ], [ ( 3 mod 16 ), ( 0 mod 16 ) ] ] 
]
# But found:
[ [ [ ( 1 mod 16 ), ( 7 mod 16 ) ], [ ( 11 mod 16 ), ( 14 mod 16 ) ] 
    ] ]
########
=========OUTPUT END: testmanuals with autoloaded packages=========

@olexandr-konovalov
Copy link
Member

This PR has been made into master but then cherry-picked onto stable-4.8. That's why it belongs to GAP 4.8.4 milestone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants