trace — SciPy v1.15.2 Manual (original) (raw)
scipy.sparse.csr_array.
csr_array.trace(offset=0)[source]#
Returns the sum along diagonals of the sparse array/matrix.
Parameters:
offsetint, optional
Which diagonal to get, corresponding to elements a[i, i+offset]. Default: 0 (the main diagonal).