Algebraic necessary and sufficient conditions of input-output linearization