On generalized inverses of matrices