• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pychebfun.Chebfun类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: test_init

def test_init(ufunc):
    xx = Chebfun.from_function(lambda x: x,[0.25,0.75])
    ff = ufunc(xx)
    assert isinstance(ff, Chebfun)
    result = ff.values()
    expected = ufunc(ff._ui_to_ab(ff.p.xi))
    npt.assert_allclose(result, expected)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_domain.py


示例17: test_chebyshev_points

 def test_chebyshev_points(self):
     """
     First and last interpolation points are -1 and 1
     """
     N = pow(2,5)
     pts = Chebfun.interpolation_points(N)
     npt.assert_array_almost_equal(pts[[0,-1]],np.array([1.,-1]))
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py


示例18: test_roots_of_flat_function

 def test_roots_of_flat_function(self):
     """
     Check roots() does not fail for extremely flat Chebfuns such
     as those representing cumulative distribution functions.
     """
     cdf = Chebfun.from_data(flat_chebfun_vals, domain=[-0.7, 0.7])
     npt.assert_allclose((cdf-0.05).roots(), 0.1751682246791747)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:7,代码来源:test_chebfun.py


示例19: test_integrate

 def test_integrate(self):
     """
     Integrate exp
     """
     e = Chebfun.from_function(lambda x:np.exp(x))
     antideriv = e.integrate()
     result = antideriv - antideriv(antideriv._domain[0])
     tools.assert_close(result, e - e(antideriv._domain[0]))
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:8,代码来源:test_chebfun.py


示例20: test_diff_x

 def test_diff_x(self):
     """
     First and second derivative of Chebfun(x) are close to one and zero respectively.
     """
     self.p = Chebfun.from_function(tools.Identity)
     one = self.p.differentiate()
     zero = one.differentiate()
     npt.assert_allclose(one(tools.xs), 1.)
     npt.assert_allclose(tools.Zero(tools.xs), 0.)
开发者ID:olivierverdier,项目名称:pychebfun,代码行数:9,代码来源:test_chebfun.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pcm_log.debug函数代码示例发布时间:2022-05-25
下一篇:
Python color.hex2rgb函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap