Added dense_to_sparse function.