residual vector should be intent inout