fix sparse matrix off diagnol elements