def test_initvalues(self): # test n = 0 case separately vals = rand(0) fun = Chebtech2.initvalues(vals) cfs = Chebtech2._vals2coeffs(vals) self.assertTrue(fun.coeffs.size == cfs.size == 0) # now test the other cases for n in range(1, 10): vals = rand(n) fun = Chebtech2.initvalues(vals) cfs = Chebtech2._vals2coeffs(vals) self.assertEqual(infnorm(fun.coeffs - cfs), 0.)
def test_initvalues(self): # test n = 0 case separately vals = np.random.rand(0) fun = Chebtech2.initvalues(vals) cfs = Chebtech2._vals2coeffs(vals) self.assertTrue(fun.coeffs.size==cfs.size==0) # now test the other cases for n in range(1,10): vals = np.random.rand(n) fun = Chebtech2.initvalues(vals) cfs = Chebtech2._vals2coeffs(vals) self.assertEqual(infnorm(fun.coeffs-cfs), 0.)
def evalTester(method, fun, evalpts, chebpts): x = evalpts xk = chebpts fvals = fun(xk) if method is bary: vk = Chebtech2._barywts(fvals.size) a = bary(x, fvals, xk, vk) tol_multiplier = 1e0 elif method is clenshaw: ak = Chebtech2._vals2coeffs(fvals) a = clenshaw(x, ak) tol_multiplier = 2e1 b = fun(evalpts) n = evalpts.size tol = tol_multiplier * scaled_tol(n) return infNormLessThanTol(a, b, tol)
def evalTester(method, fun, evalpts, chebpts): x = evalpts xk = chebpts fvals = fun(xk) if method is bary: vk = Chebtech2._barywts(fvals.size) a = bary(x, fvals, xk, vk) tol_multiplier = 1e0 elif method is clenshaw: ak = Chebtech2._vals2coeffs(fvals) a = clenshaw(x, ak) tol_multiplier = 2e1 b = fun(evalpts) n = evalpts.size tol = tol_multiplier * scaled_tol(n) return infNormLessThanTol(a, b, tol)