function LinearValue.ToBaseValue(Q)return Q._constructor(unpack(Q._values))end local function Q(Q)return function(m,V)if LinearValue.isLinear(m)and LinearValue.isLinear(V)then assert(m._constructor==V._constructor,"\097 \105\115 \110\111\116 \116\104\101 \115\097\109\101 \116\121\112\101 \111\102 \108\105\110\101\097\114\086\097\108\117\101 \097\115 \098")local e={}for B=1,#m._values,1 do e[B]=Q(m._values[B],V._values[B])end return LinearValue.new(m._constructor,e)elseif LinearValue.isLinear(m)then if type(V)=="\110\117\109\098\101\114"then local e={}for B=1,#m._values,1 do e[B]=Q(m._values[B],V)end return LinearValue.new(m._constructor,e)else error("\066\097\100 \116\121\112\101 \040\098\041")end elseif LinearValue.isLinear(V)then if type(m)=="\110\117\109\098\101\114"then local e={}for B=1,#V._values,1 do e[B]=Q(m,V._values[B])end return LinearValue.new(V._constructor,e)else error("\066\097\100 \116\121\112\101 \040\097\041")end else error("\078\101\105\116\104\101\114 \118\097\108\117\101 \105\115 \097 \108\105\110\101\097\114\086\097\108\117\101")end end end
--[=[
	Converts the value back to the base value

	@return T
]=]
function LinearValue:ToBaseValue()
	return self._constructor(unpack(self._values))
end

local function operation(func)
	return function(a, b)
		if LinearValue.isLinear(a) and LinearValue.isLinear(b) then
			assert(a._constructor == b._constructor, "a is not the same type of linearValue as b")

			local values = {}
			for i = 1, #a._values do
				values[i] = func(a._values[i], b._values[i])
			end
			return LinearValue.new(a._constructor, values)
		elseif LinearValue.isLinear(a) then
			if type(b) == "number" then
				local values = {}
				for i = 1, #a._values do
					values[i] = func(a._values[i], b)
				end
				return LinearValue.new(a._constructor, values)
			else
				error("Bad type (b)")
			end
		elseif LinearValue.isLinear(b) then
			if type(a) == "number" then
				local values = {}
				for i = 1, #b._values do
					values[i] = func(a, b._values[i])
				end
				return LinearValue.new(b._constructor, values)
			else
				error("Bad type (a)")
			end
		else
			error("Neither value is a linearValue")
		end
	end
end
