dgl.sparse.DiagMatrix.neg

DiagMatrix.neg()dgl.sparse.diag_matrix.DiagMatrix

Returns a new diagonal matrix with the negation of the original nonzero values, equivalent to -D.

Returns

Negation of the diagonal matrix

Return type

DiagMatrix

Examples

>>> val = torch.arange(3).float()
>>> D = dglsp.diag(val)
>>> D = -D
DiagMatrix(val=tensor([-0., -1., -2.]),
           shape=(3, 3))