Welcome to mirror list, hosted at ThFree Co, Russian Federation.

random.lua - github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a6f0c3da8822da313785f0778bbd2d65d9788fb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local wrap = require 'cwrap'

require 'torchcwrap'

local interface = wrap.CInterface.new()

interface:print(
   [[
#include "luaT.h"
#include "TH.h"

extern void torch_Generator_init(lua_State *L);
extern void torch_Generator_new(lua_State *L);
   ]])

for _,name in ipairs({"seed", "initialSeed"}) do
   interface:wrap(name,
                  string.format("THRandom_%s",name),
                  {{name='Generator', default=true},
                   {name="long", creturned=true}})
end

interface:wrap('manualSeed',
               'THRandom_manualSeed',
               {{name='Generator', default=true},
                {name="long"}})

interface:wrap('getRNGState',
                'THByteTensor_getRNGState',
                {{name='Generator', default=true},
                 {name='ByteTensor',default=true,returned=true,method={default='nil'}}
                 })

interface:wrap('setRNGState',
                'THByteTensor_setRNGState',
                {{name='Generator', default=true},
                 {name='ByteTensor',default=true,returned=true,method={default='nil'}}
                 })

interface:register("random__")
                
interface:print(
   [[
void torch_random_init(lua_State *L)
{
  torch_Generator_init(L);
  torch_Generator_new(L);
  lua_setfield(L, -2, "_gen");
  luaT_setfuncs(L, random__, 0);
}
]])

interface:tofile(arg[1])