Returns the transpose of this sparse matrix. Returns ------- SparseMatrix The transpose of this sparse matrix. Examples -------- >>> indices = torch.tensor([[1, 1, 3], [2, 1, 3]]) >>> val = torch.tensor([1, 1, 2]) >>> A =
(self)
| 225 | return self.transpose() |
| 226 | |
| 227 | def transpose(self): |
| 228 | """Returns the transpose of this sparse matrix. |
| 229 | |
| 230 | Returns |
| 231 | ------- |
| 232 | SparseMatrix |
| 233 | The transpose of this sparse matrix. |
| 234 | |
| 235 | Examples |
| 236 | -------- |
| 237 | |
| 238 | >>> indices = torch.tensor([[1, 1, 3], [2, 1, 3]]) |
| 239 | >>> val = torch.tensor([1, 1, 2]) |
| 240 | >>> A = dglsp.spmatrix(indices, val) |
| 241 | >>> A = A.transpose() |
| 242 | SparseMatrix(indices=tensor([[2, 1, 3], |
| 243 | [1, 1, 3]]), |
| 244 | values=tensor([1, 1, 2]), |
| 245 | shape=(4, 4), nnz=3) |
| 246 | """ |
| 247 | return SparseMatrix(self.c_sparse_matrix.transpose()) |
| 248 | |
| 249 | def to(self, device=None, dtype=None): |
| 250 | """Performs matrix dtype and/or device conversion. If the target device |