MCPcopy
hub / github.com/dmlc/dgl / csr

Method csr

python/dgl/sparse/sparse_matrix.py:141–170  ·  view source on GitHub ↗

r"""Returns the compressed sparse row (CSR) representation of the sparse matrix. See `CSR in Wikipedia `_. This function also returns value indices as an index tensor, ind

(self)

Source from the content-addressed store, hash-verified

139 return self.c_sparse_matrix.indices()
140
141 def csr(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
142 r"""Returns the compressed sparse row (CSR) representation of the sparse
143 matrix.
144
145 See `CSR in Wikipedia <https://en.wikipedia.org/wiki/
146 Sparse_matrix#Compressed_sparse_row_(CSR, _CRS_or_Yale_format)>`_.
147
148 This function also returns value indices as an index tensor, indicating
149 the order of the values of non-zero elements in the CSR representation.
150 A ``None`` value indices array indicates the order of the values stays
151 the same as the values of the SparseMatrix.
152
153 Returns
154 -------
155 torch.Tensor
156 Row indptr
157 torch.Tensor
158 Column indices
159 torch.Tensor
160 Value indices
161
162 Examples
163 --------
164
165 >>> indices = torch.tensor([[1, 2, 1], [2, 4, 3]])
166 >>> A = dglsp.spmatrix(indices)
167 >>> A.csr()
168 (tensor([0, 0, 2, 3]), tensor([2, 3, 4]), tensor([0, 2, 1]))
169 """
170 return self.c_sparse_matrix.csr()
171
172 def csc(self) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
173 r"""Returns the compressed sparse column (CSC) representation of the

Callers 9

to_torch_sparse_csrFunction · 0.80
test_softmaxFunction · 0.80
test_from_csrFunction · 0.80
test_coo_to_csrFunction · 0.80
test_csc_to_csrFunction · 0.80
test_diag_conversionsFunction · 0.80
test_val_likeFunction · 0.80
test_has_duplicateFunction · 0.80

Calls

no outgoing calls

Tested by 8

test_softmaxFunction · 0.64
test_from_csrFunction · 0.64
test_coo_to_csrFunction · 0.64
test_csc_to_csrFunction · 0.64
test_diag_conversionsFunction · 0.64
test_val_likeFunction · 0.64
test_has_duplicateFunction · 0.64