fix linearizer of sparse matrices