

def update_psum(self, S):
    '\n        This routine applies the convergence acceleration to the list of partial sums.\n\n        A   = sum(a_k, k = 0..infinity)\n        s_n = sum(a_k, k = 0..n)\n\n        v, e = ...update_psum([s_0, s_1,..., s_k])\n\n        output:\n          v      current estimate of the series A\n          e      an error estimate which is simply the difference between the current\n                 estimate and the last estimate.\n        '
    if (self.variant != 'v'):
        if (self.n == 0):
            self.run(S[0], S[0])
        while (self.n < len(S)):
            self.run(S[self.n], (S[self.n] - S[(self.n - 1)]))
    else:
        if (len(S) == 1):
            self.last = 0
            return (S[0], abs(S[0]))
        if (self.n == 0):
            self.a1 = (S[1] - S[0])
            self.run(S[0], S[0], self.a1)
        while (self.n < (len(S) - 1)):
            na1 = (S[(self.n + 1)] - S[self.n])
            self.run(S[self.n], self.a1, na1)
            self.a1 = na1
    value = (self.A[0] / self.B[0])
    err = abs((value - self.last))
    self.last = value
    return (value, err)

dataset/ETHPy150Open fredrik-johansson/mpmath/mpmath/calculus/extrapolation.py levin_class.update_psum/original