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

%	A Ruhe 8-08-94.
%	Copyright (c) 1994-95 by The MathWorks, Inc.
%	$Revision: 1.3.1.1 $  $Date: 1995/08/14 15:05:01 $

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;
