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.non_contiguity = 10 self.A_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, itype=INT32_T, dtype=FLOAT64_T) 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_s) construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements) self.CSC_c = self.A_c.to_csc() self.CSC_s = self.A_s.tocsc() self.v = np.arange(0, self.size * self.non_contiguity, dtype=np.float64)
class LLMatMatVecBenchmark_3(LLMatMatVecBenchmark): label = "matvec with 100,000 elements and size = 1,000,000" each = 100 def setUp(self): self.nbr_elements = 100000 self.size = 1000000 self.A_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, itype=INT32_T, dtype=FLOAT64_T) 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_s) construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements) self.CSC_c = self.A_c.to_csc() self.CSC_s = self.A_s.tocsc() self.v = np.arange(0, self.size, dtype=np.float64)
class LLMatMatVecBenchmark(benchmark.Benchmark): label = "CSR * CSC * v 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_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_s) construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements) self.CSR_c = self.A_c.to_csr() self.CSR_s = self.A_s.tocsr() self.B_c = LLSparseMatrix(size=self.size, size_hint=self.nbr_elements, itype=INT32_T, dtype=FLOAT64_T) self.B_s = lil_matrix((self.size, self.size), dtype=np.float64) self.list_of_matrices = [] self.list_of_matrices.append(self.B_c) self.list_of_matrices.append(self.B_s) construct_random_matrices(self.list_of_matrices, self.size, self.nbr_elements) self.CSC_c = self.B_c.to_csc() self.CSC_s = self.B_s.tocsc() 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_cysparse(self): self.w_c = self.CSR_c * self.CSC_c * self.v return def test_scipy_sparse(self): self.w_s = self.CSR_s * self.CSC_s * self.v return