torch/torch7 — pull request #13 by timharley (2014-03-06 16:39:10+00:00)
Title: Make random number generator state a TH type

State of the random number generator is moved from static data to a first-class type within TH: a THGenerator. These are then available within torch as a torch.Generator object. A default generator added in to the torch namespace when loading the package and used implicitly for any random functions.

* Behaviour of the random number stream is identical [see below for a test]. i.e. outstanding bugs are not fixed.
* The torch API is backwards compatible (all unit tests pass with no changes).
* This patch makes random number generation thread safe between different interpreters within a single process.
* Additionally, the torch API is extended, allowing you to explicitly pass a generator object to any particular random function, so you can have parallel random number streams within a single lua program.