Derivative of the truncated singular value and eigen decomposition