scipy.sparse
spmatrix.
diagonal
Returns the main diagonal of the matrix
scipy.sparse.spmatrix.count_nonzero
scipy.sparse.spmatrix.dot