dgl.sparse.subο
- dgl.sparse.sub(A: SparseMatrix, B: SparseMatrix) SparseMatrix [source]ο
Elementwise subtraction for
SparseMatrix
, equivalent toA - B
.- Parameters:
A (SparseMatrix) β Sparse matrix
B (SparseMatrix) β Sparse matrix
- Returns:
Sparse matrix
- Return type:
Examples
>>> indices = torch.tensor([[1, 0, 2], [0, 1, 2]]) >>> val = torch.tensor([10, 20, 30]) >>> A = dglsp.spmatrix(indices, val) >>> B = dglsp.diag(torch.arange(1, 4)) >>> dglsp.sub(A, B) SparseMatrix(indices=tensor([[0, 0, 1, 1, 2], [0, 1, 0, 1, 2]]), values=tensor([-1, 20, 10, -2, 27]), shape=(3, 3), nnz=5)