test_quadrilateral.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:quadpy 作者: nschloe 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号