A Variable Metric Method for Approximating Generalized Inverses of Matrices