Returns ``True`` if the sparse matrix contains duplicate indices. Examples -------- >>> indices = torch.tensor([[1, 0, 0, 0, 1], [1, 1, 1, 2, 2]]) >>> val = torch.tensor([0, 1, 2, 3, 4]) >>> A = dglsp.spmatrix(indices, val) >>> A.has_duplicate()
(self)
| 461 | return SparseMatrix(self.c_sparse_matrix.coalesce()) |
| 462 | |
| 463 | def has_duplicate(self): |
| 464 | """Returns ``True`` if the sparse matrix contains duplicate indices. |
| 465 | |
| 466 | Examples |
| 467 | -------- |
| 468 | >>> indices = torch.tensor([[1, 0, 0, 0, 1], [1, 1, 1, 2, 2]]) |
| 469 | >>> val = torch.tensor([0, 1, 2, 3, 4]) |
| 470 | >>> A = dglsp.spmatrix(indices, val) |
| 471 | >>> A.has_duplicate() |
| 472 | True |
| 473 | >>> A.coalesce().has_duplicate() |
| 474 | False |
| 475 | """ |
| 476 | return self.c_sparse_matrix.has_duplicate() |
| 477 | |
| 478 | def is_diag(self): |
| 479 | """Returns whether the sparse matrix is a diagonal matrix.""" |
no outgoing calls