forked from jcosborn/qhmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLattice.lua
61 lines (53 loc) · 1.29 KB
/
Lattice.lua
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
54
55
56
57
58
59
60
61
require 'Util'
require 'Field'
local latticemt = {}
latticemt._type = "Lattice"
function Lattice(latsize)
local self = {}
self.latsize = tableCopy(latsize)
self.name = "L"
self.defaultPrecision = 'D'
self.defaultGroup = "SU"
self.defaultNc = 3
--self.volume = 1
--for i=1,#latsize do self.volume=self.volume*latsize[i] end
self.qdplat = qopqdp.lattice(latsize)
self.volume = self.qdplat:volume()
return setmetatable(self,latticemt)
end
function latticemt.__tostring(self)
local s = {}
s[#s+1] = self.name
s[#s+1] = " = Lattice{ "
for i=1,#self.latsize do
if i>1 then s[#s+1] = ", " end
s[#s+1] = self.latsize[i]
end
s[#s+1] = " }\n"
return table.concat(s)
end
function latticemt.__index(self, k)
if type(k)=="number" then
return self.latsize[k]
end
return latticemt[k]
end
function latticemt.__len(self)
return #self.latsize
end
function latticemt.Set(self, opts)
tableCopyTo(self, opts)
end
function latticemt.Seed(self, seed)
--qopqdp.seed(seed)
self.qdplat:seed(seed)
end
function latticemt.GaugeField(self, opts)
local opts = opts or {}
local opt = {}
opt.precision = opts.precision or self.defaultPrecision
opt.group = opts.group or self.defaultGroup
opt.nc = opts.nc or self.defaultNc
opt.kind = "gauge"
return Field(self, opt)
end