I need to solve x from sparse matrix expression A*x = B in loops, where A is a Scipy CSC sparse-matrix and B is Numpy 1D array. Both A and B are large about 500K rows. Basically, I need to update B in each loop. So the speed to update B is critical. Right now, my way is to define csc_matrix in each loop, and then convert it to 1D Numpy array as below which is really expensive in terms of time:
B = csc_matrix((data,(row, col)),shape=(500000, 1), dtype='complex128').toarray()[:,0];
Please note:
rowhas lots of the repeated index, such as[0,1,2,0,2,2,3,3....],colis[0,0, 0,.......0];
Is there fast way to update B in each loop?