gauss_kronrod.py 文件源码

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

项目:quadpy 作者: nschloe 项目源码 文件源码
def __init__(self, n, a=0.0, b=0.0):
        # The general scheme is:
        # Get the Jacobi recurrence coefficients, get the Kronrod vectors alpha
        # and beta, and hand those off to orthopy.line.schemes.custom. There,
        # the eigenproblem for a tridiagonal matrix with alpha and beta is
        # solved to retrieve the points and weights.
        # TODO replace math.ceil by -(-k//n)
        length = int(math.ceil(3*n/2.0)) + 1
        self.degree = 2*length + 1
        _, _, alpha, beta = \
            orthopy.line.recurrence_coefficients.jacobi(length, a, b, 'monic')
        flt = numpy.vectorize(float)
        alpha = flt(alpha)
        beta = flt(beta)
        a, b = self.r_kronrod(n, alpha, beta)
        x, w = orthopy.line.schemes.custom(a, b, mode='numpy')
        # sort by x
        i = numpy.argsort(x)
        self.points = x[i]
        self.weights = w[i]
        return

    # pylint: disable=no-self-use
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号