def test_scheme(scheme, tol):
# Test integration until we get to a polynomial degree `d` that can no
# longer be integrated exactly. The scheme's degree is `d-1`.
def eval_orthopolys(x):
return numpy.concatenate(
orthopy.quadrilateral.tree(scheme.degree+1, x, symbolic=False)
)
quad = quadpy.quadrilateral.rectangle_points([-1.0, +1.0], [-1.0, +1.0])
vals = quadpy.quadrilateral.integrate(eval_orthopolys, quad, scheme)
# Put vals back into the tree structure:
# len(approximate[k]) == k+1
approximate = [
vals[k*(k+1)//2:(k+1)*(k+2)//2]
for k in range(scheme.degree+2)
]
exact = [numpy.zeros(k+1) for k in range(scheme.degree+2)]
exact[0][0] = 2.0
degree = check_degree_ortho(approximate, exact, abs_tol=tol)
assert degree >= scheme.degree, \
'Observed: {}, expected: {}'.format(degree, scheme.degree)
return
评论列表
文章目录