Added invariants for SparseMatrix class