An algorithm for the computation of the transfer function matrix for singular systems