

def run(self, s, a0, a1=0):
    if (self.variant == 't'):
        w = a0
    elif (self.variant == 'u'):
        w = (a0 * (self.theta + self.n))
    elif (self.variant == 'v'):
        w = ((a0 * a1) / (a0 - a1))
    else:
        assert False, 'unknown variant'
    if (w == 0):
        raise ValueError('levin: zero weight')
    self.A.append((s / w))
    self.B.append((1 / w))
    for i in range((self.n - 1), (- 1), (- 1)):
        if (i == (self.n - 1)):
            f = 1
        else:
            f = self.factor(i)
        self.A[i] = (self.A[(i + 1)] - (f * self.A[i]))
        self.B[i] = (self.B[(i + 1)] - (f * self.B[i]))
    self.n += 1

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