function vec_mt.__add(E,l)local i,h=typeof(E),typeof(l)if i=="\086\101\099\116\111\114"and h=="\086\101\099\116\111\114"then local i={}for h in next,E do i[h]=E[h]+l[h]end return vec.new(i)end end function vec_mt.__sub(E,l)local i,h=typeof(E),typeof(l)if i=="\086\101\099\116\111\114"and h=="\086\101\099\116\111\114"then local i={}for h in next,E do i[h]=E[h]-l[h]end return vec.new(i)end end function vec_mt.__mul(E,l)local i,h=typeof(E),typeof(l)local q=i=="\110\117\109\098\101\114"if q or h=="\110\117\109\098\101\114"then local i={}local h,z=q and l or E,q and E or l for E in next,h do i[E]=h[E]*z end return vec.new(i)elseif i=="\086\101\099\116\111\114"and h=="\086\101\099\116\111\114"then local i={}for h in next,E do i[h]=E[h]*l[h]end return vec.new(i)end end function vec_mt.__div(E,l)local i,h=typeof(E),typeof(l)if i=="\110\117\109\098\101\114"then local i={}for h in next,l do i[h]=E/l[h]end return vec.new(i)elseif h=="\110\117\109\098\101\114"then local i={}for h in next,E do i[h]=E[h]/l end return vec.new(i)elseif i=="\086\101\099\116\111\114"and h=="\086\101\099\116\111\114"then local i={}for h in next,E do i[h]=E[h]/l[h]end return vec.new(i)end end function vec_mt.__unm(E)local l={}for i in next,E do l[i]=-E[i]end return vec.new(l)end function vec_mt.__tostring(E)return table.concat(E,"\044 ")end


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
	