def test_simplify(self): interval = Interval(-2, 1) ff = Bndfun.initfun_fixedlen(self.f, interval, 1000) gg = ff.simplify() self.assertEqual(gg.size, standard_chop(ff.onefun.coeffs)) self.assertEqual(infnorm(ff.coeffs[:gg.size] - gg.coeffs), 0) self.assertEqual(ff.interval, gg.interval)
def test_simplify(self): interval = Interval(-2,1) ff = Bndfun.initfun_fixedlen(self.f, interval, 1000) gg = ff.simplify() self.assertEqual(gg.size, standard_chop(ff.onefun.coeffs)) self.assertEqual(infnorm(ff.coeffs[:gg.size]-gg.coeffs), 0) self.assertEqual(ff.interval, gg.interval)
def test_simplify(self): gg = self.ff.simplify() # check that simplify is calling standard_chop underneath self.assertEqual(gg.size, standard_chop(self.ff.coeffs)) self.assertEqual(infnorm(self.ff.coeffs[:gg.size] - gg.coeffs), 0) # check we are returned a copy of self's coeffcients by changing # one entry of gg fcfs = self.ff.coeffs gcfs = gg.coeffs self.assertEqual((fcfs[:gg.size] - gcfs).sum(), 0) gg.coeffs[0] = 1 self.assertNotEqual((fcfs[:gg.size] - gcfs).sum(), 0)
def test_simplify(self): gg = self.ff.simplify() # check that simplify is calling standard_chop underneath self.assertEqual(gg.size, standard_chop(self.ff.coeffs)) self.assertEqual(infnorm(self.ff.coeffs[:gg.size]-gg.coeffs), 0) # check we are returned a copy of self's coeffcients by changing # one entry of gg fcfs = self.ff.coeffs gcfs = gg.coeffs self.assertEqual((fcfs[:gg.size]-gcfs).sum(),0) gg.coeffs[0] = 1 self.assertNotEqual((fcfs[:gg.size]-gcfs).sum(),0)
def simplify(self): '''Call standard_chop on the coefficients of self, returning a Chebtech comprised of a copy of the truncated coefficients.''' # coefficients oldlen = len(self.coeffs) longself = self.prolong(max(17, oldlen)) cfs = longself.coeffs # scale (decrease) tolerance by hscale tol = prefs.eps * max(self.interval.hscale, 1) # chop npts = standard_chop(cfs, tol=tol) npts = min(oldlen, npts) # construct return self.__class__(cfs[:npts].copy(), interval=self.interval)
def simplify(self): '''Call standard_chop on the coefficients of self, returning a Chebtech comprised of a copy of the truncated coefficients.''' cfs = self.coeffs npts = standard_chop(cfs) return self.__class__(cfs[:npts].copy())