def get_table(xdata, ydata): N = len(xdata) table = Tabular('|c|' + 'c|' * N) table.add_hline() table.add_row(('x_i', ) + xdata) table.add_hline() table.add_row(('y_i', ) + ydata) table.add_hline() return table.dumps()
def __init__(self, xdata, ydata, basis='1,x,x^2'): N = xdata.shape[0] table = Tabular('|c|' + 'c|' * N) table.add_hline() table.add_row(('$x_i$', ) + xdata) table.add_hline() table.add_row(('$y_i$', ) + ydata) table.add_hline() template = '用一组基$\\{{{basis}}\\}$拟合数据 %s.' % table.dumps() parameter = {'basis': basis, 'xdata': xdata, 'ydata': ydata} super(LeastSquareProblem, self).__init__(template, parameter)