def main():
	args = argparser().parse_args()
	data = read_data(args.source)
	if len(data) == 0:
		print('Error: No data, not numeric data or not expected data.');
		return False
	result = tomas_method(data)
	if result != None:
		write_data(args.output, result)
	else:
		print('Error: Algorithm is unstable for this system of linear algebraic equations.')
		return False
	print('Success!')
예제 #2
0
	def __init__(self, keys, values, extra):
		sys.path.insert(0, "..\sole")
		from sole import tomas_method
		if len(keys) == len(values) and len(extra[0]) == len(extra[1]):
			self.__n = len(keys)
			self.__keys = [x for x in keys]
			self.__values = [x for x in values]
			self.__extra[0] = [x for x in extra[0]]
			self.__extra[1] = [x for x in extra[1]]
		else:
			raise ValueError('Invalid mapping from keys to values.')
		moment_im = [0]+[self.__getH(i-1)/(self.__getH(i-1)+self.__getH(i)) for i in range(1, self.__n-1)]+[self.__extra[1][0]]
		moment_i = [self.__extra[0][0]]+[2 for i in range(self.__n-2)]+[self.__extra[1][1]]
		moment_ip = [self.__extra[0][1]]+[self.__getH(i)/(self.__getH(i-1)+self.__getH(i)) for i in range(1, self.__n-1)]+[0]
		d = [extra[0][2]]+[6/(self.__getH(i-1)+self.__getH(i))*((self.__values[i+1]-self.__values[i])/self.__getH(i)-(self.__values[i]-self.__values[i-1])/self.__getH(i-1)) for i in range(1, self.__n-1)]+[extra[1][2]]
		self.__moment = tomas_method([moment_im, moment_i, moment_ip, d])