0
votes

I would like to compute the inverse of some large block diagonal sparse matrix. The number of rows and columns is somewhat over 50,000. The blocks are 12 by 12 and are sparse (27 non zero elements).

I tried to compute the inverse of the entire matrix (using solve). This was not possible, the entire matrix is too big.

After that, i use a for-loop. Within each iteration, i take out one block, compute its inverse and place it back.

That method works, but i takes about 5 minutes. I wonder if there is some faster way.

Many thanks in advance.

2
I think you might consider asking in scicomp.SE, but they'll likely just tell you not to invert any big matrix. Why do you need the inverse? The reason it's so slow, BTW, is that removing the blocks and putting them back in is slow. The math is doable very fast.Emmet
are you already using a sparse matrix and the methods in the Matrix package? it's not clear from your question.Ben Bolker
yes that is true; a dgCMatrixuser3499209

2 Answers

0
votes

How do you end up with a 50k x 50k matrix?

Inverting a 12 x 12 is simple and quick. Is it the inverting that's causing the slowness or the accessing of the matrix object?

What are you going to do with your large inversion?

0
votes

I made by code much faster, by:

1) storing the inverse of the block diagonal matrices in a list, rather than 'placing them back in the large matrix. At the end I built the entire matrix from the list by using the bdiag() command. 2) by considering the block diagonal matrices not one by one, but in groups of about 10 So, I repeatedly calculate the inverse of a submatrix consisting of 10 block diagonal matrices.

In the original question i did not tell that i do not only take the inverse of each block, but that i also applied some transformation on each block. Now the transformation is done in advance for the entire block diagonal matrix, which also saves time.