do
  matrix = {}
  matrix["__index"] = matrix
  local function _0_(cls_0_, ...)
    local inst_0_ = {}
    local function _1_(cls, self, n, m)
      assert((nil ~= m), ("Missing argument %s on %s:%s"):format("m", "sources/mods/electricity/matrix.fnl", 4))
      assert((nil ~= n), ("Missing argument %s on %s:%s"):format("n", "sources/mods/electricity/matrix.fnl", 4))
      assert((nil ~= self), ("Missing argument %s on %s:%s"):format("self", "sources/mods/electricity/matrix.fnl", 4))
      assert((nil ~= cls), ("Missing argument %s on %s:%s"):format("cls", "sources/mods/electricity/matrix.fnl", 4))
      local size = (n * m)
      self.data = allocate("complex[?]", size)
      self.size = {height = n, width = m}
      return nil
    end
    _1_(cls_0_, inst_0_, ...)
    setmetatable(inst_0_, cls_0_)
    return inst_0_
  end
  setmetatable(matrix, {__call = _0_})
end
matrix.idx = function(self, i, j)
  return (((i - 1) * self.size.width) + (j - 1))
end
matrix.get = function(self, i, j)
  return self.data[matrix.idx(self, i, (j or 1))]
end
matrix.set = function(self, i, j, val)
  self.data[matrix.idx(self, i, (j or 1))] = val
  return nil
end
matrix.print = function(self)
  for i = 1, self.size.width do
    for j = 1, self.size.height do
      io.write(self:get(i, j), " ")
    end
    io.write("\n")
  end
  return nil
end
return matrix.print
