当前位置: 首页>>代码示例>>Python>>正文


Python pychebfun.Chebfun类代码示例

本文整理汇总了Python中pychebfun.Chebfun的典型用法代码示例。如果您正苦于以下问题:Python Chebfun类的具体用法?Python Chebfun怎么用?Python Chebfun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Chebfun类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_interp_values

 def test_interp_values(self):
     """
     Instanciate Chebfun from interpolation values.
     """
     p2 = Chebfun(self.p.values())
     npt.assert_almost_equal(self.p.coefficients(), p2.coefficients())
     tools.assert_close(self.p, p2)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例2: test_prune

 def test_prune(self):
     N = 10
     coeffs = np.array([1.]+N*[0])
     c0 = Chebfun.from_coeff(coeffs)
     npt.assert_allclose(c0.coefficients(), [1.])
     c1 = Chebfun.from_coeff(coeffs, prune=False)
     npt.assert_allclose(c1.coefficients(), coeffs)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例3: test_add

 def test_add(self):
     s = Chebfun.from_function(np.sin)
     c = Chebfun.from_function(np.cos)
     r = c + s
     def expected(x):
         return np.sin(x) + np.cos(x)
     tools.assert_close(r, expected)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例4: test_diff_one

 def test_diff_one(self):
     """
     Derivative of Chebfun(1) close to zero
     """
     one = Chebfun(1.)
     zero = one.differentiate()
     npt.assert_allclose(tools.Zero(tools.xs), 0.)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例5: test_truncate

 def test_truncate(self, N=17):
     """
     Check that the Chebyshev coefficients are properly truncated.
     """
     small = Chebfun.from_function(tools.f, N=N)
     new = Chebfun.from_function(small)
     self.assertEqual(new.size(), small.size(),)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例6: test_real_imag

 def test_real_imag(self):
     datar = np.random.rand(10)
     datai = np.random.rand(10)
     cc = Chebfun.from_data(datar + 1j*datai)
     cr = Chebfun.from_data(datar)
     ci = Chebfun.from_data(datai)
     tools.assert_close(np.real(cc), cr)
     tools.assert_close(np.imag(cc), ci)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:8,代码来源:test_chebfun.py

示例7: test_runge

 def test_runge(self):
     """
     Test some of the capabilities of operator overloading.
     """
     r = Chebfun.from_function(runge)
     x = Chebfun.basis(1)
     rr = 1./(1+25*x**2)
     tools.assert_close(r, rr, rtol=1e-13)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:8,代码来源:test_chebfun.py

示例8: test_scalarvectormult

 def test_scalarvectormult(self):
     """
     Possible to multiply scalar with vector chebfun.
     """
     v = Chebfun.from_function(segment)
     s = np.sin(Chebfun.identity())
     m = s * v
     tools.assert_close(m[0], s*v[0])
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:8,代码来源:test_chebfun.py

示例9: test_slice

 def test_slice(self):
     """
     Test slicing: f[0] should return the first component.
     """
     s = Chebfun.from_function(segment)
     tools.assert_close(s[0], Chebfun.identity())
     tools.assert_close(s[1], Chebfun(0.))
     tools.assert_close(s[:], s)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:8,代码来源:test_chebfun.py

示例10: a

def a(p, order):
    if p > 0:
        return Chebfun.from_function(lambda x: sqrt(2)* np.sin(p*x)/p,[0,pi])\
                      .differentiate(order)
    else:
        if order == 1:
            return Chebfun.from_function(lambda x: np.ones_like(x), [0, pi])
        else:
            return Chebfun.from_function(lambda x: np.zeros_like(x), [0, pi])
开发者ID:nbren12,项目名称:gnl,代码行数:9,代码来源:galerkin.py

示例11: test_sum

 def test_sum(self):
     """
     Integral of chebfun of x**2 on [-1,1] is 2/3
     """
     p = Chebfun.from_function(Quad)
     i = p.sum()
     npt.assert_array_almost_equal(i,2/3)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例12: test_highdiff

 def test_highdiff(self):
     """
     Higher order derivatives of exp(x)
     """
     e = Chebfun.from_function(lambda x:np.exp(x))
     e4 = e.differentiate(4)
     tools.assert_close(e4, e)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例13: test_diffquad

 def test_diffquad(self):
     """
     Derivative of Chebfun(x**2/2) is close to identity function
     """
     self.p = .5*Chebfun.from_function(Quad)
     X = self.p.differentiate()
     tools.assert_close(X, lambda x:x)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例14: test_nonzero

 def test_nonzero(self):
     """
     nonzero is True for Chebfun(f) and False for Chebfun(0)
     """
     self.assertTrue(self.p)
     mp = Chebfun.from_function(tools.Zero)
     self.assertFalse(mp)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py

示例15: test_basis

 def test_basis(self, n=4):
     """
     Tn(cos(t)) = cos(nt)
     """
     Tn = Chebfun.basis(n)
     ts = np.linspace(0, 2*np.pi, 100)
     npt.assert_allclose(Tn(np.cos(ts)), np.cos(n*ts))
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py


注:本文中的pychebfun.Chebfun类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。