Fix int32 overflows in sparsetools

The sparsetools code has several int32 overflows on 64-bit systems:

- Some of the sparsetools routines index into 2D dense arrays.  The indices into these are not bounded by nnz, and can overflow int32 limits.
- The nnz of BSR is not bounded by the index data type, which only bounds the number of blocks.  The block size may easily overflow int32.

This PR contains some tests that require a lot of memory, so we check the available amount first (doing this on Linux should be enough). Some of the tests are also very slow (~ minutes), so they are enabled only if an environment variable is set.

Fixes gh-3212, gh-2179