Dear Ha, On 23 Jul 2014, at 22:19, Ha T. Lam <hat...@gmail.com> wrote:
> Dear GAP forum, > > I'm trying to generate random 2x2 matrices with entries from GF(947). > Normally, I would just use RandomMat(2,2,GF(947)), but I want to get > different results every time I start GAP. I found that RandomSource( r, dev > ) from the io package ( > http://www.gap-system.org/Manuals/pkg/io/doc/chap6.html) allows randomness > from /dev/random, but I don't know how to use it as the random source for > RandomMat. Any advice? This is doable - first you have to create a real random source: gap> rs:=RandomSource(IsRealRandomSource,"random"); <a real random source> Then you may create a list of all elements of GF(947) and pick up elements from it using "Random": gap> gf:=AsList(GF(947));; gap> Random(rs,gf); Z(947)^42 gap> Random(rs,gf); Z(947)^817 Now you may take the code for RandomMat from the library and adjust it to say ReallyRandomMat which will use the approach above instead of calling Random( GF(947) ); There is a warning, however. If it may be enough for you to use dev/urandom instead of dev/random, then it is advised to go for the 'urandom' option. I remember once we were very puzzled by the slow performance of GAP on the server where dev/random was used to generate some random strings. It was not possible to reproduce the slowdown at all while using GAP interactively. Then we figured out what happened: dev/random needs some noise in the entropy pool, and it may block when the pool is empty to wait for some more events to happen. There was a plenty of events when one was sitting in front of the keyboard; however, that was not the case on the server when GAP was running as a daemon. So please be aware of this feature. Hope this helps, Alexander _______________________________________________ Forum mailing list Forum@mail.gap-system.org http://mail.gap-system.org/mailman/listinfo/forum