Use arrays instead of HashMaps in sparse matrices.