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


Python LLSparseMatrix.to_csr方法代码示例

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


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

示例1: LLMatMatVecBenchmark_4

# 需要导入模块: from cysparse.sparse.ll_mat import LLSparseMatrix [as 别名]
# 或者: from cysparse.sparse.ll_mat.LLSparseMatrix import to_csr [as 别名]
class LLMatMatVecBenchmark_4(LLMatMatVecBenchmark):


    label = "matvec with 5000 elements and size = 1,000,000"
    each = 100


    def setUp(self):

        self.nbr_elements = 5000
        self.size = 1000000

        self.A_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, itype=INT32_T, dtype=FLOAT64_T)
        self.A_p = spmatrix.ll_mat(self.size, self.size, self.nbr_elements)
        self.A_s = lil_matrix((self.size, self.size), dtype=np.float64)

        self.list_of_matrices = []
        self.list_of_matrices.append(self.A_c)
        self.list_of_matrices.append(self.A_p)
        self.list_of_matrices.append(self.A_s)

        construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements)

        self.CSR_c = self.A_c.to_csr()
        self.CSR_p = self.A_p.to_csr()
        self.CSR_s = self.A_s.tocsr()

        self.v = np.arange(0, self.size, dtype=np.float64)
开发者ID:PythonOptimizers,项目名称:cysparse,代码行数:30,代码来源:matvec_csr.py

示例2: LLMatToCSRBenchmark

# 需要导入模块: from cysparse.sparse.ll_mat import LLSparseMatrix [as 别名]
# 或者: from cysparse.sparse.ll_mat.LLSparseMatrix import to_csr [as 别名]
class LLMatToCSRBenchmark(benchmark.Benchmark):


    label = "to_csr() with 100 elements and size = 1,000"
    each = 100

    def setUp(self):

        self.nbr_elements = 100
        self.size = 1000

        self.A_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, dtype=FLOAT64_T)
        construct_sparse_matrix(self.A_c, self.size, self.nbr_elements)

        self.A_p = spmatrix.ll_mat(self.size, self.size, self.nbr_elements)
        construct_sparse_matrix(self.A_p, self.size, self.nbr_elements)

    #def tearDown(self):

    #    for i in xrange(self.size):
    #        for j in xrange(self.size):
    #            assert self.csr_c[i, j] == self.A_c[i, j]


    def test_pysparse(self):
        self.csr_p = self.A_p.to_csr()
        return

    def test_cysparse(self):
        self.csr_c = self.A_c.to_csr()
        return
开发者ID:PythonOptimizers,项目名称:cysparse,代码行数:33,代码来源:to_csr.py

示例3: LLMatMatVecBenchmark

# 需要导入模块: from cysparse.sparse.ll_mat import LLSparseMatrix [as 别名]
# 或者: from cysparse.sparse.ll_mat.LLSparseMatrix import to_csr [as 别名]
class LLMatMatVecBenchmark(benchmark.Benchmark):


    label = "matvec with 1000 elements and size = 10,000"
    each = 100


    def setUp(self):

        self.nbr_elements = 1000
        self.size = 10000

        self.A_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, itype=INT32_T, dtype=FLOAT64_T)
        self.A_p = spmatrix.ll_mat(self.size, self.size, self.nbr_elements)
        self.A_s = lil_matrix((self.size, self.size), dtype=np.float64)

        self.list_of_matrices = []
        self.list_of_matrices.append(self.A_c)
        self.list_of_matrices.append(self.A_p)
        self.list_of_matrices.append(self.A_s)

        construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements)

        self.CSR_c = self.A_c.to_csr()
        self.CSR_p = self.A_p.to_csr()
        self.CSR_s = self.A_s.tocsr()

        self.v = np.arange(0, self.size, dtype=np.float64)

    #def tearDown(self):
    #    for i in xrange(self.size):
    #        assert self.w_c[i] == self.w_p[i]
    #        assert self.w_c[i] == self.w_s[i]


    def test_pysparse(self):
        self.w_p = np.empty(self.size, dtype=np.float64)
        self.CSR_p.matvec(self.v, self.w_p)
        return

    def test_cysparse(self):
        self.w_c = self.CSR_c * self.v
        return

    def test_cysparse2(self):
        self.w_c2 = self.CSR_c.matvec(self.v)
        return

    def test_scipy_sparse(self):
        self.w_s = self.CSR_s * self.v
        return

    def test_scipy_sparse2(self):
        self.w_s2 = self.CSR_s._mul_vector(self.v)
开发者ID:PythonOptimizers,项目名称:cysparse,代码行数:56,代码来源:matvec_csr.py


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