scipy.sparse.coo_array.

trace#

coo_array.trace(offset=0)[source]#

返回稀疏陣列/矩陣對角線元素的總和。

參數:
offsetint,可選

要取得哪條對角線,對應於元素 a[i, i+offset]。預設值:0(主對角線)。