1. 程式人生 > 其它 >scipy csr_matrix和csc_matrix函式詳解

scipy csr_matrix和csc_matrix函式詳解

[連結]:scipy csr_matrix和csc_matrix函式詳解_Sundrops的專欄-CSDN部落格_csc_matrix

概述
在用python進行科學運算時,常常需要把一個稀疏的np.array壓縮,這時候就用到scipy庫中的sparse.csr_matrix(csr:Compressed Sparse Row marix) 和sparse.csc_matric(csc:Compressed Sparse Column marix)

scipy.sparse.csr_matrix
官方API介紹(省略前幾種容易理解的了)
csr_matrix((data, indices, indptr), [shape=(M, N)])
is the standard CSR representation where the column indices for row i are stored in indices[indptr[i]:indptr[i+1]] and their corresponding values are stored in data[indptr[i]:indptr[i+1]]. If the shape parameter is not supplied, the matrix dimensions are inferred from the index arrays.

官方API介紹(省略前幾種容易理解的了)

csc_matrix((data, indices, indptr), [shape=(M, N)])
is the standard CSC representation where the row indices for column i are stored in indices[indptr[i]:indptr[i+1]] and their corresponding values are stored in data[indptr[i]:indptr[i+1]]. If the shape parameter is not supplied, the matrix dimensions are inferred from the index arrays.