offsets = np.array([0, -1, 2]) mtx = sparse.dia_matrix((data, offsets), shape=(4, 4)) mtx. Out[6]: <4x4 sparse matrix of type '<type 'numpy.int64'>' with 9 ...
確定! 回上一頁