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


Python BPoly.derivative方法代码示例

本文整理汇总了Python中scipy.interpolate.BPoly.derivative方法的典型用法代码示例。如果您正苦于以下问题:Python BPoly.derivative方法的具体用法?Python BPoly.derivative怎么用?Python BPoly.derivative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.interpolate.BPoly的用法示例。


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

示例1: test_derivative

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
 def test_derivative(self):
     x = [0, 1, 3]
     c = [[3, 0], [0, 0], [0, 2]]
     bp = BPoly(c, x)  # [3*(1-x)**2, 2*((x-1)/2)**2]
     bp_der = bp.derivative()
     assert_allclose(bp_der(0.4), -6*(0.6))
     assert_allclose(bp_der(1.7), 0.7)
开发者ID:AGPeddle,项目名称:scipy,代码行数:9,代码来源:test_interpolate.py

示例2: test_make_poly_12

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_make_poly_12(self):
        np.random.seed(12345)
        ya = np.r_[0, np.random.random(5)]
        yb = np.r_[0, np.random.random(5)]

        c = BPoly._construct_from_derivatives(0, 1, ya, yb)
        pp = BPoly(c[:, None], [0, 1])
        for j in range(6):
            assert_allclose([pp(0.), pp(1.)], [ya[j], yb[j]])
            pp = pp.derivative()
开发者ID:AGPeddle,项目名称:scipy,代码行数:12,代码来源:test_interpolate.py

示例3: test_deriv_inplace

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_deriv_inplace(self):
        np.random.seed(1234)
        m, k = 5, 8   # number of intervals, order
        x = np.sort(np.random.random(m))
        c = np.random.random((k, m-1))
        bp = BPoly(c, x)

        xp = np.linspace(x[0], x[-1], 21)
        for i in range(k):
            assert_allclose(bp(xp, i), bp.derivative(i)(xp))
开发者ID:RobTAT,项目名称:scipy,代码行数:12,代码来源:test_interpolate.py

示例4: test_multi_shape

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_multi_shape(self):
        c = np.random.rand(6, 2, 1, 2, 3)
        x = np.array([0, 0.5, 1])
        p = BPoly(c, x)
        assert_equal(p.x.shape, x.shape)
        assert_equal(p.c.shape, c.shape)
        assert_equal(p(0.3).shape, c.shape[2:])
        assert_equal(p(np.random.rand(5,6)).shape,
                     (5,6)+c.shape[2:])

        dp = p.derivative()
        assert_equal(dp.c.shape, (5, 2, 1, 2, 3))
开发者ID:AGPeddle,项目名称:scipy,代码行数:14,代码来源:test_interpolate.py

示例5: test_derivative

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_derivative(self):
        x = [0, 1, 3]
        c = [[3, 0], [0, 0], [0, 2]]
        bp = BPoly(c, x)  # [3*(1-x)**2, 2*((x-1)/2)**2]
        bp_der = bp.derivative()
        assert_allclose(bp_der(0.4), -6*(0.6))
        assert_allclose(bp_der(1.7), 0.7)

        # derivatives in-place
        assert_allclose([bp(0.4, nu=1), bp(0.4, nu=2), bp(0.4, nu=3)],
                        [-6*(1-0.4), 6., 0.])
        assert_allclose([bp(1.7, nu=1), bp(1.7, nu=2), bp(1.7, nu=3)],
                        [0.7, 1., 0])
开发者ID:RobTAT,项目名称:scipy,代码行数:15,代码来源:test_interpolate.py

示例6: test_derivative_ppoly

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_derivative_ppoly(self):
        # make sure it's consistent w/ power basis
        np.random.seed(1234)
        m, k = 5, 8   # number of intervals, order
        x = np.sort(np.random.random(m))
        c = np.random.random((k, m-1))
        bp = BPoly(c, x)
        pp = PPoly.from_bernstein_basis(bp)

        for d in range(k):
            bp = bp.derivative()
            pp = pp.derivative()
            xp = np.linspace(x[0], x[-1], 21)
            assert_allclose(bp(xp), pp(xp))
开发者ID:AGPeddle,项目名称:scipy,代码行数:16,代码来源:test_interpolate.py

示例7: test_extrapolate_attr

# 需要导入模块: from scipy.interpolate import BPoly [as 别名]
# 或者: from scipy.interpolate.BPoly import derivative [as 别名]
    def test_extrapolate_attr(self):
        x = [0, 2]
        c = [[3], [1], [4]]
        bp = BPoly(c, x)

        for extrapolate in (True, False, None):
            bp = BPoly(c, x, extrapolate=extrapolate)
            bp_d = bp.derivative()
            if extrapolate is False:
                assert_(np.isnan(bp([-0.1, 2.1])).all())
                assert_(np.isnan(bp_d([-0.1, 2.1])).all())
            else:
                assert_(not np.isnan(bp([-0.1, 2.1])).any())
                assert_(not np.isnan(bp_d([-0.1, 2.1])).any())
开发者ID:AGPeddle,项目名称:scipy,代码行数:16,代码来源:test_interpolate.py


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