trace
scipy.sparse.coo_matrix.
- coo_matrix.trace(offset=0)
Returns the sum along diagonals of the sparse array/matrix.
- Parameters:
- offset : int, optional
Which diagonal to get, corresponding to elements a[i, i+offset]. Default: 0 (the main diagonal).
- Returns:
- scalar