As could be seen in the following code:
AbsoluteTiming[
n = 100000;
A = SparseArray[{
Band[{1, 120}] -> -2., Band[{950, 1}] -> -1.,
Band[{1, 1}] -> 20., Band[{1, 100}] -> 2.,
Band[{6, 800}] -> 1.1}, {n, n}, 0.];
b = SparseArray[Table[1., {i, n}]];
DA = Diagonal[A];
(* I think constructing B is time-consuming. My ParallelTable[] does
not work or show any improvement herein! *)
B = SparseArray[Table[(1/DA[[i]]), {i, 1, n}]];
V = DiagonalMatrix[SparseArray[B]];
]
I'm trying to extract the diagonal entries of a very large sparse matrix and to compute $1/a_{ii}$ to make my new large sparse diagonal matrix $V$. This process takes around 18 seconds, and I would like to accelerate this process.



SparseArray[Band[{1, 1}] -> 1/Diagonal[A]]... – J. M.♦ Jun 14 '12 at 13:44DiagonalMatrix[1/Diagonal[A]]-- I cannot remember who first put me onto it butBandoften is not fast(est). -- I found a record: it was Norbert Pozar who first showed me thatBandcan be much slower than alternatives. – Mr.Wizard♦ Jun 14 '12 at 13:48