A Generalized Stress Inversion Approach With Application to Residual Stress Estimation