0
$\begingroup$

I have a large sparse matrix A and i want to pick the submatrix of it to do block jacobi iterations.

For the blocks, i have get a matrix Q that contains the index of nonzero entries in its Jth column define the nodes of Jth block.

my code is:

for i=1:J
lg=find(Q(level).agg(:,i));
D(i).matrix=inv((sparse(A(lg,lg))));
end
D_inverse=sparse(blkdiag(D(1:J).matrix));

and I found that the operations A(lg,lg) cost much time, because A is sparse format,

Is there any other ways to do this purpose (building D_inverse)quickly and efficently?

Thank you

$\endgroup$
  • 1
    $\begingroup$ is it A(lg, lg) that takes time, or is the inv( )? Maybe you could split the operations up into separate lines and profile them. $\endgroup$ – Dylan Richard Muir Nov 21 '14 at 14:14
  • $\begingroup$ Also, A(lg, lg) will already be sparse; the call the sparse on line 3 is redundant. $\endgroup$ – Dylan Richard Muir Nov 21 '14 at 14:15
  • $\begingroup$ Thank you! I have splited the operations into two steps, and it's commonly like that, A(lg,lg) takes much time. $\endgroup$ – Z. Shen Nov 26 '14 at 15:06
  • $\begingroup$ In that case, I'm not sure there's much you can do. $\endgroup$ – Dylan Richard Muir Nov 27 '14 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.