I have a 1000 x 100 numpy array. I figured out how to calculate the matrix of external products of my transposed lines
Create an array of external products in numpy
This gives a numpy array of 1000x100x100 D. I would like to save each of D [i,:,:] as one of the block diagonals of a sparse matrix of size 1000 * 100 ^ 2 x 1000 * 100 ^ 2. I can do this using scipy. sparse.block_diag
E = spspar.block_diag (D, "lil")
I am wondering if there is a more efficient way to do this. Some of the elements of E need to be manipulated first (hence the "lil"). The resulting matrix will be used to solve the sequence of sparse linear systems.
Thanks in advance.
source
share