Exemple #1
0
    def tocsr(self):
        M, N = self.shape
        indptr = np.empty(M + 1, dtype=np.intc)
        indices = np.empty(self.nnz, dtype=np.intc)
        data = np.empty(self.nnz, dtype=upcast(self.dtype))

        csc_tocsr(M, N, self.indptr, self.indices, self.data, indptr, indices, data)

        from csr import csr_matrix

        A = csr_matrix((data, indices, indptr), shape=self.shape)
        A.has_sorted_indices = True
        return A
Exemple #2
0
    def tocsr(self):
        M, N = self.shape
        indptr = np.empty(M + 1, dtype=np.intc)
        indices = np.empty(self.nnz, dtype=np.intc)
        data = np.empty(self.nnz, dtype=upcast(self.dtype))

        csc_tocsr(M, N, \
                 self.indptr, self.indices, self.data, \
                 indptr, indices, data)

        from csr import csr_matrix
        A = csr_matrix((data, indices, indptr), shape=self.shape)
        A.has_sorted_indices = True
        return A