fix an error for magic matrix