Added a sparse matrix routine to write the matrix to a file