Efficiently Invert a Square, Block Diagonal Matrix

I am generating an n x n matrix where n is specified by DIM:

DIM = 10;
T = Table[Join[Table[0, {j, 1, i - 1}], {1, -2, 1},Table[0, {j, i + 3,DIM}]], {i, 1, DIM - 2}];
T = Join[{Table[If[i == 1, 1, 0], {i, 1, DIM}]},T, {Table[If[i == DIM, 1, 0], {i, 1, DIM}]}];

T // MatrixForm


The resulting matrix is square, and block diagonal. I then need to take the inverse of this matrix:

Tinv = Inverse[T];
Tinv // MatrixForm


This works fine as expected. However, I need to increase the dimensions of the matrix to be 2880 x 2880. When I go to invert this new matrix, my computer locks up. Is there an algorithm or efficient method for computing the inverse of such a simple matrix?

• Try SparseArray[T] – Algohi Mar 26 '16 at 19:19

Thank you Algohi! I looked up how to invert a SparseArray and found some code which I implemented:
s = SparseArray[T];