Algorithm of J-factorization of rational matrices with zeros and poles on the imaginary axis