# How can I efficiently ArrayFlatten a matrix of sparse matrices?

I have a matrix of sparse matrices that I want to convert to a sparse block matrix. So, basically I want what ArrayFlatten does, except that I want the output to be sparse. So e.g.:

sp = SparseArray[{{2, 2} -> 1.}, {50, 50}];
sparseArrayFlatten[
{
{sp, 0},
{0, -sp}
}]


should return SparseArray[{{2, 2} -> 1., {52, 52} -> -1., {_, _} -> 0},{100,100}].

Currently, I use SparseArray@ArrayFlatten[...], but for large matrices, this is inefficient.

(Sometimes ArrayFlatten does return a sparse array, but I haven't completely figured out when. For example, if I remove the - sign above, or if I use -> 1 instead of -> 1., I get a sparse result.)

-

sp = SparseArray[{{2, 2} -> 1.}, {50, 50}, 0.];

will return a SparseArray without creating a dense matrix first.