On computing sparse generalized inverses