A generalized Schur-type algorithm for the joint factorization of a structured matrix and its inverse