torch/torch7-distro — pull request #191 by jucor (2013-11-04 17:30:46+00:00)
Title: randn() not reset by manualSeed nor by set/getRNGState

As spotted by @schaul, and mentioned to @koraykv, the seed and state of the RNG do not reset properly when an odd number of gaussian has been generated:
```
[julien@stmartin Research]$ torch
Try the IDE: torch -ide
Type help() for more info
Torch 7.0 Copyright (C) 2001-2011 Idiap, NEC Labs, NYU
Lua 5.1 Copyright (C) 1994-2008 Lua.org, PUC-Rio
t7> torch.manualSeed(31); print(torch.randn(3))
-0.0545
0.2364
0.8518
[torch.DoubleTensor of dimension 3]

t7> torch.manualSeed(31); print(torch.randn(3))
-0.2295
-0.0545
0.2364
[torch.DoubleTensor of dimension 3]

t7> torch.manualSeed(31); print(torch.randn(3))
-0.0545
0.2364
0.8518
[torch.DoubleTensor of dimension 3]
```

This is due to the global variables `int normal_is_valid` , `double normal_x`, `double normal_y`, and `double normal_rho` lines 17-20 of `THRandom.c` , which are ignored by `getRNGState`, `setRNGState`, and `manualSeed`.