def __init__(self, index):
self.points = numpy.linspace(-1.0, 1.0, index+2)[1:-1]
self.degree = index if (index+1) % 2 == 0 else index - 1
#
n = index+1
self.weights = numpy.empty(n-1)
t = sympy.Symbol('t')
for r in range(1, n):
# Compare with get_weights().
f = sympy.prod([(t - i) for i in range(1, n) if i != r])
alpha = 2 * \
(-1)**(n-r+1) * sympy.integrate(f, (t, 0, n)) \
/ (math.factorial(r-1) * math.factorial(n-1-r)) \
/ n
self.weights[r-1] = alpha
return
评论列表
文章目录