function vec_mt.__add(v,Y)local y,w=typeof(v),typeof(Y)if y=="\086\101\099\116\111\114"and w=="\086\101\099\116\111\114"then local y={}for w in next,v do y[w]=v[w]+Y[w]end return vec.new(y)end end function vec_mt.__sub(v,Y)local y,w=typeof(v),typeof(Y)if y=="\086\101\099\116\111\114"and w=="\086\101\099\116\111\114"then local y={}for w in next,v do y[w]=v[w]-Y[w]end return vec.new(y)end end function vec_mt.__mul(v,Y)local y,w=typeof(v),typeof(Y)local I=y=="\110\117\109\098\101\114"if I or w=="\110\117\109\098\101\114"then local y={}local w,n=I and Y or v,I and v or Y for v in next,w do y[v]=w[v]*n end return vec.new(y)elseif y=="\086\101\099\116\111\114"and w=="\086\101\099\116\111\114"then local y={}for w in next,v do y[w]=v[w]*Y[w]end return vec.new(y)end end function vec_mt.__div(v,Y)local y,w=typeof(v),typeof(Y)if y=="\110\117\109\098\101\114"then local y={}for w in next,Y do y[w]=v/Y[w]end return vec.new(y)elseif w=="\110\117\109\098\101\114"then local y={}for w in next,v do y[w]=v[w]/Y end return vec.new(y)elseif y=="\086\101\099\116\111\114"and w=="\086\101\099\116\111\114"then local y={}for w in next,v do y[w]=v[w]/Y[w]end return vec.new(y)end end function vec_mt.__unm(v)local Y={}for y in next,v do Y[y]=-v[y]end return vec.new(Y)end function vec_mt.__tostring(v)return table.concat(v,"\044 ")end
-- meta methods

function vec_mt.__add(a, b)
	local at, bt = typeof(a), typeof(b)
	if at == "Vector" and bt == "Vector" then
		local t = {}
		for k in next, a do
			t[k] = a[k] + b[k]
		end
		return vec.new(t)
	end
end

function vec_mt.__sub(a, b)
	local at, bt = typeof(a), typeof(b)
	if at == "Vector" and bt == "Vector" then
		local t = {}
		for k in next, a do
			t[k] = a[k] - b[k]
		end
		return vec.new(t)
	end
end

function vec_mt.__mul(a, b)
	local at, bt = typeof(a), typeof(b)
	local aisNum = at == "number"
	if aisNum or bt == "number" then
		local t = {}
		local v, n = aisNum and b or a, aisNum and a or b
		for k in next, v do
			t[k] = v[k] * n
		end
		return vec.new(t)
	elseif at == "Vector" and bt == "Vector" then
		local t = {}
		for k in next, a do
			t[k] = a[k] * b[k]
		end
		return vec.new(t)
	end
end

function vec_mt.__div(a, b)
	local at, bt = typeof(a), typeof(b)
	if at == "number" then
		local t = {}
		for k in next, b do
			t[k] = a / b[k]
		end
		return vec.new(t)
	elseif bt == "number" then
		local t = {}
		for k in next, a do
			t[k] = a[k] / b
		end
		return vec.new(t)
	elseif at == "Vector" and bt == "Vector" then
		local t = {}
		for k in next, a do
			t[k] = a[k] / b[k]
		end
		return vec.new(t)
	end
end

function vec_mt.__unm(v)
	local t = {}
	for k in next, v do
		t[k] = -v[k]
	end
	return vec.new(t)
end

function vec_mt.__tostring(v)
	return table.concat(v, ", ")
end
