Bilal
Bilal

Reputation: 3854

How to assign values to slices in Scipy sparse huge matrix

Mat_A

Mat_A = sparse.coo_matrix((weights, (i_indices_O, j_indices_O)), shape=(pixel_nb_O, pixel_nb_O))
Mat_A[:,0 ] = np.ravel(Mat_A.sum(axis=0))
Mat_A[:,1:] = 0
Mat_A = Mat_A.tocsr()

Upvotes: 0

Views: 915

Answers (1)

yatu
yatu

Reputation: 88246

coo_matrix's sparse format comes with some disadvantages, which are well mentioned in the docs:

does not directly support:

  • arithmetic operations
  • slicing

COO is a fast format for constructing sparse matrices, though for arithmetic operations you should switch to CSR or CSC.

Upvotes: 3

Related Questions