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


Python DataVector.componentwise_div方法代码示例

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


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

示例1: testOps

# 需要导入模块: from pysgpp import DataVector [as 别名]
# 或者: from pysgpp.DataVector import componentwise_div [as 别名]
    def testOps(self):
        from pysgpp import DataVector
        # sum
        self.assertAlmostEqual(self.d_rand.sum(), sum(self.l_rand_total))

        # sqr
        d = DataVector(self.d_rand)
        d.sqr()
        for i in xrange(self.N):
            self.assertEqual(self.d_rand[i]**2, d[i])

        # abs
        d = DataVector(self.d_rand)
        d.abs()
        for i in xrange(self.N):
            self.assertEqual(abs(self.d_rand[i]), d[i])

        # componentwise_mult
        d = DataVector(self.d_rand)
#	d2 = DataVector(self.nrows, self.ncols)
	d2 = DataVector(self.N)
        for i in xrange(self.N):
            d2[i] = i
	d.componentwise_mult(d2)
        for i in xrange(self.N):
            self.assertEqual(self.d_rand[i]*i, d[i])

        # componentwise_div
        d = DataVector(self.d_rand)
        for i in xrange(self.N):
            d2[i] = i+1
	d.componentwise_div(d2)
        for i in xrange(self.N):
            self.assertEqual(self.d_rand[i]/(i+1), d[i])
开发者ID:samhelmholtz,项目名称:skinny-dip,代码行数:36,代码来源:test_DataVector.py


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