Пример #1
0
def test_neville():
    func = numpy.exp
    tol = 1.0e-6
    num = 10
    # TODO: can we not just use vectorized code here?
    x = []
    y = []
    for ii in range(num):
        x.append(ii / float(num))
        y.append(func(x[ii]))
    xx = numpy.array(x)
    yy = numpy.array(y)
    for ii in range(num):
        tmp = 1.01 * (ii / float(num))
        answer = func(tmp)
        val = utils.neville(tmp, xx, yy)
        assert utils.Knuth_close(answer, val, tol)
Пример #2
0
 def test_neville(self):
     func = numpy.exp
     tol = 1.0e-6
     num = 10
     # TODO: can we not just use vectorized code here?
     x = []
     y = []
     for ii in xrange(num):
         x.append(ii / float(num))
         y.append(func(x[ii]))
     xx = numpy.array(x)
     yy = numpy.array(y)
     for ii in xrange(num):
         tmp = 1.01 * (ii / float(num))
         answer = func(tmp)
         val = utils.neville(tmp, xx, yy)
         self.assertTrue(utils.Knuth_close(answer, val, tol))