function  [y,h]=pdegrmsc(r,v)
%PDEGRMSC Gram Schmidt phase of Arnoldi algorithm.

%       A Ruhe 8-08-94.
%       Copyright (c) 1994-98 by The MathWorks, Inc.
%       $Revision: 1.7 $  $Date: 1997/11/25 17:05:41 $

maxort=4;
qmax=0.7;
[n j]=size(v);
rnn=norm(r);
hc=zeros(j,1);
if j>0,
  for iort=1:maxort,
    hv=v'*r;
    hc=hc+hv;
    r=r-v*hv;
    rnorm=rnn;
    rnn=norm(r);
    if rnn > qmax*rnorm, break, end;
  end;
end;
h=[hc;rnn];
y=r/rnn;

