Add support for sparse matrices.