More code for sparse matrices