An elimination method for computing the generalized inverse