Fast algorithms for generalized displacement structures and lossless systems