added method, example and test for getSparseMatrix()