give S_pinv_k to refine function.