49、编写一个名为 add_point 的方法,该方法接受一个多项式 q 和一个元组 (x, y) 作为参数,并返回一个对 self.points 和 (x, y) 进行插值的新多项式。
下面是给定的【文本内容】:
```python
import numpy as np
class PolyNomial:
base ='monomial'
def __init__(self, **args):
if 'points' in args:
self.points = np.array(args['points'])
self.xi = self.points[:, 0]
self.coeff = self.point_2_coeff()
self.degree = len(self.coeff) - 1
elif 'coeff' in args:
self.coeff = np.array(args['coeff'])
self.degree = len(self.coeff) - 1
self.points = self.coeff_2_point()
else:
self.points = np.array([[0, 0]])
self.xi = np.array([1.])
self.coeff = self.point_2_coeff()
self.degree = 0
def point_2_coeff(self):
import scipy.linalg as sl
return sl.solve(np.vander(self.xi), self.points[:, 1])
def coeff_2_point(self):
from numpy import lins