fix sparse matrix