def test_coeffmult(self): f, g = self.f, self.g fn, gn = self.fn, self.gn hn = fn + gn - 1 h = lambda x: self.f(x) * self.g(x) fc = Chebtech2.initfun(f, fn).prolong(hn).coeffs gc = Chebtech2.initfun(g, gn).prolong(hn).coeffs hc = coeffmult(fc, gc) HC = Chebtech2.initfun(h, hn).coeffs self.assertLessEqual( infnorm(hc-HC), 2e1*eps)
def test_coeffmult(self): f, g = self.f, self.g fn, gn = self.fn, self.gn hn = fn + gn - 1 h = lambda x: self.f(x) * self.g(x) fc = Chebtech2.initfun(f, fn).prolong(hn).coeffs gc = Chebtech2.initfun(g, gn).prolong(hn).coeffs hc = coeffmult(fc, gc) HC = Chebtech2.initfun(h, hn).coeffs self.assertLessEqual(infnorm(hc - HC), 2e1 * eps)
def __mul__(self, g): cls = self.__class__ if np.isscalar(g): cfs = g * self.coeffs return cls(cfs, interval=self.interval) else: # TODO: review with reference to __add__ if g.isempty: return g.copy() f = self n = f.size + g.size - 1 f = f.prolong(n) g = g.prolong(n) cfs = coeffmult(f.coeffs, g.coeffs) out = cls(cfs, interval=self.interval) return out
def __mul__(self, g): cls = self.__class__ if np.isscalar(g): cfs = g * self.coeffs return cls(cfs) else: # TODO: review with reference to __add__ if g.isempty: return g.copy() f = self n = f.size + g.size - 1 f = f.prolong(n) g = g.prolong(n) cfs = coeffmult(f.coeffs, g.coeffs) out = cls(cfs) return out