working python implementation of newton-gmres, need to edit c++ to match