Approximate calculation of a pseudoinverse matrix using a generalized discrepancy principle